/* SEPO Budget Database: one stylesheet, light and dark. Colors are role tokens. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6e69;
  --rule: #e1e0d9;
  --axis: #c3c2b7;
  --brand: #002060;          /* SEPO dark blue */
  --brand-ink: #ffffff;
  --link: #1c5cab;
  --up: #2a78d6;             /* diverging pole: increase (blue) */
  --down: #e34948;           /* diverging pole: decrease (red) */
  --bar: #2a78d6;            /* magnitude */
  --mid: #f0efec;            /* neutral midpoint */
  --note-bg: #fff6d6;
  --note-ink: #4a3b00;
  --ring: rgba(11, 11, 11, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #a3a29b;
    --rule: #2c2c2a; --axis: #383835; --brand: #8fb3ff; --brand-ink: #0d0d0d; --link: #86b6ef;
    --up: #3987e5; --down: #e66767; --bar: #3987e5; --mid: #383835;
    --note-bg: #2e2810; --note-ink: #f3e3a6; --ring: rgba(255, 255, 255, 0.10);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #a3a29b;
  --rule: #2c2c2a; --axis: #383835; --brand: #8fb3ff; --brand-ink: #0d0d0d; --link: #86b6ef;
  --up: #3987e5; --down: #e66767; --bar: #3987e5; --mid: #383835;
  --note-bg: #2e2810; --note-ink: #f3e3a6; --ring: rgba(255, 255, 255, 0.10);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 16px/1.5 Calibri, Carlito, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

header.site { border-bottom: 3px solid var(--brand); background: var(--surface); }
header.site .wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 24px; padding-top: 14px; padding-bottom: 10px; }
.brand { font-weight: 700; font-size: 20px; color: var(--brand); text-decoration: none; }
.brand small { display: block; font-weight: 400; font-size: 14px; color: var(--ink-2); }
nav.main { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-left: auto; }
nav.main a { text-decoration: none; color: var(--ink-2); padding: 4px 0; border-bottom: 2px solid transparent; }
nav.main a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }

.preview { background: var(--note-bg); color: var(--note-ink); font-size: 14px; }
.preview .wrap { padding-top: 8px; padding-bottom: 8px; }

main { padding: 24px 0 48px; }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; color: var(--brand); }
h2 { font-size: 21px; margin: 36px 0 6px; color: var(--brand); }
h3 { font-size: 17px; margin: 22px 0 6px; }
p.lede { color: var(--ink-2); margin: 0 0 18px; max-width: 760px; }
p.note, .source { color: var(--muted); font-size: 14px; }
.source em { font-style: italic; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 18px 0 8px; }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; padding: 14px 16px; }
.tile .label { color: var(--ink-2); font-size: 14px; }
.tile .value { font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.tile .delta { font-size: 14px; color: var(--ink-2); margin-top: 2px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; margin: 10px 0; font-size: 15px; }
.controls label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
input[type="search"] { font: inherit; padding: 8px 10px; border: 1px solid var(--axis); border-radius: 6px; background: var(--surface); color: var(--ink); width: min(100%, 420px); }
button.more { font: inherit; font-size: 14px; padding: 6px 12px; border: 1px solid var(--axis); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; margin-top: 8px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; margin: 8px 0; }
table.data { border-collapse: collapse; width: 100%; font-size: 15px; }
table.data caption { text-align: left; padding: 10px 12px 4px; font-weight: 700; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.data thead th { text-align: left; font-weight: 700; color: var(--ink-2); font-size: 14px; white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
table.data thead th.sortable { cursor: pointer; }
table.data thead th.sortable::after { content: " \2195"; color: var(--muted); font-weight: 400; }
table.data thead th[aria-sort="ascending"]::after { content: " \2191"; color: var(--ink); }
table.data thead th[aria-sort="descending"]::after { content: " \2193"; color: var(--ink); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.total td { font-weight: 700; border-top: 2px solid var(--axis); }
table.data tbody tr:hover { background: color-mix(in srgb, var(--bar) 6%, transparent); }
table.data td:first-child { min-width: 15em; }
td.barcell { width: 18%; min-width: 120px; }

/* magnitude bar */
.bar { height: 10px; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 1px; }
/* diverging bar: neutral midline, blue right for increase, red left for decrease */
.div { position: relative; height: 12px; }
.div::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--axis); }
.div span { position: absolute; top: 1px; height: 10px; }
.div span.up { left: 50%; background: var(--up); border-radius: 0 4px 4px 0; }
.div span.down { right: 50%; background: var(--down); border-radius: 4px 0 0 4px; }

.badge { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--ring); color: var(--ink-2); margin-left: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 24px; }
.found a { display: block; padding: 6px 0; border-bottom: 1px solid var(--rule); text-decoration: none; }
.found a span { color: var(--muted); font-size: 14px; }
.error { color: var(--down); }

footer.site { border-top: 1px solid var(--rule); color: var(--muted); font-size: 14px; padding: 18px 0 32px; }
@media (max-width: 600px) {
  h1 { font-size: 24px; }
  .tile .value { font-size: 22px; }
  td.barcell { min-width: 80px; }
}
@media print {
  header.site nav, .controls, button.more, .preview { display: none; }
  .table-wrap { overflow: visible; border: 0; }
}
