/* yngvi-Wächter. Farben und Grundformen aus der Depot-App (Dataviz-Referenzpalette, hell/dunkel).
   Kurvenfarben --r1/--r2 am 2026-11-23 mit validate_palette.js in beiden Modi geprüft (alle Prüfungen bestanden). */
:root {
  color-scheme: light;
  --seite: #f1f1ee; --flaeche: #fcfcfb; --flaeche-2: #f5f5f2;
  --ink: #0b0b0b; --ink-2: #52514e; --ink-3: #898781;
  --gitter: #e1e0d9; --achse: #c3c2b7; --rand: rgba(11,11,11,.10);
  --akzent: #2a78d6; --akzent-ink: #ffffff; --akzent-wash: rgba(42,120,214,.10);
  --schlecht-text: #d03b3b;
  --s-gut: #0ca30c; --s-warn: #fab219; --s-ernst: #ec835a; --s-krit: #d03b3b;
  --r1: #2a78d6; --r2: #eb6834;
  --radius: 18px; --schatten: 0 1px 2px rgba(11,11,11,.04), 0 8px 24px -12px rgba(11,11,11,.12);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --seite: #0d0d0d; --flaeche: #1a1a19; --flaeche-2: #222220;
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #898781;
    --gitter: #2c2c2a; --achse: #383835; --rand: rgba(255,255,255,.10);
    --akzent: #3987e5; --akzent-ink: #0b0b0b; --akzent-wash: rgba(57,135,229,.14);
    --schlecht-text: #e66767;
    --r1: #3987e5; --r2: #d95926;
    --schatten: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--seite); color: var(--ink); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
h1 { font-size: 1.7rem; margin: .4rem 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 .8rem; letter-spacing: -.005em; }
p { margin: .5rem 0; }
.leise { color: var(--ink-2); }
.klein { font-size: .85rem; }
.fehler { color: var(--schlecht-text); min-height: 1.2em; }
svg { flex: none; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Knöpfe und Eingaben */
button { font: inherit; border-radius: 12px; border: 1px solid var(--rand); padding: .65rem 1rem; cursor: pointer; background: var(--flaeche-2); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
button.primaer { background: var(--akzent); color: var(--akzent-ink); border-color: transparent; font-weight: 600; }
button.zweit { background: transparent; }
button.gefahr { background: var(--s-krit); color: #ffffff; border-color: transparent; font-weight: 600; }
button.breit { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, svg:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
input, select { font: inherit; width: 100%; padding: .65rem .75rem; border-radius: 12px; border: 1px solid var(--rand); background: var(--flaeche-2); color: var(--ink); margin-top: .35rem; }
label { display: block; margin-bottom: 1rem; font-size: .9rem; color: var(--ink-2); }
label.haken { display: flex; gap: .55rem; align-items: center; color: var(--ink); }
label.haken input { width: auto; margin: 0; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: .6rem; margin: .8rem 0; }
.knopfreihe.ende { justify-content: flex-end; margin-bottom: 0; }

/* Anmeldung */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(120% 60% at 50% 0%, var(--akzent-wash), transparent 70%), var(--seite); }
.login-karte { width: min(380px, 100%); text-align: center; padding: 28px 22px; }
.login-karte label { text-align: left; }
.login-logo { border-radius: 14px; }

/* Kopf */
.kopf { position: sticky; top: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--seite) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--rand); }
.kopf-marke { display: flex; gap: .7rem; align-items: center; min-width: 0; }
.kopf-marke > div { min-width: 0; }
.kopf-marke img { border-radius: 9px; }
.kopf-titel { font-weight: 700; font-size: 1.1rem; line-height: 1.1; }
.kopf-titel, #stand { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf button { padding: .45rem .8rem; font-size: .88rem; flex: none; }
main { padding: 16px 16px calc(32px + env(safe-area-inset-bottom)); max-width: 860px; margin: 0 auto; }

/* Karten */
.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--schatten); }
.karte-kopf { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .9rem; flex-wrap: wrap; }
.karte-kopf h2 { margin: 0; }

/* Status: immer Zeichen und Wort, nie Farbe allein */
.status { display: inline-flex; align-items: center; gap: .3rem; font-size: .82rem; color: var(--ink-2); white-space: nowrap; }
.status .icon { width: 16px; height: 16px; }
.st-gut .icon { color: var(--s-gut); }
.st-hinweis .icon { color: var(--akzent); }
.st-warnung .icon { color: var(--s-warn); }
.st-dringend .icon { color: var(--s-krit); }
.st-still .icon { color: var(--ink-3); }

/* Lagebild */
.lage-zeile { display: flex; gap: .9rem; align-items: center; }
.lage-icon .icon { width: 40px; height: 40px; }
.lage-titel { font-size: 1.45rem; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; }
.alarme { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; gap: .5rem; }
.alarme:empty { display: none; }
.alarme li { display: grid; grid-template-columns: auto 1fr; gap: .1rem .6rem; align-items: start; padding: .6rem .7rem; border-radius: 12px; background: var(--flaeche-2); }
.alarme .status { grid-row: span 2; padding-top: .15rem; }
.alarme strong { font-weight: 600; }
.alarme span.leise { grid-column: 2; font-size: .9rem; }

