:root {
  color-scheme: light;
  --page: #f5f4f1;
  --surface: #fcfcfb;
  --line: #e6e4df;
  --grid: #eeede9;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --before: #2a78d6;   /* categorical slot 1 */
  --after: #eb6834;    /* categorical slot 2 */
  --bar: #2a78d6;
  --track: #eeede9;
  --accent: #184f95;
  --radius: 10px;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #121211;
    --surface: #1a1a19;
    --line: #2e2e2b;
    --grid: #262624;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #93928a;
    --before: #3987e5;
    --after: #d95926;
    --bar: #3987e5;
    --track: #262624;
    --accent: #86b6ef;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #121211;
  --surface: #1a1a19;
  --line: #2e2e2b;
  --grid: #262624;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #93928a;
  --before: #3987e5;
  --after: #d95926;
  --bar: #3987e5;
  --track: #262624;
  --accent: #86b6ef;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.shell { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }

/* ------------------------------------------------------------ masthead */
.masthead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.logo { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; background: var(--surface); }
.kicker { margin: 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 650; }
.updated { margin: 0 0 0 auto; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------- filters */
.filters {
  display: flex; flex-wrap: wrap; align-items: end; gap: 12px;
  padding: 12px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  position: sticky; top: 0; z-index: 5;
}
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 14px; padding: 7px 14px; border: 0; cursor: pointer;
  background: transparent; color: var(--text-2);
}
.seg button[aria-selected="true"] { background: var(--text); color: var(--surface); }
.field { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.field.wide { flex: 1 1 280px; }
.field select {
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--page); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; min-width: 130px; max-width: 100%;
}
.field.wide select { width: 100%; }
.field[hidden] { display: none; }

.check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2); cursor: pointer; padding-bottom: 8px;
}
.check input { accent-color: var(--bar); width: 15px; height: 15px; }
.check[hidden] { display: none; }

.download {
  margin-left: auto;
  font-size: 14px;
  text-decoration: none;
  color: var(--surface);
  background: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  white-space: nowrap;
}
.download:hover { opacity: .9; }
.download[aria-disabled="true"] { opacity: .4; pointer-events: none; }


/* ------------------------------------------------------------ sections */
section { margin-bottom: 28px; }
h2 { font-size: 17px; margin: 0 0 4px; font-weight: 650; }
.lede { margin: 0 0 14px; color: var(--text-2); font-size: 14px; max-width: 70ch; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; min-width: 0;
}
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.state { color: var(--text-2); padding: 32px 0; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }
.note { font-size: 12px; margin: -6px 0 12px; }

/* --------------------------------------------------------------- tiles */
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 28px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--text-2); }
.tile .value { font-size: 30px; font-weight: 650; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.withheld { color: var(--muted); }

/* ---------------------------------------------------------------- bars */
.bars { display: grid; gap: 8px; }
.bar-row {
  display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: 10px;
  font-size: 13px;
}
.bar-row .name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .num { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; min-width: 64px; }
.bar-row .num small { color: var(--muted); }
.track { height: 12px; display: flex; align-items: center; }
.fill { height: 10px; border-radius: 0 4px 4px 0; background: var(--bar); min-width: 2px; }
.pair .track { height: auto; flex-direction: column; align-items: stretch; gap: 2px; }
.pair .fill.before { background: var(--before); }
.pair .fill.after { background: var(--after); }
.pair .num { line-height: 1.25; }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin: -4px 0 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
/* ------------------------------------------------- stacked share bar */
/* Categorical slots, in the order the palette fixes them. */
.s1 { background: var(--series-1); }
.s2 { background: var(--series-2); }
.s3 { background: var(--series-3); }
.s4 { background: var(--series-4); }

.stack { display: flex; gap: 2px; height: 16px; border-radius: 4px; overflow: hidden; }
.stack .seg { min-width: 3px; }
.keys { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.keys .key { display: inline-flex; align-items: center; gap: 6px; }
.keys i { width: 10px; height: 10px; border-radius: 2px; }
.keys b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.keys small { color: var(--muted); }

/* ----------------------------------------------------------- dumbbell */
.dumb .track { height: 16px; position: relative; }
.dumb .rail { position: absolute; left: 0; right: 0; top: 7px; height: 2px; background: var(--track); }
.dumb .span { position: absolute; top: 7px; height: 2px; background: var(--text-2); opacity: .35; }
.dumb .dot { position: absolute; top: 3px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); }
.dumb .dot.before { background: var(--before); }
.dumb .dot.after { background: var(--after); }
.dumb .num small { color: var(--muted); }


/* ------------------------------------------------------------- columns */
.cols { display: flex; align-items: flex-end; gap: 4px; height: 140px; border-bottom: 1px solid var(--line); padding-top: 18px; }
.col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; position: relative; }
.col .fill { border-radius: 4px 4px 0 0; width: 100%; min-height: 0; }
.col .v { position: absolute; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.col-labels { display: flex; gap: 4px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.col-labels span { flex: 1; text-align: center; }

/* --------------------------------------------------------------- table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
th { font-weight: 600; color: var(--text-2); font-size: 12px; background: var(--surface); }
th:first-child, td:first-child { text-align: left; white-space: normal; min-width: 220px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--grid); }
td .sub { display: block; font-size: 12px; color: var(--muted); }


/* ------------------------------------------------------------- updates */
.update {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 20px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius);
  font-size: 14px;
}
.update button {
  font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
  color: var(--surface); background: var(--text); border: 0; border-radius: 8px; padding: 7px 14px;
}

/* -------------------------------------------------------------- misc */
.tip {
  position: fixed; pointer-events: none; z-index: 20;
  background: var(--text); color: var(--surface);
  font-size: 12px; padding: 6px 9px; border-radius: 6px; max-width: 260px;
}
.footnote { margin-top: 32px; font-size: 12px; color: var(--muted); max-width: 80ch; }
.footnote p { margin: 0 0 6px; }

@media (max-width: 560px) {
  h1 { font-size: 20px; }
  .updated { margin-left: 0; width: 100%; }
  .filters { position: static; }
  .download { margin-left: 0; width: 100%; text-align: center; }
  .check { width: 100%; }
  .tile .value { font-size: 26px; }
  .bar-row { grid-template-columns: minmax(80px, 38%) 1fr auto; }
}
