:root {
  --bg: #0f1420; --flaeche: #171e2d; --flaeche2: #1d2638; --rand: #263045; --text: #e8edf6; --leise: #8f9bb3;
  --gruen: #3fae2a; --gruen-hell: #c6f432; --blau: #3d8bff; --blau-hell: #a8ddff; --gelb: #f5b82e; --rot: #ef4b4b; --grau: #4a5468;
  --verlauf: linear-gradient(90deg, #c6f432, #3fae2a 35%, #3d8bff 70%, #a8ddff);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --bg: #f3f6fb; --flaeche: #fff; --flaeche2: #f3f6fb; --rand: #dbe2ee; --text: #172033; --leise: #5d6a82; --grau: #c3cad8; --blau-hell: #1f63d6; }
}
:root[data-theme="dark"] { --bg: #0f1420; --flaeche: #171e2d; --flaeche2: #1d2638; --rand: #263045; --text: #e8edf6; --leise: #8f9bb3; --grau: #4a5468; --blau-hell: #a8ddff; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.leise { color: var(--leise); }
.klein { font-size: 13px; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
input, select { font: inherit; color: var(--text); background: var(--flaeche2); border: 1px solid var(--rand); border-radius: 9px; padding: 9px 11px; width: 100%; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--blau); outline-offset: 1px; }
label { display: block; font-size: 14px; color: var(--leise); margin: 12px 0; }
label input { margin-top: 4px; }
button { font: inherit; cursor: pointer; }
.haupt, .knopf { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 9px; padding: 9px 14px; border: 1px solid transparent; text-decoration: none; }
.haupt { background: var(--blau); color: #fff; font-weight: 600; }
.haupt:hover { filter: brightness(1.08); }
.knopf { background: var(--flaeche2); color: var(--text); border-color: var(--rand); }
.knopf:hover { border-color: var(--blau); }
.knopf.geist { background: transparent; }
.knopf.gefahr:hover { border-color: var(--rot); color: var(--rot); }
.knopf:disabled, .haupt:disabled { opacity: .45; cursor: default; }
.klein-k { padding: 6px 10px; font-size: 13px; }
button.link { background: none; border: 0; color: var(--blau-hell); padding: 6px; margin-top: 8px; }
.fehler { color: var(--rot); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }

/* Anmelde-Karten */
.karte-mitte { max-width: 380px; margin: 8vh auto 32px; padding: 26px 22px; background: var(--flaeche); border: 1px solid var(--rand); border-radius: 16px; text-align: center; }
.karte-mitte form { text-align: left; }
.karte-mitte .logo { width: 200px; height: auto; display: block; margin: 0 auto 6px; }
.karte-mitte h1 { font-size: 20px; margin: 6px 0 4px; }
.karte-mitte .haupt { width: 100%; margin-top: 6px; }
@media (max-width: 420px) { .karte-mitte { margin: 16px; } }
input.code { font: 600 30px/1 ui-monospace, Menlo, monospace; letter-spacing: .4em; text-align: center; padding: 12px 8px 12px 18px; margin-top: 14px; }
.qr-box { background: var(--flaeche2); border: 1px solid var(--rand); border-radius: 12px; padding: 12px; text-align: center; margin: 12px 0; }
.qr-box p { margin: 4px 0 8px; font-size: 14px; }
.qr img { background: #fff; padding: 8px; border-radius: 8px; width: 200px; max-width: 100%; image-rendering: pixelated; }

/* Kopfleiste */
.leiste { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rand); }
.leiste img { width: 64px; height: auto; }
.leiste .titel { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.leiste .wer { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.leiste::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--verlauf); opacity: .7; }
.rolle { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: color-mix(in srgb, var(--blau) 18%, transparent); color: var(--blau-hell); }
@media (max-width: 520px) { .leiste .wer button span, .leiste #host { display: none; } }

main { max-width: 1180px; margin: 0 auto; padding: 16px 16px 48px; }
h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 26px 0 10px; }
h2 svg { color: var(--blau-hell); }
.kasten { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 14px; padding: 14px 16px; }
.zwei { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 0 16px; }

/* Werte-Kacheln */
.werte { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 12px; }
.wert { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 14px; padding: 13px 14px; min-width: 0; }
.wert .k { display: flex; align-items: center; gap: 8px; color: var(--leise); font-size: 13px; font-weight: 600; }
.wert .k .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.wert .z { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wert .z small { font-size: 13px; font-weight: 500; color: var(--leise); }
.wert .u { font-size: 12px; color: var(--leise); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balken { height: 6px; border-radius: 6px; background: var(--flaeche2); margin-top: 8px; overflow: hidden; }
.balken i { display: block; height: 100%; border-radius: 6px; background: var(--gruen); transition: width .6s; }
.balken i.mittel { background: var(--gelb); }
.balken i.hoch { background: var(--rot); }
.kerne { display: flex; gap: 2px; height: 22px; align-items: flex-end; margin-top: 8px; }
.kerne i { flex: 1; background: var(--blau); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; transition: height .6s; }
.c1 { background: linear-gradient(135deg, #3d8bff, #a8ddff); }
.c2 { background: linear-gradient(135deg, #8f5bff, #ff4fd8); }
.c3 { background: linear-gradient(135deg, #ff8a3d, #ffc93d); }
.c4 { background: linear-gradient(135deg, #ef4b4b, #ff8a3d); }
.c5 { background: linear-gradient(135deg, #25b39e, #6fe0c8); }
.c6 { background: linear-gradient(135deg, #3fae2a, #c6f432); }
.c7 { background: linear-gradient(135deg, #4f84e2, #7aa7f0); }

/* Dienste */
.dienste { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.dienst { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 14px; padding: 13px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dienst .kopf { display: flex; align-items: center; gap: 9px; }
.dienst .kopf b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.punkt { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--grau); }
.an .punkt { background: var(--gruen); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gruen) 20%, transparent); }
.schlaf .punkt { background: var(--blau); }
.aus .punkt { background: var(--rot); box-shadow: 0 0 0 4px color-mix(in srgb, var(--rot) 20%, transparent); }
.wechsel .punkt { background: var(--gelb); }
.dienst .info { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--leise); }
.dienst .info span { display: inline-flex; align-items: center; gap: 5px; }
.dienst .info svg { width: 14px; height: 14px; }
.dienst .knoepfe { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.dienst .knoepfe .knopf { padding: 6px 9px; font-size: 13px; }
.dienst .knoepfe svg { width: 14px; height: 14px; }
.tps { font-weight: 600; }
.tps.gut { color: var(--gruen); } .tps.mittel { color: var(--gelb); } .tps.schlecht { color: var(--rot); }

/* Listen */
.zeile { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rand); font-size: 14px; }
.zeile:last-child { border-bottom: 0; }
.zeile > span:first-child { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: var(--flaeche2); border: 1px solid var(--rand); }
.ok-t { color: var(--gruen); font-weight: 600; } .fehl-t { color: var(--rot); font-weight: 600; } .lauf-t { color: var(--gelb); font-weight: 600; }
.ansage { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.ansage p { grid-column: 1 / -1; margin: 0; }
.einladen { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 10px; }
.einladen .ergebnis { grid-column: 1 / -1; margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .einladen { grid-template-columns: 1fr; } .ansage { grid-template-columns: 1fr; } }
.protokoll { max-height: 320px; overflow: auto; font-size: 13px; }
.protokoll .zeile { font-size: 13px; }
a.cockpit { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
a.cockpit > svg { width: 30px; height: 30px; color: var(--blau-hell); }
a.cockpit:hover { border-color: var(--blau); }

/* Dialoge */
dialog { background: var(--flaeche); color: var(--text); border: 1px solid var(--rand); border-radius: 14px; padding: 16px; max-width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(5, 8, 14, .6); }
#d-log { width: min(1000px, calc(100vw - 24px)); max-width: none; height: min(80vh, 760px); padding: 0; display: none; flex-direction: column; }
#d-log[open] { display: flex; }
.dlg-kopf { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--rand); }
.dlg-kopf input { max-width: 260px; }
.dlg-kopf b { margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#log-text { flex: 1; margin: 0; overflow: auto; padding: 12px; font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border-radius: 0 0 14px 14px; }
.dlg-knoepfe { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.haken { display: flex; align-items: center; gap: 8px; color: var(--text); }
.haken input { width: auto; margin: 0; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--flaeche2); border: 1px solid var(--rand); border-radius: 10px; padding: 10px 16px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .25s; max-width: calc(100vw - 32px); z-index: 20; }
#toast.zeigen { opacity: 1; }
#toast.fehl { border-color: var(--rot); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.oben { margin-top: 10px; }
