/*
  Feldwerkzeug, kein Schaufenster.
  Hoher Kontrast fuer Sonnenlicht, Touchziele ab 48px, Systemschrift
  (laedt auch bei schlechtem Netz sofort), Ziffern tabellarisch, weil
  Permitnummern verglichen werden. Rot ist ausschliesslich Gefahr —
  deshalb ist der Akzent petrol und nicht orange.
*/

:root {
  --grund: #e9eded;
  --flaeche: #ffffff;
  --linie: #c8d0cf;
  --text: #0e1413;
  --text-leise: #55605e;
  --kopf: #9BA64B;         /* GEOPS-Gruen: Kopfzeile und Speichern */
  --akzent: #5F6B2C;       /* dunkleres GEOPS-Gruen: Bestaetigen */
  --akzent-hell: #4A5423;  /* gedrueckt */
  --still: #EDEBE6;        /* GEOPS-Grau, aufgehellt: alle uebrigen Knoepfe */
  --gefahr: #a8231b;
  --gefahr-grund: #fdecea;

  --st-offen: #2f6fd0;
  --st-arbeit: #F0C020;  /* Gelb; traegt dunkle Schrift */
  --st-wartend: #c26a12;
  --st-angenommen: #9BA64B;  /* GEOPS-Gruen */
  --st-abgelehnt: #a8231b;

  --radius: 10px;
  --luft: 16px;
}

* { box-sizing: border-box; }

/* Sonst ueberschreiben .blatt und .anmeldung mit display:flex/grid das hidden-Attribut. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--grund);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

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

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

.anmeldung {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--luft);
  background: var(--akzent);
}

.anmeldung-feld {
  width: 100%;
  max-width: 380px;
  background: var(--flaeche);
  border-radius: var(--radius);
  padding: 28px 22px;
}

.anmeldung-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.anmeldung-feld h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.02em;
}

/* Die Bilddatei hat weissen Grund — der Kasten auch, darum faellt das nicht auf. */
.marke {
  flex: 0 0 auto;
  width: 120px;
  height: auto;
}

.projektzeile {
  margin: 4px 0 24px;
  color: var(--text-leise);
}

.anmeldung-feld label {
  display: block;
  margin: 14px 0 6px;
  font-size: 15px;
  color: var(--text-leise);
}

.anmeldung-feld input,
.anmeldung-feld select {
  width: 100%;
  height: 50px;
  padding: 0 12px;
  border: 1.5px solid var(--linie);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: inherit;
}

.anmeldung-feld input:focus-visible,
.anmeldung-feld select:focus-visible,
.kopf input:focus-visible,
.feld input:focus-visible,
.feld textarea:focus-visible,
.feld select:focus-visible {
  outline: 3px solid var(--akzent-hell);
  outline-offset: 1px;
}

.knopf-haupt {
  width: 100%;
  height: 52px;
  margin-top: 22px;
  border: 0;
  border-radius: 8px;
  background: var(--akzent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.knopf-haupt:active { background: var(--akzent-hell); }

.fehler {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--gefahr-grund);
  color: var(--gefahr);
  font-size: 15px;
}

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

.kopf {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px var(--luft);
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--kopf);
  color: #fff;
}

.kopf input {
  flex: 1;
  /* Ohne das schrumpft ein Eingabefeld nicht unter seine Standardbreite
     (rund 250 px). Mit Info-Symbol und Menue wird die Kopfzeile auf einem
     schmalen Handy dann breiter als der Schirm, der Browser verkleinert die
     ganze Seite - und schiebt dabei auch die Fussleiste unten hinaus. */
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  /* Die Kopfzeile faerbt Text weiss; im Suchfeld waere er unsichtbar. */
  color: var(--text);
}

.kopf input::placeholder { color: var(--text-leise); }

