@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/schibsted-grotesk.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --papier: #ffffff;
  --flaeche: #f4f4f1;
  --linie: #e2e2dc;
  --tinte: #000000;
  --tinte-2: #5c5c57;
  --gelb: #ffcc00;          /* Stuttgarter Wappengelb */
  --gelb-tief: #e0a800;
  --mehr: #257de0;
  --weniger: #d93a3b;
  --grau-mark: #d6d6cf;
  --schrift: "Schibsted Grotesk", system-ui, sans-serif;
  --rand: clamp(16px, 4vw, 48px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--schrift);
  font-size: 17px;
  line-height: 1.5;
  color: var(--tinte);
  background: var(--papier);
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--tinte); outline-offset: 2px; }

/* Kopf: Titel links, Gesamtsumme rechts – die Zahl ist Teil der Überschrift */
.kopf {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 8px 32px; padding: 40px var(--rand) 20px;
}
.kopf h1 {
  margin: 0; font-size: clamp(44px, 8vw, 104px); line-height: .92;
  font-weight: 800; letter-spacing: -0.035em;
}
.unterzeile { margin: 14px 0 0; max-width: 38em; color: var(--tinte-2); }
.summe { margin: 0; text-align: right; font-size: 15px; color: var(--tinte-2); }
.summe strong { display: block; font-size: clamp(32px, 5vw, 56px); line-height: 1; color: var(--tinte); font-weight: 700; letter-spacing: -0.02em; }

/* Filterzeile: eine Reihe über allem, was sie steuert */
.filter {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px var(--rand); background: rgba(255,255,255,.94);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--linie);
}
.jahre { display: inline-flex; border: 1px solid var(--tinte); border-radius: 999px; overflow: hidden; }
.jahre button {
  font: inherit; font-size: 15px; padding: 6px 14px; border: 0; background: none; cursor: pointer; color: var(--tinte);
}
.jahre button[aria-checked="true"] { background: var(--tinte); color: var(--papier); font-weight: 600; }
.suche input, .auswahl select {
  font: inherit; font-size: 15px; padding: 6px 12px; border: 1px solid var(--linie); border-radius: 999px;
  background: var(--papier); color: var(--tinte); min-height: 36px;
}
.suche input { width: min(280px, 60vw); }

/* Das Feld */
.feld-bereich { padding: 16px var(--rand) 0; }
.feld { position: relative; width: 100%; height: clamp(520px, 78vh, 900px); }
.feld .sparte-rahmen { position: absolute; }
.feld .sparte-name {
  position: absolute; left: 0; right: 0; top: 0; height: 22px; overflow: hidden;
  font-size: 13px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; padding-right: 4px;
}
.feld .sparte-name span { font-weight: 400; color: var(--tinte-2); margin-left: 6px; }
.feld .stueck {
  position: absolute; background: var(--gelb); border: 0; padding: 0; margin: 0; cursor: pointer;
  border-radius: 2px; overflow: hidden; text-align: left; font: inherit; color: var(--tinte);
  transition: background-color .12s;
}
.feld .stueck:hover, .feld .stueck:focus-visible { background: var(--tinte); color: var(--gelb); outline: none; }
.feld .stueck .n { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; padding: 5px 6px 0; font-size: 12px; line-height: 1.15; font-weight: 600; hyphens: auto; overflow-wrap: anywhere; }
.feld .stueck .b { display: block; padding: 2px 6px; font-size: 12px; }
.feld .stueck.gross .n { font-size: 16px; -webkit-line-clamp: 4; }
.feld .stueck.gross .b { font-size: 14px; }
.feld.sucht .stueck { background: var(--grau-mark); color: transparent; }
.feld.sucht .stueck.treffer { background: var(--tinte); color: var(--gelb); }
.feld .stueck.leer { background: var(--flaeche); }
.hinweis { font-size: 14px; color: var(--tinte-2); margin: 10px 0 0; max-width: 60em; }

/* Abschnitte */
.block { padding: 72px var(--rand) 0; max-width: 1400px; }
.block h2 { margin: 0 0 6px; font-size: clamp(28px, 3.4vw, 40px); line-height: 1.05; letter-spacing: -0.02em; font-weight: 750; }
.block h3 { margin: 0 0 10px; font-size: 18px; }
.lead { margin: 0 0 24px; max-width: 40em; color: var(--tinte-2); }
.zwei { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 56px; }

/* Rangbalken */
.balken-liste { display: grid; gap: 2px; }
.zeile {
  display: grid; grid-template-columns: minmax(120px, 15em) 1fr 7.5em; gap: 12px; align-items: center;
  padding: 5px 0; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%;
}
.zeile:hover .balken i, .zeile:focus-visible .balken i { background: var(--tinte); }
.zeile .name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zeile .balken { height: 14px; position: relative; }
.zeile .balken i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--gelb-tief); border-radius: 0 4px 4px 0; min-width: 2px; }
.zeile .wert { font-size: 15px; text-align: right; }
.zeile .wert small { display: block; color: var(--tinte-2); font-size: 12px; }

