:root {
  color-scheme: light;
  --page: #f9f9f9;
  --surface: #ffffff;
  --text: #191919;
  --text-2: #666666;
  --border: rgba(11, 11, 11, 0.10);
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --accent: #1b64be;
  --row-hover: #f3f6fb;
  --good: #006c10;
  --good-bg: #e3f4e5;
  --bad: #b42d2e;
  --bad-bg: #fbe6e6;
  --tag-bg: #eeeeee;
  --s1: #257de0;
  --s2: #f47230;
  --s3: #00b894;
  --s4: #f2a600;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0b0b0b;
    --surface: #191919;
    --text: #efefef;
    --text-2: #9c9c9c;
    --border: rgba(255, 255, 255, 0.10);
    --grid: #303030;
    --axis: #474747;
    --accent: #6aabf1;
    --row-hover: #20242b;
    --good: #53c556;
    --good-bg: #16301a;
    --bad: #f07a7b;
    --bad-bg: #3a1a1a;
    --tag-bg: #2a2a2a;
    --s1: #338ced;
    --s2: #e76624;
    --s3: #00a888;
    --s4: #d28e05;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0b0b;
  --surface: #191919;
  --text: #efefef;
  --text-2: #9c9c9c;
  --border: rgba(255, 255, 255, 0.10);
  --grid: #303030;
  --axis: #474747;
  --accent: #6aabf1;
  --row-hover: #20242b;
  --good: #53c556;
  --good-bg: #16301a;
  --bad: #f07a7b;
  --bad-bg: #3a1a1a;
  --tag-bg: #2a2a2a;
  --s1: #338ced;
  --s2: #e76624;
  --s3: #00a888;
  --s4: #d28e05;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 16px/1.5 var(--font);
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; min-height: 56px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.site-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-header nav a { color: var(--text-2); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.site-header nav a:hover { color: var(--text); background: var(--tag-bg); }
.site-header nav a[aria-current="page"] { color: var(--text); font-weight: 600; background: var(--tag-bg); }

main { padding: 8px 16px 48px; }
section { margin-top: 40px; }
section.intro { margin-top: 32px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 1.3rem; margin: 0 0 4px; }
h3 { font-size: 1rem; margin: 0 0 6px; }
.lead { font-size: 1.1rem; color: var(--text-2); margin: 0 0 8px; max-width: 60em; }
.muted { color: var(--text-2); }
.small { font-size: 0.875rem; }
.empty { color: var(--text-2); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 16px; }
.crumbs { margin-top: 24px; color: var(--text-2); font-size: 0.9rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 24px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.tile-label { color: var(--text-2); font-size: 0.875rem; }
.tile-value { font-size: 2rem; font-weight: 700; line-height: 1.2; margin: 4px 0; }
.tile-value-sm { font-size: 1.5rem; }
.tile-sub { color: var(--text-2); font-size: 0.875rem; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 0.925rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
thead th { font-weight: 600; color: var(--text-2); font-size: 0.825rem; position: sticky; top: 0; background: var(--surface); }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:hover { background: var(--row-hover); }
tbody th { font-weight: 500; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }
thead th button {
  all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center;
}
thead th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
thead th button::after { content: "↕"; opacity: 0.35; font-size: 0.8em; }
thead th[aria-sort="ascending"] button::after { content: "▲"; opacity: 1; }
thead th[aria-sort="descending"] button::after { content: "▼"; opacity: 1; }
.linkish { all: unset; cursor: pointer; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.linkish:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.825rem; color: var(--text-2); }
.filters select, .filters input {
  font: inherit; font-size: 0.95rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 8px; padding: 7px 10px; min-width: 170px;
}
.filters select:focus, .filters input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Tags and change markers (icon + label, never color alone) */
.tag { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--tag-bg); color: var(--text); }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.chg { font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chg.up { color: var(--good); }
.chg.down { color: var(--bad); }
.chg.same { color: var(--text-2); }

/* Change log */
.day { margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.day h3 { color: var(--text-2); font-weight: 600; font-size: 0.9rem; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { padding: 4px 0; border-top: 1px solid var(--grid); }
.events li:first-child { border-top: 0; }

/* Bank facts */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 24px 0 0; }
.facts div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.facts dt { color: var(--text-2); font-size: 0.825rem; }
.facts dd { margin: 2px 0 0; font-weight: 500; }

/* Chart */
.chart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-top: 12px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 8px; padding: 0; font-size: 0.875rem; color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 16px; height: 2px; border-radius: 1px; }
.plot { position: relative; outline: none; }
.plot:focus-visible { box-shadow: 0 0 0 2px var(--accent); border-radius: 6px; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.grid { stroke: var(--grid); stroke-width: 1; }
.axis { stroke: var(--axis); stroke-width: 1; }
.tick { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.dlabel { fill: var(--text-2); font-size: 11px; }
.dlabel .dv { fill: var(--text); font-weight: 600; }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.s1 { stroke: var(--s1); background: var(--s1); }
.s2 { stroke: var(--s2); background: var(--s2); }
.s3 { stroke: var(--s3); background: var(--s3); }
.s4 { stroke: var(--s4); background: var(--s4); }
.crosshair { stroke: var(--axis); stroke-width: 1; visibility: hidden; }
.dot { stroke: var(--surface); stroke-width: 2; }
.dot.s1 { fill: var(--s1); } .dot.s2 { fill: var(--s2); } .dot.s3 { fill: var(--s3); } .dot.s4 { fill: var(--s4); }
.tooltip {
  position: absolute; top: 0; pointer-events: none; z-index: 2;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); padding: 8px 10px; font-size: 0.8rem; min-width: 180px;
}
.tooltip .tt-date { color: var(--text-2); margin-bottom: 4px; }
.tooltip .tt-row { display: grid; grid-template-columns: 12px auto 1fr; gap: 6px; align-items: center; }
.tooltip .tt-row strong { font-variant-numeric: tabular-nums; }
.tooltip .tt-row span:last-child { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-view { margin-top: 8px; font-size: 0.875rem; }
.table-view summary { cursor: pointer; color: var(--accent); }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 0.875rem; }
.site-footer .wrap { padding-top: 16px; padding-bottom: 24px; }
.site-footer p { margin: 0 0 8px; max-width: 70em; }

@media (max-width: 640px) {
  th, td { padding: 6px 8px; }
  .filters label { flex: 1 1 140px; }
  .filters select, .filters input { min-width: 0; width: 100%; }
  .tile-value { font-size: 1.6rem; }
}
@media (forced-colors: active) {
  .line { stroke: CanvasText; }
  .s2.line { stroke-dasharray: 6 3; } .s3.line { stroke-dasharray: 2 3; } .s4.line { stroke-dasharray: 10 3 2 3; }
}

/* Brand, bank/term facts, plain event lists, day pages, explainer */
.brand .tld { color: var(--text-2); font-weight: 500; }
.facts dd.big { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.events.plain li { padding: 6px 0; }
.events.plain time { color: var(--text-2); font-variant-numeric: tabular-nums; }
.events.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 16px; margin-top: 16px; }
.day h3 a { color: inherit; text-decoration: none; }
.day h3 a:hover { color: var(--accent); text-decoration: underline; }
.pager { margin-top: 24px; }
.prose { max-width: 46em; margin-top: 24px; }
.prose h2 { margin-top: 32px; }
.prose p, .prose li { line-height: 1.65; }
.prose li { margin: 4px 0; }
