:root {
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efeb;
  --ink: #1b1b1a;
  --ink-2: #4a4a47;
  --muted: #7a7a75;
  --line: #e2e0da;
  --grid: #ebe9e4;
  --accent: #1b1b1a;
  --accent-ink: #fcfcfb;
  --focus: #2f6fdf;

  /* party colours — conventional identities, darkened where needed for contrast */
  --p-cdu: #2b2b2b;
  --p-afd: #0a7fc2;
  --p-spd: #e3000f;
  --p-gru: #3a9a3a;
  --p-lin: #b0157a;
  --p-bsw: #7d3c98;
  --p-fdp: #d4a900;
  --p-fw:  #e07b00;
  --p-son: #8a8f98;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --ink: #ecebe7; --ink-2: #bdbcb6;
    --muted: #8d8c86; --line: #2e2e2b; --grid: #262624; --accent: #ecebe7; --accent-ink: #1a1a19; --focus: #6ea0ff;
    --p-cdu: #d6d6d6; --p-afd: #4aa8ff; --p-spd: #ff4d57; --p-gru: #5cc45c; --p-lin: #e055b0;
    --p-bsw: #b07ad6; --p-fdp: #f2cc2e; --p-fw: #ff9a2e; --p-son: #9aa0a8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --ink: #ecebe7; --ink-2: #bdbcb6;
  --muted: #8d8c86; --line: #2e2e2b; --grid: #262624; --accent: #ecebe7; --accent-ink: #1a1a19; --focus: #6ea0ff;
  --p-cdu: #d6d6d6; --p-afd: #4aa8ff; --p-spd: #ff4d57; --p-gru: #5cc45c; --p-lin: #e055b0;
  --p-bsw: #b07ad6; --p-fdp: #f2cc2e; --p-fw: #ff9a2e; --p-son: #9aa0a8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: inherit; text-underline-offset: 2px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 700; line-height: 1.1; }
h2 { font-size: 17px; font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); padding: 24px 0 16px; }
.top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.meta { margin: 6px 0 0; color: var(--ink-2); font-size: 13px; }
.theme-btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  width: 38px; height: 38px; border-radius: 10px; font-size: 18px; cursor: pointer; flex: none;
}
.scope { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }

select {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 30px 6px 10px; max-width: 100%;
  appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 14px center, right 9px center; background-size: 5px 5px; background-repeat: no-repeat;
}
select[hidden] { display: none; }

/* segmented controls & chips */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button {
  font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--ink-2);
  padding: 5px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg button:disabled { opacity: .4; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 4px 10px; border-radius: 999px; cursor: pointer;
}
.chip[aria-pressed="false"] { color: var(--muted); background: transparent; text-decoration: line-through; }
.chip[aria-pressed="false"] .sw { opacity: .3; }
.chip .n { color: var(--muted); font-size: 12px; }
.chip.reset { border-style: dashed; color: var(--ink-2); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* termine */
.termine { margin: 20px 0 0; }
.mini-head { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.termine-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.termin {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  display: flex; gap: 12px; align-items: center; text-align: left; font: inherit; color: inherit;
}
button.termin { cursor: pointer; }
button.termin:hover { border-color: var(--muted); }
.termin .days { font-size: 24px; font-weight: 700; line-height: 1; min-width: 52px; }
.termin .days small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 3px; }
.termin .what { font-weight: 600; font-size: 14px; }
.termin .when { color: var(--ink-2); font-size: 13px; }

/* filters */
.filters {
  margin: 16px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: grid; gap: 12px;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; }
.filter-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; min-width: 72px; }
.toggle { font-size: 14px; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; color: var(--ink-2); }
.coal-toggle { margin-top: 8px; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.kpi .name { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.kpi .val { font-size: 28px; font-weight: 700; line-height: 1.15; margin: 2px 0; }
.kpi .val small { font-size: 15px; font-weight: 500; color: var(--muted); }
.kpi .delta { font-size: 12px; color: var(--ink-2); }
.kpi .delta b { font-weight: 600; color: var(--ink); }
.kpi.out .val { color: var(--muted); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; min-width: 0; }
.card-head { margin-bottom: 12px; }
.card-head.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; max-width: 70ch; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; gap: 0; } }
.chart-box { position: relative; height: 340px; }
.chart-box.tall { height: 460px; }
@media (max-width: 600px) { .chart-box.tall { height: 360px; } }
.empty { color: var(--muted); text-align: center; padding: 40px 0; margin: 0; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw.solid { background: var(--ink-2); }
.legend .sw.ghost { background: transparent; border: 1.5px solid var(--ink-2); }

/* trend tooltip */
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 170px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14); padding: 10px 12px; font-size: 13px;
}
.tooltip .tt-date { font-weight: 600; margin-bottom: 6px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tooltip .tt-row b { font-weight: 600; }
.tooltip .tt-foot { color: var(--muted); font-size: 12px; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }

/* tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data th { font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data th[aria-sort="ascending"]::after { content: " ▲"; }
table.data th[aria-sort="descending"]::after { content: " ▼"; }
table.data .l { text-align: left; }
table.data td.lead { font-weight: 700; }
table.data td.dim { color: var(--muted); }
table.data tbody tr:hover td { background: var(--surface-2); }
.party-cell { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.up { color: var(--ink); }
.down { color: var(--ink); }
.arrow { display: inline-block; width: 1em; color: var(--muted); }
.spark { display: block; }
.more {
  display: block; margin: 12px auto 0; font: inherit; font-size: 14px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); padding: 7px 16px; border-radius: 8px; cursor: pointer;
}
.more[hidden] { display: none; }

/* thanks */
.thanks { text-align: center; }
.thanks h2 { font-size: 20px; }
.thanks p { max-width: 640px; margin: 8px auto 0; color: var(--ink-2); }
.thanks a { color: var(--focus); font-weight: 600; }

.foot { color: var(--muted); font-size: 13px; padding-bottom: 32px; }
.foot p { margin: 4px 0; }
.foot .legal { margin-top: 10px; }
.foot .legal a { color: var(--ink-2); }
