/* ─────────────────────────────────────────────────────────────────────────
   assets/gemeinsam.css – Stil für auswertung.html und daten.html
   Farben als Tokens (hell/dunkel), farbenblind-taugliche Kategorienpalette.
   ───────────────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --seite: #f9f9f7;
  --flaeche: #fcfcfb;
  --flaeche-2: #f0efec;
  --tinte: #0b0b0b;
  --tinte-2: #52514e;
  --tinte-leise: #6f6d68;
  --linie: #e1e0d9;
  --achse: #c3c2b7;
  --rand: rgba(11, 11, 11, 0.10);
  --akzent: #2a78d6;
  --akzent-text: #1c5cab;
  --akzent-wash: #e6f0fc;
  --gut: #006300;
  --gut-wash: #effaef;
  --warn: #8a5a00;
  --warn-wash: #fff6df;
  --fehler: #b42323;
  --fehler-wash: #fdf0f0;
  /* Kategorien (feste Reihenfolge) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --series-andere: #898781;
  /* Sequentiell (blau, hell → dunkel) */
  --seq-1: #b7d3f6; --seq-2: #86b6ef; --seq-3: #3987e5; --seq-4: #256abf; --seq-5: #104281;
  --schatten: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --radius: 12px;
  --kopf-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --seite: #0d0d0d; --flaeche: #1a1a19; --flaeche-2: #242422; --tinte: #ffffff; --tinte-2: #c3c2b7;
    --tinte-leise: #9d9b94; --linie: #2c2c2a; --achse: #45443f; --rand: rgba(255,255,255,0.10);
    --akzent: #3987e5; --akzent-text: #86b6ef; --akzent-wash: #16263b;
    --gut: #0ca30c; --gut-wash: #132613; --warn: #fab219; --warn-wash: #2b2210; --fehler: #ff8a8a; --fehler-wash: #2e1515;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --seq-1: #184f95; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #6da7ec; --seq-5: #b7d3f6;
    --schatten: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --seite: #0d0d0d; --flaeche: #1a1a19; --flaeche-2: #242422; --tinte: #ffffff; --tinte-2: #c3c2b7;
  --tinte-leise: #9d9b94; --linie: #2c2c2a; --achse: #45443f; --rand: rgba(255,255,255,0.10);
  --akzent: #3987e5; --akzent-text: #86b6ef; --akzent-wash: #16263b;
  --gut: #0ca30c; --gut-wash: #132613; --warn: #fab219; --warn-wash: #2b2210; --fehler: #ff8a8a; --fehler-wash: #2e1515;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --seq-1: #184f95; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #6da7ec; --seq-5: #b7d3f6;
  --schatten: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--seite); color: var(--tinte);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--akzent-text); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--akzent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--flaeche); padding: 8px 12px; z-index: 2000; }
.skip-link:focus { left: 8px; }

/* ── Kopfzeile ─────────────────────────────────────────────────────────── */
.kopf {
  position: sticky; top: 0; z-index: 1000; min-height: var(--kopf-h);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--flaeche); border-bottom: 1px solid var(--linie);
}
.kopf .logo { font-weight: 700; font-size: 16px; text-decoration: none; color: var(--tinte); white-space: nowrap; }
.kopf nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.kopf nav a {
  text-decoration: none; color: var(--tinte-2); padding: 6px 10px; border-radius: 8px; font-size: 14px;
}
.kopf nav a:hover { background: var(--flaeche-2); color: var(--tinte); }
.kopf nav a[aria-current="page"] { background: var(--akzent-wash); color: var(--akzent-text); font-weight: 600; }
.kopf .rechts { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--tinte-2); }

