:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.22);
  --wash: rgba(11, 11, 11, 0.05);
  --accent: #2a78d6;
  --accent-bg: #e6f0fc;
  --up: #b42323;
  --down: #006300;
  --danger: #b42323;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9a9890;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.24);
    --wash: rgba(255, 255, 255, 0.06);
    --accent: #3987e5;
    --accent-bg: #16263b;
    --up: #f07070;
    --down: #3cc23c;
    --danger: #f07070;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }

.masthead { margin-bottom: 20px; }
.brand { margin: 0 0 4px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
h1 { margin: 0 0 6px; font-size: clamp(22px, 3.2vw, 30px); line-height: 1.2; font-weight: 650; }
h2 { margin: 0; font-size: 17px; font-weight: 600; }
.lede { margin: 0 0 8px; color: var(--ink-2); }
.status { margin: 0; font-size: 13px; color: var(--muted); }
.stale { margin: 6px 0 0; font-size: 13px; color: var(--danger); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.card-label { font-size: 13px; color: var(--ink-2); }
.card-value { font-size: 32px; font-weight: 650; line-height: 1.15; margin: 4px 0 8px; }
.card-value small { font-size: 15px; font-weight: 500; color: var(--ink-2); }
.deltas { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-2); }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }

.controls { padding: 10px 0 6px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.control-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 8px; }
.ranges, .actions, .legend, .legend-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.legend { flex: 1 1 600px; }
button { font: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 11px; cursor: pointer; min-height: 32px; }
button:hover { background: var(--wash); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ranges button[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.legend button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; }
.legend button[aria-pressed="false"] { color: var(--muted); border-style: dashed; background: transparent; }
.legend button[aria-pressed="false"] svg { opacity: .3; }
.legend svg { flex: none; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }

.chart-card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-top: 16px; }
.chart-sub { margin: 2px 0 10px; font-size: 13px; color: var(--muted); }
.chart-wrap { position: relative; height: 380px; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; color: var(--muted); text-align: center; padding: 0 24px; }
.empty[hidden] { display: none; }

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
th { font-weight: 600; color: var(--ink-2); font-size: 13px; }
th button { border: 0; background: none; padding: 2px 0; min-height: 0; font-weight: 600; color: inherit; }
th button:hover { background: none; text-decoration: underline; }
td.up { color: var(--up); font-weight: 600; }
td.down { color: var(--down); font-weight: 600; }
tr.us td { font-weight: 650; }
.note { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

.fsc-tiles, .fsc-inputs, .fsc-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--wash); border-radius: 8px; padding: 12px 14px; }
.tile-label { display: block; font-size: 13px; color: var(--ink-2); }
.tile-value { display: block; font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.fsc-inputs label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.fsc-inputs input { font: inherit; font-size: 15px; color: var(--ink); background: var(--page); border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; }
.fsc-inputs input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.help { font-size: 12px; color: var(--muted); line-height: 1.4; }
.error { margin: 0 0 8px; min-height: 0; font-size: 13px; color: var(--danger); }
.result { display: block; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.fsc-table { max-width: 520px; margin-top: 6px; }
.fsc-table tr.current td { background: var(--accent-bg); font-weight: 650; }

.footer { margin-top: 24px; font-size: 12px; color: var(--muted); }

@media (max-width: 640px) {
  .page { padding-top: 16px; }
  .chart-wrap { height: 300px; }
  .card-value { font-size: 28px; }
  .chart-card, .panel { padding: 14px 12px; }
  table.latest { font-size: 12px; }
  table.latest th, table.latest td { padding: 7px 3px; }
  table.latest th { font-size: 12px; }
  table.latest td:first-child { white-space: normal; min-width: 84px; }
  .fsc-table td:first-child { white-space: normal; }
}
