/* Atemschutzüberwachung – Gestaltung
   Ziel: iPad quer (1080 × 810 pt beim iPad 7), Bedienung durch Schutzfolie und mit Handschuh.
   Regeln: nichts scrollbar, große Schaltflächen (≈ 2 cm = 96–100 px), Rot nur für Alarm und Einsatz. */

@font-face {
  font-family: "Source Sans 3";
  src: url("fonts/source-sans-3-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-display: block;
}

:root {
  --rot: #C8102E;
  --rot-dunkel: #A00D25;
  --gruen: #1A7F3C;
  --gruen-dunkel: #13612D;
  --gelb: #F2B705;
  --blau: #0F5BB5;
  --blau-dunkel: #0B4689;
  --orange: #C75A0A;
  --orange-dunkel: #9C4708;
  --grau: #9AA1AA;

  --bg: #E4E7EB;
  --flaeche: #FFFFFF;
  --flaeche-2: #F3F4F6;
  --text: #16181C;
  --gedimmt: #59606A;
  --rand: #BFC5CE;
  --kopf: #1E2126;

  --tipp: 96px;
  --abstand: 12px;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body {
  position: fixed;
  inset: 0;
  font-family: "Source Sans 3", -apple-system, system-ui, "Segoe UI", sans-serif;
  font-size: 22px;
  line-height: 1.2;
  color: var(--text);
  background: var(--bg);
}
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
input { -webkit-user-select: text; user-select: text; }
small { font-size: .72em; }

#app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.laden { margin: auto; font-size: 28px; color: var(--gedimmt); }

/* ---------- Kopf, Hauptfläche, Fuß ---------- */

.kopf {
  flex: 0 0 auto;
  height: 92px;
  display: flex;
  align-items: center;
  gap: var(--abstand);
  padding: 0 var(--abstand) 0 20px;
  background: var(--kopf);
  color: #fff;
}
.kopf-titel {
  flex: 1;
  min-width: 0;
  font-size: 28px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kopf .knopf { min-height: 76px; min-width: 150px; background: #3A3F47; border-color: #555B64; color: #fff; }
.kopf-uhr { font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }

.haupt {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--abstand);
  padding: var(--abstand);
}
.fuss {
  flex: 0 0 auto;
  display: flex;
  gap: var(--abstand);
  padding: 0 var(--abstand) var(--abstand);
}
.fuss .knopf { flex: 1; }

.hinweis { padding: 0 var(--abstand); font-size: 20px; color: var(--gedimmt); }
.hinweis.stark { color: var(--rot); font-weight: 700; padding: 0; }
.klein { font-size: 17px; color: var(--gedimmt); }
.leer { grid-column: 1 / -1; padding: 30px; text-align: center; color: var(--gedimmt); }

/* ---------- Schaltflächen ---------- */

.knopf {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: var(--tipp);
  padding: 6px 16px;
  border: 2px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.knopf small { font-weight: 400; }
.knopf-rot { background: var(--rot); border-color: var(--rot-dunkel); color: #fff; }
.knopf-rot-rand { border-color: var(--rot); color: var(--rot); }
.knopf-gruen { background: var(--gruen); border-color: var(--gruen-dunkel); color: #fff; }
.knopf-blau { background: var(--blau); border-color: var(--blau-dunkel); color: #fff; }
.knopf-orange { background: var(--orange); border-color: var(--orange-dunkel); color: #fff; }
.knopf[disabled] { opacity: .35; }
.knopf.aktiv { background: var(--kopf); border-color: var(--kopf); color: #fff; }
.riesig { font-size: 34px; font-weight: 700; }

/* Sofortige Rückmeldung beim Aufsetzen */
.gedrueckt, .knopf:active, .kachel:active, .slot.voll:active, .druckfeld:active {
  filter: brightness(.78);
  transform: scale(.97);
}

/* ---------- Start ---------- */

.start { justify-content: center; gap: 20px; }
.start-gross { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.start-gross .knopf { min-height: 220px; }
.start-reihe { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.start .hinweis { padding: 0; }

/* ---------- Einsatz: Truppkarten ---------- */

.kopf-einsatz { gap: 20px; }
.kopf-links { display: flex; flex-direction: column; min-width: 220px; }
.kopf-art { font-size: 28px; font-weight: 700; }
.kopf-dauer { font-size: 20px; color: #C9CDD3; font-variant-numeric: tabular-nums; }
.kopf-dauer b { color: #fff; }
.kopf-mitte { flex: 1; display: flex; align-items: center; justify-content: center; gap: 20px; }
.testmodus { padding: 6px 12px; border-radius: 8px; background: var(--orange); font-weight: 700; font-size: 20px; }
.tonaus {
  min-height: 76px;
  padding: 0 20px;
  border-radius: var(--radius);
  background: var(--gelb);
  color: #222;
  font-weight: 700;
  font-size: 22px;
  animation: blinken 1s steps(1) infinite;
}

.trupps {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: var(--abstand);
  padding: var(--abstand);
}
.karte {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 12px;
  border: 3px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche);
  overflow: hidden;
}
.karte-frei {
  align-items: center;
  justify-content: center;
  border-style: dashed;
  background: transparent;
  color: var(--gedimmt);
  font-size: 26px;
  font-weight: 600;
}
.karte-kopf { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.karte-name { font-size: 26px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.karte-status { flex: 0 0 auto; font-size: 18px; padding: 2px 10px; border-radius: 20px; background: var(--flaeche-2); color: var(--gedimmt); }
.s-vor .karte-status { background: #DCE9FA; color: var(--blau-dunkel); font-weight: 700; }
.s-rueckzug .karte-status { background: #FBE3D0; color: var(--orange-dunkel); font-weight: 700; }
.s-zurueck { background: var(--flaeche-2); }
.s-zurueck .karte-name, .s-zurueck .karte-zeit { color: var(--gedimmt); }
.s-vor { border-color: var(--blau); }
.s-rueckzug { border-color: var(--orange); }

.karte-zeit { font-size: 58px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.karte-zeit.klein { font-size: 24px; font-weight: 600; color: var(--gedimmt); padding: 14px 0; }
.karte-naechste { font-size: 21px; min-height: 26px; color: var(--gedimmt); font-variant-numeric: tabular-nums; }
.karte-naechste.ueber { color: var(--rot); font-weight: 700; }
.karte-alarm { font-size: 23px; min-height: 26px; font-weight: 800; text-transform: uppercase; }

.karte-leute { flex: 1; min-height: 0; list-style: none; display: flex; flex-direction: column; justify-content: center; gap: 2px; overflow: hidden; }
.karte-leute li { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.l-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l-druck { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--gedimmt); }
.l-druck b { color: var(--text); }
.ampel { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; background: var(--ampel, var(--grau)); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }

.karte-knoepfe { display: flex; gap: 10px; }
.karte-knoepfe .knopf { flex: 1; min-height: 88px; font-size: 23px; padding: 4px 8px; }
.karte-knoepfe .knopf.breit { flex: 2; }

/* ---------- Alarm ---------- */

@keyframes blinken { 50% { opacity: .25; } }
@keyframes kartenalarm {
  0%, 49% { background: var(--rot); color: #fff; border-color: var(--rot-dunkel); }
  50%, 100% { background: #FFE3E7; color: var(--text); border-color: var(--rot); }
}
.karte.alarm { animation: kartenalarm 1s steps(1) infinite; border-width: 4px; }
.karte.alarm-stark { animation-duration: .5s; }
.karte.alarm .karte-status, .karte.alarm .l-druck { color: inherit; background: transparent; }
.karte.alarm .l-druck b { color: inherit; }
.karte.alarm .knopf-rot { background: #fff; color: var(--rot); border-color: #fff; font-weight: 800; }

body::after {
  content: "";
  position: fixed;
  inset: 0;
  border: 14px solid var(--rot);
  pointer-events: none;
  display: none;
  z-index: 50;
}
body.alarm::after { display: block; animation: blinken 1s steps(1) infinite; }
body.alarm-stark::after { border-width: 22px; animation-duration: .5s; }

/* ---------- Oben: Alarmband und Mitteilungen ---------- */

/* Alles hier bleibt in der Höhe des Kopfes (92 px) und verdeckt nie Bedienelemente darunter. */
#oben {
  position: fixed;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  height: 0;
  z-index: 40;
  pointer-events: none;
}
#oben > * { pointer-events: auto; }
.alarmband {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 92px;
  overflow: hidden;
  padding: 0 24px;
  line-height: 1.1;
  background: var(--rot);
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: blinken 1s steps(1) infinite;
}
.toast {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 560px;
  height: 76px;
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 8px 6px 22px;
  border-radius: var(--radius);
  background: #2D3138;
  color: #fff;
  font-size: 22px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.toast span { padding: 12px 0; overflow: hidden; text-overflow: ellipsis; }
.toast .knopf { flex: 0 0 auto; }
.toast .knopf { min-height: 64px; background: var(--gelb); border-color: var(--gelb); color: #222; }

/* ---------- Menü, Trupparten ---------- */

.menue, .arten { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 20px; padding: 20px; }
.menue .knopf, .arten .knopf { min-height: 0; }
.blinkt { animation: blinken 1s steps(1) infinite; }
.menue-hinweis { padding-bottom: var(--abstand); }

/* ---------- Kachelgitter (Personen) ---------- */

.seitenwahl { flex: 0 0 auto; display: flex; gap: var(--abstand); }
.seitenwahl .knopf { flex: 1; min-height: 80px; }
.gitter { flex: 1; min-height: 0; display: grid; gap: var(--abstand); align-content: start; overflow: hidden; }
.kachel {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 4px 10px 4px 24px;
  border: 2px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche);
  text-align: left;
  overflow: hidden;
}
.kachel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 12px; background: var(--ampel, var(--grau)); }
.kachel > span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-nach { font-size: 23px; font-weight: 700; }
.k-vor { font-size: 20px; }
.k-info { font-size: 15px; color: var(--gedimmt); min-height: 18px; }
.kachel.gewaehlt { background: #DCE9FA; border-color: var(--blau); box-shadow: inset 0 0 0 3px var(--blau); }
.kachel[disabled] { opacity: .4; }

.ampel-gruen { --ampel: var(--gruen); }
.ampel-gelb { --ampel: var(--gelb); }
.ampel-rot { --ampel: var(--rot); }
.ampel-grau { --ampel: var(--grau); }

/* Kopf mit den Plätzen des Trupps */
.kopf-slots .kopf-titel { flex: 0 1 auto; max-width: 260px; }
.slot {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 34px 0 18px;
  border: 2px dashed #6B717A;
  border-radius: var(--radius);
  color: #C9CDD3;
  text-align: left;
  overflow: hidden;
}
.slot b { font-size: 22px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot small { font-size: 16px; }
.slot.voll { border-style: solid; border-color: #555B64; background: #3A3F47; }
.slot.voll::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--ampel, var(--grau)); }
.slot-x { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 22px; color: #C9CDD3; }

/* ---------- Vordruck-Ergänzungen (0.2) ---------- */

.kopf-titel small { display: block; font-size: 17px; font-weight: 400; color: #C9CDD3; }
.karte-name small { font-size: 16px; font-weight: 600; color: var(--gedimmt); }
.karte.alarm .karte-name small { color: inherit; }
.warn { font-size: 15px; font-weight: 700; color: var(--orange); }
.karte.alarm .warn { color: inherit; }
.karte-vermisst { border-color: var(--rot); border-width: 5px; box-shadow: inset 0 0 0 4px var(--rot); }
.karte-alarm.vermisst { color: var(--rot); }
.karte.alarm .karte-alarm.vermisst { color: inherit; }

.druckzeile { display: flex; gap: var(--abstand); flex: 0 1 112px; min-height: 92px; }
.druckzeile .druckfeld { flex: 1; min-width: 0; }
.totmann { flex: 0 0 150px; font-size: 20px; padding: 4px 8px; }
.totmann:not(.knopf-gruen) { border-color: var(--orange); color: var(--orange-dunkel); }

.edaten { flex-direction: row; gap: 20px; }
.edaten-links { flex: 1; display: flex; flex-direction: column; gap: var(--abstand); }
.edaten-rechts { flex: 1; }
.kasten { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 14px; border-radius: var(--radius); background: var(--flaeche); }
.kasten h3 { font-size: 22px; }
.kasten h3 small { font-weight: 400; color: var(--gedimmt); }
.kasten-reihe { display: flex; gap: var(--abstand); }
.kasten-reihe .knopf { flex: 1; font-size: 22px; font-weight: 400; }
.formular-feld { display: flex; flex-direction: column; gap: 4px; font-size: 19px; color: var(--gedimmt); }
.formular-feld input { height: 64px; padding: 0 16px; border: 2px solid var(--rand); border-radius: 10px; background: var(--flaeche);
  color: var(--text); font-size: 26px; -webkit-appearance: none; appearance: none; }
.vermisst-liste { display: grid; grid-template-columns: 1fr 1fr; gap: var(--abstand); }
.vermisst-liste .knopf { font-size: 24px; }
.stark-neutral { color: var(--text); padding: 0; }

/* ---------- Ziffernblock ---------- */

.druck { flex-direction: row; }
.druck-links { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--abstand); }
.druckfeld {
  flex: 0 1 112px;
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border: 3px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche);
  text-align: left;
}
.druckfeld.aktiv { border-color: var(--blau); box-shadow: inset 0 0 0 3px var(--blau); background: #F1F6FD; }
.druckfeld.fehler .df-wert { color: var(--rot); }
.df-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.df-text b { font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.df-text small { font-size: 17px; color: var(--gedimmt); }
.df-wert { font-size: 48px; font-weight: 700; font-variant-numeric: tabular-nums; }
.df-wert small { font-size: 20px; font-weight: 400; }
.schnell { display: flex; gap: var(--abstand); margin-top: auto; }
.schnell .knopf { flex: 1; }
.ziffern { flex: 0 0 420px; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; gap: var(--abstand); }
.taste { min-height: 0; font-size: 38px; font-weight: 700; }
.taste[data-k="weiter"] { font-size: 20px; }

/* ---------- Formular ---------- */

.formular { display: grid; grid-template-columns: 1fr; align-content: start; gap: 16px 20px; }
.formular.zwei { grid-template-columns: 1fr 1fr; }
.formular label { display: flex; flex-direction: column; gap: 4px; font-size: 19px; color: var(--gedimmt); }
.formular input {
  height: 64px;
  padding: 0 16px;
  border: 2px solid var(--rand);
  border-radius: 10px;
  background: var(--flaeche);
  color: var(--text);
  font-size: 26px;
  -webkit-appearance: none;
  appearance: none;
}
.formular input:focus { outline: none; border-color: var(--blau); box-shadow: 0 0 0 3px rgba(15, 91, 181, .25); }
.ampelbox { align-self: end; min-height: 64px; display: flex; align-items: center; padding: 8px 16px 8px 26px; position: relative;
  border-radius: 10px; background: var(--flaeche); font-size: 19px; overflow: hidden; }
.ampelbox::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 12px; background: var(--ampel, var(--grau)); }

/* ---------- Einstellungen ---------- */

.einst { flex-direction: row; gap: 24px; }
.einst-links { flex: 3; display: flex; flex-direction: column; gap: var(--abstand); }
.einst-rechts { flex: 2; display: flex; flex-direction: column; gap: var(--abstand); }
.einst-zeile { display: flex; align-items: center; gap: var(--abstand); padding: 0 0 0 16px; border-radius: var(--radius); background: var(--flaeche); }
.einst-text { flex: 1; font-size: 22px; }
.einst-wert { width: 110px; text-align: center; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pm { width: 96px; font-size: 40px; }
.schalter { width: 228px; }

/* ---------- Listen und Tabellen ---------- */

.liste .zeile { align-items: flex-start; padding: 6px 24px; min-height: 92px; }
.liste .zeile span { font-size: 19px; font-weight: 400; color: var(--gedimmt); }
.blaettern { flex: 0 0 auto; display: flex; align-items: center; gap: var(--abstand); padding: 0 var(--abstand) var(--abstand); }
.blaettern .knopf { flex: 1; min-height: 80px; }
.blaettern span { flex: 0 0 auto; padding: 0 12px; color: var(--gedimmt); }
.tabelle { width: 100%; border-collapse: collapse; background: var(--flaeche); border-radius: var(--radius); overflow: hidden; font-size: 20px; }
.tabelle th, .tabelle td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--flaeche-2); }
.tabelle th { background: var(--flaeche-2); font-size: 17px; color: var(--gedimmt); }
.tabelle .zahl { text-align: right; font-variant-numeric: tabular-nums; }
.tabelle .rot { color: var(--rot); font-weight: 600; }
.protokoll td { padding: 8px 14px; font-size: 19px; }
.protokoll .zeit { width: 110px; font-variant-numeric: tabular-nums; color: var(--gedimmt); }

/* ---------- Hochformat (Notbetrieb) ---------- */

@media (orientation: portrait) {
  .trupps { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(3, 1fr); }
  .druck { flex-direction: column; }
  .ziffern { flex: 1 1 auto; }
  .einst { flex-direction: column; }
}