/* ── Layout ────────────────────────────────────────────────────────────── */
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.abschnitt { margin: 20px 0 28px; }
h1 { font-size: 26px; line-height: 1.25; margin: 8px 0 6px; }
h2 { font-size: 20px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.untertitel { color: var(--tinte-2); margin: 0 0 12px; max-width: 70ch; }
.karte-box, .box {
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius);
  box-shadow: var(--schatten); padding: 16px;
}
.raster-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.raster-gleich { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
@media (max-width: 860px) { .raster-2 { grid-template-columns: 1fr; } }

/* ── Buttons & Formulare ───────────────────────────────────────────────── */
.btn {
  font: inherit; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  min-height: 40px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--rand); background: var(--flaeche); color: var(--tinte); text-decoration: none;
}
.btn:hover { background: var(--flaeche-2); }
.btn.primaer { background: var(--akzent); border-color: var(--akzent); color: #fff; font-weight: 600; }
.btn.primaer:hover { filter: brightness(1.08); }
.btn.gefahr { color: var(--fehler); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.klein { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.segment { display: inline-flex; border: 1px solid var(--rand); border-radius: 8px; overflow: hidden; }
.segment button {
  font: inherit; font-size: 13px; border: 0; background: var(--flaeche); color: var(--tinte-2);
  padding: 6px 12px; min-height: 34px; cursor: pointer;
}
.segment button + button { border-left: 1px solid var(--rand); }
.segment button[aria-pressed="true"] { background: var(--akzent-wash); color: var(--akzent-text); font-weight: 600; }
label.feld { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--tinte-2); }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--tinte); background: var(--flaeche);
  border: 1px solid var(--achse); border-radius: 8px; padding: 7px 10px; min-height: 38px; max-width: 100%;
}
.filterzeile { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.hinweis { font-size: 13px; color: var(--tinte-leise); }

/* ── Kennzahlen-Kacheln ───────────────────────────────────────────────── */
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kachel { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 12px 14px; }
.kachel .label { font-size: 13px; color: var(--tinte-2); }
.kachel .wert { font-size: 26px; font-weight: 650; line-height: 1.2; margin-top: 2px; }
.kachel .zusatz { font-size: 12px; color: var(--tinte-leise); margin-top: 2px; }

/* ── Meldungen ─────────────────────────────────────────────────────────── */
.meldung { border-radius: 10px; padding: 10px 12px; margin: 8px 0; border: 1px solid transparent; font-size: 14px; }
.meldung.info { background: var(--akzent-wash); }
.meldung.ok { background: var(--gut-wash); border-color: var(--gut); }
.meldung.warn { background: var(--warn-wash); border-color: var(--warn); }
.meldung.fehler { background: var(--fehler-wash); border-color: var(--fehler); }
.meldung strong:first-child::before { margin-right: 4px; }
.leer { text-align: center; padding: 32px 16px; color: var(--tinte-2); }
.leer .gross { font-size: 18px; font-weight: 600; color: var(--tinte); margin-bottom: 6px; }

/* ── Tabellen ──────────────────────────────────────────────────────────── */
.tabelle-wrap { overflow-x: auto; max-width: 100%; }
table.daten { border-collapse: collapse; width: 100%; font-size: 13px; }
table.daten th, table.daten td { padding: 6px 8px; border-bottom: 1px solid var(--linie); text-align: left; }
table.daten th { color: var(--tinte-2); font-weight: 600; background: var(--flaeche); position: sticky; top: 0; }
table.daten td.zahl, table.daten th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
table.daten caption { text-align: left; font-weight: 600; padding: 4px 0 8px; }
details > summary { cursor: pointer; color: var(--akzent-text); padding: 6px 0; }

/* ── Diagramme ─────────────────────────────────────────────────────────── */
figure.diagramm { margin: 0; position: relative; }
figure.diagramm figcaption { font-weight: 600; margin-bottom: 2px; }
figure.diagramm .beschr { font-size: 13px; color: var(--tinte-2); margin-bottom: 8px; }
.legende { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--tinte-2); margin: 6px 0; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legende i.linie { height: 3px; border-radius: 2px; width: 16px; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart text { fill: var(--tinte-leise); font-size: 12px; font-family: inherit; }
svg.chart .gitter { stroke: var(--linie); stroke-width: 1; }
svg.chart .achse { stroke: var(--achse); stroke-width: 1; }
svg.chart .achsentitel { fill: var(--tinte-2); font-size: 12px; }
svg.chart .wertlabel { fill: var(--tinte); font-size: 12px; font-weight: 600; }
svg.chart:focus-visible { outline: 3px solid var(--akzent); }
.tooltip {
  position: absolute; pointer-events: none; z-index: 20; background: var(--flaeche); color: var(--tinte);
  border: 1px solid var(--rand); box-shadow: var(--schatten); border-radius: 8px; padding: 6px 10px;
  font-size: 13px; line-height: 1.4; min-width: 120px; display: none;
}
.tooltip .t-kopf { font-weight: 600; margin-bottom: 2px; }
.tooltip .t-zeile { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tooltip .t-zeile i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ── Karte ─────────────────────────────────────────────────────────────── */
.karte { height: 460px; border-radius: 10px; overflow: hidden; border: 1px solid var(--rand); background: var(--flaeche-2); }
@media (max-width: 600px) { .karte { height: 340px; } }
.leaflet-container { font: inherit; }
.leaflet-tooltip { font-size: 13px; }
:root[data-theme="dark"] .leaflet-tooltip, :root[data-theme="dark"] .leaflet-popup-content-wrapper {
  background: #242422; color: #fff; border-color: #45443f;
}
.kartenlegende { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; margin-top: 10px; font-size: 13px; color: var(--tinte-2); }
.kartenlegende svg text { fill: var(--tinte-2); font-size: 12px; }

/* ── Liste der Zählstellen ────────────────────────────────────────────── */
.zs-liste { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow-y: auto; }
.zs-liste li + li { border-top: 1px solid var(--linie); }
.zs-liste button {
  width: 100%; text-align: left; font: inherit; background: none; border: 0; color: var(--tinte);
  padding: 10px 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; border-radius: 6px;
}
.zs-liste button:hover, .zs-liste button[aria-current="true"] { background: var(--akzent-wash); }
.zs-liste .zs-name { font-weight: 600; }
.zs-liste .zs-meta { font-size: 12px; color: var(--tinte-leise); }
.zs-liste .zs-wert { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }

/* ── Erklärungen ───────────────────────────────────────────────────────── */
.erklaerungen { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.erklaerungen details { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 8px 14px; }
.erklaerungen summary { font-weight: 600; color: var(--tinte); }
.erklaerungen p { margin: 6px 0 8px; color: var(--tinte-2); font-size: 14px; }

/* ── Assistent (daten.html) ───────────────────────────────────────────── */
.schritte { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; flex-wrap: wrap; counter-reset: schritt; }
.schritte li {
  counter-increment: schritt; flex: 1; min-width: 130px; padding: 8px 10px; border-radius: 8px;
  background: var(--flaeche-2); color: var(--tinte-leise); font-size: 13px;
}
.schritte li::before { content: counter(schritt) ". "; font-weight: 700; }
.schritte li[aria-current="step"] { background: var(--akzent-wash); color: var(--akzent-text); font-weight: 600; }
.schritte li.erledigt { color: var(--gut); }
.dropzone {
  display: block; border: 2px dashed var(--achse); border-radius: var(--radius); padding: 28px 16px; text-align: center;
  background: var(--flaeche); cursor: pointer;
}
.dropzone.aktiv { border-color: var(--akzent); background: var(--akzent-wash); }
.dropzone .gross { font-size: 17px; font-weight: 600; }
.formraster { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.auswahlkarte { border: 1px solid var(--rand); border-radius: 10px; padding: 10px 12px; display: flex; gap: 8px; align-items: flex-start; cursor: pointer; background: var(--flaeche); }
.auswahlkarte:has(input:checked) { border-color: var(--akzent); background: var(--akzent-wash); }
.auswahlkarte input { min-height: auto; margin-top: 4px; }
.liste-klein { max-height: 220px; overflow-y: auto; margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.picker-karte { height: 300px; border-radius: 10px; border: 1px solid var(--rand); margin-top: 8px; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--flaeche-2); color: var(--tinte-2); }
.badge.ok { background: var(--gut-wash); color: var(--gut); }
.badge.warn { background: var(--warn-wash); color: var(--warn); }
.fuss { text-align: center; color: var(--tinte-leise); font-size: 12px; padding: 24px 16px 40px; }
.fuss-links { margin-bottom: 6px; font-size: 13px; }
.fuss-links a { color: var(--tinte-2); }
@media (max-width: 640px) {
  .kopf { gap: 6px; }
  .kopf nav { order: 3; flex-basis: 100%; }
  .kopf .rechts { margin-left: auto; }
}
@media (max-width: 480px) {
  body { font-size: 14px; }
  h1 { font-size: 22px; }
  .kachel .wert { font-size: 22px; }
  main { padding: 12px; }
}
@media (forced-colors: active) {
  .legende i, .tooltip .t-zeile i { forced-color-adjust: none; }
}
