:root {
  color-scheme: light;
  --seite: #f9f9f7;
  --flaeche: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-leise: #6f6d68;
  --gitter: #e1e0d9;
  --achse: #c3c2b7;
  --rand: rgba(11, 11, 11, 0.10);
  --serie-1: #2a78d6;
  --serie-2: #eb6834;
  --serie-3: #1baf7a;
  --gut: #0ca30c;
  --warnung: #fab219;
  --ernst: #ec835a;
  --kritisch: #d03b3b;
  --kritisch-flaeche: rgba(208, 59, 59, 0.10);
  --knopf: #0b0b0b;
  --knopf-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --seite: #0d0d0d;
    --flaeche: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-leise: #9b998f;
    --gitter: #2c2c2a;
    --achse: #383835;
    --rand: rgba(255, 255, 255, 0.10);
    --serie-1: #3987e5;
    --serie-2: #d95926;
    --serie-3: #199e70;
    --kritisch-flaeche: rgba(208, 59, 59, 0.18);
    --knopf: #ffffff;
    --knopf-ink: #0b0b0b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --seite: #0d0d0d; --flaeche: #1a1a19; --ink: #ffffff; --ink-2: #c3c2b7; --ink-leise: #9b998f;
  --gitter: #2c2c2a; --achse: #383835; --rand: rgba(255, 255, 255, 0.10);
  --serie-1: #3987e5; --serie-2: #d95926; --serie-3: #199e70;
  --kritisch-flaeche: rgba(208, 59, 59, 0.18); --knopf: #ffffff; --knopf-ink: #0b0b0b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--seite); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.seite {
  max-width: 760px; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}
h1 { font-size: 1.25rem; margin: 8px 0 0; font-weight: 650; }
h2 { font-size: 1rem; margin: 0; font-weight: 650; }
.stand { margin: 2px 0 16px; color: var(--ink-2); font-size: .875rem; min-height: 1.3em; }
.untertitel { margin: 2px 0 8px; color: var(--ink-2); font-size: .8125rem; }

.karte {
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: 14px;
  padding: 16px; margin-bottom: 16px;
}

/* Zustand */
.held {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: 14px;
  padding: 18px 16px; margin-bottom: 16px;
  border-left: 6px solid var(--zustand, var(--achse));
}
.held-symbol {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px; font-weight: 700;
  background: var(--zustand, var(--achse)); color: #fff;
}
.held[data-zustand="ok"] { --zustand: var(--gut); }
.held[data-zustand="stoerung"] { --zustand: var(--kritisch); }
.held[data-zustand="kein_kabel"], .held[data-zustand="keine_antwort"] { --zustand: var(--warnung); }
.held[data-zustand="pi_stumm"] { --zustand: var(--ernst); }
.held[data-zustand="kein_kabel"] .held-symbol, .held[data-zustand="keine_antwort"] .held-symbol { color: #0b0b0b; }
.held-titel { margin: 0; font-size: 1.375rem; font-weight: 700; line-height: 1.2; }
.held-text { margin: 4px 0 0; color: var(--ink-2); }
.held-hinweis { margin: 8px 0 0; white-space: pre-line; font-weight: 550; }
.held-hinweis:empty { display: none; }

/* Kacheln */
.kacheln { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
@media (max-width: 480px) { .kacheln { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kachel { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 12px; padding: 12px; min-width: 0; }
.kachel-label { margin: 0; color: var(--ink-2); font-size: .8125rem; }
.kachel-wert { margin: 2px 0 0; font-size: 1.5rem; font-weight: 650; line-height: 1.2; }
.kachel-wert small { font-size: .875rem; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.kachel-zusatz { margin: 2px 0 0; color: var(--ink-leise); font-size: .75rem; }

/* Zeitraum */
.filter { display: flex; gap: 6px; margin-bottom: 12px; }
.filter button {
  font: inherit; font-size: .875rem; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--rand); background: var(--flaeche); color: var(--ink); cursor: pointer;
}
.filter button[aria-pressed="true"] { background: var(--knopf); color: var(--knopf-ink); border-color: var(--knopf); font-weight: 600; }

/* Diagramme */
.legende { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 6px; padding: 0; font-size: .8125rem; color: var(--ink-2); }
.legende li { display: flex; align-items: center; gap: 6px; }
.legende .schluessel { width: 14px; height: 2px; border-radius: 1px; background: var(--f); }
.legende .flaeche-schluessel { width: 12px; height: 12px; border-radius: 3px; background: var(--kritisch-flaeche); outline: 1px solid var(--kritisch); outline-offset: -1px; }
.diagramm { position: relative; width: 100%; height: 220px; touch-action: pan-y; }
.diagramm svg { display: block; width: 100%; height: 100%; overflow: visible; }
.diagramm svg:focus-visible { outline: 2px solid var(--serie-1); outline-offset: 4px; border-radius: 4px; }
.diagramm.laedt { opacity: .5; transition: opacity .15s; }
.leer { color: var(--ink-2); font-size: .875rem; display: grid; place-items: center; height: 100%; margin: 0; }
.achse-text { fill: var(--ink-leise); font-size: 11px; font-variant-numeric: tabular-nums; }
.end-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; min-width: 140px;
  background: var(--flaeche); color: var(--ink); border: 1px solid var(--rand); border-radius: 10px;
  padding: 8px 10px; font-size: .8125rem; box-shadow: 0 6px 24px rgba(0,0,0,.14);
}
.tooltip .tt-zeit { color: var(--ink-2); margin-bottom: 4px; }
.tooltip .tt-zeile { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-zeile i { width: 12px; height: 2px; border-radius: 1px; background: var(--f); flex: none; }
.tooltip .tt-zeile b { font-variant-numeric: tabular-nums; min-width: 3.5em; }
.tooltip .tt-zeile span { color: var(--ink-2); }

.tabelle { margin-top: 10px; font-size: .8125rem; }
.tabelle summary { cursor: pointer; color: var(--ink-2); }
.tabelle div { max-height: 260px; overflow: auto; margin-top: 6px; }
.tabelle table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tabelle th, .tabelle td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--gitter); white-space: nowrap; }
.tabelle th:first-child, .tabelle td:first-child { text-align: left; }
.tabelle th { position: sticky; top: 0; background: var(--flaeche); color: var(--ink-2); font-weight: 600; }

/* Meldungen */
.ereignisse { list-style: none; margin: 8px 0 0; padding: 0; }
.ereignisse li { padding: 10px 0; border-top: 1px solid var(--gitter); }
.ereignisse li:first-child { border-top: 0; }
.ereignis-kopf { display: flex; justify-content: space-between; gap: 12px; }
.ereignis-titel { font-weight: 600; }
.ereignis-zeit { color: var(--ink-leise); font-size: .8125rem; white-space: nowrap; }
.ereignis-text { margin: 2px 0 0; color: var(--ink-2); font-size: .875rem; white-space: pre-line; }

/* Anmeldung */
.anmeldung form { display: grid; gap: 8px; margin-top: 12px; }
.anmeldung input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--achse); background: var(--seite); color: var(--ink); }
button[type="submit"] { font: inherit; font-weight: 600; padding: 10px 12px; border-radius: 10px; border: 0; background: var(--knopf); color: var(--knopf-ink); cursor: pointer; }
.formfehler { color: var(--kritisch); margin: 0; min-height: 1.3em; font-size: .875rem; }
.fuss { text-align: center; margin-top: 8px; }
.leise { font: inherit; font-size: .875rem; background: none; border: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; padding: 8px; }
