/* Gemeinsame Styles für Feld-App und Verwaltung. Breakpoint: 900 px. */

:root {
  --akzent: #c8102e;
  --akzent-text: #fff;
  --bg: #f3f4f5;
  --flaeche: #fff;
  --flaeche2: #eceef0;
  --text: #1c2126;
  --text2: #5b6670;
  --rand: #d3d8dc;
  --grau: #8a949c;
  --gruen: #2e9d63;
  --orange: #c97614;
  --rot: #c8102e;
  --kopf-h: 56px;
  --tabs-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="hell"]) {
    --bg: #111518;
    --flaeche: #1b2025;
    --flaeche2: #262d33;
    --text: #e6e9eb;
    --text2: #9ba6af;
    --rand: #343c43;
    --rot: #ff5a6e;
    color-scheme: dark;
  }
}
:root[data-theme="dunkel"] {
  --bg: #111518;
  --flaeche: #1b2025;
  --flaeche2: #262d33;
  --text: #e6e9eb;
  --text2: #9ba6af;
  --rand: #343c43;
  --rot: #ff5a6e;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
small { color: var(--text2); }
a { color: var(--akzent); }

/* ---------- Formularelemente ---------- */

label { display: grid; gap: 4px; font-weight: 500; }
input, select, textarea {
  font: inherit;
  font-size: 16px;
  min-height: 44px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: var(--flaeche);
  color: var(--text);
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--akzent) 60%, transparent);
  outline-offset: 1px;
}
.schalter { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; cursor: pointer; }
.schalter input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--akzent); flex: none; }

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: var(--flaeche);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
}
.knopf.primaer { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); font-weight: 600; }
.knopf.gefahr { background: var(--rot); color: #fff; border-color: var(--rot); }
.knopf.breit { width: 100%; }
.knopf:disabled { opacity: .5; cursor: default; }
.link {
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: none;
  color: var(--akzent);
  font: inherit;
  cursor: pointer;
}
.link.gefahr { color: var(--rot); }
.formfehler { margin: 0; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--rot) 14%, var(--flaeche)); color: var(--rot); font-weight: 500; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--flaeche2);
  color: var(--text2);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.rot { background: var(--rot); color: #fff; }
.badge.orange { background: var(--orange); color: #fff; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; color: #fff; font-size: 14px; font-weight: 600; }
.leer { padding: 16px; color: var(--text2); list-style: none; }

/* ---------- Login ---------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-karte { width: min(380px, 100%); display: grid; gap: 14px; padding: 24px; background: var(--flaeche); border-radius: 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, .12); }
.login-karte h1 { color: var(--akzent); font-size: 1.5rem; }
.untertitel { margin: -8px 0 0; color: var(--text2); }
.untertitel:empty { display: none; }

/* ---------- Feld-App: Grundlayout (mobil zuerst) ---------- */

#app { height: 100dvh; display: flex; flex-direction: column; }
.kopfleiste {
  position: relative;
  z-index: 1200; /* über den Leaflet-Controls (1000) */
  flex: none;
  height: var(--kopf-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 12px;
  background: var(--akzent);
  color: var(--akzent-text);
}
.app-name { flex: 1; min-width: 0; font-weight: 700; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nur-desktop { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #1c2126;
  font: inherit;
  font-size: 14px;
  white-space: nowrap;
}
.chip .punkt-text { color: var(--grau); }
.chip.online .punkt-text { color: var(--gruen); }
button.chip { min-height: 44px; background: none; padding: 0 2px; cursor: pointer; }
button.chip > span { display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: 999px; background: #fff; color: var(--akzent); font-weight: 600; }
.menue-knopf { width: 44px; height: 44px; border: 0; background: none; color: inherit; font-size: 24px; cursor: pointer; }
.menue {
  position: absolute;
  top: calc(var(--kopf-h) - 4px);
  right: 6px;
  min-width: 240px;
  max-width: calc(100vw - 12px);
  padding: 6px 0;
  background: var(--flaeche);
  color: var(--text);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .25);
}
.menue-benutzer { padding: 8px 16px 10px; border-bottom: 1px solid var(--rand); font-weight: 600; }
.menue button, .menue a {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menue button:hover, .menue a:hover { background: var(--flaeche2); }

.haupt { flex: 1; min-height: 0; display: flex; }
.seite { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--flaeche); }
.karte { flex: 1; min-width: 0; }
.haupt[data-tab="liste"] .karte { display: none; }
.haupt[data-tab="karte"] .seite { display: none; }
body.vollbild-offen .haupt .seite { display: flex; }

.tabs { flex: none; display: flex; border-top: 1px solid var(--rand); background: var(--flaeche); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; height: var(--tabs-h); border: 0; background: none; color: var(--text2); font: inherit; font-weight: 600; cursor: pointer; }
.tabs button[aria-pressed="true"] { color: var(--akzent); box-shadow: inset 0 3px 0 var(--akzent); }

/* ---------- Liste und Filter ---------- */

.liste-bereich { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.filter { flex: none; display: grid; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--rand); }
.zeile { display: flex; gap: 8px; align-items: center; }
.zeile select { flex: 1; min-width: 0; }
.zeile .schalter { flex: none; }
.segment { display: flex; border: 1px solid var(--akzent); border-radius: 8px; overflow: hidden; }
.segment button { flex: 1; min-height: 44px; border: 0; background: var(--flaeche); color: var(--akzent); font: inherit; font-weight: 600; cursor: pointer; }
.segment button[aria-pressed="true"] { background: var(--akzent); color: var(--akzent-text); }

.liste { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.listen-eintrag {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--rand);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.listen-eintrag:hover { background: var(--flaeche2); }
.punkt { flex: none; width: 14px; height: 14px; border-radius: 50%; }
.kuerzel { flex: none; width: 24px; text-align: center; border: 1px solid var(--rand); border-radius: 4px; font-size: 13px; font-weight: 700; color: var(--text2); }
.eintrag-text { flex: 1; min-width: 0; display: grid; }
.eintrag-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jahr { flex: none; min-width: 3.2em; font-weight: 700; }
.jahr.ueberfaellig { color: var(--rot); }

/* ---------- Vollbild-Ansichten (Detail, Panels) ---------- */

.vollbild { position: fixed; inset: 0; z-index: 1300; overflow-y: auto; background: var(--flaeche); padding-bottom: env(safe-area-inset-bottom); }
.vollbild-kopf {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
  padding: 6px 12px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
}
.detail-inhalt, .panel-inhalt { padding: 12px; display: grid; gap: 12px; }
.panel-inhalt { padding: 0; }
.detail-titel { font-size: 1.4rem; }
.detail-adresse { margin: 2px 0 6px; color: var(--text2); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.abschnitt { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--rand); }
details.abschnitt > summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; list-style: revert; }
details.abschnitt > summary h3 { display: inline; }
.aktionen { display: flex; flex-wrap: wrap; gap: 8px; }

.kontrolle-form { display: grid; gap: 12px; }
.feldgruppe.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auswahl { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.auswahl legend { padding: 0; margin-bottom: 4px; font-weight: 500; }
.auswahl-knopf { flex: 1 1 0; min-width: 88px; display: block; cursor: pointer; }
.strahlrohr .auswahl-knopf { flex: 1 1 calc(50% - 4px); }
.auswahl-knopf input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; pointer-events: none; }
.auswahl-knopf span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 6px 8px;
  border: 2px solid var(--zf, var(--rand));
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  text-align: center;
}
.zustand-knopf span { min-height: 64px; font-size: 1.05rem; }
.auswahl-knopf input:checked + span { background: var(--zf, var(--akzent)); border-color: var(--zf, var(--akzent)); color: #fff; }
.auswahl-knopf input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--akzent) 60%, transparent); outline-offset: 1px; }
.leistung { margin: 0; font-size: 1.15rem; font-weight: 700; }
.foto { display: grid; gap: 8px; justify-items: start; }
.foto-knopf { display: inline-flex; font-weight: 500; }
.foto-vorschau { display: flex; align-items: flex-end; gap: 8px; }
.foto-vorschau img { max-width: 60%; max-height: 180px; border-radius: 8px; }
.foto-gross { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; }

.kontrollen { margin: 0; padding: 0; list-style: none; }
.kontrolle { padding: 8px 0; border-bottom: 1px solid var(--rand); display: grid; gap: 2px; }
.kontrolle-zeile { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.kontrolle-bemerkung { overflow-wrap: anywhere; white-space: pre-wrap; }
.kontrolle-fuss { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--text2); font-size: 14px; }
.kontrolle-fuss .link { font-size: 14px; }
.stammdaten { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.stammdaten dt { color: var(--text2); }
.stammdaten dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

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

.leaflet-container { font: inherit; }
.objekt-marker-huelle { background: none; border: 0; }
.objekt-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}
.objekt-marker.faellig { box-shadow: 0 0 0 3px #e0001b, 0 1px 4px rgba(0, 0, 0, .45); }
.karten-knoepfe { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.karten-knopf {
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid rgba(0, 0, 0, .2);
  border-radius: 6px;
  background: #fff;
  color: #1c2126;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.karten-knopf.aktiv { background: var(--akzent); border-color: var(--akzent); color: #fff; }

/* ---------- Dialog und Toast ---------- */

.dialog {
  width: min(480px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--flaeche);
  color: var(--text);
}
.dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog form { display: grid; gap: 14px; padding: 18px; }
.dialog-inhalt { display: grid; gap: 12px; }
.dialog-inhalt p { margin: 0; }
.dialog-knoepfe { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom));
  z-index: 2000;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 10px;
  background: #1c2126;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
  transform: translateX(-50%);
  visibility: hidden;
}
.toast.sichtbar { visibility: visible; }
.toast.fehler { background: #b00d26; }

/* ---------- Desktop ---------- */

@media (min-width: 900px) {
  .nur-desktop { display: inline; }
  .tabs { display: none; }
  .haupt[data-tab] .seite { display: flex; flex: 0 0 400px; border-right: 1px solid var(--rand); }
  .haupt[data-tab] .karte { display: block; }
  .vollbild { position: static; flex: 1; min-height: 0; }
  .toast { bottom: 24px; }
}
