:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1a1d21;
  --muted: #5b6470;
  --line: #e2e5ea;
  --accent: #2f6df6;
  --yes: #2f6df6;
  --no: #e2683a;
  --shadow: 0 1px 3px rgba(10, 20, 40, .07), 0 8px 24px rgba(10, 20, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #171b21;
    --ink: #e8eaed;
    --muted: #9aa4b2;
    --line: #2a2f37;
    --accent: #5b8dff;
    --yes: #5b8dff;
    --no: #f0865a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
header, main, footer { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
header { padding-top: 34px; }
h1 { font-size: 26px; margin: 0 0 14px; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 0 0 20px; max-width: 62ch; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tab-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 550; padding: 9px 16px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.on { color: var(--ink); border-bottom-color: var(--accent); }
.tab[hidden] { display: none; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 8px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi .v { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

section {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; margin: 22px 0; box-shadow: var(--shadow);
}
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
h2 { font-size: 18px; margin: 0 0 2px; letter-spacing: -.01em; }
h3 { font-size: 14px; margin: 4px 0 8px; color: var(--muted); font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.toggle[hidden] { display: none; }
.toggle button {
  border: 0; background: transparent; color: var(--muted); padding: 6px 11px;
  font: inherit; font-size: 13px; cursor: pointer;
}
.toggle button.on { background: var(--accent); color: #fff; }

.chart { width: 100%; height: 420px; }
.chart.tall { height: 620px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.note { color: var(--muted); font-size: 12.5px; margin-top: 6px; min-height: 1em; }

.kpis.mini { grid-template-columns: repeat(5, 1fr); margin: 6px 0 14px; }
.kpis.mini .kpi { padding: 10px 12px; }
.kpis.mini .v { font-size: 16px; }
.kpis.mini .l { font-size: 11.5px; }

.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.sw.yes { background: var(--yes); }
.sw.no { background: var(--no); }

.controls select, .controls input[type="text"], .controls input:not([type]) {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 6px 9px; font: inherit; font-size: 13px;
}
.controls input { min-width: 170px; }
.minlab { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.minlab input[type="range"] { width: 120px; }
.linkbtn { border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; }

.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; max-height: 420px; }
.tablewrap.tall { max-height: 560px; margin-top: 14px; }
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th, table.data td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { position: sticky; top: 0; background: var(--panel); cursor: pointer; user-select: none; color: var(--muted); font-weight: 600; }
table.data th.sorted::after { content: " \25be"; }
table.data th.asc::after { content: " \25b4"; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:hover td { background: color-mix(in srgb, var(--accent) 8%, transparent); cursor: pointer; }
table.data td.side-yes { border-left: 3px solid var(--yes); }
table.data td.side-no { border-left: 3px solid var(--no); }

.pill {
  display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.pill.paid { background: color-mix(in srgb, var(--no) 16%, transparent); border-color: transparent; color: var(--ink); }
.pill.unpaid { opacity: .7; }
table.data td.dec-1 { border-left: 3px solid var(--yes); }
table.data td.dec-2 { border-left: 3px solid var(--no); }
table.data td.dec-3, table.data td.dec-0 { border-left: 3px solid var(--line); }
.branchips { display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0 10px; align-items: center; }
.branchip {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  color: var(--ink); border: 1px solid transparent;
  background: color-mix(in srgb, var(--bc) 20%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bc) 45%, transparent);
}
.branchip-src { font-size: 10.5px; color: var(--muted); }
table.data td.br-cell { color: var(--muted); }
#polCampaign .big { font-size: 20px; font-weight: 650; }
#polCampaign ul { margin: 8px 0 0; padding-left: 18px; }
#polCampaign li { font-size: 12.5px; margin: 2px 0; }
#polMandatesText { margin-top: 10px; }

#nrsaal, #srsaal { width: 100%; height: 460px; }
.saal-info {
  margin: 2px 0 0; min-height: 2.7em; font-size: 12.5px; color: var(--ink);
  line-height: 1.35;
}
.saal-info:empty::before { content: "Über einen Punkt fahren für Details."; color: var(--muted); }
.nrsaal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.nrsaal-legend .lg-item { display: inline-flex; align-items: center; gap: 5px; }
.nrsaal-legend .lg-sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }

footer { padding: 8px 20px 60px; color: var(--muted); font-size: 12.5px; }
footer p { max-width: 78ch; }

@media (max-width: 780px) {
  .kpis, .kpis.mini { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .chart { height: 360px; }
  .chart.tall { height: 560px; }
  .controls input { min-width: 130px; }
}
