@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, 'Pretendard', 'Noto Sans KR', sans-serif; background: #f6f5f4; color: #1a1a1a; font-size: 14px; }

/* Sidebar — 뷰포트 > 1500px 일 때 콘텐츠와 함께 중앙 정렬 */
.sidebar { position: fixed; left: max(0px, calc((100vw - 1500px) / 2)); top: 0; bottom: 0; width: 220px; background: #ffffff; border-right: 1px solid #e5e3df; padding: 0; z-index: 100; transition: transform 0.25s; }
.sidebar .logo { display: block; padding: 20px 20px 16px; font-size: 16px; font-weight: 800; color: #1a1a1a; border-bottom: 1px solid #f6f5f4; cursor: pointer; }
.sidebar .logo span { color: #5645d4; }
.sidebar .section-label { padding: 16px 20px 6px; font-size: 11px; font-weight: 600; color: #a4a097; text-transform: uppercase; letter-spacing: 1px; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 9px 20px; font-size: 13px; color: #787671; text-decoration: none; border-left: 3px solid transparent; transition: all 0.12s; }
.sidebar a:hover { color: #1a1a1a; background: #f6f5f4; }
.sidebar a.active { color: #5645d4; background: #ede9f8; border-left-color: #5645d4; font-weight: 600; }

/* Hamburger */
.hamburger { display: none; background: none; border: none; padding: 4px 6px; cursor: pointer; font-size: 20px; line-height: 1; color: #5d5b54; flex-shrink: 0; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 99; }

/* Main */
.main { margin-left: max(220px, calc((100vw - 1500px) / 2 + 220px)); padding: 28px 32px; min-height: 100vh; }
.main-inner { max-width: 1280px; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.topbar h2 { font-size: 20px; font-weight: 700; color: #1a1a1a; }
.topbar .sub { font-size: 13px; color: #a4a097; margin-top: 3px; }

/* Loading state */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 80px 32px; }
.loading-spinner { width: 40px; height: 40px; border: 3px solid #e5e3df; border-top-color: #5645d4; border-radius: 50%; animation: spin 0.8s linear infinite; }
.loading-state p { font-size: 14px; color: #a4a097; font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons */
.btn-primary { background: #5645d4; color: #ffffff; border: none; padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn-primary:active { background: #4534b3; }
.btn-secondary { background: #ffffff; color: #37352f; border: 1px solid #c8c4be; padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }

/* Cards */
.card { background: #ffffff; border: 1px solid #e5e3df; border-radius: 12px; padding: 20px; }
.card-title { font-size: 14px; font-weight: 600; color: #1a1a1a; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-title select { background: #ffffff; border: 1px solid #e5e3df; color: #787671; font-size: 12px; padding: 4px 8px; border-radius: 6px; }

/* KPI */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi-card { background: #ffffff; border: 1px solid #e5e3df; border-radius: 12px; padding: 20px; }
.kpi-label { font-size: 11px; font-weight: 600; color: #a4a097; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px; }
.kpi-value { font-size: 24px; font-weight: 800; color: #1a1a1a; line-height: 1; }
.kpi-meta { margin-top: 6px; font-size: 12px; color: #a4a097; }
.up { color: #1aae39; font-weight: 600; }
.down { color: #e03131; font-weight: 600; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green  { background: #d9f3e1; color: #1aae39; }
.badge-blue   { background: #dcecfa; color: #0075de; }
.badge-red    { background: #fee2e2; color: #e03131; }
.badge-yellow { background: #fef7d6; color: #9a6700; }
.badge-purple { background: #e6e0f5; color: #391c57; }
.badge-gray   { background: #f0eeec; color: #787671; }
.badge-orange { background: #ffe8d4; color: #dd5b00; }

/* Table */
.table-wrap { background: #ffffff; border: 1px solid #e5e3df; border-radius: 12px; overflow: hidden; }
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap thead { background: #fafaf9; }
.table-wrap th { padding: 10px 16px; font-size: 11px; font-weight: 600; color: #a4a097; text-transform: uppercase; letter-spacing: 0.5px; text-align: left; border-bottom: 1px solid #e5e3df; white-space: nowrap; }
.table-wrap td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid #f6f5f4; color: #5d5b54; vertical-align: middle; }
.table-wrap td.td-amount { text-align: right; font-weight: 700; white-space: nowrap; }
.table-wrap th.th-amount { text-align: center; }
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tr:hover td { background: #fafaf9; }
.table-wrap .td-main { color: #1a1a1a; font-weight: 600; }

/* Alert */
.alert-bar { background: #ede9f8; border: 1px solid #d6b6f6; border-radius: 10px; padding: 12px 18px; margin-bottom: 12px; display: flex; align-items: center; gap: 12px; font-size: 13px; color: #3a2a99; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #ede9e4; margin-bottom: 20px; }
.tab { padding: 10px 20px; font-size: 13px; color: #a4a097; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; font-weight: 500; user-select: none; }
.tab.active { color: #5645d4; border-bottom-color: #5645d4; font-weight: 700; }

/* Dropdown filter */
.filter-dropdown { position: relative; display: inline-block; }
.filter-btn { background: #ffffff; border: 1px solid #e5e3df; color: #5d5b54; font-size: 13px; padding: 8px 12px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap; user-select: none; }
.filter-btn .arrow { font-size: 10px; color: #a4a097; transition: transform 0.15s; }
.filter-btn.open .arrow { transform: rotate(180deg); }
.filter-menu { display: none; position: absolute; top: calc(100% + 4px); left: 0; background: #ffffff; border: 1px solid #e5e3df; border-radius: 10px; box-shadow: 0 4px 16px rgba(15,15,15,0.08); min-width: 190px; z-index: 50; padding: 6px 0; max-height: 280px; overflow-y: auto; }
.filter-menu.open { display: block; }
.filter-menu-header { padding: 8px 14px 6px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #f6f5f4; margin-bottom: 4px; position: sticky; top: 0; background: #ffffff; }
.filter-menu-header span { font-size: 11px; font-weight: 700; color: #a4a097; text-transform: uppercase; }
.filter-menu-header a { font-size: 11px; color: #5645d4; cursor: pointer; text-decoration: none; font-weight: 600; }
.filter-menu label { display: flex; align-items: center; gap: 8px; padding: 7px 14px; font-size: 13px; color: #5d5b54; cursor: pointer; }
.filter-menu label:hover { background: #fafaf9; }
.filter-menu input[type=checkbox] { accent-color: #5645d4; width: 14px; height: 14px; flex-shrink: 0; }

/* Tooltip */
.tooltip-wrap { position: relative; cursor: default; }
.tooltip-wrap .tooltip {
  display: none; position: absolute;
  bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #1a1a1a; color: #ffffff; font-size: 12px; padding: 6px 11px;
  border-radius: 6px; white-space: nowrap; z-index: 60; pointer-events: none; line-height: 1.5;
}
.tooltip-wrap:hover .tooltip { display: block; }
.tooltip-wrap .tooltip.tip--below  { bottom: auto; top: calc(100% + 6px); }
.tooltip-wrap .tooltip.tip--left   { left: auto; right: 0; transform: none; }
.tooltip-wrap .tooltip.tip--right  { left: 0; transform: none; }

/* Responsive */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar { transform: translateX(-220px); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(15,15,15,0.1); }
  .sidebar-overlay.open { display: block; }
  .main { margin-left: 0; padding: 20px 16px; }
  .topbar { flex-direction: column; gap: 12px; align-items: flex-start; }
  .topbar > div:last-child { display: flex; gap: 8px; }
  .topbar-title { display: flex; align-items: center; gap: 8px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .table-wrap { overflow-x: auto; }
  .table-wrap table { min-width: 700px; }
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr; }
}
