/* ==========================================================================
   Baumkontrolle – Feldoberfläche
   Ein Telefon im Freien: hoher Kontrast, große Ziele für den Daumen,
   Zustände immer sichtbar statt versteckt.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Diese Regel steht bewusst ganz oben und trägt !important.
   Das hidden-Attribut bewirkt display:none nur über das Browser-Stylesheet.
   Jede Klasse mit eigenem display (grid, flex …) hebt es sonst auf, und die
   gesamte Ansichtssteuerung läuft ins Leere. Genau daran ist die erste
   Fassung gescheitert: Anmeldemaske und App lagen gleichzeitig übereinander.
   -------------------------------------------------------------------------- */
[hidden] { display: none !important; }

:root {
  --papier:        #eef1ec;
  --papier-tief:   #e2e8e1;
  --flaeche:       #ffffff;
  --flaeche-2:     #f7f9f6;
  --tinte:         #16201a;
  --tinte-leise:   #55655b;
  --tinte-zart:    #7d8d83;
  --linie:         #c6d0c5;
  --linie-zart:    #dde4dc;
  --moos:          #1d5c3c;
  --moos-hell:     #2a7a51;
  --moos-blass:    #e6f0e9;
  --signal:        #d94a06;
  --signal-blass:  #fdeee6;

  --d-keine:       #4b7a5a;
  --d-gering:      #7f9430;
  --d-mittel:      #cc9010;
  --d-hoch:        #d94a06;
  --d-akut:        #b32218;
  --d-unbestimmt:  #8a988d;

  --schrift: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;

  --leiste: 60px;
  --r: 4px;
  --r-gross: 8px;
  --schatten: 0 1px 2px rgba(22, 32, 26, .06), 0 4px 12px rgba(22, 32, 26, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --papier:      #121814;
    --papier-tief: #0c110e;
    --flaeche:     #1a221c;
    --flaeche-2:   #202a23;
    --tinte:       #e7ede7;
    --tinte-leise: #9aab9e;
    --tinte-zart:  #77877c;
    --linie:       #35443a;
    --linie-zart:  #29352d;
    --moos:        #4fa578;
    --moos-hell:   #66c092;
    --moos-blass:  #1c2f25;
    --signal:      #f2762f;
    --signal-blass:#2e1d13;
    --schatten:    0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior-y: none; }

body {
  font-family: var(--schrift);
  font-size: 16px;
  line-height: 1.45;
  color: var(--tinte);
  background: var(--papier);
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
}

button, input, textarea, select { font: inherit; color: inherit; }

:where(button, a, input, textarea, select):focus-visible {
  outline: 2px solid var(--moos-hell);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ Fehlerbanner
   Ein Skriptfehler darf nicht mehr unsichtbar bleiben. Er erscheint oben,
   im Klartext, auch auf dem Telefon ohne Entwicklerwerkzeuge. */

#fehlerbanner {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 9999;
  background: #b32218;
  color: #fff;
  padding: 12px 46px 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  font-size: 13px;
  line-height: 1.45;
  font-family: var(--mono);
  max-height: 45dvh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
#fehlerbanner b { display: block; font-family: var(--schrift); font-size: 15px; margin-bottom: 5px; }
#fehlerbanner button {
  position: absolute; right: 8px;
  top: calc(8px + env(safe-area-inset-top));
  background: rgba(255,255,255,.22); color: #fff;
  border: 0; border-radius: var(--r); width: 30px; height: 30px;
  font-size: 18px; line-height: 1; cursor: pointer;
}

/* ------------------------------------------------------------------ Gerüst */

#app { display: flex; flex-direction: column; height: 100dvh; }

.ansicht {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom);
}

.ansicht.voll { padding: 0; overflow: hidden; position: relative; }

.spalte { max-width: 44rem; margin: 0 auto; padding: 16px 16px 40px; }

/* -------------------------------------------------------------------- Kopf */

.kopf {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
  flex: none;
}

.kopf h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; flex: 1; }

.netzstand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--tinte-leise);
  background: var(--flaeche-2);
  border: 1px solid var(--linie-zart);
  border-radius: 20px;
  padding: 4px 11px 4px 9px;
  white-space: nowrap;
}
.netzstand.wartet { color: var(--signal); background: var(--signal-blass); border-color: transparent; }
.netzstand.aktuell { color: var(--moos); background: var(--moos-blass); border-color: transparent; }

