:root {
  --gruen: #018137;
  --gruen-dunkel: #01642b;
  --gruen-hell: #e3f3e9;
  --schwarz: #111111;
  --grau-1: #f4f5f4;
  --grau-2: #e2e5e3;
  --grau-3: #9aa19c;
  --grau-4: #5a615c;
  --rot: #c0392b;
  --rot-hell: #fbe9e7;
  --gelb: #b7791f;
  --gelb-hell: #fdf3e0;
  --weiss: #ffffff;
  --radius: 12px;
  --schatten: 0 1px 3px rgba(0, 0, 0, 0.12);
  --safe-unten: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--schwarz);
  background: var(--grau-1);
  min-height: 100vh;
}
a { color: var(--gruen); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; color: var(--grau-4); text-transform: uppercase; letter-spacing: 0.04em; }
p { margin: 0 0 10px; }
.klein { font-size: 13px; color: var(--grau-4); }
.grau { color: var(--grau-4); }
.rot { color: var(--rot); }
.gruen { color: var(--gruen); }

/* Kopf */
.kopf {
  position: sticky; top: 0; z-index: 20;
  background: var(--schwarz); color: var(--weiss);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; min-height: 56px;
}
.kopf .zurueck { background: none; border: 0; color: var(--weiss); font-size: 26px; padding: 4px 8px 4px 0; cursor: pointer; line-height: 1; }
.kopf .titel { flex: 1; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { font-weight: 800; letter-spacing: 0.02em; font-size: 18px; }
.logo span { color: var(--gruen); }
.kopf .logo span { color: #4ccf7a; }
.status-punkt { width: 10px; height: 10px; border-radius: 50%; background: #4ccf7a; flex: none; }
.status-punkt.offline { background: var(--gelb); }
.outbox-zahl { background: var(--gelb); color: var(--schwarz); font-weight: 700; font-size: 12px; border-radius: 10px; padding: 2px 8px; cursor: pointer; }
.outbox-zahl.leer { display: none; }

main { padding: 14px 14px calc(96px + var(--safe-unten)); max-width: 720px; margin: 0 auto; }
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--schwarz); }
.login-karte { background: var(--weiss); border-radius: 16px; padding: 28px 22px; width: min(92vw, 380px); box-shadow: 0 8px 30px rgba(0,0,0,0.4); }
.login-karte .logo { font-size: 26px; }

/* Karten und Listen */
.karte { background: var(--weiss); border-radius: var(--radius); box-shadow: var(--schatten); padding: 14px; margin-bottom: 12px; }
.karte.warnung { background: var(--gelb-hell); border-left: 4px solid var(--gelb); }
.karte.fehler { background: var(--rot-hell); border-left: 4px solid var(--rot); }
.karte.hinweis { background: var(--gruen-hell); border-left: 4px solid var(--gruen); }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--grau-2); }
.liste li:last-child { border-bottom: 0; }
.liste li.klickbar { cursor: pointer; }
.liste .text { flex: 1; min-width: 0; }
.liste .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste .pfeil { color: var(--grau-3); font-size: 22px; }
.mini-foto { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; background: var(--grau-2); flex: none; }
.mini-foto.leer { display: flex; align-items: center; justify-content: center; color: var(--grau-3); font-size: 26px; }

.zeilen { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 6px 12px; font-size: 15px; }
.zeilen dt { color: var(--grau-4); margin: 0; }
.zeilen dd { margin: 0; overflow-wrap: anywhere; }

.plakette { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--grau-2); color: var(--grau-4); vertical-align: middle; }
.plakette.gruen { background: var(--gruen-hell); color: var(--gruen-dunkel); }
.plakette.gelb { background: var(--gelb-hell); color: var(--gelb); }
.plakette.rot { background: var(--rot-hell); color: var(--rot); }

