:root {
  --bg: #f3f1ea; --panel: #ffffff; --panel2: #f7f6f1; --text: #22261f; --muted: #6b6f66; --rand: #dedbd0;
  --akzent: #2e7d32; --akzent2: #e8f5e9; --warn: #c62828; --gut: #2e7d32; --mittel: #f9a825;
  --schatten: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
  --kopf: #234d26; --kopftext: #f1f8e9;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151814; --panel: #1e221d; --panel2: #252a24; --text: #e7eadf; --muted: #9aa190; --rand: #343a31;
    --akzent: #81c784; --akzent2: #24331f; --warn: #ef9a9a; --gut: #81c784; --mittel: #ffd54f; --kopf: #10200f; --kopftext: #e8f5e9;
    --schatten: 0 1px 3px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--rand); border-radius: 8px; padding: 6px 8px; }

.kopf { display: flex; align-items: center; gap: 18px; padding: 8px 16px; background: var(--kopf); color: var(--kopftext); flex-wrap: wrap; }
.titel { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 26px; }
.kopf h1 { font-size: 18px; margin: 0; letter-spacing: .2px; }
.unter { font-size: 12px; opacity: .75; }
.uhr { text-align: center; min-width: 170px; }
.uhr-gross { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.uhr-klein { font-size: 12px; opacity: .8; }
.kennzahlen { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; }
.kennzahl { font-size: 12px; opacity: .9; white-space: nowrap; }
.kennzahl b { font-size: 15px; font-variant-numeric: tabular-nums; }
.verbindung { font-size: 12px; white-space: nowrap; }
.verbindung.ok { color: #a5d6a7; } .verbindung.weg { color: #ffab91; }

.haupt { flex: 1; display: flex; min-height: 0; }
.kartenbereich { flex: 1; position: relative; min-width: 0; background: #7fa86a; }
#karte { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#karte.ziehen { cursor: grabbing; }
.kartenwerkzeuge { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kartenwerkzeuge button { width: 34px; height: 34px; border-radius: 8px; border: 0; background: rgba(255,255,255,.92); color: #222; box-shadow: var(--schatten); font-size: 18px; }
.schalter { background: rgba(255,255,255,.92); color: #222; border-radius: 8px; padding: 6px 9px; font-size: 13px; box-shadow: var(--schatten); user-select: none; }
.tooltip { position: absolute; pointer-events: none; background: rgba(20,24,18,.92); color: #fff; padding: 6px 9px; border-radius: 8px; font-size: 12px; max-width: 260px; z-index: 5; }
.legende { position: absolute; bottom: 8px; left: 8px; right: 8px; display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: #1d2a17; background: rgba(255,255,255,.82); padding: 5px 8px; border-radius: 8px; max-height: 64px; overflow: auto; }
.legende span { white-space: nowrap; }
.legende i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.25); }

.seite { width: 430px; max-width: 46vw; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--rand); min-height: 0; }
.reiter { display: flex; overflow-x: auto; border-bottom: 1px solid var(--rand); background: var(--panel2); }
.reiter button { border: 0; background: none; color: var(--muted); padding: 10px 11px; border-bottom: 2px solid transparent; white-space: nowrap; }
.reiter button.aktiv { color: var(--text); border-bottom-color: var(--akzent); font-weight: 600; }
.inhalt { flex: 1; overflow-y: auto; padding: 12px; position: relative; }

.karte { background: var(--panel2); border: 1px solid var(--rand); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.karte h3 { margin: 0 0 6px; font-size: 14px; }
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.zahl { background: var(--panel); border: 1px solid var(--rand); border-radius: 10px; padding: 6px 8px; }
.zahl b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.zahl span { font-size: 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { padding: 3px 4px; text-align: left; border-bottom: 1px solid var(--rand); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
.balken { height: 7px; background: var(--rand); border-radius: 4px; overflow: hidden; }
.balken > i { display: block; height: 100%; background: var(--akzent); border-radius: 4px; }
.balkenzeile { display: grid; grid-template-columns: 110px 1fr 38px; gap: 8px; align-items: center; font-size: 13px; margin: 3px 0; }
.balkenzeile .r { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.hinweis { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.abschnitt { font-size: 14px; margin: 16px 0 6px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--akzent2); color: var(--akzent); margin-left: 4px; vertical-align: 1px; }
.badge.rot { background: rgba(198,40,40,.12); color: var(--warn); }
.badge.gelb { background: rgba(249,168,37,.15); color: #b26a00; }
a, .link { color: var(--akzent); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.tot { color: var(--muted); }

.filterzeile { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.filterzeile input[type=search] { flex: 1; min-width: 160px; }
.chips button, #protLos, .mehr { border: 1px solid var(--rand); background: var(--panel2); color: var(--text); border-radius: 16px; padding: 4px 11px; font-size: 13px; }
.chips button.aktiv, #protLos { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.mehr { display: block; margin: 10px auto; }

.liste .zeile { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--rand); cursor: pointer; align-items: center; }
.liste .zeile:hover { background: var(--panel2); }
.liste .punkt { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); }
.liste .name { font-weight: 600; }
.liste .neben { font-size: 12px; color: var(--muted); }
.liste.klein .zeile { padding: 3px 4px; font-size: 12px; }
.mini { width: 60px; }

.ereignisliste .ev { padding: 5px 2px; border-bottom: 1px solid var(--rand); font-size: 13px; }
.ereignisliste .ev.w { font-weight: 600; }
.ereignisliste .ev .zeit { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; margin-right: 6px; }
.ereignisliste .ev .typ { font-size: 10px; color: var(--muted); border: 1px solid var(--rand); border-radius: 6px; padding: 0 4px; margin-right: 4px; font-weight: 400; }
.ev.neu { animation: neu 1.5s ease-out; }
@keyframes neu { from { background: var(--akzent2); } to { background: transparent; } }

.detail { position: sticky; top: -12px; margin: -12px -12px 12px; padding: 12px; background: var(--panel); border-bottom: 2px solid var(--akzent); z-index: 3; max-height: none; }
.detail .schliessen { float: right; border: 0; background: var(--panel2); border-radius: 8px; width: 30px; height: 30px; color: var(--text); }
.detail h2 { margin: 0 0 2px; font-size: 18px; }
.detail .unterzeile { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.detail .knopfzeile { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.detail .knopfzeile button { border: 1px solid var(--rand); background: var(--panel2); color: var(--text); border-radius: 8px; padding: 3px 9px; font-size: 12px; }
.baum { font-size: 13px; }
.baum .ebene { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; align-items: center; }
.baum .ebene .lbl { width: 86px; color: var(--muted); font-size: 12px; }
.baum .p { border: 1px solid var(--rand); border-radius: 8px; padding: 2px 7px; background: var(--panel2); cursor: pointer; }
.baum .p.ich { border-color: var(--akzent); background: var(--akzent2); font-weight: 600; }
.diagramm { width: 100%; height: 170px; display: block; }
.diagramm-titel { font-size: 13px; font-weight: 600; margin: 10px 0 2px; }
.diagramm-legende { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--muted); }
.diagramm-legende i { display: inline-block; width: 10px; height: 3px; margin-right: 4px; vertical-align: 3px; }
.regeln h3 { margin: 14px 0 4px; font-size: 14px; }
.regeln p, .regeln li { font-size: 13px; }
.regeln ul { padding-left: 18px; margin: 4px 0; }

@media (max-width: 900px) {
  body { height: auto; min-height: 100%; }
  .haupt { flex-direction: column; }
  .kartenbereich { height: 62vh; flex: none; }
  .seite { width: 100%; max-width: none; border-left: 0; border-top: 1px solid var(--rand); }
  .inhalt { overflow: visible; }
  .kennzahlen { order: 4; width: 100%; gap: 10px; }
  .uhr { min-width: 0; text-align: left; }
  .kopf { gap: 10px; padding: 8px 12px; }
  .legende { max-height: 44px; }
}
