:root {
  --bg: #222;
  --panel: #303030;
  --panel-2: #3a3a3a;
  --line: #464646;
  --text: #ffffff;
  --muted: #9a9a9a;
  --head: #375a7f;
  --link: #3498db;
  --red: #e74c3c;
  --blue: #3498db;
  --green: #00bc8c;
  --orange: #f39c12;
  --grey: #888;
  --badge-dark: #375a7f;
  --radius: 6px;
  font-family: "Lato", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); display: flex; flex-direction: column; min-height: 100vh; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* ---------------------------------------------------------- Kopfzeile -- */
.topbar {
  background: var(--head);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 84px; flex-shrink: 0; position: relative; z-index: 1000;
}
.brand { font-size: clamp(1.4rem, 2.6vw, 2.2rem); font-weight: 700; color: #fff; text-decoration: none; letter-spacing: .01em; }
.brand small { font-weight: 400; opacity: .75; font-size: .55em; margin-left: .6em; }
.menu-btn {
  background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff;
  border-radius: var(--radius); width: 52px; height: 44px; cursor: pointer;
  display: grid; place-items: center;
}
.menu-btn:hover { background: rgba(255,255,255,.1); }
.menu-btn svg { width: 24px; height: 24px; }
.menu {
  position: absolute; right: 24px; top: 74px; min-width: 230px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.45); padding: 6px 0; display: none;
}
.menu.open { display: block; }
.menu a { display: block; padding: 12px 18px; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.menu a:hover, .menu a.current { background: var(--panel-2); }
.menu a.current { border-left: 3px solid var(--link); padding-left: 15px; }

main { flex: 1; padding: 20px 24px; width: 100%; }
footer { flex-shrink: 0; display: flex; justify-content: space-between; color: var(--muted); padding: 14px 24px; font-size: .95rem; }

/* ---------------------------------------------------------- Panels ----- */
.panel { background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.panel-head { color: var(--link); font-weight: 700; font-size: 1.25rem; padding: 18px 24px; border-bottom: 2px solid var(--line); }
.panel-body { padding: 18px 24px; }
.divider { border: 0; border-top: 1px solid #555; margin: 24px 24px; }

/* ---------------------------------------------------------- Standby ---- */
.standby { flex: 1; display: grid; place-items: center; text-align: center; min-height: calc(100vh - 160px); }
.standby .clock { font-size: clamp(5rem, 16vw, 13rem); font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; }
.standby .date { font-size: clamp(1.4rem, 3vw, 2.4rem); color: var(--muted); margin-top: .4em; }
.standby .wache { font-size: clamp(1.6rem, 3.6vw, 3rem); font-weight: 700; margin-top: 1.4em; }
.standby .untertitel { color: var(--link); font-size: clamp(1rem, 2vw, 1.5rem); margin-top: .3em; }

/* ---------------------------------------------------------- Alarm ------ */
.meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--text); font-size: 1.3rem; margin-bottom: 16px; }
.meta .lbl { color: #5c5c5c; margin-right: .3em; }
.alarm-grid { display: grid; grid-template-columns: minmax(300px, 1fr) 2fr; gap: 0 46px; }
.stichwort {
  border-radius: var(--radius); padding: 22px 24px; font-size: 1.6rem; font-weight: 700;
  display: flex; align-items: center; gap: 12px;
}
.stichwort .bell { margin-left: auto; width: 26px; height: 26px; }
.stichwort.kat-B { background: var(--red); }
.stichwort.kat-H { background: var(--blue); }
.stichwort.kat-RD { background: var(--orange); }
.stichwort.kat-S { background: #6c757d; }
.stichwort.blink { animation: flash 1s steps(2, start) 6; }
@keyframes flash { 50% { filter: brightness(1.45); } }
@media (prefers-reduced-motion: reduce) { .stichwort.blink { animation: none; } }

#map { height: 540px; border-radius: var(--radius); background: #444; }
.map-empty { height: 540px; border-radius: var(--radius); background: var(--panel); display: grid; place-items: center; color: var(--muted); }
.ort-list .row { display: flex; justify-content: space-between; align-items: baseline; padding: 20px 30px; border-top: 2px solid var(--bg); font-size: 1.4rem; }
.ort-list .row span:last-child { color: var(--muted); font-size: 1.1rem; }
.meldebild { font-size: 1.3rem; line-height: 1.5; }

.einheiten-head { display: grid; grid-template-columns: 220px 1fr; gap: 20px; }
.einheit { display: grid; grid-template-columns: 220px 1fr; gap: 20px; padding: 22px 24px; border-bottom: 2px solid var(--line); }
.einheit:last-child { border-bottom: 0; }
.einheit .wache { font-size: 1.55rem; font-weight: 700; line-height: 1.35; }
.fz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.fz { background: var(--panel-2); border-radius: var(--radius); padding: 12px 14px; }
.fz .fk { font-size: 1.5rem; }
.fz .name { color: var(--muted); font-size: 1rem; margin-top: 2px; }

.einheit .wache .abt { font-size: .7em; font-weight: 400; color: var(--link); margin-top: 4px; }
.crew { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.crew-name { background: #2a2a2a; border: 1px solid var(--line); border-radius: 4px; padding: 3px 10px; font-size: 1.1rem; }
body.alarm-mode .crew { margin-top: 8px; }
body.alarm-mode .crew-name { font-size: 1rem; padding: 2px 9px; }
.abt-edit { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.abt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 12px; }
.sc select.abt-pick { width: auto; padding: 6px 8px; }
.rm { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.rm-group { display: flex; align-items: center; gap: 14px; border: 2px solid var(--line); border-radius: 30px; padding: 8px 16px; font-size: 1.15rem; }
.rm-group.big { font-size: 1.5rem; padding: 12px 18px; }
.rm-item { display: inline-flex; align-items: center; gap: 6px; }
.badge { display: inline-block; min-width: 1.4em; text-align: center; border-radius: 4px; padding: 0 5px; font-size: .85em; font-weight: 700; color: #fff; background: var(--badge-dark); }
.c-EK { color: var(--green); } .c-EK .badge { background: var(--green); }
.c-GF { color: var(--blue); } .c-GF .badge { background: var(--blue); }
.c-ZF { color: #bbb; } .c-ZF .badge { background: #aaa; color: #222; }
.c-VF { color: var(--red); } .c-VF .badge { background: var(--red); }
.c-AGT { color: var(--orange); } .c-AGT .badge { background: var(--orange); }
.c-MA, .c-FZF, .c-MED { color: var(--muted); }

.sound-hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--orange); color: #222; font-weight: 700; padding: 12px 20px; border-radius: var(--radius);
  border: 0; cursor: pointer; z-index: 2000; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

/* Alarm-Modus: alles auf eine Bildschirmhöhe, kein Scrollen */
body.alarm-mode { height: 100vh; overflow: hidden; }
body.alarm-mode footer { display: none; }
body.alarm-mode .topbar { height: 64px; }
body.alarm-mode main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 20px 16px; }
body.alarm-mode .meta { font-size: 1.1rem; margin-bottom: 10px; }
body.alarm-mode .alarm-grid { flex: 1; min-height: 0; gap: 0 24px; }
.col { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
body.alarm-mode #map, body.alarm-mode .map-empty { flex: 1; min-height: 160px; height: auto; }
body.alarm-mode .stichwort { padding: 16px 20px; font-size: 1.5rem; flex-shrink: 0; }
body.alarm-mode .panel-head { padding: 10px 20px; font-size: 1.1rem; }
body.alarm-mode .panel-body { padding: 12px 20px; }
body.alarm-mode .ort-list { flex-shrink: 0; }
body.alarm-mode .ort-list .row { padding: 10px 20px; font-size: 1.25rem; }
.units-panel { display: flex; flex-direction: column; min-height: 0; flex: 0 1 auto; }
.units-scroll { overflow-y: auto; min-height: 0; }
body.alarm-mode .einheit { grid-template-columns: 190px 1fr; padding: 14px 20px; }
body.alarm-mode .einheiten-head { grid-template-columns: 190px 1fr; }
body.alarm-mode .einheit .wache { font-size: 1.35rem; }
body.alarm-mode .fz { padding: 8px 12px; }
body.alarm-mode .fz .fk { font-size: 1.35rem; }
body.alarm-mode .fz-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
body.alarm-mode .rm { gap: 8px; margin-top: 10px; }
body.alarm-mode .rm-group { font-size: 1rem; gap: 10px; padding: 5px 12px; }
body.alarm-mode .rm-group.big { font-size: 1.35rem; padding: 8px 16px; }
.col-right > .panel:not(.units-panel):not(.meldebild-panel) { flex-shrink: 0; }
.meldebild-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.meldebild-panel .meldebild { overflow-y: auto; }
body.alarm-mode .meldebild { font-size: 1.2rem; }

/* ---------------------------------------------------------- Startseite - */
.home { max-width: 860px; margin: 40px auto; }
.home h1 { font-size: clamp(2rem, 4.4vw, 3.2rem); margin: 0 0 .3em; }
.home p { font-size: 1.2rem; line-height: 1.6; color: #ddd; max-width: 70ch; }
.home .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-top: 34px; }
.home .card { display: block; text-decoration: none; color: var(--text); background: var(--panel); border-left: 5px solid var(--blue); padding: 22px 24px; border-radius: var(--radius); }
.home .card.red { border-left-color: var(--red); }
.home .card:hover { background: var(--panel-2); }
.home .card strong { display: block; font-size: 1.4rem; margin-bottom: 6px; }
.home .card span { color: var(--muted); }
.home ul { color: #ddd; font-size: 1.1rem; line-height: 1.7; padding-left: 1.2em; }

/* ---------------------------------------------------------- Admin ------ */
.admin { max-width: 1200px; margin: 0 auto; display: grid; gap: 22px; }
.login { max-width: 380px; margin: 80px auto; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { color: var(--muted); font-size: .95rem; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; background: #2a2a2a; color: var(--text); border: 1px solid #555; border-radius: 4px; padding: 10px 12px;
}
textarea { min-height: 90px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.btn { border: 0; border-radius: 4px; padding: 10px 16px; cursor: pointer; color: #fff; background: #555; font-weight: 700; }
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: var(--blue); }
.btn.danger { background: var(--red); }
.btn.go { background: var(--green); }
.btn.small { padding: 6px 10px; font-weight: 400; font-size: .9rem; }
.btn.ghost { background: transparent; border: 1px solid #666; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.active-box { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.active-box .stichwort { padding: 12px 18px; font-size: 1.2rem; }
.status-idle { color: var(--muted); }

.sc-list { display: grid; gap: 10px; }
.sc { display: flex; align-items: center; gap: 14px; background: var(--panel-2); border-radius: var(--radius); padding: 12px 14px; }
.sc .kat { width: 10px; align-self: stretch; border-radius: 3px; }
.sc .kat-B { background: var(--red); } .sc .kat-H { background: var(--blue); } .sc .kat-RD { background: var(--orange); } .sc .kat-S { background: #6c757d; }
.sc .info { flex: 1; min-width: 0; }
.sc .info strong { font-size: 1.15rem; }
.sc .info div { color: var(--muted); font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.editor-map { height: 340px; border-radius: var(--radius); margin-bottom: 10px; }
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; }
.search-results { display: grid; gap: 4px; margin-bottom: 10px; }
.search-results button { text-align: left; background: #2a2a2a; color: var(--text); border: 1px solid #444; border-radius: 4px; padding: 8px 10px; cursor: pointer; }
.hint { color: var(--muted); font-size: .9rem; }

.unit-edit { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.veh-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 8px; }
.rm-edit { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.rm-edit label { text-align: center; font-weight: 700; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--green); color: #fff; padding: 12px 18px; border-radius: var(--radius); z-index: 3000; }
.toast.err { background: var(--red); }
.error { color: var(--red); margin: 8px 0; }

/* ---------------------------------------------------------- Responsive - */
@media (max-width: 1000px) {
  body.alarm-mode { height: auto; overflow: auto; }
  body.alarm-mode #map, body.alarm-mode .map-empty { flex: none; height: 320px; }
  .alarm-grid { grid-template-columns: 1fr; gap: 24px; }
  #map, .map-empty { height: 360px; }
  .einheit { grid-template-columns: 1fr; }
  .rm-edit { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
  .topbar { padding: 0 14px; height: 68px; }
  .menu { top: 60px; right: 14px; }
  main { padding: 14px; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .brand small { display: none; }
}

/* Kleine Bildschirme (z. B. 720p-TV): Alarm-Modus kompakter */
@media (max-height: 820px) and (min-width: 1001px) {
  body.alarm-mode .topbar { height: 52px; }
  body.alarm-mode .brand { font-size: 1.5rem; }
  body.alarm-mode .meta { font-size: .95rem; margin-bottom: 6px; }
  body.alarm-mode .col { gap: 10px; }
  body.alarm-mode .stichwort { padding: 10px 16px; font-size: 1.3rem; }
  body.alarm-mode .panel-head { padding: 6px 16px; font-size: 1rem; }
  body.alarm-mode .panel-body { padding: 8px 16px; }
  body.alarm-mode .einheit { padding: 8px 16px; }
  body.alarm-mode .einheit .wache, body.alarm-mode .fz .fk { font-size: 1.15rem; }
  body.alarm-mode .fz { padding: 5px 10px; }
  body.alarm-mode .rm-group { font-size: .9rem; padding: 3px 10px; }
  body.alarm-mode .rm-group.big { font-size: 1.1rem; padding: 5px 12px; }
  body.alarm-mode .ort-list .row { padding: 6px 16px; font-size: 1.1rem; }
  body.alarm-mode .meldebild { font-size: 1.05rem; }
}
.meldebild-panel { min-height: 110px; }
