@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&display=swap');

:root {
  --bg: #f4f6f8;
  --bg-white: #ffffff;
  --bg-hover: #f0f2f5;
  --sidebar-bg: #0f1f14;
  --sidebar-hover: #1a3322;
  --sidebar-active: #234a2e;
  --accent: #1d9e4e;
  --accent-light: #e8f7ee;
  --accent-dark: #14703a;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-dim: #9ca3af;
  --border: #e5e7eb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --info: #3b82f6;
  --info-light: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== LOGIN ===== */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #0f1f14 0%, #1a3d24 50%, #0f1f14 100%);
  position: relative;
}
.login-page::before {
  content:''; position:absolute; inset:0;
  background: radial-gradient(ellipse at 30% 20%, rgba(46,204,113,0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(46,204,113,0.05) 0%, transparent 50%);
}
.login-card {
  background: var(--bg-white);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  padding: 48px 44px; width: 440px; text-align: center;
  position: relative; z-index: 1;
}
.login-logo {
  font-family: 'Playfair Display', serif;
  font-size: 34px; font-weight: 900;
  color: var(--accent); margin-bottom: 4px;
}
.login-subtitle {
  font-size: 14px; color: var(--text-secondary); margin-bottom: 36px;
}
.login-error {
  background: var(--danger-light); color: var(--danger);
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px; text-align: left;
}
.login-info {
  margin-top: 24px; padding: 16px; background: #f9fafb;
  border-radius: var(--radius-sm); text-align: left;
  font-size: 12px; color: var(--text-secondary); line-height: 1.8;
}
.login-info strong { color: var(--text); }

/* ===== LAYOUT ===== */
.app-layout { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px; background: var(--sidebar-bg);
  color: #fff;
  display: flex; flex-direction: column;
  position: fixed; top:0; left:0; bottom:0;
  z-index: 100;
}
.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo {
  font-family: 'Playfair Display', serif;
  font-size: 22px; font-weight: 900;
  color: #2ecc71;
}
.sidebar-role {
  font-size: 12px; color: rgba(255,255,255,0.5);
  margin-top: 4px;
}
.sidebar-nav { flex:1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a { text-decoration: none; }
.nav-section {
  padding: 8px 20px;
  font-size: 10px; text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  letter-spacing: 2px; margin-top: 12px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.65);
  cursor: pointer; transition: all 0.2s;
  font-size: 14px; font-weight: 500;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
  background: var(--sidebar-active);
  color: #2ecc71;
  border-left-color: #2ecc71;
}
.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }
.nav-item .badge {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 10px;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 13px; color: rgba(255,255,255,0.5);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #2ecc71; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #0f1f14;
}
.logout-btn {
  margin-left: auto; background: none; border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5); padding: 5px 10px; border-radius: 6px;
  font-size: 11px; cursor: pointer; font-family: inherit;
  transition: all 0.2s;
}
.logout-btn:hover { border-color: #ef4444; color: #ef4444; }

/* ===== MAIN ===== */
.main {
  flex: 1; margin-left: 260px;
  display: flex; flex-direction: column;
}
.topbar {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top:0; z-index: 50;
}
.topbar-title { font-size: 20px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.topbar-badge.green { background: var(--accent-light); color: var(--accent-dark); }
.topbar-badge.blue { background: var(--info-light); color: var(--info); }
.topbar-badge.orange { background: var(--warning-light); color: #92400e; }
.topbar-date { font-size: 13px; color: var(--text-secondary); }
.content { padding: 28px 32px; flex:1; }

/* ===== STATS ===== */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.stat-card .value { font-size: 28px; font-weight: 800; }
.stat-card .change { font-size: 12px; margin-top: 4px; }
.stat-card .change.up { color: var(--accent); }
.stat-card .change.down { color: var(--danger); }

/* ===== TABLE ===== */
.table-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 24px;
}
.table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.table-title { font-size: 16px; font-weight: 700; }
.table-actions { display: flex; gap: 8px; align-items: center; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: #f9fafb; }
th {
  text-align: left; padding: 12px 16px;
  font-weight: 600; color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg-hover); }
.empty-row td { text-align: center; color: var(--text-dim); padding: 32px 16px; }

.status-badge {
  display: inline-flex; padding: 3px 10px;
  border-radius: 12px; font-size: 11px; font-weight: 600;
}
.status-badge.active { background: var(--accent-light); color: var(--accent-dark); }
.status-badge.expired { background: var(--danger-light); color: var(--danger); }
.status-badge.pending { background: var(--warning-light); color: var(--warning); }
.status-badge.selling { background: var(--accent-light); color: var(--accent-dark); }
.status-badge.stopped { background: #f3f4f6; color: var(--text-dim); }

/* ===== BUTTONS ===== */
.btn {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s;
  font-family: inherit; background: var(--bg-white); color: var(--text);
}
.btn:hover { border-color: var(--text-dim); }
.btn-green { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-green:hover { background: var(--accent-dark); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-light); }
.btn-full { width: 100%; padding: 14px; font-size: 15px; }

/* ===== SEARCH ===== */
.search-bar { display: flex; gap: 8px; margin-bottom: 20px; }
.search-input {
  flex: 1; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; outline: none; background: var(--bg-white);
}
.search-input:focus { border-color: var(--accent); }

/* ===== FILTER ROW (input + 4 input-combos in one line) ===== */
.filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(4, minmax(140px, 200px)) auto auto;
  gap: 8px;
  margin-bottom: 20px;
  align-items: stretch;
}
.filter-row .search-input { min-width: 0; }
.filter-combo {
  position: relative;
  display: flex;
}
.filter-combo input {
  width: 100%;
  padding: 10px 32px 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg-white);
  appearance: none;
  -webkit-appearance: none;
}
.filter-combo input:focus { border-color: var(--accent); }
.filter-combo input::-webkit-calendar-picker-indicator { display: none !important; }
.filter-combo::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 10px;
  height: 6px;
  margin-top: -3px;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M2 2l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-size: 10px 6px;
  background-repeat: no-repeat;
}
@media (max-width: 1100px) {
  .filter-row { grid-template-columns: 1fr 1fr; }
}

