:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  /* Job position types: permanent, temporary, not known. */
  --perm: #8e2a3f;
  --temp: #20509f;
  --unk: #898781;
  /* One colour per year wherever bars stand for a year; earlier years are grey. */
  --y2024: #0b98b8;
  --y2025: #a3207e;
  --y2026: #cf9e00;
  --y-other: #b5b3aa;
  /* Council motions that add spending. */
  --spend: #b8467a;
  --hover: rgba(11, 11, 11, 0.04);
  --link: #1c5cab;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --perm: #b04359;
    --temp: #3d6cc8;
    --unk: #6b6a65;
    --y2024: #12a0bd;
    --y2025: #b02f8a;
    --y2026: #d9a812;
    --y-other: #5a5954;
    --spend: #c95591;
    --hover: rgba(255, 255, 255, 0.05);
    --link: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --perm: #b04359;
  --temp: #3d6cc8;
  --unk: #6b6a65;
  --y2024: #12a0bd;
  --y2025: #b02f8a;
  --y2026: #d9a812;
  --y-other: #5a5954;
  --spend: #c95591;
  --hover: rgba(255, 255, 255, 0.05);
  --link: #86b6ef;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--link); }
main { max-width: 1040px; margin: 0 auto; padding: 32px 16px 64px; }
header p { color: var(--ink-2); margin: 4px 0 0; max-width: 64ch; }
h1 { font-size: 28px; line-height: 1.2; margin: 0; }
h2 { font-size: 17px; margin: 0 0 2px; }
.sub { color: var(--ink-2); font-size: 13px; margin: 0 0 16px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumb a { color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 16px; align-items: end; }
.filters label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
select {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-width: 180px;
}

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.hero { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) {
  .hero { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .hero .big { grid-column: 1 / -1; }
  .hero .stat:not(.big) { padding: 14px; }
  .hero .stat:not(.big) .value { font-size: 22px; }
}
.stat .label { font-size: 13px; color: var(--ink-2); }
.stat .value { font-size: 28px; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.stat.big .value { font-size: 48px; }
.stat .note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.charts { grid-template-columns: 3fr 2fr; }
@media (max-width: 760px) { .charts { grid-template-columns: 1fr; } }

/* Horizontal bars, one HTML row per department */
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(0, 13rem) 1fr 4.5rem; gap: 10px; align-items: center;
        border-radius: 6px; padding: 2px 4px; cursor: default; outline: none; }
.hbar:hover, .hbar:focus-visible { background: var(--hover); }
.hbar .name { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 16px; position: relative; border-left: 1px solid var(--axis); }
.hbar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .val { font-size: 13px; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .hbar { grid-template-columns: 1fr 4.5rem; row-gap: 2px; }
  .hbar .name { grid-column: 1 / -1; }
}

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { white-space: nowrap; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px;
                       margin-right: 6px; vertical-align: -1px; background: var(--c); }
svg text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg .grid line { stroke: var(--grid); }
svg .base { stroke: var(--axis); }
svg .col { outline: none; }
svg .col:hover rect.seg, svg .col:focus-visible rect.seg { filter: brightness(1.12); }
svg .lbl { fill: var(--ink); font-size: 12px; }
svg path.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg circle.dot { stroke: var(--surface); stroke-width: 2; }
svg line.hl { stroke: var(--axis); }
svg .hl { opacity: 0; }
svg .col:hover .hl, svg .col:focus-visible .hl { opacity: 1; }

/* Diverging bars: gains grow right of zero, losses left */
.dbar .track { border-left: 0; }
.dbar .track::before { content: ""; position: absolute; left: var(--zero); top: -3px; bottom: -3px; border-left: 1px solid var(--axis); }
.dbar .fill.pos { background: var(--s1); border-radius: 0 4px 4px 0; }
.dbar .fill.neg { background: var(--s2); border-radius: 4px 0 0 4px; }

#tip { position: fixed; pointer-events: none; z-index: 10; background: var(--surface); color: var(--ink);
       border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px;
       box-shadow: 0 4px 16px rgba(0,0,0,.12); min-width: 160px; max-width: 340px; display: none; }
#tip .t { color: var(--ink-2); margin-bottom: 4px; }
#tip .r { display: flex; justify-content: space-between; gap: 16px; }
#tip .r b { font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; }
td.date { white-space: nowrap; }
td.job { min-width: 14rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; white-space: nowrap; }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 2px solid var(--s1); border-radius: 2px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: var(--hover); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
footer { margin-top: 32px; color: var(--ink-2); font-size: 13px; }
footer ul { padding-left: 18px; }

nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 16px 0 0; border-bottom: 1px solid var(--grid); }
nav.tabs a, nav.tabs span { padding: 8px 12px; font-size: 14px; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
nav.tabs a:hover { color: var(--ink); }
nav.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--s1); font-weight: 600; }
nav.tabs span { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 24px; }
a.card { color: inherit; text-decoration: none; display: block; }
a.card:hover { border-color: var(--s1); }
.card .more { color: var(--link); font-size: 13px; margin-top: 8px; }

