* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0e0b09;
  --fg: #f0ebe4;
  --muted: rgba(240,235,228,0.45);
  --line: rgba(255,255,255,0.08);
  --card: rgba(255,255,255,0.03);
  --accent: #c8b99a;
  --accent2: #4e79a7;
  --good: #6b9080;
  --bad: #c8896b;
}

body {
  font-family: 'Pretendard Variable', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(130px); opacity: 0.22; }
.orb-1 { width: 600px; height: 600px; background: radial-gradient(circle, #7b6151, transparent 70%); top: -240px; left: -160px; }
.orb-2 { width: 520px; height: 520px; background: radial-gradient(circle, #4e79a7, transparent 70%); bottom: -200px; right: -140px; opacity: 0.14; }

.container { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 40px 24px 64px; }

header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
header h1 {
  font-size: 30px; font-weight: 800; letter-spacing: -0.5px;
  background: linear-gradient(135deg, #f0ebe4, #c8b99a 60%, #7b6151);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.subtitle { font-size: 14px; color: var(--muted); margin-top: 6px; }
.refresh-btn {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--card); border: 1px solid var(--line); color: var(--accent);
  font-size: 20px; cursor: pointer; transition: all 0.25s;
}
.refresh-btn:hover { background: rgba(255,255,255,0.08); transform: rotate(90deg); }

.loading { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 120px 0; color: var(--muted); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { padding: 40px; text-align: center; color: var(--bad); background: var(--card); border: 1px solid var(--line); border-radius: 16px; }

/* ── 과목 필터바 ── */
.filterbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.filter-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 600; padding: 7px 15px;
  border-radius: 999px; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 7px;
}
.chip:hover { color: var(--fg); border-color: rgba(255,255,255,0.2); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.active { color: #0e0b09; border-color: transparent; }
.chip .cnt { opacity: 0.6; font-weight: 500; }

/* ── 인사이트 요약 ── */
.insights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.insight {
  background: linear-gradient(135deg, rgba(200,185,154,0.07), rgba(255,255,255,0.02));
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; font-size: 14px; line-height: 1.5;
}
.insight .ic { font-size: 18px; margin-bottom: 8px; display: block; }
.insight b { color: var(--accent); font-weight: 700; }

/* ── KPI ── */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px 20px; }
.kpi .label { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.kpi .value { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.kpi .value small { font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 8px; }
.kpi .delta { font-weight: 700; }
.kpi .delta.up { color: var(--good); }
.kpi .delta.down { color: var(--bad); }
.kpi.accent .value { color: var(--accent); }
.kpi.good .value { color: var(--good); }

.section { margin-top: 34px; }
.section-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.section-head .section-title { margin-bottom: 0; }

.toggle { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.toggle button {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600; padding: 6px 16px; border-radius: 7px; transition: all 0.2s;
}
.toggle button:hover { color: var(--fg); }
.toggle button.active { background: rgba(200,185,154,0.18); color: var(--accent); }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 18px; }
.chart-wrapper { position: relative; height: 280px; }
.chart-wrapper.tall { height: 380px; }
.hint { font-size: 12px; color: rgba(240,235,228,0.3); margin-top: 14px; text-align: center; }

.table-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 12px 14px; text-align: right; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); font-size: 13px; }
.data-table tbody tr { border-bottom: 1px solid rgba(255,255,255,0.04); transition: background 0.15s; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: rgba(255,255,255,0.04); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr.total-row { font-weight: 700; }
.data-table tbody tr.total-row td { border-top: 1px solid var(--line); color: var(--accent); }
.data-table .bar-cell { position: relative; }
.data-table .bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; margin-left: 8px; opacity: 0.7; }

footer { margin-top: 48px; text-align: center; font-size: 12px; color: rgba(240,235,228,0.2); }

@media (max-width: 900px) {
  .insights { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .container { padding: 28px 16px 48px; }
  header h1 { font-size: 24px; }
  .kpi .value { font-size: 24px; }
}
