/* 서울 전월세 3D 보드 — 공용 스타일 */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-other: #898781;
  --critical: #d03b3b;
  --seq: #86b6ef, #5598e7, #3987e5, #2a78d6, #256abf, #184f95, #0d366b;
  --seq2: #f6b394, #f08c60, #eb6834, #d95926, #c9501f, #a03d14, #7a2d0d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 6px 24px rgba(11, 11, 11, 0.05);
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --critical: #e66767;
    --seq: #104281, #184f95, #256abf, #3987e5, #6da7ec, #9ec5f4, #cde2fb;
    --seq2: #6b260b, #8f3512, #b8461a, #d95926, #e98258, #f2a985, #f8cdb6;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --critical: #e66767;
  --seq: #104281, #184f95, #256abf, #3987e5, #6da7ec, #9ec5f4, #cde2fb;
    --seq2: #6b260b, #8f3512, #b8461a, #d95926, #e98258, #f2a985, #f8cdb6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; color: inherit; }
a { color: var(--accent); }

.wrap { max-width: 1440px; margin: 0 auto; padding: 0 20px 40px; }

/* ── 헤더 ── */
.top {
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  padding: 20px 0 14px;
}
.brand h1 { margin: 0; font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.brand p { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, select:focus-visible, input:focus-visible, .seg label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn.icon { width: 36px; padding: 0; justify-content: center; }

/* ── 필터 ── */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--ink-2); font-weight: 600; }
select, input[type="search"] {
  height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); padding: 0 10px; min-width: 140px;
}
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: 13px; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.filters .grow { flex: 1 1 200px; }
.hint { font-size: 12px; color: var(--muted); }

/* ── 상태 ── */
.status { display: flex; align-items: center; gap: 8px; min-height: 28px; margin: 10px 2px 4px; color: var(--ink-2); font-size: 13px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status[data-state="loading"] .dot { background: var(--accent); animation: pulse 1s infinite ease-in-out; }
.status[data-state="ok"] .dot { background: #0ca30c; }
.status[data-state="error"] { color: var(--critical); }
.status[data-state="error"] .dot { background: var(--critical); }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ── KPI ── */
.kpis { display: grid; grid-template-columns: 1.35fr repeat(4, 1fr); gap: 12px; margin: 8px 0 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.hero .value { font-size: 30px; }
.kpi .sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.kpi .delta { font-weight: 650; color: var(--ink); white-space: nowrap; }
.kpi .unit { font-size: 0.55em; font-weight: 600; color: var(--ink-2); margin-left: 2px; }

/* ── 카드 그리드 ── */
.grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.card.span2 { grid-column: 1 / -1; }
.grid.lower { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.4fr); margin-top: 14px; }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 12px; margin-bottom: 8px; }
.card-head h2 { font-size: 15px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-2); }
.card-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

#chart3d { height: 540px; }
.chart { width: 100%; }
.chart.h300 { height: 300px; }
.chart.h200 { height: 200px; }
.chart.h360 { height: 360px; }
.chart.h420 { height: 420px; }

/* ── 타임라인 ── */
.timeline { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--grid); }
.timeline input[type="range"] { width: 100%; accent-color: var(--accent); }
.timeline .month { font-weight: 750; font-variant-numeric: tabular-nums; min-width: 86px; text-align: right; }
.snapshot { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.snapshot b { color: var(--ink); font-weight: 700; }

.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); }

/* ── 표 ── */
.table-wrap { overflow: auto; max-height: 440px; border-radius: 10px; border: 1px solid var(--grid); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--grid); }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-2); font-weight: 650; font-size: 12px; z-index: 1; }
th.sortable { cursor: pointer; }
th.sortable::after { content: " ↕"; color: var(--muted); }
th[aria-sort="ascending"]::after { content: " ↑"; color: var(--ink); }
th[aria-sort="descending"]::after { content: " ↓"; color: var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 650; border: 1px solid var(--border); color: var(--ink-2); }
.tag.j { color: var(--ink); }
.tag.j::before, .tag.w::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.tag.j::before { background: var(--series-1); }
.tag.w::before { background: var(--series-2); }

details.data-table { margin-top: 8px; }
details.data-table summary { cursor: pointer; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }

.empty { display: grid; place-items: center; height: 100%; min-height: 200px; color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }

.foot { margin-top: 22px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.foot code { font-size: 11.5px; }

/* ── 반응형 ── */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi.hero { grid-column: 1 / -1; }
  .grid, .grid.lower { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px 32px; }
  .top { flex-direction: column; align-items: flex-start; }
  .top-actions { justify-content: flex-start; }
  select { min-width: 0; width: 100%; }
  .field { flex: 1 1 140px; }
  .field:has(.seg), .filters .grow { flex: 1 1 100%; }
  .filters .seg { display: flex; }
  .filters .seg label { flex: 1 1 auto; text-align: center; }
  #go { width: 100%; justify-content: center; }
  .timeline { grid-template-columns: auto 1fr auto; }
  .timeline #allMonths { display: none; }
  #chart3d { height: 420px; }
  .kpi .value { font-size: 20px; }
  .kpi.hero .value { font-size: 26px; }
}
