/* Performance — Serverzustand auf einen Blick.
   Ruhig und dicht. Farbe traegt Bedeutung: Statusfarben (gut/Warnung/kritisch)
   nur fuer Zustaende, nie fuer Datenreihen; Reihen haben feste Farben je Rolle.
   Keine Inline-Stile (die CSP verbietet sie); Werte kommen per CSSOM. */

:root {
  color-scheme: dark;
  --bg:      #0b0d11;
  --panel:   #13161c;
  --panel2:  #1a1e26;
  --hover:   rgba(255,255,255,.04);
  --line:    rgba(255,255,255,.07);
  --line2:   rgba(255,255,255,.13);
  --txt:     #eef1f5;
  --dim:     #a3acba;
  --muted:   #6f7888;
  --grid:    #22262e;
  --axis:    #353a44;
  --acc:     #5b9cf0;

  --s1: #3987e5;   /* blau */
  --s2: #d95926;   /* orange */
  --s3: #199e70;   /* aqua */
  --s4: #c98500;   /* gelb */
  --s5: #d55181;   /* magenta */
  --s6: #9085e9;   /* violett */

  --gut:  #0ca30c;
  --warn: #fab219;
  --ernst:#ec835a;
  --krit: #d03b3b;
  --gut-txt: #3ecf5c;

  --r: 12px;
  --r-sm: 8px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f4f1; --panel: #fcfcfb; --panel2: #f0efeb; --hover: rgba(0,0,0,.035);
    --line: rgba(11,11,11,.08); --line2: rgba(11,11,11,.15);
    --txt: #0b0b0b; --dim: #52514e; --muted: #7c7a74; --grid: #e6e5df; --axis: #c3c2b7;
    --acc: #2a78d6;
    --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #4a3aa7;
    --gut-txt: #006300;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f1; --panel: #fcfcfb; --panel2: #f0efeb; --hover: rgba(0,0,0,.035);
  --line: rgba(11,11,11,.08); --line2: rgba(11,11,11,.15);
  --txt: #0b0b0b; --dim: #52514e; --muted: #7c7a74; --grid: #e6e5df; --axis: #c3c2b7;
  --acc: #2a78d6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #4a3aa7;
  --gut-txt: #006300;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--txt);
  font-family: var(--sans); font-size: 14px; line-height: 1.45; }