/* Geraetepass */
.pass-kopf { display: flex; gap: 14px; align-items: flex-start; }
.pass-foto { width: 100%; max-height: 260px; aspect-ratio: 4 / 3; border-radius: var(--radius); object-fit: cover; background: var(--grau-2); display: block; margin-bottom: 12px; cursor: zoom-in; }
.pass-foto.leer { display: flex; align-items: center; justify-content: center; color: var(--grau-3); font-size: 44px; max-height: 120px; cursor: default; }
.pass-kopf { flex-direction: column; }
.foto-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 60; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.foto-overlay img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.pass-kopf .text { flex: 1; min-width: 0; }
.pass-kopf h1 { font-size: 20px; overflow-wrap: anywhere; }
.messstand { display: flex; align-items: baseline; gap: 6px; }
.messstand .wert { font-size: 28px; font-weight: 700; }
.messstand .einheit { color: var(--grau-4); }

.aktionen { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.aktionen .knopf { min-height: 64px; }
.aktionen .knopf.breit { grid-column: 1 / -1; }

/* Knoepfe und Formulare */
.knopf {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 12px 16px;
  border: 2px solid var(--grau-2); border-radius: var(--radius);
  background: var(--weiss); color: var(--schwarz);
  font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.knopf:active { transform: scale(0.99); }
.knopf.primaer { background: var(--gruen); border-color: var(--gruen); color: var(--weiss); }
.knopf.primaer:active { background: var(--gruen-dunkel); }
.knopf.dunkel { background: var(--schwarz); border-color: var(--schwarz); color: var(--weiss); }
.knopf.gefahr { border-color: var(--rot); color: var(--rot); }
.knopf.klein { min-height: 40px; font-size: 14px; padding: 6px 12px; width: auto; display: inline-flex; }
.knopf.flach { border-color: transparent; background: transparent; color: var(--gruen); }
.knopf[disabled] { opacity: 0.5; cursor: default; }
.knopf .ikone { font-size: 22px; }
.knopfleiste { display: flex; gap: 10px; margin-top: 12px; }
.knopfleiste .knopf { flex: 1; }

label { display: block; font-size: 14px; color: var(--grau-4); margin: 10px 0 4px; }
label.zeile { display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--schwarz); }
input, select, textarea {
  width: 100%; font: inherit; font-size: 17px; padding: 12px; border: 2px solid var(--grau-2); border-radius: 10px; background: var(--weiss); color: var(--schwarz);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gruen); }
input[type="checkbox"] { width: 22px; height: 22px; }
input.gross { font-size: 28px; font-weight: 700; text-align: center; padding: 16px; }
textarea { min-height: 80px; resize: vertical; }
.feld-hinweis { font-size: 13px; color: var(--grau-4); margin-top: 4px; }
.formular .karte { padding: 14px; }
form.suchen { display: flex; gap: 8px; }
form.suchen input { flex: 1; }
form.suchen button { width: auto; min-width: 56px; }

/* Scanner */
.scanner { position: relative; background: var(--schwarz); border-radius: var(--radius); overflow: hidden; aspect-ratio: 1 / 1; max-height: 70vh; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .rahmen { position: absolute; inset: 14%; border: 3px solid rgba(255,255,255,0.85); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,0.35); pointer-events: none; }
.scanner .meldung { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px; background: rgba(0,0,0,0.6); color: var(--weiss); text-align: center; font-size: 14px; }
.scanner.gefunden .rahmen { border-color: #4ccf7a; }

/* Kette */
.kette { display: flex; flex-direction: column; gap: 6px; }
.kette .knoten { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--grau-1); border-radius: 10px; cursor: pointer; }
.kette .knoten.aktuell { background: var(--gruen-hell); border: 2px solid var(--gruen); cursor: default; }
.kette .knoten .tiefe { color: var(--grau-3); }
.kette .knoten .name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Reiter */
.reiter { display: flex; gap: 4px; margin: 6px 0 12px; border-bottom: 2px solid var(--grau-2); overflow-x: auto; }
.reiter button { background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 10px 12px; font: inherit; font-weight: 600; color: var(--grau-4); cursor: pointer; white-space: nowrap; }
.reiter button.aktiv { color: var(--gruen); border-bottom-color: var(--gruen); }