.punkt { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.netzstand.wartet .punkt { animation: pulsieren 1.6s ease-in-out infinite; }

@keyframes pulsieren { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

/* -------------------------------------------------------------- Navigation */

.navleiste {
  display: flex;
  border-top: 1px solid var(--linie);
  background: var(--flaeche);
  padding-bottom: env(safe-area-inset-bottom);
  flex: none;
}

.navleiste button {
  flex: 1;
  min-height: var(--leiste);
  border: 0;
  border-top: 2px solid transparent;
  margin-top: -1px;
  background: none;
  color: var(--tinte-zart);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}
.navleiste button[aria-current="page"] { color: var(--moos); border-top-color: var(--moos); font-weight: 600; }
.navleiste svg { width: 22px; height: 22px; }
.navleiste .huelle { position: relative; display: block; }

.zaehler {
  position: absolute;
  top: -5px; left: 12px;
  background: var(--signal);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 17px; height: 17px;
  border-radius: 9px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* ------------------------------------------------------------------- Karte */

#karte { width: 100%; height: 100%; background: var(--papier-tief); }
.leaflet-container { font: inherit; background: var(--papier-tief); }

.baum-marker {
  width: 17px; height: 17px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.3);
}

.karte-knoepfe {
  position: absolute;
  z-index: 500;
  left: 12px; bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.karte-knopf {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--r);
  padding: 9px 13px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--schatten);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--tinte);
}

.legende {
  position: absolute;
  z-index: 500;
  right: 12px; bottom: 12px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--r);
  padding: 9px 11px;
  font-size: 11.5px;
  box-shadow: var(--schatten);
  line-height: 1.75;
  color: var(--tinte-leise);
}
.legende i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

.popup h3 { margin: 0 0 3px; font-size: 15px; }
.popup .meta { color: var(--tinte-leise); font-size: 12.5px; }
.popup img { width: 100%; max-width: 210px; border-radius: var(--r); display: block; margin: 8px 0; background: var(--papier-tief); }

/* --------------------------------------------------------------------- GPS
   Kernstück: unter Kronen wird der Empfang schlecht, und das muss der
   Kontrolleur vor dem Auslösen sehen, nicht hinterher am Schreibtisch. */

.gps {
  border: 1px solid var(--linie);
  border-radius: var(--r-gross);
  background: var(--flaeche);
  padding: 14px 16px;
  box-shadow: var(--schatten);
}