[hidden] { display: none !important; }

/* Council votes */
.filters input[type="search"] {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-width: 220px;
}
td.motion { min-width: 22rem; max-width: 40rem; }
td.motion details summary { cursor: pointer; color: var(--ink); list-style: none; }
td.motion details summary::-webkit-details-marker { display: none; }
td.motion details summary .more-toggle { color: var(--link); white-space: nowrap; }
td.motion details[open] summary .more-toggle { display: none; }
td.motion .full { margin-top: 6px; color: var(--ink-2); }
.result { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.result::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
.load-more { margin-top: 12px; font: inherit; font-size: 14px; color: var(--link); background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; }

/* Theme switch: sits at the end of the tab row */
nav.tabs .theme { margin-left: auto; align-self: center; display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 6px; }
nav.tabs .theme button { font: inherit; font-size: 13px; color: var(--ink-2); background: var(--surface); border: 0; padding: 4px 10px; cursor: pointer; }
nav.tabs .theme button + button { border-left: 1px solid var(--border); }
nav.tabs .theme button[aria-pressed="true"] { color: var(--ink); background: var(--hover); font-weight: 600; }
nav.tabs .theme button:focus-visible { outline: 2px solid var(--s1); outline-offset: -2px; }
.tag { display: inline-block; margin-left: 6px; font-size: 11px; color: var(--ink-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; vertical-align: 1px; white-space: nowrap; }
.check { display: flex !important; align-items: center; gap: 6px; font-size: 13px !important; color: var(--ink) !important; padding-bottom: 6px; cursor: pointer; }
.check input { margin: 0; accent-color: var(--s1); }
.check.off { color: var(--muted) !important; cursor: default; }
.hbar.pick { cursor: pointer; }
.yoy { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .yoy { grid-template-columns: 1fr; } }
.yoy h3 { font-size: 14px; margin: 0 0 4px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font: inherit; font-size: 13px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; cursor: pointer; }
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.vote-no { font-weight: 600; }
/* Segmented switch inside a card, e.g. No / Yes / Added spending */
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; }
.card-head + .sub { margin-top: 4px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; color: var(--ink-2); background: var(--surface); border: 0; padding: 4px 10px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { color: var(--ink); background: var(--hover); font-weight: 600; }
.seg button:focus-visible { outline: 2px solid var(--s1); outline-offset: -2px; }
.hbars.spend .fill { background: var(--spend); }
/* Highlighted motions take the colour of the chart view that marks them. */
tbody tr.mark { --mark: var(--s1); background: color-mix(in srgb, var(--mark) 8%, transparent); }
tbody tr.mark.spend { --mark: var(--spend); }
tbody tr.mark:hover { background: color-mix(in srgb, var(--mark) 13%, transparent); }
tbody tr.mark td:first-child { box-shadow: inset 3px 0 0 var(--mark); }
.tags { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 4px; }
.spend-tag, .minutes-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.minutes-tag { color: var(--muted); text-decoration: underline dotted; text-underline-offset: 2px; }
.minutes-tag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; border: 1.5px solid var(--muted); box-sizing: border-box; }
.spend-tag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--spend); }
.vote-away { color: var(--muted); }