/* Kennzahlen */
.kacheln { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
@media (max-width: 560px) { .kacheln { grid-template-columns: repeat(2, 1fr); } }
.kachel { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--schatten); min-width: 0; }
.kachel-name { font-size: .85rem; color: var(--ink-2); display: flex; justify-content: space-between; gap: .4rem; align-items: center; }
.kachel-wert { font-size: 1.75rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; margin-top: .15rem; white-space: nowrap; }
.kachel-wert small { font-size: .95rem; font-weight: 500; color: var(--ink-2); margin-left: .2rem; }
.kachel-zusatz { font-size: .82rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Auslastung: Name, Balken, Zahl; die Spur ist eine hellere Stufe der Füllfarbe */
.meterliste { display: grid; gap: .85rem; }
/* feste Spalten für Name und Zahl, damit alle Balken gleich lang sind und sich vergleichen lassen */
.meterzeile { display: grid; grid-template-columns: 10.5rem 1fr 10.5rem; gap: .2rem .8rem; align-items: center; }
.meter-name { font-size: .92rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-zahl { font-size: .92rem; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.meter-zahl .leise { margin-left: .4rem; font-size: .82rem; }
.meter-spur { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--meter) 20%, var(--flaeche)); overflow: hidden; --meter: var(--akzent); }
.meter-spur i { display: block; height: 100%; border-radius: 999px; background: var(--meter); min-width: 2px; }
.meter-spur.warnung { --meter: var(--s-warn); }
.meter-spur.dringend { --meter: var(--s-krit); }
.meterzeile .status { grid-column: 2 / -1; }
@media (max-width: 520px) {
  .meterzeile { grid-template-columns: 1fr auto; }
  .meter-spur { grid-column: 1 / -1; grid-row: 2; }
  .meterzeile .status { grid-column: 1 / -1; }
}

/* Zeitraumwahl */
.bereich { display: inline-flex; border: 1px solid var(--rand); border-radius: 12px; overflow: hidden; }
.bereich button { border: 0; border-radius: 0; background: transparent; padding: .35rem .75rem; font-size: .85rem; color: var(--ink-2); }
.bereich button.aktiv { background: var(--akzent-wash); color: var(--ink); font-weight: 600; }

/* Diagramme */
.diagramm { margin-bottom: 1.1rem; }
.diagramm-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .2rem; }
.diagramm-titel { font-size: .92rem; font-weight: 600; }
.legende { display: flex; gap: .9rem; font-size: .82rem; color: var(--ink-2); }
.legende span { display: inline-flex; align-items: center; gap: .35rem; }
.schluessel { display: inline-block; width: 14px; height: 2px; border-radius: 2px; background: var(--farbe); }
.diagramm svg { width: 100%; height: auto; display: block; touch-action: pan-y; border-radius: 8px; }
.gitter { stroke: var(--gitter); stroke-width: 1; }
.achse-text { fill: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.linie { fill: none; stroke: var(--farbe); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.punkt { fill: var(--farbe); stroke: var(--flaeche); stroke-width: 2; }
.endwert { fill: var(--ink); font-size: 12px; font-weight: 600; }
.fadenkreuz { stroke: var(--achse); stroke-width: 1; }
.f1 { --farbe: var(--r1); }
.f2 { --farbe: var(--r2); }
.leer-hinweis { color: var(--ink-3); font-size: .9rem; padding: 1.2rem 0; text-align: center; }
.tooltip { position: fixed; z-index: 9; pointer-events: none; background: var(--flaeche); border: 1px solid var(--rand); border-radius: 12px; padding: .5rem .7rem; font-size: .85rem; box-shadow: 0 8px 24px -8px rgba(0,0,0,.35); min-width: 9rem; }
.tooltip .zeit { color: var(--ink-2); margin-bottom: .25rem; }
.tooltip .zeile { display: flex; align-items: center; gap: .45rem; }
.tooltip .zeile strong { margin-left: auto; padding-left: .8rem; font-variant-numeric: tabular-nums; }
.tooltip .zeile span.name { color: var(--ink-2); }

/* Tabellensicht */
.tabellensicht summary { cursor: pointer; color: var(--ink-2); font-size: .9rem; padding: .3rem 0; }
.tabelle-rahmen { overflow-x: auto; margin-top: .5rem; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: .3rem .6rem; border-bottom: 1px solid var(--gitter); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--ink-2); font-weight: 600; }

/* Listen und Wertepaare */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; padding: .5rem 0; border-bottom: 1px solid var(--gitter); }
.liste li:last-child { border-bottom: 0; }
.liste .haupt { min-width: 0; }
.liste .haupt small { display: block; color: var(--ink-3); font-size: .82rem; }
.liste .rechts { text-align: right; flex: none; color: var(--ink-2); font-size: .85rem; }
.werte { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .1rem 1.4rem; margin: 0; }
.werte div { display: flex; justify-content: space-between; gap: .8rem; padding: .45rem 0; border-bottom: 1px solid var(--gitter); }
.werte dt { color: var(--ink-2); font-size: .9rem; }
.werte dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

.push-form { margin-top: .6rem; max-width: 26rem; }
.schalt-status { min-height: 1.4em; }

/* Rückfrage */
dialog { border: 1px solid var(--rand); border-radius: var(--radius); background: var(--flaeche); color: var(--ink); padding: 22px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { font-size: 1.2rem; }