.gps-zeile { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.gps-wert { font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.gps-wert small { font-size: 15px; font-weight: 500; color: var(--tinte-leise); }

.gps-urteil { font-size: 13.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.gps-urteil.gut      { color: var(--moos);   background: var(--moos-blass); }
.gps-urteil.mittel   { color: #8a6200;       background: #fdf3dc; }
.gps-urteil.schlecht { color: var(--signal); background: var(--signal-blass); }
.gps-urteil.suchen   { color: var(--tinte-leise); background: var(--flaeche-2); }

.gps-balken { height: 5px; border-radius: 3px; background: var(--papier-tief); margin: 12px 0 9px; overflow: hidden; }
.gps-balken i { display: block; height: 100%; width: 0; background: var(--moos); border-radius: 3px; transition: width .4s ease, background-color .4s ease; }
.gps-balken i.mittel   { background: var(--d-mittel); }
.gps-balken i.schlecht { background: var(--signal); }

.gps-fuss { font-family: var(--mono); font-size: 12px; color: var(--tinte-leise); word-break: break-all; }

/* ---------------------------------------------------------------- Erfassen */

.block { margin-top: 24px; }
.block:first-child { margin-top: 0; }

.block > h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.block > h2 .neben { font-weight: 400; color: var(--tinte-zart); font-size: 13px; }

.fotofeld {
  position: relative;
  border: 1px solid var(--linie);
  border-radius: var(--r-gross);
  background: var(--flaeche);
  min-height: 150px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.fotofeld.leer { border-style: dashed; background: var(--flaeche-2); }
.fotofeld img { width: 100%; display: block; max-height: 44dvh; object-fit: cover; }
.fotofeld .hinweis { color: var(--tinte-zart); font-size: 13.5px; text-align: center; padding: 28px 24px; line-height: 1.5; }
.fotofeld .hinweis svg { width: 30px; height: 30px; display: block; margin: 0 auto 10px; opacity: .5; }

.miniaturen { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.miniatur {
  position: relative;
  width: 72px; height: 72px;
  flex: none;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--linie);
  background: var(--papier-tief);
}
.miniatur img { width: 100%; height: 100%; object-fit: cover; display: block; }
.miniatur .rolle {
  position: absolute; inset: auto 0 0 0;
  background: rgba(22,32,26,.75);
  color: #fff; font-size: 10px; text-align: center; padding: 2px 0;
}
.miniatur .weg {
  position: absolute; top: 3px; right: 3px;
  width: 24px; height: 24px;
  border: 0; border-radius: 50%;
  background: rgba(22,32,26,.8); color: #fff;
  font-size: 15px; line-height: 1;
  display: grid; place-items: center;
  cursor: pointer; padding: 0;
}

.aufnahme {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--linie);
  border-radius: var(--r-gross);
  background: var(--flaeche);
  padding: 13px 15px;
}

.mikro {
  width: 56px; height: 56px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--moos);
  background: var(--flaeche);
  color: var(--moos);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.mikro svg { width: 24px; height: 24px; }
.mikro[data-laeuft="1"] { background: var(--signal); border-color: var(--signal); color: #fff; }
.mikro:disabled { opacity: .4; cursor: not-allowed; }

.pegel { flex: 1; height: 30px; display: flex; align-items: center; gap: 2px; }
.pegel span { flex: 1; background: var(--linie); height: 3px; border-radius: 2px; transition: height .07s linear, background-color .2s; }
.pegel span.an { background: var(--moos-hell); }

.zeit { font-family: var(--mono); font-size: 16px; min-width: 4.2em; text-align: right; }

textarea, input[type="text"], input[type="password"], select {
  width: 100%;
  border: 1px solid var(--linie);
  border-radius: var(--r);
  background: var(--flaeche);
  padding: 11px 13px;
  color: var(--tinte);
}
textarea { min-height: 90px; resize: vertical; }
textarea::placeholder, input::placeholder { color: var(--tinte-zart); }

.schalter {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--linie);
  border-radius: var(--r-gross);
  background: var(--flaeche);
  cursor: pointer;
}
.schalter input { width: 20px; height: 20px; accent-color: var(--moos); flex: none; margin: 1px 0 0; }
.schalter .text { font-size: 14.5px; }
.schalter .text small { display: block; color: var(--tinte-leise); font-size: 13px; margin-top: 2px; }

/* ------------------------------------------------------------------ Knöpfe */

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--moos);
  border-radius: var(--r);
  background: var(--moos);
  color: #fff;
  font-size: 15.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity .15s;
}
.knopf.breit { width: 100%; }
.knopf.gross { min-height: 56px; font-size: 16.5px; }
.knopf.klein { min-height: 38px; font-size: 13.5px; padding: 0 13px; }
.knopf.leise { background: var(--flaeche); color: var(--tinte); border-color: var(--linie); font-weight: 500; }
.knopf.warn  { background: var(--signal); border-color: var(--signal); }
.knopf:disabled { opacity: .4; cursor: not-allowed; }
.knopf svg { width: 19px; height: 19px; flex: none; }

.fusshinweis { color: var(--tinte-leise); font-size: 13px; margin: 10px 0 0; line-height: 1.5; }
.fusshinweis.warnend { color: var(--signal); }

/* ------------------------------------------------------------------ Listen */

.abschnitt-titel {
  margin: 26px 0 2px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--tinte-zart);
}

.eintrag {
  display: flex;
  gap: 13px;
  padding: 13px 0;
  border: 0;
  border-bottom: 1px solid var(--linie-zart);
  align-items: center;
  width: 100%;
  background: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.eintrag .bild {
  width: 60px; height: 60px;
  flex: none;
  border-radius: var(--r);
  object-fit: cover;
  background: var(--papier-tief);
  display: grid; place-items: center;
  color: var(--tinte-zart);
  font-size: 10.5px;
  text-align: center;
}
.eintrag .inhalt { flex: 1; min-width: 0; }
.eintrag .titel { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.eintrag .zeile2 {
  color: var(--tinte-leise);
  font-size: 13px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.marke {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  color: #fff;
  background: var(--d-unbestimmt);
  white-space: nowrap;
}
.marke.keine{background:var(--d-keine)} .marke.gering{background:var(--d-gering)}
.marke.mittel{background:var(--d-mittel)} .marke.hoch{background:var(--d-hoch)}
.marke.akut{background:var(--d-akut)}
.marke.offen{background:var(--signal)} .marke.fehler{background:var(--d-akut)}
.marke.arbeit{background:var(--tinte-zart)}
.marke.frei{background:var(--moos)}

.leerzustand { padding: 48px 20px; text-align: center; color: var(--tinte-leise); }
.leerzustand svg { width: 44px; height: 44px; opacity: .35; margin-bottom: 14px; }
.leerzustand p { margin: 0 0 16px; }

/* --------------------------------------------------------------- Protokoll */

.galerie {
  display: flex; gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-radius: var(--r-gross);
}
.galerie::-webkit-scrollbar { display: none; }
.galerie figure { margin: 0; flex: 0 0 100%; scroll-snap-align: center; position: relative; }
.galerie img { width: 100%; display: block; border-radius: var(--r-gross); background: var(--papier-tief); }
.galerie figcaption {
  position: absolute; left: 9px; bottom: 9px;
  background: rgba(22,32,26,.75); color: #fff;
  font-size: 12px; padding: 3px 9px; border-radius: 20px;
}
.galerie-punkte { display: flex; justify-content: center; gap: 6px; margin-top: 9px; }
.galerie-punkte i { width: 6px; height: 6px; border-radius: 50%; background: var(--linie); transition: background-color .2s; }
.galerie-punkte i.an { background: var(--moos); }

.kopfzeile-protokoll { margin: 18px 0 4px; font-size: 21px; font-weight: 650; letter-spacing: -.015em; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.datenliste { margin: 16px 0 0; }
.datenzeile { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--linie-zart); font-size: 14.5px; }
.datenzeile dt { color: var(--tinte-leise); flex: none; }
.datenzeile dd { margin: 0; text-align: right; }

.befund { border-left: 3px solid var(--linie); padding: 3px 0 3px 12px; margin: 12px 0; }
.befund.gering { border-left-color: var(--d-gering); }
.befund.mittel { border-left-color: var(--d-mittel); }
.befund.hoch   { border-left-color: var(--d-hoch); }
.befund .wo { font-weight: 600; font-size: 13.5px; color: var(--tinte-leise); }

.kasten {
  border: 1px solid var(--linie);
  border-left: 3px solid var(--tinte-zart);
  border-radius: var(--r);
  padding: 11px 14px;
  font-size: 14px;
  background: var(--flaeche);
  line-height: 1.5;
}
.kasten.warn { border-left-color: var(--signal); }
.kasten.fehler { border-left-color: var(--d-akut); }

.transkript {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--r);
  padding: 13px 15px;
  font-size: 14.5px;
  white-space: pre-wrap;
  line-height: 1.55;
}

.knopfreihe { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.knopfreihe .knopf { flex: 1; min-width: 145px; }

/* --------------------------------------------------------------- Anmeldung */

#anmeldung { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }

.anmeldekarte { width: 100%; max-width: 21rem; }
.anmeldekarte .logo { width: 46px; height: 46px; margin-bottom: 18px; display: block; border-radius: var(--r); }
.anmeldekarte h1 { margin: 0 0 6px; font-size: 23px; letter-spacing: -.02em; }
.anmeldekarte > p { margin: 0 0 22px; color: var(--tinte-leise); font-size: 14.5px; }
.anmeldekarte .feld { margin-bottom: 12px; }
.anmeldekarte label { display: block; font-size: 13px; font-weight: 500; color: var(--tinte-leise); margin-bottom: 5px; }

.fehlertext { color: var(--d-akut); font-size: 14px; min-height: 1.3em; margin: 4px 0 12px; }

/* ----------------------------------------------------------------- Meldung */

.meldung {
  position: fixed;
  left: 50%;
  bottom: calc(var(--leiste) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--tinte);
  color: var(--papier);
  padding: 12px 17px;
  border-radius: var(--r);
  font-size: 14.5px;
  z-index: 2000;
  max-width: 92vw;
  box-shadow: 0 4px 18px rgba(0,0,0,.28);
  animation: einblenden .2s ease;
}
@keyframes einblenden { from { opacity: 0; transform: translate(-50%, 8px) } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ------------------------------------------------------------------- Druck */

@media print {
  .kopf, .navleiste, .knopfreihe, .meldung, #fehlerbanner { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  #app { height: auto; display: block; }
  .ansicht { overflow: visible; height: auto; }
  .spalte { max-width: none; padding: 0; }
  .galerie { display: grid; grid-template-columns: 1fr 1fr; gap: 4mm; overflow: visible; }
  .galerie figure { flex: none; }
  .galerie-punkte { display: none; }
  .transkript, .kasten, .datenzeile, .befund { break-inside: avoid; }
}