body { min-height: 100dvh; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
a { color: var(--acc); text-decoration: none; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.dim { color: var(--dim); }
.muted { color: var(--muted); }
.klein { font-size: 12px; }
.versteckt { display: none !important; }
.gut-txt { color: var(--gut-txt); }

/* ----------------------------------------------------------- Geruest */
.huelle { display: flex; min-height: 100dvh; }
.leiste { width: 212px; flex: 0 0 212px; border-right: 1px solid var(--line);
  padding: 16px 10px; position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 2px; }
.marke { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.marke img { width: 26px; height: 26px; }
.marke b { font-size: 14px; letter-spacing: .02em; }
.marke small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--dim); cursor: pointer; border: 0; background: none; text-align: left; width: 100%; font-size: 13.5px; }
.nav:hover { background: var(--hover); color: var(--txt); }
.nav.aktiv { background: var(--panel2); color: var(--txt); font-weight: 600; }
.nav svg { width: 16px; height: 16px; flex: 0 0 16px; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.nav .zahl { margin-left: auto; font-size: 11px; padding: 0 6px; border-radius: 99px; background: var(--krit); color: #fff; }
.nav .zahl.warn { background: var(--warn); color: #1a1300; }
.leiste .fuss { margin-top: auto; padding: 10px; font-size: 11.5px; color: var(--muted); display: grid; gap: 6px; }
.leiste .fuss button { background: none; border: 1px solid var(--line2); border-radius: var(--r-sm);
  padding: 5px 8px; cursor: pointer; color: var(--dim); }
.leiste .fuss button:hover { color: var(--txt); }

.haupt { flex: 1; min-width: 0; padding: 18px 24px 40px; }
.kopf { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.kopf h1 { margin-right: auto; }

.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--dim);
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live.an i { background: var(--gut); box-shadow: 0 0 0 0 rgba(12,163,12,.5); animation: puls 2s infinite; }
.live.aus i { background: var(--krit); }
@keyframes puls { 0% { box-shadow: 0 0 0 0 rgba(12,163,12,.45); } 70% { box-shadow: 0 0 0 7px rgba(12,163,12,0); } 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); } }
@media (prefers-reduced-motion: reduce) { .live.an i { animation: none; } }

/* ----------------------------------------------------------- Bausteine */
.raster { display: grid; gap: 14px; }
.r2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.r3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.r4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.r6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.abstand { margin-top: 14px; }
.karte { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.karte > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.karte > header h2 { margin-right: auto; }
.karte > header .dim { font-size: 12px; }
.karte.flach { padding: 0; overflow: hidden; }
.karte.flach > header { padding: 14px 16px 0; }

.kpi { cursor: default; display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden; }
.kpi .titel { font-size: 12px; color: var(--dim); display: flex; gap: 6px; align-items: center; }
.kpi .wert { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.kpi .wert small { font-size: 14px; font-weight: 500; color: var(--dim); margin-left: 2px; }
.kpi .unter { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .spark { height: 34px; margin: 6px -4px -4px; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; }
.kpi.warn::before { background: var(--warn); }
.kpi.krit::before { background: var(--krit); }

.balken { height: 6px; border-radius: 99px; background: var(--panel2); overflow: hidden; margin-top: 6px; }
.balken > i { display: block; height: 100%; width: var(--fuell, 0%); background: var(--s1); border-radius: 99px; }
.balken.warn > i { background: var(--warn); }
.balken.krit > i { background: var(--krit); }

.punkt { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 8px; }
.punkt.gut { background: var(--gut); }
.punkt.warn { background: var(--warn); }
.punkt.krit { background: var(--krit); }
.punkt.hinweis { background: var(--s1); }

.marke-st { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; background: var(--panel2); color: var(--dim); white-space: nowrap; }
.marke-st.gut { color: var(--gut-txt); }
.marke-st.warn { color: var(--warn); }
.marke-st.krit { color: #fff; background: var(--krit); }
.marke-st.hinweis { color: var(--acc); }
:root[data-theme="light"] .marke-st.warn { color: #8a5a00; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .marke-st.warn { color: #8a5a00; } }

/* Gesundheit */
.gesund { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.ring { width: 118px; height: 118px; position: relative; }
.ring canvas { width: 118px; height: 118px; }
.ring .zahl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .zahl b { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1; display: block; }
.ring .zahl span { font-size: 11px; color: var(--muted); }
.urteil { font-size: 18px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.abzuege { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; color: var(--dim); }
.abzuege li { display: flex; gap: 8px; align-items: center; }
.abzuege li b { margin-left: auto; font-weight: 600; color: var(--txt); font-variant-numeric: tabular-nums; }

.fakten { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 18px; }
.fakten div span { display: block; font-size: 11.5px; color: var(--muted); }
.fakten div b { font-weight: 600; font-size: 13px; }

/* Listen */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); min-width: 0; }
.liste li:first-child { border-top: 0; }
.liste .haupt-t { flex: 1; min-width: 0; }
.liste .haupt-t b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste .haupt-t span { font-size: 12px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste .rechts { text-align: right; font-size: 12px; color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.leer { color: var(--muted); font-size: 13px; padding: 14px 0; text-align: center; }

/* Tabellen */
.tabwrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; font-size: 11.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; user-select: none; }
th.sort { cursor: pointer; }
th.sort:hover { color: var(--txt); }
th.sort.an::after { content: " ↓"; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.klick { cursor: pointer; }
tr.klick:hover td { background: var(--hover); }
tr.gewaehlt td { background: var(--panel2); }
td .klein { display: block; }
td.brechen { white-space: normal; }
.minibalken { display: inline-block; width: 60px; height: 5px; border-radius: 99px; background: var(--panel2);
  vertical-align: middle; margin-right: 8px; overflow: hidden; }
.minibalken > i { display: block; height: 100%; width: var(--fuell, 0%); background: var(--s1); }

/* Bedienelemente */
.knopfreihe { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; flex-wrap: wrap; }
.knopfreihe button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--dim); font-size: 12.5px; }
.knopfreihe button:hover { color: var(--txt); background: var(--hover); }
.knopfreihe button.an { background: var(--panel2); color: var(--txt); font-weight: 600; }
.knopf { border: 1px solid var(--line2); background: var(--panel); padding: 6px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px; }
.knopf:hover { background: var(--panel2); }
.knopf.primaer { background: var(--acc); border-color: var(--acc); color: #fff; font-weight: 600; }
.knopf:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=number], input[type=password], input[type=search] {
  font: inherit; color: var(--txt); background: var(--panel2); border: 1px solid var(--line2);
  border-radius: var(--r-sm); padding: 6px 10px; min-width: 0; }
input[type=number] { width: 84px; text-align: right; }
input:focus-visible, button:focus-visible, .nav:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.schalter { position: relative; width: 32px; height: 18px; appearance: none; background: var(--axis); border-radius: 99px; cursor: pointer; margin: 0; vertical-align: middle; }
.schalter::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.schalter:checked { background: var(--acc); }
.schalter:checked::after { left: 16px; }

.hinweis-box { font-size: 12.5px; color: var(--dim); background: var(--panel2); border-radius: var(--r-sm); padding: 10px 12px; }
.meldung { padding: 10px 12px; border-radius: var(--r-sm); font-size: 13px; margin-top: 10px; }
.meldung.schlecht { background: rgba(208,59,59,.14); color: #ff9b9b; }
.meldung.gut { background: rgba(12,163,12,.14); color: var(--gut-txt); }

/* Alarme */
.alarm { display: flex; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--panel2); align-items: flex-start; }
.alarm + .alarm { margin-top: 8px; }
.alarm .icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: 0 0 20px; color: #fff; }
.alarm.krit .icon { background: var(--krit); }
.alarm.warn .icon { background: var(--warn); color: #1a1300; }
.alarm.hinweis .icon { background: var(--s1); }
.alarm b { display: block; font-weight: 600; }
.alarm span { font-size: 12.5px; color: var(--dim); }
.alarm .seit { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Diagramme */
.diagramm { position: relative; }
.diagramm canvas { display: block; width: 100%; touch-action: pan-y; }
.legende { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--dim); margin-bottom: 6px; }
.legende button { border: 0; background: none; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-size: 12px; }
.legende button.aus { opacity: .4; text-decoration: line-through; }
.legende i { width: 12px; height: 3px; border-radius: 2px; background: var(--farbe); display: inline-block; }
.legende i.flaeche { height: 10px; width: 10px; border-radius: 2px; }
.legende .wert { color: var(--txt); font-variant-numeric: tabular-nums; font-weight: 600; margin-left: 2px; }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--panel); border: 1px solid var(--line2);
  border-radius: var(--r-sm); padding: 8px 10px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25); min-width: 140px;
  left: var(--x, 0); top: var(--y, 0); }
.tooltip .zeit { color: var(--muted); margin-bottom: 4px; font-size: 11.5px; }
.tooltip .zeile { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.tooltip .zeile i { width: 10px; height: 2px; background: var(--farbe); border-radius: 2px; }
.tooltip .zeile b { font-variant-numeric: tabular-nums; font-weight: 650; }
.tooltip .zeile span { color: var(--dim); margin-left: auto; padding-left: 12px; }
.tooltip .ereignis { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--dim); max-width: 280px; white-space: normal; }

/* Wasserfall der Antwortzeit */
.wasserfall { display: flex; height: 10px; border-radius: 3px; overflow: hidden; background: var(--panel2); gap: 2px; }
.wasserfall i { display: block; height: 100%; flex: 0 0 var(--anteil, 0%); }
.wasserfall i:nth-child(1) { background: var(--s6); }
.wasserfall i:nth-child(2) { background: var(--s3); }
.wasserfall i:nth-child(3) { background: var(--s4); }
.wasserfall i:nth-child(4) { background: var(--s1); }
.wf-legende { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.wf-legende span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--farbe); vertical-align: -1px; }

.statusleiste { display: flex; gap: 2px; height: 22px; margin-top: 6px; }
.statusleiste i { flex: 1; border-radius: 2px; background: var(--gut); opacity: .85; }
.statusleiste i.warn { background: var(--warn); }
.statusleiste i.krit { background: var(--krit); }
.statusleiste i.leer { background: var(--panel2); }

.stundenbalken { display: flex; align-items: flex-end; gap: 2px; height: 70px; }
.stundenbalken i { flex: 1; background: var(--s2); border-radius: 2px 2px 0 0; height: var(--h, 0%); min-height: 1px; }

/* Anmeldung */
.anmeldung { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.anmeldekarte { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; display: grid; gap: 14px; }
.anmeldekarte .marke { padding: 0; }
.feld label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.feld input { width: 100%; padding: 9px 12px; }

/* ----------------------------------------------------------- Mobil */
@media (max-width: 1200px) {
  .r6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .r4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .huelle { display: block; }
  .leiste { position: sticky; top: 0; z-index: 10; width: auto; height: auto; flex-direction: row; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 10px; background: var(--bg); gap: 4px; scrollbar-width: none; }
  .leiste::-webkit-scrollbar { display: none; }
  .marke { padding: 0 8px 0 2px; }
  .marke small, .marke b { display: none; }
  .nav { width: auto; white-space: nowrap; padding: 6px 10px; }
  .leiste .fuss { display: none; }
  .haupt { padding: 14px 16px 32px; }
  .r2, .r3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .r6, .r4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .wert { font-size: 22px; }
  .gesund { grid-template-columns: 1fr; justify-items: start; }
}

/* Beim Nachladen den alten Stand halten, nur abgedunkelt -- kein Springen */
.laedt { opacity: .5; transition: opacity .15s; }
td.brechen .klein { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