.knopf-still {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1.5px solid rgba(14, 20, 19, .22);
  border-radius: 8px;
  background: var(--still);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

/* Titel in den Detailansichten: Permitnummer, "Person" oder "Organisation". */
.kopf-titel {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  color: #fff;
}

/* Das Projekt steht unter der Kopfzeile, nicht darin: in der Kopfzeile naehme
   es der Suche den Platz. Auf eigener Zeile ist Raum fuer den ganzen Namen. */
.projektband {
  padding: 8px var(--luft);
  border-bottom: 1px solid var(--linie);
  background: var(--flaeche);
  color: var(--akzent);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Das Info-Symbol steht immer da. Gibt es Neues, leuchtet es blau und traegt
   die Zahl - blau wie der Status "Offen": ein Hinweis ist eine offene Aufgabe,
   die neu dazukam. Rot bleibt Gefahr. */
.info-knopf { position: relative; }

.info-knopf.neu {
  border-color: var(--st-offen);
  background: var(--st-offen);
  color: #fff;
}

.info-knopf .zaehler {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 2px solid var(--st-offen);
  border-radius: 999px;
  background: #fff;
  color: var(--st-offen);
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ Menü */

/* Liegt ueber allem ausser Blatt und Rueckfrage; ein Tipp daneben schliesst.
   top setzt app.js auf die Unterkante der Kopfzeile: die bleibt antippbar. */
.menue {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(14, 20, 19, .25);
}

/* top und --zipfel setzt app.js (klappeAusrichten) nach dem Symbol, zu dem
   die Klappe gehoert. Der Schatten ist ein Filter statt box-shadow: so faellt
   er auch unter das Eckchen. */
.menue-inhalt {
  position: fixed;
  top: calc(max(10px, env(safe-area-inset-top)) + 58px);
  right: var(--luft);
  width: min(340px, calc(100vw - 2 * var(--luft)));
  padding: 6px;
  border-radius: var(--radius);
  background: var(--flaeche);
  filter: drop-shadow(0 6px 16px rgba(14, 20, 19, .25));
}

/* Das Eckchen wie bei einer Sprechblase, auf das Symbol gerichtet. */
.menue-inhalt::before {
  content: '';
  position: absolute;
  top: -10px;
  left: calc(var(--zipfel, calc(100% - 30px)) - 11px);
  width: 22px;
  height: 11px;
  background: var(--flaeche);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

/* Die Hinweise koennen laenger sein als der Schirm: gerollt wird innen, damit
   das Eckchen stehen bleibt. */
.klappe-rollen {
  max-height: var(--hoehe, 70dvh);
  overflow-y: auto;
}

.klappe-titel {
  margin: 6px 14px 2px;
  font-size: 14px;
  color: var(--text-leise);
}

.klappe-leer {
  margin: 0;
  padding: 14px;
  color: var(--text-leise);
}

.menue-punkt.hinweis-punkt {
  min-height: 0;
  padding: 12px 14px;
  font-weight: 400;
}

.hinweis-punkt .zeilentext { flex: 1; min-width: 0; }

.hinweis-punkt + .hinweis-punkt {
  border-top: 1px solid var(--linie);
  border-radius: 0;
}

/* Neuigkeiten: dieselben Zeilen, aufklappbar. Ungelesen traegt einen blauen
   Punkt wie die Zahl am Info-Symbol, gelesen steht der Titel normal. */
.neuigkeit + .neuigkeit,
.hinweis-punkt + .klappe-titel { border-top: 1px solid var(--linie); }

.hinweis-punkt + .klappe-titel { padding-top: 10px; }

/* Auf Hoehe der ersten Zeile, auch wenn der Titel umbricht. */
.neu-punkt {
  flex: none;
  align-self: flex-start;
  margin-top: 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--st-offen);
}

.zeile-kopf .gelesen { font-weight: 600; }

.neuigkeit.offen { background: var(--grund); border-radius: 8px; }

/* Gelesen und zugeklappt: nur der Titel, eine flache Zeile. */
.neuigkeit.kurz .hinweis-punkt { padding-top: 8px; padding-bottom: 8px; }

/* Eingerueckt auf die Hoehe des Textes neben dem Zeichen. */
.neuigkeit-text {
  padding: 0 14px 14px 46px;
  font-size: 16px;
}

.neuigkeit-text p { margin: 0 0 8px; }
.neuigkeit-text ul,
.neuigkeit-text ol { margin: 0 0 8px; padding-left: 20px; }
.neuigkeit-text li { margin: 0 0 6px; }
.neuigkeit-text > :last-child { margin-bottom: 0; }

.menue-punkt {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.menue-punkt:active { background: #f2f5f4; }
.menue-punkt svg { flex: none; color: var(--text-leise); }
.menue-punkt[aria-current="page"] { background: var(--grund); color: var(--akzent); }
.menue-punkt[aria-current="page"] svg { color: var(--akzent); }

/* Benachrichtigungen sind eine Einstellung, keine Liste: mit einer Linie
   abgesetzt, aber noch vor dem Abstand zu Abmelden. */
.menue-punkt.push {
  position: relative;
  margin-top: 13px;
  font-weight: 400;
}

.menue-punkt.push::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 14px;
  right: 14px;
  border-top: 1px solid var(--linie);
}

/* Abmelden steht abgesetzt: mit Abstand und einer Linie davor, damit es beim
   Wechseln zwischen den Listen keiner trifft. */
.menue-punkt.abmelden {
  position: relative;
  margin-top: 29px;
  font-weight: 400;
}

.menue-punkt.abmelden::before {
  content: '';
  position: absolute;
  top: -15px;
  left: 14px;
  right: 14px;
  border-top: 1px solid var(--linie);
}

main {
  padding: var(--luft);
  padding-bottom: 96px;
  max-width: 720px;
  margin: 0 auto;
}

/* ----------------------------------------------------------- Fussleiste */

.fussleiste {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 10px;
  padding: 10px var(--luft);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--flaeche);
  border-top: 1px solid var(--linie);
}

.fuss-knopf {
  flex: 1;
  height: 52px;
  border: 1.5px solid rgba(14, 20, 19, .22);
  border-radius: 8px;
  background: var(--still);
  font-weight: 600;
  cursor: pointer;
}

/* Speichern sitzt jetzt in der Fussleiste, nicht mehr auf der Seite. Farbe
   wie bisher, nur der Rand muss zur Fuellung passen - .fuss-knopf bringt
   einen grauen mit. */
.fuss-knopf.knopf-speichern { border-color: var(--kopf); }

.fuss-knopf.betont {
  background: var(--akzent);
  border-color: var(--akzent);
  color: #fff;
}

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

.gruppe-titel {
  margin: 22px 0 8px;
  font-size: 15px;
  color: var(--text-leise);
}

.gruppe-titel:first-child { margin-top: 0; }

.zeile {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 8px;
  cursor: pointer;
}

.zeile:active { background: #f2f5f4; }

.zeile-kopf {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.nummer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
}

/* Zeile mit Symbol: links das Zeichen, rechts Kopf und Unterzeile als ein
   Block. Nur diese Zeilen sind Flexboxen - ohne die Klasse stuenden in der
   Startliste Kopf, Unterzeile und Fuss nebeneinander statt untereinander. */
.zeile.mit-symbol {
  display: flex;
  align-items: center;
  gap: 12px;
}

.zeile.mit-symbol .zeilentext {
  flex: 1;
  min-width: 0;
}

.zeilensymbol {
  flex: none;
  display: flex;
  color: var(--text-leise);
}

/* Das Zeichen rechts sagt, was ein Tipp bewirkt. Es steht etwas blasser als
   das Sachsymbol links: das ist die erste Auskunft, dies die zweite. */
.zeilensymbol-rechts {
  margin-left: 8px;
  opacity: .65;
}

.zeile-unten {
  margin-top: 3px;
  color: var(--text-leise);
  font-size: 15px;
}

.chip {
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.chip[data-status="OFFEN"] { background: var(--st-offen); }
.chip[data-status="IN_ARBEIT"] { background: var(--st-arbeit); color: var(--text); }
.chip[data-status="WARTEND"] { background: var(--st-wartend); }
.chip[data-status="ANGENOMMEN"] { background: var(--st-angenommen); }
.chip[data-status="ABGELEHNT"] { background: var(--st-abgelehnt); }

.leer {
  padding: 40px 0;
  text-align: center;
  color: var(--text-leise);
}

.leer-anlegen {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Dieselben Knoepfe wie "+ Permit" unten, nur untereinander. */
.leer-anlegen .fuss-knopf { flex: none; }

/* ---------------------------------------------------------------- Warnung */

.warnband {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gefahr);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  font-weight: 700;
}

/* Beanstandung an der Konfiguration. Bewusst nicht rot: Rot heisst in dieser
   App koerperliche Gefahr, und das soll es auch bleiben. */
.konfigband {
  display: block;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border-left: 5px solid var(--st-wartend);
  background: var(--flaeche);
  color: var(--text);
  text-decoration: none;
}

.konfigband span {
  display: block;
  margin-top: 2px;
  color: var(--st-wartend);
  font-size: 14px;
  text-decoration: underline;
}

.warnpunkt {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gefahr);
  flex: none;
}

/* ----------------------------------------------------------- Permitseite */

.karte {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.karte h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--text-leise);
  font-weight: 600;
}

.titelzeile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.titelzeile .nummer { font-size: 27px; letter-spacing: -0.01em; }

.feld { margin-bottom: 14px; }
.feld:last-child { margin-bottom: 0; }

.feld label {
  display: block;
  margin-bottom: 5px;
  font-size: 15px;
  color: var(--text-leise);
}

/* Alle Eingabefelder, egal welcher Typ; nur Kaestchen bleiben aussen vor. */
.feld input:not([type="checkbox"]):not([type="radio"]),
.feld select,
.feld textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--linie);
  border-radius: 8px;
  background: #fff;
}

.feld textarea { min-height: 120px; resize: vertical; }

/* Betraege: Waehrung zur Wahl davor, Zeichen im Feld — wie Twenty es zeigt.
   Die Regeln muessen schwerer wiegen als die allgemeine oben, sonst gewinnen
   deren Rahmen, Breite und Innenabstand. */
.betragsfeld { display: flex; gap: 8px; }

/* Zeichen und Betrag stehen in einer Reihe, nicht uebereinander: ein
   dreistelliges Zeichen wie CHF klebte sonst am Betrag. Den Rahmen traegt
   der Kasten, das Feld darin ist rahmenlos. */
.betragseingabe {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding-left: 12px;
  border: 1.5px solid var(--linie);
  border-radius: 8px;
  background: #fff;
}

.betragseingabe:focus-within {
  outline: 3px solid var(--akzent-hell);
  outline-offset: 1px;
}

/* Enger als ein gewoehnliches Auswahlfeld: nur drei Buchstaben stehen darin,
   und der Betrag daneben braucht den Platz. Der Pfeil rueckt mit, sonst
   liegt er auf dem Text. */
.feld .betragsfeld .waehrungswahl {
  width: auto;
  flex: 0 0 auto;
  padding-left: 10px;
  padding-right: 28px;
  background-position: right 10px center;
  color: var(--text-leise);
}

.betragsfeld .waehrungszeichen {
  flex: 0 0 auto;
  margin-right: 6px;
  color: var(--text-leise);
}

.feld .betragsfeld .betragseingabe input[type="number"] {
  flex: 1;
  min-width: 0;
  padding-left: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.feld .betragsfeld .betragseingabe input[type="number"]:focus-visible { outline: none; }

.schalter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 6px 0;
  border-bottom: 1px solid var(--linie);
}

.schalter:last-child,
.schalter:has(+ [hidden]:last-child) { border-bottom: 0; }

/* Feld direkt unter einem Schalter braucht Luft nach oben. */
.schalter + .feld { margin-top: 14px; }

.schalter input[type="checkbox"] {
  width: 26px;
  height: 26px;
  flex: none;
  accent-color: var(--akzent);
}

/* Kaestchen rechts, wie bei den Erlaubnissen; die ganze Zeile ist antippbar. */
.kaestchen {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 6px 0;
  border-bottom: 1px solid var(--linie);
}

.kaestchen:last-child { border-bottom: 0; }

.kaestchen input { width: 26px; height: 26px; flex: none; accent-color: var(--akzent); }

.knopfreihe {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.knopfreihe.drei { grid-template-columns: repeat(3, 1fr); }

/* Laut CI: auf dem GEOPS-Gruen weisse Schrift, in Versalien. */
.knopf-speichern {
  background: var(--kopf);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.knopf-speichern:active { background: #8b9543; }

.knopf-flach {
  min-height: 52px;
  border: 1.5px solid rgba(14, 20, 19, .22);
  border-radius: 8px;
  background: var(--still);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.knopf-flach:active { background: #dcd9d1; }

.notizzeile {
  padding: 11px 0;
  border-bottom: 1px solid var(--linie);
  font-size: 15px;
}

.notizzeile:last-child { border-bottom: 0; }

.einzeilig {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Darf umbrechen statt abzuschneiden - fuer den Dateinamen eines Anhangs, der
   die ganze Auskunft traegt. overflow-wrap faengt ab, was auch ohne
   Unterstriche kein Leerzeichen hat. */
.mehrzeilig {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.chip[data-abgesagt] { background: var(--gefahr); }

.chip[data-aufgabe-status="TODO"] { background: var(--st-offen); }
.chip[data-aufgabe-status="IN_PROGRESS"] { background: var(--st-arbeit); color: var(--text); }
.chip[data-aufgabe-status="DONE"] { background: var(--st-angenommen); }

/* Zufriedenheit: Gesichter wie auf dem Zettel, links sehr zufrieden. */
.gesichter {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.gesicht {
  display: grid;
  place-items: center;
  min-height: 58px;
  padding: 6px 0;
  border: 1.5px solid rgba(14, 20, 19, .22);
  border-radius: 10px;
  background: var(--still);
  color: var(--text);
  cursor: pointer;
}

.gesicht[aria-pressed="true"] {
  border-color: var(--akzent);
  background: var(--akzent);
  color: #fff;
}

/* -------------------------------------------------------- Verknuepfungen */

.verknuepft {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.verknuepft .zeile {
  flex: 1;
  min-width: 0;
  margin: 0;
}

/* Entfernen steht neben der Zeile, nicht auf ihrer ganzen Hoehe: ein Knopf,
   der mit dem Inhalt mitwaechst, wird bei drei Zeilen zur Flaeche, die man
   im Vorbeigehen trifft. Darum feste 48px und mittig daneben. */
.verknuepft .knopf-icon {
  flex: none;
  align-self: center;
}

/* Das X gehoert dem Schliessen. Hier steht es nur noch am Blatt. */
.knopf-x {
  flex: none;
  width: 48px;
  border: 1.5px solid rgba(14, 20, 19, .22);
  border-radius: 8px;
  background: var(--still);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

/* Zwei Suchfelder untereinander - Person und Firma bei den weiteren
   Beteiligten. Ohne Abstand kleben sie aneinander; 8px ist derselbe, den die
   Zeilen darueber untereinander haben. */
.suchfeld + .suchfeld { margin-top: 8px; }

.suchauswahl input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--linie);
  border-radius: 8px;
  background: #fff;
}

.suchauswahl input:focus-visible { outline: 3px solid var(--akzent-hell); outline-offset: 1px; }

.treffer .zeile { margin: 8px 0 0; }
.treffer .knopf-flach { margin-top: 8px; }

/* Formular zum Anlegen, direkt im Auswahlfeld. */
.neu-anlegen { margin: 8px 0 0; }

.leise {
  margin: 8px 0 0;
  color: var(--text-leise);
  font-size: 15px;
}

/* ----------------------------------------------------------------- Blatt */

.blatt {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(14,20,19,.45);
  display: flex;
  align-items: flex-end;
}

.blatt-inhalt {
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--grund);
  border-radius: 14px 14px 0 0;
  padding: 20px var(--luft);
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.blatt-kopf {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

/* Nimmt den freien Platz, damit die Knopfreihe rechts steht und ein langer
   Titel (E-Mail-Betreff) umbricht, statt die Knoepfe zusammenzudruecken. */
.blatt-kopf h2 { flex: 1; min-width: 0; margin: 0; font-size: 20px; color: var(--text); }

.blatt-knoepfe {
  display: flex;
  flex: none;
  gap: 8px;
}

.knopf-icon {
  display: flex;
  text-decoration: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1.5px solid rgba(14, 20, 19, .22);
  border-radius: 8px;
  background: var(--still);
  color: var(--text);
  cursor: pointer;
}

.knopf-icon:active { background: #dcd9d1; }

/* Rot heisst in dieser App Gefahr. Was etwas wegnimmt, traegt es - und nur das. */
.knopf-icon.gefahr {
  border-color: rgba(168, 35, 27, .35);
  background: var(--gefahr-grund);
  color: var(--gefahr);
}

.knopf-icon.gefahr:active { background: #f8d7d3; }

.knopf-haupt.gefahr { background: var(--gefahr); }
.knopf-haupt.gefahr:active { background: #8c1d16; }

/* Rueckfrage vor dem Loeschen: liegt ueber dem Blatt, damit das Formular
   darunter stehen bleibt, wenn jemand danebengegriffen hat. */
.nachfrage {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--luft);
  background: rgba(14, 20, 19, .55);
}

.nachfrage-inhalt {
  width: 100%;
  max-width: 420px;
  background: var(--grund);
  border-radius: 14px;
  padding: 20px var(--luft);
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.nachfrage-inhalt h2 { margin: 0 0 8px; font-size: 20px; color: var(--text); }
.nachfrage-inhalt .knopf-haupt { margin-top: 18px; }

@media (min-width: 700px) {
  .blatt { align-items: center; justify-content: center; }
  .blatt-inhalt { max-width: 620px; border-radius: 14px; }
}

/* --------------------------------------------------------------- Scanner */

.scanner {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--grund);
}

.scanner-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px var(--luft);
  padding-top: max(10px, env(safe-area-inset-top));
}

.scanner-kopf h2 { margin: 0; font-size: 19px; }

.scanner-inhalt {
  flex: 1;
  overflow-y: auto;
  padding: 4px var(--luft) max(20px, env(safe-area-inset-bottom));
}

.scanner-flaeche {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0e1413;
}

.scanner-flaeche canvas {
  touch-action: none;
  max-width: 100%;
  max-height: 100%;
  background: #fff;
}

.scanner-fuss {
  display: grid;
  gap: 10px;
  padding: 12px var(--luft);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.scanner-hinweis { margin: 0; font-size: 15px; color: var(--text-leise); }

.modus {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.modus .knopf-flach[aria-pressed="true"] {
  background: var(--akzent);
  border-color: var(--akzent);
  color: #fff;
}

.seiten {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.seite { position: relative; }

.seite img {
  display: block;
  width: 100%;
  border: 1px solid var(--linie);
  border-radius: 6px;
  background: #fff;
}

.seite .knopf-x {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 38px;
  height: 38px;
  font-size: 22px;
}

.seite-nr {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
}

.knopf-haupt:disabled { opacity: .45; cursor: default; }

/* ----------------------------------------------------------- Kleinigkeiten */
/* Wenige Helfer, damit im Markup keine Styles stehen. */

.ohne-abstand { margin: 0; }
.voll-breit { width: 100%; }
.titel-name { font-size: 23px; }

#verlauf { margin-top: 22px; }

.knopf-flach.klein { min-height: 44px; padding: 0 14px; }
.knopf-flach.breit { width: 100%; margin-top: 6px; }

/* Anrufen und Route: teilen sich die Breite, egal ob einer oder zwei da sind. */
.knopfreihe.kontakt {
  display: flex;
  margin: 8px 0 0;
}

.knopfreihe.kontakt > * { flex: 1; }

/* Datum und Verfasser ueber einem Blatt-Formular. */
.blatt-meta { margin: -6px 0 12px; }

/* Was der Verweis von dieser Seite aus heisst, unter dem Auswahlfeld im Blatt. */
.verweis-satz { margin: 0 0 12px; font-size: 16px; line-height: 1.4; }

/* Wo ein Termin ist: Firma oder Person, Strasse, PLZ Ort - untereinander,
   so wie man es auf einen Zettel schreiben wuerde. */
.anschrift {
  margin: -4px 0 14px;
  line-height: 1.45;
}

/* E-Mail im Blatt: Betreff der einzelnen Nachricht, wenn er vom Gespraech
   abweicht, und der Text so umbrochen, wie er geschrieben wurde. */
.mail-betreff { margin: 6px 0 0; font-weight: 600; }
.mail-text {
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Erklaerender Vorspann, z.B. "Wozu gehoert die Notiz?" */
.erklaerung { margin: 0 0 8px; color: var(--text-leise); }

/* Rueckmeldung unter der Permitnummer beim Anlegen. */
.pruefzeile { margin: 8px 0 0; font-size: 15px; }
.pruefzeile[data-frei="ja"] { color: var(--st-angenommen); }
.pruefzeile[data-frei="nein"] { color: var(--gefahr); }

/* Anhang-Zeile ist ein Link, soll aber wie eine Zeile aussehen. */
a.zeile { text-decoration: none; color: inherit; display: block; }

/* --------------------------------------------------------------- Hinweis */

.hinweis {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  z-index: 40;
  max-width: 90vw;
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-size: 15px;
  text-align: center;
}

.hinweis[data-art="fehler"] { background: var(--gefahr); }

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

/* Knopf mit Icon vor dem Text (Anrufen, Route) */
.knopf-flach.mit-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

/* ---------------------------------------------------------- Startliste */

.sortierleiste {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.sortierleiste label { font-size: 15px; color: var(--text-leise); white-space: nowrap; }

.sortierleiste select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 6px 10px;
  border: 1.5px solid var(--linie);
  border-radius: 8px;
  background: #fff;
}

.sortierleiste .knopf-flach { flex: none; width: 48px; font-size: 20px; }

.zeile-datum { margin-top: 2px; font-size: 13px; color: var(--text-leise); }
/* Das Datum steht rechts, damit die Namen darueber links buendig bleiben. */
.zeile-datum.rechts { text-align: right; }

/* Fuss der Zeile: links die Marken, rechts das Datum. */
.zeile-fuss {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.zeile-fuss .zeile-datum { margin-top: 0; white-space: nowrap; }

/* Woran ein Permit haengt. Leise gezeichnet: die Zeile soll ihre Nummer
   zuerst zeigen, die Symbole sind die zweite Auskunft. */
.marken {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-leise);
}

.marken svg { display: block; }

/* ------------------------------------------------------------ Permitter */
/* Rundes Bild rechts oben, zur Haelfte ueber den Kartenrand geschoben. */

.karte.vorgang { margin-top: 40px; }

.vorgang-kopf {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.permitter {
  flex: none;
  max-width: 45%;
  margin-top: -48px;
  text-align: right;
}

.permitter-bild {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 0 4px auto;
  border: 3px solid var(--flaeche);
  border-radius: 50%;
  object-fit: cover;
  background: var(--still);
  box-shadow: 0 1px 4px rgba(14, 20, 19, .2);
}

.permitter-bild.ohne-bild {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--text-leise);
}

.permitter-name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.permitter-datum { font-size: 13px; color: var(--text-leise); }

/* Auswahlfelder: eigener Pfeil mit Abstand zum Rand; der des Browsers klebt am Rand. */
.feld select,
.sortierleiste select,
.filterleiste select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230e1413' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
}

/* ------------------------------------------------------------ Filter */
/* Ueber der Sortierung: "Alle / Meine" und bei Permits der Status. */

.filterleiste {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.filterleiste label {
  margin-left: auto;
  font-size: 15px;
  color: var(--text-leise);
  white-space: nowrap;
}

.filterleiste select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 6px 10px;
  border: 1.5px solid var(--linie);
  border-radius: 8px;
  background-color: #fff;
}

.umschalter {
  display: flex;
  flex: none;
  overflow: hidden;
  border: 1.5px solid var(--linie);
  border-radius: 8px;
  background: #fff;
}

.umschalter button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  background: none;
  font-weight: 600;
  cursor: pointer;
}

.umschalter button + button { border-left: 1.5px solid var(--linie); }

.umschalter button[aria-pressed="true"] {
  background: var(--akzent);
  color: #fff;
}

/* Woran eine Aufgabe haengt: Zeichen und Text in einer Zeile. */
.zeile-datum.bezug {
  display: flex;
  align-items: center;
  gap: 6px;
}

.zeile-datum.bezug svg { flex: none; }

/* Schritte zum Nachmachen, etwa "Zum Home-Bildschirm". */
ol.schritte { margin: 8px 0 0; padding-left: 24px; }
ol.schritte li { margin: 6px 0; }

/* Image record: art choice, camera/gallery buttons and tiles in the sheet. */
.art-wahl { display: flex; flex-wrap: wrap; gap: 8px; }
.art-kaste {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 12px;
  background: #f2f3ee; border: 1.5px solid transparent;
}
.art-kaste:has(input:checked) { background: #e6ebd8; border-color: #9ba64b; }
.art-kaste input { margin: 0; }
.bild-knoepfe { display: flex; flex-wrap: wrap; gap: 8px; }
.bild-knoepfe .knopf-flach { flex: 1; }

/* Image tiles: three per row on the phone, the whole tile is the button. */
.kacheln { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
@media (min-width: 700px) { .kacheln { grid-template-columns: repeat(4, 1fr); } }
.kachel {
  position: relative; display: block; padding: 0; border: none; border-radius: 8px;
  aspect-ratio: 1; overflow: hidden; background: #e2e4dc; cursor: pointer;
}
.kachel img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kachel-marke {
  position: absolute; left: 4px; right: 4px; bottom: 4px;
  padding: 2px 4px; border-radius: 6px;
  background: rgba(168, 35, 27, .88); color: #fff; font-size: 11px; line-height: 1.3;
}
.zeile-unten.nicht-hochgeladen { color: var(--gefahr); font-weight: 600; }

/* Full-screen view over the sheet, below the delete question. */
.vollbild {
  position: fixed; inset: 0; z-index: 32;
  display: flex; flex-direction: column;
  background: #0e1413; color: #fff;
}
.vollbild-kopf {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px var(--luft);
  padding-top: max(12px, env(safe-area-inset-top));
}
.vollbild-zaehler { font-size: 15px; }
.vollbild-flaeche { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.vollbild-flaeche img { width: 100%; height: 100%; object-fit: contain; display: block; }
.vollbild-text {
  margin: 0; padding: 10px var(--luft);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  font-size: 14px; text-align: center; overflow-wrap: anywhere;
}
.vollbild-pfeil {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 64px; border: none; border-radius: 8px;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: 34px; line-height: 1; cursor: pointer;
}
.vollbild-pfeil.links { left: 8px; }
.vollbild-pfeil.rechts { right: 8px; }
.vollbild-pfeil:disabled { opacity: .25; cursor: default; }

/* Damage reports: status colours as for permits, size as two fields, a poor
   position in red under the field. */
.chip[data-schaden-status="GEMELDET"] { background: var(--st-offen); }
.chip[data-schaden-status="IN_PRUEFUNG"] { background: var(--st-arbeit); color: var(--text); }
.chip[data-schaden-status="BERICHT_ERSTELLT"] { background: var(--st-wartend); }
.chip[data-schaden-status="REGULIERT"] { background: var(--st-angenommen); }
.chip[data-schaden-status="ABGELEHNT"] { background: var(--st-abgelehnt); }
.gps-info.schlecht { color: var(--gefahr); font-weight: 600; }
.masse { display: flex; align-items: center; gap: 8px; }
.masse input { flex: 1; min-width: 0; }
.zeuge .feld { margin: 8px 0 0; }
/* "Noch keine Fotos." spans the whole tile grid; buttons below tiles keep a gap. */
.kacheln > p { grid-column: 1 / -1; }
.kacheln + .bild-knoepfe { margin-top: 10px; }

/* Building condition: postcode and town side by side, descriptions keep
   their line breaks. */
.plz-ort { display: grid; grid-template-columns: minmax(0, 6.5em) minmax(0, 1fr); gap: 8px; }
.mehrzeilig-text { white-space: pre-wrap; overflow-wrap: anywhere; }