/* Säulen Verlauf */
.saeulen { display: flex; align-items: flex-end; gap: 10px; height: 260px; border-bottom: 1px solid var(--tinte); }
.saeule { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.saeule i { display: block; width: 100%; max-width: 64px; background: var(--gelb-tief); border-radius: 4px 4px 0 0; }
.saeule.letzte i { background: var(--tinte); }
.saeule b { font-size: 15px; margin-bottom: 4px; }
.saeulen-achse { display: flex; gap: 10px; }
.saeulen-achse span { flex: 1; text-align: center; font-size: 13px; color: var(--tinte-2); padding-top: 6px; }
.quelle-zeile { font-size: 13px; color: var(--tinte-2); }

/* Veränderung: Balken = Differenz, Text = vorher → nachher */
.wandel { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 40px 56px; }
.hantel {
  display: grid; grid-template-columns: minmax(110px, 1fr) 11em; grid-template-rows: auto auto; gap: 2px 12px; align-items: center; padding: 7px 0;
  border: 0; border-bottom: 1px solid var(--linie); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%;
}
.hantel .name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hantel .d { text-align: right; font-size: 15px; font-weight: 600; }
.hantel .spur { height: 6px; position: relative; }
.hantel .spur i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 3px 3px 0; min-width: 2px; }
.hantel.auf .spur i { background: var(--mehr); }
.hantel.ab .spur i { background: var(--weniger); }
.hantel .vn { font-size: 13px; color: var(--tinte-2); text-align: right; }
.hantel:hover .name, .hantel:focus-visible .name { text-decoration: underline; }
.mehr-zeigen { margin-top: 16px; font: inherit; font-size: 15px; padding: 8px 18px; border: 1px solid var(--tinte); border-radius: 999px; background: none; cursor: pointer; }
.mehr-zeigen:hover { background: var(--tinte); color: var(--papier); }

/* Tabelle */
.tabelle-rahmen { overflow-x: auto; border-top: 2px solid var(--tinte); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--linie); text-align: left; vertical-align: top; }
th { font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; user-select: none; position: sticky; top: 0; background: var(--papier); }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: 10px; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: 10px; }
td.zahl, th.zahl { text-align: right; white-space: nowrap; }
td.auf { color: #1b64be; }
td.ab { color: #b52a2b; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--flaeche); }
td a { color: inherit; }
td .klein { display: block; font-size: 13px; color: var(--tinte-2); }

/* Methodik */
.methodik .spalten { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 0 48px; }
.methodik p { max-width: 36em; margin: 0 0 14px; }
.quellen { padding-left: 1.2em; font-size: 15px; }
.quellen li { margin-bottom: 6px; }
.quellen a { color: inherit; }

.fuss { padding: 72px var(--rand) 40px; font-size: 14px; color: var(--tinte-2); }

/* Tooltip */
.tip {
  position: fixed; z-index: 20; pointer-events: none; max-width: 300px;
  background: var(--tinte); color: var(--papier); padding: 8px 10px; border-radius: 6px; font-size: 14px; line-height: 1.3;
}
.tip strong { display: block; font-size: 17px; }
.tip span { color: #c9c9c2; }

/* Detail */
.detail { border: 0; padding: 0; width: min(640px, 94vw); max-height: 90vh; border-radius: 10px; color: var(--tinte); }
.detail::backdrop { background: rgba(0,0,0,.35); }
.detail #detail-inhalt { padding: 28px 28px 24px; }
.detail .schliessen { position: absolute; right: 12px; top: 8px; font: inherit; font-size: 28px; line-height: 1; border: 0; background: none; cursor: pointer; padding: 4px 8px; }
.detail h2 { margin: 0 32px 4px 0; font-size: 28px; line-height: 1.1; letter-spacing: -0.015em; }
.detail .meta { color: var(--tinte-2); margin: 0 0 20px; font-size: 15px; }
.detail .jahreswerte { display: flex; align-items: flex-end; gap: 12px; height: 160px; margin: 8px 0 0; border-bottom: 1px solid var(--tinte); }
.detail .jahreswerte div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; text-align: center; }
.detail .jahreswerte i { display: block; background: var(--gelb); border-radius: 4px 4px 0 0; }
.detail .jahreswerte b { font-size: 14px; margin-bottom: 4px; font-weight: 600; }
.detail .achse { display: flex; gap: 12px; }
.detail .achse span { flex: 1; text-align: center; font-size: 13px; color: var(--tinte-2); padding-top: 4px; }
.detail .positionen { margin-top: 20px; font-size: 14px; }
.detail .positionen td, .detail .positionen th { padding: 6px 6px; }
.detail .anm { font-size: 14px; color: var(--tinte-2); }
.detail .jahreswerte + .achse + .meta { margin-top: 14px; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .summe { text-align: left; }
  .zeile { grid-template-columns: 1fr 6.5em; }
  .zeile .balken { grid-column: 1 / -1; grid-row: 2; }
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .filter { position: static; } .feld .stueck { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* Kennzahlen Gemeinderat */
.kennzahlen { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 2px; margin: 0 0 40px; max-width: 980px; }
.kennzahl { padding: 16px 18px 18px; background: var(--flaeche); }
.kennzahl.betont { background: var(--gelb); }
.kennzahl b { display: block; font-size: clamp(28px, 3.6vw, 44px); line-height: 1.05; letter-spacing: -0.02em; font-weight: 700; }
.kennzahl span { display: block; font-size: 14px; color: var(--tinte-2); margin-top: 6px; max-width: 18em; }
.kennzahl.betont span { color: var(--tinte); }
.rat-listen h3 { margin-top: 0; }
.zeile .sub { display: block; font-size: 12px; color: var(--tinte-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail .rat { margin: 16px 0 0; padding: 12px 14px; background: var(--flaeche); font-size: 15px; }
