:root {
  color-scheme: light;
  --surface-0: #f4f4f1;
  --surface-1: #fcfcfb;
  --border: #dedcd5;
  --border-strong: #c4c1b7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7871;
  --series-1: #2a78d6;
  --series-1-soft: rgba(42, 120, 214, 0.14);
  --good: #008300;
  --bad: #e34948;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --border: #33332f;
    --border-strong: #4a4a44;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #93918a;
    --series-1: #3987e5;
    --series-1-soft: rgba(57, 135, 229, 0.2);
    --good: #4caf50;
    --bad: #e66767;
  }
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface-0);
  color: var(--text-primary);
  line-height: 1.5;
  padding: 2rem 1.25rem 4rem;
}

.page-head, .controls, .tiles, main, .page-foot {
  max-width: 1180px;
  margin-inline: auto;
}

.page-head { margin-bottom: 1.75rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.15; letter-spacing: -0.02em; }
.lede { margin-top: 0.75rem; max-width: 62ch; color: var(--text-secondary); }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.ctrl { display: flex; flex-direction: column; gap: 0.25rem; min-width: 150px; }
.ctrl.grow { flex: 1 1 200px; }
.ctrl label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.ctrl select, .ctrl input {
  font: inherit;
  padding: 0.45rem 0.6rem;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.tiles { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem; }
.tile {
  flex: 1 1 200px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}
.tile-label { display: block; font-size: 0.8rem; color: var(--text-muted); }
.tile-value { display: block; font-size: 1.5rem; font-weight: 650; letter-spacing: -0.01em; }

.section-head {
  font-size: 1.15rem;
  margin: 2rem 0 0.5rem;
  letter-spacing: -0.01em;
}
.section-lede {
  max-width: 72ch;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-0);
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
thead th.num, td.num { text-align: right; }
.col-chart { width: 190px; }

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr.item:hover { background: var(--surface-1); }
tbody td { padding: 0.5rem 0.6rem; vertical-align: middle; }

.name-btn {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.name-btn:hover .name { text-decoration: underline; }
.name { font-weight: 550; }
.unit { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.caret { color: var(--text-muted); font-size: 0.7rem; }

.muted { color: var(--text-muted); }

.change { font-weight: 650; white-space: nowrap; }
.change.up { color: var(--good); }
.change.down { color: var(--bad); }

.spark { display: block; }

tr.detail > td { padding: 0 0.6rem 1rem; }
.detail-box {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.detail-head { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: baseline; margin-bottom: 0.5rem; }
.detail-title { font-weight: 650; }
.detail-note { font-size: 0.8rem; color: var(--text-muted); }
.chart-wrap { position: relative; }
.axis-line { stroke: var(--border-strong); stroke-width: 1; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.axis-text { fill: var(--text-muted); font-size: 11px; }
.ref-line { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 3; }
.hover-line { stroke: var(--border-strong); stroke-width: 1; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  line-height: 1.35;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  transform: translate(-50%, -115%);
}
.tooltip-floating {
  position: fixed;
  z-index: 10;
}
.spark { cursor: crosshair; }
.tooltip b { font-variant-numeric: tabular-nums; }

.empty { padding: 2rem 0; color: var(--text-muted); }

.page-foot { margin-top: 3rem; font-size: 0.85rem; color: var(--text-secondary); }
.page-foot h2 { font-size: 0.95rem; margin-bottom: 0.5rem; color: var(--text-primary); }
.page-foot ul { padding-left: 1.1rem; display: grid; gap: 0.4rem; max-width: 80ch; }
.page-foot a { color: var(--series-1); }

@media (max-width: 720px) {
  body { padding: 1.25rem 0.75rem 3rem; }
  thead th:nth-child(2), tbody td:nth-child(2),
  thead th:nth-child(4), tbody td:nth-child(4) { display: none; }
  .col-chart { width: 120px; }
}
