/* Fonts served from this site (SIL Open Font License), so visitors' browsers never contact Google. */
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("../fonts/source-sans-3-latin.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("../fonts/source-serif-4-latin.woff2") format("woff2"); }

/* Civic dashboard: calm off-white ground, Delft-blue accent, serif numbers. */
:root {
  --bg: #f4f5f2;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #5b6573;
  --line: #dfe2dc;
  --accent: #1f4e8c;
  --accent-soft: #e6edf7;
  --good: #1b7a46;
  --bad: #b3261e;
  --grid: #eceee9;
  --s1: #1f4e8c; --s2: #d9822b; --s3: #2a9d8f; --s4: #8e5ba8; --s5: #c9a227; --s6: #6b7a8f; --s7: #c4544b; --s8: #4f9fd8;
  --muted-series: #b8bfc8;
  --heat-0: #f1f3ef; --heat-1: #1f4e8c;
  --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "Source Serif 4", Georgia, serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b; --panel: #1a2027; --ink: #e8ebee; --muted: #9aa5b1; --line: #2c343d; --accent: #7fb0f0;
    --accent-soft: #1f2d3f; --good: #5cc48a; --bad: #f08a80; --grid: #232a32;
    --s1: #7fb0f0; --s2: #f0a35a; --s3: #4cc2b3; --s4: #c08ddb; --s5: #e3c24f; --s6: #9aa8bb; --s7: #e57d74; --s8: #8cc8f2;
    --muted-series: #4a535e; --heat-0: #222930; --heat-1: #7fb0f0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Elements hidden by script must stay hidden, even when a component rule sets display (e.g. .consent { display: grid }). */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.5; }
a { color: var(--accent); }
h1, h2 { text-wrap: balance; }
.wrap { max-width: 1240px; margin-inline: auto; padding-inline: max(16px, 3vw); }

/* Header */
.site-head { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-head-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; padding-block: 10px; }
.brand { font-family: var(--font-num); font-weight: 600; font-size: 1.15rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--accent); }
.site-nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1 1 0; min-width: 0; }
.nav-toggle { display: none; }
@media (max-width: 760px) {
  .site-head-inner { justify-content: space-between; }
  .nav-toggle { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; color: var(--ink);
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
  .nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after { display: block; width: 16px; height: 2px; background: currentColor;
    border-radius: 1px; position: relative; }
  .nav-toggle-bars::before, .nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
  .nav-toggle-bars::before { top: -5px; } .nav-toggle-bars::after { top: 5px; }
  .site-nav { display: none; flex: 1 1 100%; flex-direction: column; gap: 0; padding: 6px 0 4px; }
  .site-nav.is-open { display: flex; }
  .site-nav a { padding: 10px 8px; border-radius: 6px; font-size: 1rem; }
}
.site-nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; white-space: nowrap; font-size: .95rem; }
.site-nav a:hover { color: var(--ink); background: var(--bg); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* Page head */
.hero, .page-head { padding-block: 32px 8px; }
.hero h1, .page-head h1 { font-family: var(--font-num); font-weight: 600; font-size: clamp(1.8rem, 3.5vw, 2.6rem); line-height: 1.15; margin: 0 0 8px; }
.lede { color: var(--muted); font-size: 1.1rem; max-width: 68ch; margin: 0; }

/* Home tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; padding-block: 24px 40px; }
.tile { display: grid; gap: 6px; align-content: start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 20px; color: var(--ink); text-decoration: none; transition: border-color .15s; }
.tile:hover, .tile:focus-visible { border-color: var(--accent); }
.tile h2 { margin: 0; font-size: 1.25rem; color: var(--accent); }
.tile p { margin: 0; color: var(--muted); }
.tile-for { font-size: .88rem; }
.tile-for span, .who span { text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 600; color: var(--muted); margin-right: .5em; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 12px 20px; padding-block: 16px 0; }
.filters label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.filters select { font: inherit; font-size: 1rem; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
                  border-radius: 8px; padding: 6px 10px; min-width: 220px; max-width: 100%; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 12px; padding-block: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; display: grid; gap: 2px; align-content: start; }
.kpi-label { font-size: .88rem; color: var(--muted); }
.kpi-value { font-family: var(--font-num); font-size: 2rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi-note .good { color: var(--good); font-weight: 600; }
.kpi-note .bad { color: var(--bad); font-weight: 600; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.card-wide { grid-column: 1 / -1; }
.card h2 { font-size: 1.1rem; margin: 0; }
.note { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.who { margin: 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: .9rem; }
.chart { position: relative; min-height: 280px; min-width: 0; }
.card-tall .chart { min-height: 520px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-family: var(--font); font-size: 12px; }
.chart .end-label { fill: var(--ink); font-variant-numeric: tabular-nums; }
.chart .domain, .chart .tick line { stroke: var(--line); }
.chart .empty { color: var(--muted); padding: 40px 0; text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
       box-shadow: 0 6px 18px rgb(0 0 0 / .12); padding: 6px 10px; font-size: .85rem; white-space: nowrap; z-index: 5; font-variant-numeric: tabular-nums; }
.tip b { display: block; color: var(--muted); font-weight: 500; }
.tip i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }

.is-loading { position: relative; }
.chart.is-loading::after, .kpi.is-loading .kpi-value::after {
  content: ""; position: absolute; inset: 10px 0; border-radius: 6px; background: var(--grid); animation: pulse 1.4s ease-in-out infinite; }
.kpi.is-loading .kpi-value { position: relative; }
@keyframes pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .chart.is-loading::after, .kpi.is-loading .kpi-value::after { animation: none; } }

/* Tables */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.chart table { font-size: .9rem; }
.chart td { white-space: nowrap; }
.chart td:last-child, .chart td.wrap { white-space: normal; }
.chart .table-wrap { max-height: 460px; overflow: auto; }
.chart .table-wrap thead th { position: sticky; top: 0; background: var(--panel); }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* Heat grid */
.heat { display: grid; gap: 2px; font-size: .8rem; }
.heat .h-row { display: grid; grid-template-columns: minmax(150px, 190px) repeat(var(--cols), minmax(26px, 1fr)); gap: 2px; align-items: center; }
.heat .h-group { margin-top: 10px; font-weight: 600; color: var(--ink); font-size: .9rem; }
.heat .h-label { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 6px; }
.heat .h-cell { height: 24px; border-radius: 3px; background: var(--heat-0); }
.heat .h-head { color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; line-height: 1.1; }
.heat .h-head small { display: block; font-size: .7rem; }

/* Audience + sources */
.audience, .page-sources { padding-block: 28px 0; }
.audience h2, .page-sources h2 { font-size: 1.15rem; }
.audience td:first-child { font-weight: 600; white-space: nowrap; }
#sources { padding-left: 1.1em; color: var(--muted); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .8rem; background: var(--grid); }
.pill-ok { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.pill-error { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.sources-table { font-size: .92rem; }
.site-foot { color: var(--muted); font-size: .9rem; padding-block: 40px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 600px) {
  .card { padding: 14px; }
  .kpi-value { font-size: 1.6rem; }
  .heat .h-row { grid-template-columns: 110px repeat(var(--cols), minmax(18px, 1fr)); }
  .card-tall .chart { min-height: 380px; }
}

.feed-link { margin: 10px 0 0; font-size: .95rem; color: var(--muted); }
.since { margin: 12px 0 0; padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); font-size: .95rem; max-width: 80ch; }
.summary-list { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; font-size: 1.05rem; line-height: 1.45; }
.chart:has(.summary-list) { min-height: 0; }
.pill-new { margin-left: 6px; background: var(--accent); color: var(--panel); }

/* Over */
.about { display: grid; gap: 8px; padding-block: 8px 24px; max-width: 760px; }
.about h2 { font-size: 1.2rem; margin: 22px 0 0; }
.about p { margin: 0; }
.about p, .about li { font-size: 1.05rem; line-height: 1.6; max-width: 68ch; }
.callout h2 { margin: 0; }
.about ul { margin: 0; padding-left: 1.2em; }
.donate { display: inline-flex; align-items: center; gap: 10px; background: #ffdd00; color: #1b1b1b; font-weight: 600;
          text-decoration: none; padding: 10px 18px; border-radius: 999px; border: 1px solid #e5c600; width: fit-content; }
.donate:hover, .donate:focus-visible { background: #ffe74d; }
.donate[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.donate-cup { font-size: 1.2rem; line-height: 1; }
.site-foot .donate { padding: 6px 14px; font-size: .9rem; margin-top: 8px; }
.callout { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 10px; }

/* Donation: header button and slide-in */
.donate-head { padding: 6px 14px; font-size: .9rem; white-space: nowrap; margin-left: auto; }
.donate-slide { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: 24px; z-index: 20; width: min(340px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgb(0 0 0 / .18);
  padding: 18px 20px 20px; display: grid; gap: 8px; transform: translateX(calc(100% + 40px)); transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
.donate-slide.is-open { transform: none; }
.donate-slide p { margin: 0; font-size: .95rem; line-height: 1.5; }
.donate-slide .donate-slide-title { font-weight: 600; font-size: 1.05rem; padding-right: 24px; }
.donate-slide .donate { margin-top: 4px; }
.donate-close { position: absolute; top: 6px; right: 8px; width: 32px; height: 32px; border: 0; border-radius: 6px; background: none;
  color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.donate-close:hover { background: var(--bg); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .donate-slide { transition: none; } }
@media (max-width: 600px) {
  .donate-head { display: none; }
  .donate-slide { left: 0; right: 0; bottom: 0; width: auto; border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateY(100%); }
}

.card-tools { margin: -4px 0 0; font-size: .85rem; }
.card-tools a { color: var(--muted); }
.card-tools a:hover { color: var(--accent); }

/* Benchmark: own figures */
.own-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 10px 16px; }
.own-form label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.own-form input { font: inherit; font-size: 1rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-variant-numeric: tabular-nums; }
.own-result { margin-top: 14px; }
.own-result td small { color: var(--muted); }
.chart:has(.own-form) { min-height: 0; }

/* Cookie consent */
.consent { position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); bottom: 16px; z-index: 30;
  width: min(560px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(0 0 0 / .18); padding: 16px 18px; display: grid; gap: 12px; }
.consent p { margin: 0; font-size: .95rem; line-height: 1.5; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.consent-btn { font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer; }
.consent-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.consent-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 600px) {
  .consent { left: 0; right: 0; bottom: 0; width: auto; border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)); }
}

/* Loading layer */
.loading-overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(2px); }
.loading-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgb(0 0 0 / .14);
  padding: 22px 26px; display: grid; justify-items: center; gap: 8px; max-width: 380px; text-align: center; }
.loading-title { margin: 0; font-weight: 600; font-size: 1.05rem; }
.loading-hint { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.loading-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--grid); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-spinner { animation: none; border-top-color: var(--grid); border-color: var(--accent); } }