.leer-hinweis { text-align: center; color: var(--grau-3); padding: 24px 10px; }
.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-unten)); transform: translateX(-50%); background: var(--schwarz); color: var(--weiss); padding: 12px 18px; border-radius: 30px; box-shadow: 0 6px 20px rgba(0,0,0,0.3); z-index: 50; max-width: 90vw; font-size: 15px; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.toast.sichtbar { opacity: 1; }
.toast.fehler { background: var(--rot); }
.ereignis { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--grau-2); font-size: 14px; }
.ereignis:last-child { border-bottom: 0; }
.ereignis .typ { flex: none; width: 74px; font-weight: 700; color: var(--gruen-dunkel); text-transform: capitalize; }
.ereignis .typ.warn { color: var(--gelb); }
.ereignis .text { flex: 1; min-width: 0; }
.tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabelle th, .tabelle td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--grau-2); vertical-align: top; }
.tabelle th { color: var(--grau-4); font-weight: 600; }
.rechts { text-align: right; }
.start-aktionen { display: grid; gap: 10px; margin-bottom: 14px; }
.start-aktionen .knopf { min-height: 72px; font-size: 18px; }
.fuss { text-align: center; padding: 20px 0 0; font-size: 12px; color: var(--grau-3); }
.fuss a { color: var(--grau-4); }
@media (min-width: 600px) {
  .aktionen { grid-template-columns: repeat(3, 1fr); }
}

.foto-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.foto-kachel { position: relative; aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; background: var(--grau-2); }
.foto-kachel img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.foto-kachel button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,0.6); color: #fff; font-size: 16px; cursor: pointer; }
.ereignis .typ.grau { color: var(--grau-3); }
input[type="range"] { padding: 0; height: 36px; accent-color: var(--gruen); }
input[type="file"] { padding: 8px; font-size: 15px; }

/* Navigationsleiste unten */
.leiste { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around; align-items: stretch; background: var(--weiss); border-top: 1px solid var(--grau-2); padding: 6px 4px calc(6px + var(--safe-unten)); box-shadow: 0 -2px 10px rgba(0,0,0,0.06); }
.leiste:empty { display: none; }
.leiste a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; color: var(--grau-4); text-decoration: none; font-size: 12px; font-weight: 600; border-radius: 10px; position: relative; min-width: 0; -webkit-tap-highlight-color: transparent; }
.leiste a .ikone { font-size: 26px; line-height: 1; }
.leiste a.aktiv { color: var(--gruen); }
.leiste a.scan { color: var(--weiss); }
.leiste a.scan .ikone { background: var(--gruen); border-radius: 50%; width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; margin-top: -22px; box-shadow: 0 4px 12px rgba(1,129,55,0.4); font-size: 28px; }
.leiste a.scan span:not(.ikone) { color: var(--gruen); }
.leiste .zahl { position: absolute; top: 2px; right: calc(50% - 26px); background: var(--rot); color: var(--weiss); font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 6px; min-width: 18px; text-align: center; }
.leiste .zahl.gelb { background: var(--gelb); }
.menue-liste .liste li { padding: 14px 0; font-size: 17px; }
.menue-liste .liste li .ikone { font-size: 24px; width: 34px; text-align: center; }
.login .leiste { display: none; }

.hinweis { display: inline-block; font-size: 13px; font-weight: 700; margin-right: 6px; padding: 1px 7px; border-radius: 10px; vertical-align: middle; }
.hinweis.rot { background: var(--rot); color: var(--weiss); }
.hinweis.gelb { background: var(--gelb); color: var(--weiss); }
