:root {
  --grund: #0e1117;
  --flaeche: #151a23;
  --fenster: #1b212c;
  --fenster-kopf: #232b38;
  --feld: #111620;
  --linie: #2c3544;
  --text: #e6ebf2;
  --text-2: #9aa5b5;
  --text-3: #6b7686;
  --blau: #2f7de1;
  --rot: #d8342c;
  --orange: #e8891a;
  --gruen: #2fae55;
  --gelb: #f2c230;
  --magenta: #d61f93;
  --radius: 10px;
  --schatten: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; height: 100vh; overflow: hidden; background: var(--grund); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 1rem;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: #2a3342; border: 1px solid #364154; border-radius: 8px; padding: .38rem .7rem; cursor: pointer;
  white-space: nowrap;
}
button:hover { background: #334055; }
button:disabled { opacity: .45; cursor: default; }
button.primaer { background: var(--rot); border-color: #f0564e; font-weight: 700; }
button.primaer:hover { background: #e84a41; }
button.blau { background: var(--blau); border-color: #5a9af0; }
button.gruen { background: #23813f; border-color: #36a55a; }
button.dunkelrot { background: #6b2323; border-color: #8a3030; }
button.aktiv { outline: 2px solid var(--gelb); }
input, select, textarea {
  background: var(--feld); border: 1px solid var(--linie); border-radius: 8px; padding: .42rem .6rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blau); outline-offset: -1px; }
textarea { resize: vertical; min-height: 4.5rem; }
.dezent { color: var(--text-2); }
.fehler { color: #ff7a72; min-height: 1.2em; }
.ok { color: #6fdc8c; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 999px;
  background: #242c39; font-size: .85rem; white-space: nowrap;
}
.chip.alarm { background: var(--magenta); font-weight: 700; animation: puls 1s infinite; cursor: pointer; }
@keyframes puls { 50% { opacity: .45; } }
[hidden] { display: none !important; }

/* Anmeldung */
#login { height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #1c2433, var(--grund)); }
.login-karte { width: min(420px, 92vw); background: var(--fenster); border: 1px solid var(--linie); border-radius: 18px; padding: 2rem; text-align: center; box-shadow: var(--schatten); }
.login-logo { width: 64px; height: 64px; margin: 0 auto 1rem; border-radius: 16px; background: var(--rot); display: grid; place-items: center; font-weight: 800; font-size: 1.4rem; }
.login-karte h1 { margin: 0 0 .5rem; }
.login-karte p { color: var(--text-2); line-height: 1.45; }
#login-form { display: flex; gap: .5rem; margin-top: 1.2rem; }
#login-code { font-size: 1.6rem; text-align: center; letter-spacing: .2em; font-family: ui-monospace, monospace; }
#login-form button { font-weight: 700; background: var(--blau); }

/* Kopfleiste */
#leiste {
  height: 48px; display: flex; align-items: center; gap: .55rem; padding: 0 .8rem;
  background: #10151d; border-bottom: 1px solid var(--linie); position: relative; z-index: 1000;
}
#leiste button { padding: .3rem .6rem; }
.marke { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.logo { background: var(--rot); border-radius: 6px; padding: .1rem .35rem; font-size: .8rem; font-weight: 800; }
.luecke { flex: 1; }
.uhr { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4.8em; text-align: right; }
.skala { display: flex; align-items: center; gap: .3rem; color: var(--text-2); font-size: .85rem; }
.skala input { width: 90px; padding: 0; }
.menue-halter { position: relative; }
.menue {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--fenster); border: 1px solid var(--linie);
  border-radius: 10px; padding: .35rem; box-shadow: var(--schatten); display: flex; flex-direction: column; gap: 2px;
}
.menue button { text-align: left; background: transparent; border: 0; }
.menue button:hover { background: #2a3342; }

/* Fensterfläche */
#flaeche { position: relative; height: calc(100vh - 48px); overflow: hidden; background: var(--flaeche); }
#flaeche.bearbeiten {
  background-image: linear-gradient(#ffffff08 1px, transparent 1px), linear-gradient(90deg, #ffffff08 1px, transparent 1px);
  background-size: 20px 20px;
}
.fenster {
  position: absolute; background: var(--fenster); border: 1px solid var(--linie); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.25); min-width: 180px; min-height: 120px;
}
.fenster-kopf {
  height: 2.1rem; flex: none; display: flex; align-items: center; gap: .45rem; padding: 0 .4rem 0 .7rem;
  background: var(--fenster-kopf); border-bottom: 1px solid var(--linie); font-weight: 650; font-size: .92rem; user-select: none;
}
.fenster-kopf .titel { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fenster-kopf .werkzeuge { display: flex; gap: .25rem; }
.fenster-kopf .werkzeuge button { padding: .1rem .45rem; font-size: .8rem; }
.fenster-kopf .zu { display: none; }
.bearbeiten .fenster-kopf { cursor: move; background: #2b3547; }
.bearbeiten .fenster-kopf .zu { display: inline-block; }
.bearbeiten .fenster { outline: 1px dashed #4b5b76; }
.griff { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; display: none; z-index: 5;
  background: linear-gradient(135deg, transparent 50%, #6f86ab 50%); border-bottom-right-radius: var(--radius); }
.bearbeiten .griff { display: block; }
.fenster-inhalt { flex: 1; min-height: 0; overflow: auto; padding: .6rem; }
.fenster-inhalt.voll { padding: 0; overflow: hidden; position: relative; }

/* Hinweise */
#hinweise { position: fixed; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.hinweis { background: var(--fenster); border: 1px solid var(--linie); border-left: 4px solid var(--gruen); padding: .6rem .8rem; border-radius: 8px; box-shadow: var(--schatten); max-width: 380px; }
.hinweis.fehlerhaft { border-left-color: var(--rot); }

/* Bausteine */
.zeile { display: flex; gap: .5rem; align-items: center; }
.zeile > .wachsen { flex: 1; min-width: 0; }
.spalte { display: flex; flex-direction: column; gap: .5rem; }
.abschnitt { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin: .7rem 0 .3rem; }
.abschnitt:first-child { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chips button { padding: .25rem .55rem; font-size: .85rem; }
.chips button.an { background: var(--orange); border-color: #f3a650; color: #111; font-weight: 700; }
.leer { color: var(--text-3); padding: .6rem 0; text-align: center; }
.liste { display: flex; flex-direction: column; gap: .4rem; }
.eintrag { background: #212937; border: 1px solid var(--linie); border-radius: 8px; padding: .5rem .6rem; }
.eintrag.gewaehlt { border-color: var(--blau); box-shadow: 0 0 0 1px var(--blau) inset; }
.eintrag .kopf { display: flex; gap: .5rem; align-items: baseline; }
.eintrag .kopf b { flex: 1; }
.klein { font-size: .82rem; color: var(--text-2); }
.knoepfe { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .45rem; }
.knoepfe button { padding: .25rem .55rem; font-size: .85rem; }
.meldung { min-height: 1.3em; font-size: .88rem; }

/* Karte */
.karte-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.karte-werkzeuge { position: absolute; top: 8px; left: 8px; display: flex; gap: 4px; }
.karte-werkzeuge button { padding: .2rem .5rem; background: #1b212cdd; font-size: .85rem; }
.karte-hinweis { position: absolute; bottom: 6px; left: 8px; font-size: .75rem; color: #c7d0dc; background: #0008; padding: .1rem .4rem; border-radius: 4px; pointer-events: none; }
.karte-quelle { position: absolute; bottom: 6px; right: 8px; font-size: .7rem; color: #222; background: #fffc; padding: 0 .3rem; border-radius: 3px; }

/* Fahrzeuge */
.fz-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .45rem; }
.fz { display: flex; border-radius: 8px; overflow: hidden; background: #212937; border: 1px solid var(--linie); cursor: pointer; min-height: 3.6rem; }
.fz.gewaehlt { border-color: var(--gelb); box-shadow: 0 0 0 2px var(--gelb) inset; }
.fz .nr { width: 2.8rem; display: grid; place-items: center; font-size: 1.5rem; font-weight: 800; flex: none; }
.fz .info { padding: .3rem .5rem; min-width: 0; flex: 1; }
.fz .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fz .info span { display: block; font-size: .78rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fz.blinkt .nr { animation: puls .8s infinite; }
.fz button { align-self: center; margin-right: .4rem; background: var(--gelb); color: #111; border: 0; font-weight: 800; }

/* Notrufe */
.notruf-aufbau { display: grid; grid-template-columns: minmax(9rem, 34%) 1fr; gap: .6rem; height: 100%; }
.notruf-liste { overflow: auto; }
.notruf-detail { display: flex; flex-direction: column; min-height: 0; }
.chat { flex: 1; min-height: 4rem; overflow: auto; background: var(--feld); border: 1px solid var(--linie); border-radius: 8px; padding: .5rem; display: flex; flex-direction: column; gap: .35rem; margin: .45rem 0; }
.blase { max-width: 85%; padding: .35rem .55rem; border-radius: 10px; background: #2a3342; }
.blase.lst { align-self: flex-end; background: var(--blau); }
.blase.system { align-self: center; background: transparent; color: var(--text-3); font-size: .82rem; }
.wartet { border-color: var(--magenta) !important; animation: puls 1s infinite; }

/* Tore */
.tor { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; border-radius: 8px; background: #212937; margin-bottom: .3rem; }
.tor .lampe { width: .8rem; height: .8rem; border-radius: 50%; background: #6b7280; flex: none; }
.tor.offen .lampe { background: var(--gruen); box-shadow: 0 0 8px var(--gruen); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .35rem .4rem; border-bottom: 1px solid var(--linie); vertical-align: top; }
th { color: var(--text-3); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }

@media (max-width: 800px) {
  #leiste .skala, #btn-bildschirm, #nutzer { display: none; }
}