/* ===== FILTER TABS ===== */
.filter-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: #f3f4f6; border-radius: var(--radius-sm); padding: 4px;
}
.filter-tab {
  padding: 8px 18px; border-radius: 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  color: var(--text-secondary); background: transparent;
  border: none; font-family: inherit;
}
.filter-tab.active { background: var(--bg-white); color: var(--text); box-shadow: var(--shadow); }

/* ===== CHART ===== */
.chart-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px; margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.chart-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.chart-placeholder {
  height: 240px;
  background: linear-gradient(180deg, var(--accent-light) 0%, transparent 100%);
  border-radius: var(--radius-sm);
  display: flex; align-items: flex-end;
  padding: 0 8px 8px; gap: 6px;
}
.chart-bar {
  flex: 1; background: var(--accent); border-radius: 4px 4px 0 0;
  min-height: 20px; transition: height 0.5s; position: relative;
}
.chart-bar::after {
  content: attr(data-label);
  position: absolute; bottom: -22px; left:50%; transform:translateX(-50%);
  font-size: 10px; color: var(--text-dim); white-space: nowrap;
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  /* 기본 너비 (md). size class 로 덮어씀. */
  width: 580px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 헤더/푸터 고정, body 만 스크롤 */
}
.modal.modal-sm { width: 480px; }
.modal.modal-md { width: 580px; }
.modal.modal-lg { width: 80vw; max-width: 1100px; min-width: 560px; }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 22px;
  color: var(--text-dim); cursor: pointer;
}
.modal-body {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
/* danger 버튼은 항상 왼쪽으로 정렬 (삭제/비활성/제거 등) */
.modal-footer .btn-danger { margin-right: auto; }

/* ===== TOGGLE SWITCH ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch .toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cbd5e1;
  border-radius: 13px;
  transition: .2s;
}
.toggle-switch .toggle-slider::before {
  content: "";
  position: absolute;
  height: 20px; width: 20px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: #2ecc71; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }
.toggle-switch input:disabled + .toggle-slider { opacity: 0.5; cursor: not-allowed; }

/* 토글 + 텍스트 라벨 그룹 (form-group 안에서) */
.toggle-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}
.toggle-field .toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; outline: none;
}
.form-input:focus { border-color: var(--accent); }
.form-select {
  width: 100%; padding: 10px 32px 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; outline: none; background-color: var(--bg-white);
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M2 2l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 10px 6px;
}
.form-select:focus { border-color: var(--accent); }
.form-select:disabled { background-color: #f9fafb; color: var(--text-dim); cursor: not-allowed; opacity: 0.7; }
/* paging size select 등 inline-styled 작은 select 도 화살표 위치 통일 */
select:not(.form-select) {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M2 2l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-position: right 8px center;
  background-repeat: no-repeat;
  background-size: 10px 6px;
  padding-right: 24px !important;
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-error {
  background: var(--danger-light); color: var(--danger);
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 14px;
}
.form-notice {
  padding: 12px; background: var(--warning-light);
  border-radius: 8px; font-size: 12px; color: #92400e;
  margin-top: 8px;
}
.form-notice.danger {
  background: var(--danger-light); color: #991b1b;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 16px;
}
.page-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; cursor: pointer; background: var(--bg-white);
  transition: all 0.2s; font-family: inherit;
}
.page-btn:hover { border-color: var(--accent); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.detail-row {
  display: flex; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 140px; color: var(--text-secondary); flex-shrink: 0; }
.detail-value { font-weight: 600; }

.seat-layout { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.seat-cell {
  aspect-ratio: 1; border-radius: 4px; font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.seat-cell.empty { background: #e8f7ee; color: var(--accent-dark); }
.seat-cell.occupied { background: var(--accent); color: #fff; }

/* ===== ROLE-BASED VISIBILITY ===== */
.master-only { display: none !important; }
body.role-master .master-only { display: block !important; }
body.role-master .nav-item.master-only { display: flex !important; }
body.role-master .nav-section.master-only { display: block !important; }
body.role-branch .branch-notice { display: block !important; }
.branch-notice { display: none !important; }


/* ===== ROW CLICK + ROOMY TABLES ===== */
.clickable-row:hover { background: #f9fafb !important; }
.clickable-row:active { background: #f3f4f6 !important; }
.table-roomy td { padding: 14px 16px !important; font-size: 14px !important; }
.table-roomy th { padding: 12px 16px !important; font-size: 13px !important; }

/* ===== DETAIL SECTION TITLE ===== */
.section-title { font-size: 13px; font-weight: 700; color: var(--text-primary); border-bottom: 2px solid var(--border); padding-bottom: 8px; margin-bottom: 14px; letter-spacing: 0.3px; }
.detail-grid { display: grid; gap: 24px; padding: 8px 4px 16px; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; gap: 12px;
}
.page-header .notice { font-size: 13px; color: var(--text-secondary); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: #fff;
  padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-lg);
  z-index: 300; opacity: 0; transform: translateY(20px);
  transition: all 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--accent-dark); }
.toast.error { background: var(--danger); }

/* ===== CARD GRID (출입문 등 카드형 목록) ===== */
.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.04));
}
.card.inactive { opacity: 0.55; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-meta { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.card-meta-row { display: flex; gap: 8px; }
.card-meta-label { width: 78px; color: var(--text-dim); flex-shrink: 0; }
.card-meta-value { font-weight: 500; color: var(--text-primary); word-break: break-all; }
.card-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.card-empty {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 36px 18px; text-align: center; color: var(--text-dim); font-size: 14px;
}
