/* Design tokens — reference palette from the dataviz method, both modes. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #008300;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
  }
}

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

body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }

/* ---- header ---- */
header.site { padding: 40px 0 8px; }
.eyebrow {
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.01em; }
.lede { color: var(--ink-2); max-width: 62ch; margin-top: 10px; font-size: 16px; }
.theme-toggle {
  float: right; margin-top: 4px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); border-radius: 999px;
  padding: 5px 14px; font: inherit; font-size: 13px; cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); }

/* ---- sections & cards ---- */
section { margin-top: 44px; }
.section-kicker {
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--s1); font-weight: 600;
}
:root[data-theme="dark"] .section-kicker { color: var(--s1); }
h2 { font-size: 22px; margin-top: 4px; }
.section-lede { color: var(--ink-2); max-width: 68ch; margin: 8px 0 20px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px 20px 16px; margin-top: 20px;
}
.card h3 { font-size: 15px; font-weight: 600; }
.card .sub { font-size: 13px; color: var(--muted); margin: 2px 0 14px; }

/* ---- KPI tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 24px; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px;
}
.tile .label { font-size: 13px; color: var(--ink-2); }
.tile .value { font-size: 32px; font-weight: 600; margin-top: 2px; }
.tile .note { font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (max-width: 760px) { .tiles { grid-template-columns: repeat(2, 1fr); } }

/* ---- heatmap ---- */
.heat-scroll { overflow-x: auto; }
.heat { min-width: 720px; border-collapse: separate; border-spacing: 2px 2px; width: 100%; }
.heat th {
  font-size: 12px; font-weight: 500; color: var(--muted); text-align: right;
  padding: 0 4px 6px; font-variant-numeric: tabular-nums;
}
.heat th.rowhead { text-align: left; }
.heat td.rowhead {
  font-size: 13px; text-align: left; white-space: nowrap; padding-right: 10px;
  color: var(--ink); background: none;
}
.heat tr.group td.rowhead { font-weight: 600; cursor: pointer; }
.heat tr.group td.rowhead .chev { color: var(--muted); display: inline-block; width: 14px; }
.heat tr.leaf td.rowhead { padding-left: 22px; color: var(--ink-2); }
.heat td.cell {
  font-size: 12px; text-align: right; padding: 4px 6px; border-radius: 3px;
  font-variant-numeric: tabular-nums; min-width: 44px; cursor: default;
}
.heat td.cell:hover { outline: 2px solid var(--ink); outline-offset: -2px; }
.heat td.blank { background: none; }

/* ---- svg charts ---- */
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.axis-tick { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.axis-label { font-size: 12px; fill: var(--muted); }
.direct-label { font-size: 12px; fill: var(--ink-2); font-weight: 600; }
.annot { font-size: 12px; fill: var(--muted); font-style: italic; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline-l { stroke: var(--baseline); stroke-width: 1; }

/* ---- legend ---- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; }
.legend .item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.legend .key-line { width: 16px; height: 2px; border-radius: 1px; }
.legend .key-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ---- tooltip ---- */
#tooltip {
  position: fixed; pointer-events: none; z-index: 10; display: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  max-width: 280px;
}
#tooltip .tt-title { font-weight: 600; margin-bottom: 3px; }
#tooltip .tt-row { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
#tooltip .tt-row .key-line { width: 12px; height: 2px; border-radius: 1px; flex: none; }
#tooltip .tt-row b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---- data table ---- */
.tbl-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 680px; }
table.data th {
  text-align: right; font-weight: 600; color: var(--ink-2); cursor: pointer;
  padding: 8px 10px; border-bottom: 1px solid var(--baseline); white-space: nowrap;
  user-select: none;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th .arrow { color: var(--s1); font-size: 11px; }
table.data td {
  text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.data td.name { font-weight: 600; }
table.data td .region { color: var(--muted); font-size: 12px; }
.databar { display: inline-block; height: 8px; border-radius: 4px; background: var(--s1); vertical-align: middle; }
.delta-down { color: var(--s1); }
.delta-up { color: var(--ink-2); }

/* ---- table-view twins ---- */
details.tblview { margin-top: 12px; }
details.tblview summary { font-size: 13px; color: var(--muted); cursor: pointer; }
details.tblview table { margin-top: 10px; }

footer.site {
  margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--grid);
  font-size: 13px; color: var(--muted);
}
footer.site a { color: var(--ink-2); }
