/* Oberfläche des Prüfmanagements — Gestaltungsrichtung „Messgerät".
 *
 * WARUM DUNKEL. Diese App wird nicht am Schreibtisch bedient, sondern einhändig am Handy:
 * im Keller, im Technikraum, im Baustellencontainer, bei schlechtem Licht, oft mit
 * Handschuhen. Ein helles Formular blendet dort und frisst Kontrast. Die Oberfläche ist
 * deshalb als Gerät gestaltet: dunkles Gehäuse, helles Ablesefeld, große Ziffern.
 *
 * WOHER DIE FORMENSPRACHE KOMMT. Aus der Welt des Prüflings selbst — Prüfgeräte wie
 * Secutest oder Benning ST: hoher Kontrast, Tabellenziffern, harte Einheiten (Ω, MΩ, mA, µA),
 * Signalgelb als Gehäusefarbe, nicht als Dekoration.
 *
 * DAS SIGNATURELEMENT ist die Grenzwert-Skala (.skala). Sie beantwortet die Frage, die eine
 * Prüfperson wirklich hat: nicht nur „bestanden ja/nein", sondern „wie viel Luft habe ich
 * zum Grenzwert". Und sie fehlt bewusst dort, wo kein automatischer Grenzwert existiert —
 * die Abwesenheit der Skala ist die sichtbare Form von Regel R6.
 *
 * FARBE ALS BEDEUTUNG, nicht als Schmuck:
 *   grün  = bestanden          rot = nicht bestanden
 *   gelb  = die Prüfperson muss entscheiden (Markenfarbe = Aufmerksamkeit der Fachkraft)
 * Farbe steht nie allein: jeder Zustand trägt zusätzlich Zeichen und Klartext.
 *
 * SCHRIFT: Barlow Condensed (Anzeige, Ablesewerte, Beschriftungen) und Barlow (Fließtext).
 * Beide lokal ausgeliefert, kein fremder Server (Regel R4). Eine Familie in zwei Breiten
 * statt zweier Familien — weniger Dateien für eine Mobilverbindung im Keller.
 */

@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Barlow";
  src: url("/fonts/barlow-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Barlow";
  src: url("/fonts/barlow-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}

:root {
  /* Gehäuse — kein reines Schwarz, sondern ein kühles Graphit wie ein Geräteboden. */
  --geraet:        #14171a;
  --panel:         #1d2126;
  --panel-hoch:    #262b31;
  --panel-tief:    #101316;
  --kante:         #343a41;
  --kante-hell:    #454c55;

  /* Ablesefeld */
  --display:       #eaf0f2;
  --display-leise: #9aa5af;
  /* Der leiseste Ton hält auf JEDER Fläche noch 4,5:1 — auch auf der hellsten (--panel-hoch).
     Hier steht unter anderem die Herkunft des Grenzwerts; das ist kein Kleingedrucktes,
     sondern der Beleg, gegen den bewertet wurde. */
  --display-still: #89939d;

  /* Signalgelb direkt aus dem Logo (public/bild/logo.svg) — nicht aus dem älteren
     Design-System der Website, damit App und Marke denselben Ton tragen.
     Auf Dunkel als Schrift zulässig (8,9:1 auf --panel); auf Hell niemals Schrift. */
  --signal:        #ebba00;
  --signal-hell:   #fbd800;
  --signal-tief:   #7a6100;

  --gut:           #4fb783;
  --gut-tief:      #16311f;
  --schlecht:      #f0644b;
  --schlecht-tief: #38150f;
  --offen:         var(--signal);
  --offen-tief:    #2e2708;

  /* Abstandsraster auf 4-px-Basis. Vorher waren acht krumme Einzelwerte im Umlauf —
     genau das erzeugt den unruhigen Eindruck. Alles bedient sich jetzt hieraus. */
  --r1: .25rem;   /*  4 px */
  --r2: .5rem;    /*  8 px */
  --r3: .75rem;   /* 12 px */
  --r4: 1rem;     /* 16 px */
  --r5: 1.5rem;   /* 24 px */
  --r6: 2rem;     /* 32 px */
  --r7: 3rem;     /* 48 px */

  --radius: 2px;
  --ziel: 46px;
  --spalte: 46rem;
  --seitenleiste: 15.5rem;

  --anzeige: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --text: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--text);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--display);
  background: var(--geraet);
  overflow-wrap: anywhere;
  /* Platz für die feste Kopfzeile und den Wahlschalter am unteren Rand. */
  padding: 0 0 calc(5.5rem + env(safe-area-inset-bottom));
}

h1, h2, h3, h4 {
  font-family: var(--anzeige);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.005em;
  margin: 0 0 var(--r2);
}
h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; margin-top: var(--r5); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 var(--r3); }
ul { margin: 0 0 var(--r3); padding-left: 1.1rem; }
li { margin-bottom: var(--r1); }
strong { font-weight: 600; }

a { color: var(--display); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--signal-tief); }
a:hover { text-decoration-color: var(--signal); }

/* Fokus immer sichtbar — auch mit Handschuhen wird getabbt, und die Tastatur ist der
   Rückfallweg, wenn der Touchscreen nass ist. */
:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 2px;
  border-radius: 1px;
}

.leise { color: var(--display-leise); font-size: .9rem; }
.rechts { margin-left: auto; }
.gross { font-size: 1.15rem; }

.nur-vorlesen {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.sprungmarke {
  position: fixed; top: .5rem; left: .5rem; z-index: 60;
  transform: translateY(-200%);
  background: var(--signal); color: #14171a; border: 0;
  font-family: var(--anzeige); font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; padding: var(--r3) var(--r4); border-radius: var(--radius);
}
.sprungmarke:focus { transform: none; }

/* ------------------------------------------------------------------ Gerätekopf */

.kopf {
  position: sticky; top: 0; z-index: 40;
  background: var(--panel-tief);
  /* Die gelbe Kante ist die Blende des Geräts — Hardware, keine Verzierung. */
  border-top: 3px solid var(--signal);
  border-bottom: 1px solid var(--kante);
  padding-top: env(safe-area-inset-top);
}
.kopf-innen {
  display: flex; align-items: center; gap: var(--r3);
  max-width: var(--spalte); margin: 0 auto;
  padding: var(--r2) var(--r4);
  min-height: 52px;
}
.kopf-marke {
  margin: 0; display: flex; align-items: center; gap: var(--r2);
  font-family: var(--anzeige); font-weight: 700; font-size: 1.05rem;
  text-transform: uppercase; letter-spacing: .07em;
}
/* Das Logo steht nur auf dem Anmeldeschirm. In der laufenden App wäre es reine
   Wiederholung — der Betrieb weiß, in wessen Anwendung er arbeitet, und der Platz
   gehört dem Inhalt. Der gelbe Balken bleibt als schlanke Marke. */
.kopf-balken {
  width: 3px; height: 1.1rem; background: var(--signal); display: inline-block; flex: none;
}
.kopf-werkzeuge { display: flex; gap: var(--r2); margin-left: auto; }

/* ------------------------------------------------------------------ Inhalt */

main {
  max-width: var(--spalte);
  margin: 0 auto;
  padding: var(--r4) var(--r4) var(--r6);
}
main:focus { outline: none; }

.laden { color: var(--display-leise); }

.abschnitt-kopf {
  display: flex; align-items: flex-start; gap: var(--r3); flex-wrap: wrap;
  margin-bottom: var(--r4);
}
.abschnitt-kopf h1 { margin-bottom: var(--r1); }

/* Beschriftungen im Gerätestil: schmal, versal, gesperrt. */
.karte-titel, .feld-beschriftung, .beschriftung, .zeile-titel, .titel {
  font-family: var(--anzeige); font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--display-leise); font-size: .78rem;
}

.trenner { height: 1px; background: var(--kante); border: 0; margin: var(--r5) 0; }
.linie { border-top: 1px solid var(--kante); margin-top: var(--r3); padding-top: var(--r3); }

/* ------------------------------------------------------------------ Flächen */

.karte, .flaeche, .tabellen-rahmen, .anmeldung {
  background: var(--panel);
  border: 1px solid var(--kante);
  border-radius: var(--radius);
  /* Feiner Lichtsaum an der Oberkante — wie eine gefräste Gehäusekante. */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045);
  padding: var(--r4);
  margin-bottom: var(--r4);
}
.karte-titel { display: block; margin-bottom: var(--r2); }

.gitter { display: grid; gap: var(--r3); }
.gitter-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gitter-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 40rem) {
  .gitter-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ------------------------------------------------------------------ Kennzahlen */

.kennzahl {
  background: var(--panel); border: 1px solid var(--kante);
  border-left: 3px solid var(--kante-hell);
  border-radius: var(--radius); padding: var(--r3) var(--r3);
  display: flex; flex-direction: column; gap: var(--r1);
  text-decoration: none; color: inherit;
}
.kennzahl .zahl {
  font-family: var(--anzeige); font-weight: 700; font-size: 2.4rem; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.kennzahl .text {
  font-family: var(--anzeige); text-transform: uppercase; letter-spacing: .07em;
  font-size: .74rem; font-weight: 600; color: var(--display-leise);
}
.kennzahl-ok      { border-left-color: var(--gut); }
.kennzahl-ok .zahl { color: var(--gut); }
.kennzahl-bald    { border-left-color: var(--signal); }
.kennzahl-bald .zahl { color: var(--signal); }
.kennzahl-alarm   { border-left-color: var(--schlecht); }
.kennzahl-alarm .zahl { color: var(--schlecht); }
.kennzahl-gesperrt { border-left-color: var(--schlecht); background: var(--schlecht-tief); }
.kennzahl-gesperrt .zahl { color: var(--schlecht); }

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

.liste { list-style: none; margin: 0; padding: 0; }
.zeile {
  display: flex; align-items: center; gap: var(--r3);
  padding: var(--r3) var(--r1); border-bottom: 1px solid var(--kante);
  text-decoration: none; color: inherit; min-height: var(--ziel);
}
.liste > :last-child .zeile, .zeile:last-child { border-bottom: 0; }
.zeile:hover { background: var(--panel-hoch); }
.zeile-titel {
  display: block; text-transform: none; letter-spacing: 0;
  font-family: var(--text); font-weight: 600; font-size: 1rem; color: var(--display);
}
.zeile-text { display: block; color: var(--display-leise); font-size: .88rem; }
.zeile-pfeil { margin-left: auto; color: var(--display-still); flex: none; }

/* ------------------------------------------------------------------ Marken */

.marke {
  display: inline-flex; align-items: center; gap: var(--r2);
  font-family: var(--anzeige); font-weight: 600; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .07em;
  padding: var(--r1) var(--r2); border-radius: var(--radius);
  border: 1px solid currentColor; white-space: nowrap;
}
.marke-ok     { color: var(--gut); background: var(--gut-tief); }
.marke-warn   { color: var(--signal); background: var(--offen-tief); }
.marke-alarm  { color: var(--schlecht); background: var(--schlecht-tief); }
.marke-dunkel { color: var(--display-leise); background: var(--panel-tief); }

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

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--r2);
  min-height: var(--ziel); padding: var(--r2) var(--r4);
  font-family: var(--anzeige); font-weight: 700; font-size: .95rem;
  text-transform: uppercase; letter-spacing: .06em;
  border-radius: var(--radius); border: 1px solid var(--kante-hell);
  background: var(--panel-hoch); color: var(--display);
  cursor: pointer; text-decoration: none; text-align: center;
}
.knopf:hover { background: var(--kante); }
.knopf:active { transform: translateY(1px); }
.knopf[disabled] { opacity: .45; cursor: not-allowed; }

/* Der einzige gelbe Knopf einer Ansicht ist die Haupthandlung. */
.knopf-signal {
  background: var(--signal); border-color: var(--signal-hell); color: #14171a;
}
.knopf-signal:hover { background: var(--signal-hell); }
.knopf-dunkel { background: var(--panel-tief); }
.knopf-still { background: transparent; border-color: var(--kante); color: var(--display-leise); }
.knopf-still:hover { color: var(--display); background: var(--panel-hoch); }
.knopf-warn { background: var(--schlecht-tief); border-color: var(--schlecht); color: var(--schlecht); }
.knopf-klein { min-height: 38px; padding: var(--r2) var(--r3); font-size: .82rem; }
.knopf-breit { width: 100%; }
.knopf-reihe { display: flex; flex-wrap: wrap; gap: var(--r2); margin-top: var(--r3); }

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

.feld { margin-bottom: var(--r3); }
.feld-beschriftung { display: block; margin-bottom: var(--r1); }
.feld-hilfe { display: block; color: var(--display-still); font-size: .82rem; margin-top: var(--r1); }

input, select, textarea {
  width: 100%; min-height: var(--ziel);
  padding: var(--r2) var(--r3);
  font-family: var(--text); font-size: 1.05rem; color: var(--display);
  background: var(--panel-tief);
  border: 1px solid var(--kante-hell); border-radius: var(--radius);
}
textarea { min-height: 5rem; line-height: 1.45; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--display-still); }
input:hover, select:hover, textarea:hover { border-color: var(--display-still); }

/* Auswahl als Segmentschalter statt Auswahlliste — mit Handschuhen treffsicherer. */
.wahlgruppe { display: flex; flex-wrap: wrap; gap: var(--r2); }
.wahl { position: relative; }
.wahl input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer;
}
.wahlknopf {
  display: flex; align-items: center; justify-content: center;
  min-height: var(--ziel); padding: var(--r2) var(--r3);
  font-family: var(--anzeige); font-weight: 600; font-size: .92rem;
  text-transform: uppercase; letter-spacing: .05em;
  border: 1px solid var(--kante-hell); border-radius: var(--radius);
  background: var(--panel-tief); color: var(--display-leise);
}
.wahl input:checked + .wahlknopf {
  background: var(--panel-hoch); color: var(--display);
  border-color: var(--signal); box-shadow: inset 0 -3px 0 var(--signal);
}
.wahl input:focus-visible + .wahlknopf { outline: 3px solid var(--signal); outline-offset: 2px; }
.wahl input:checked + .ist-io  { border-color: var(--gut); box-shadow: inset 0 -3px 0 var(--gut); color: var(--gut); }
.wahl input:checked + .ist-nio { border-color: var(--schlecht); box-shadow: inset 0 -3px 0 var(--schlecht); color: var(--schlecht); }

/* ------------------------------------------------------------------ Messzeile */

.messzeile {
  background: var(--panel); border: 1px solid var(--kante);
  border-radius: var(--radius); padding: var(--r3); margin-bottom: var(--r3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .045);
}
.messzeile-kopf {
  display: flex; align-items: baseline; gap: var(--r2); flex-wrap: wrap; margin-bottom: var(--r2);
}
.messzeile-kopf strong {
  font-family: var(--anzeige); font-weight: 700; font-size: 1.15rem; letter-spacing: .01em;
}
.messzeile-eingabe { display: flex; align-items: stretch; gap: var(--r2); }

/* Das Ablesefeld. Große Tabellenziffern auf tiefem Grund — der Wert ist der Held der Seite. */
.messzeile-eingabe .wert {
  flex: 1 1 auto;
  font-family: var(--anzeige); font-weight: 700;
  font-size: 2.1rem; line-height: 1.1; letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
  text-align: right;
  background: var(--panel-tief);
  border-color: var(--kante-hell);
  padding: var(--r2) var(--r3);
}
.einheit {
  display: flex; align-items: center; flex: none;
  font-family: var(--anzeige); font-weight: 600; font-size: 1.2rem;
  color: var(--display-leise); min-width: 2.6rem;
}
.operator { flex: none; width: 4.2rem; min-width: 4.2rem; text-align: center; font-size: 1.05rem; }
.messzeile-polaritaet { margin-top: var(--r2); }
.grenze { display: block; color: var(--display-leise); font-size: .85rem; margin-top: var(--r1); }

/* ------------------------------------------------------------------ Ergebnis */

.ergebniszeile {
  display: flex; gap: var(--r2); align-items: flex-start;
  margin-top: var(--r3); padding: var(--r2) var(--r3);
  border: 1px solid var(--kante); border-left-width: 3px;
  border-radius: var(--radius); background: var(--panel-tief);
  font-size: .92rem;
}
.ergebniszeile .zeichen {
  font-family: var(--anzeige); font-weight: 700; font-size: 1.15rem; line-height: 1.3; flex: none;
}
.ergebniszeile strong { display: block; }
.quelle { display: block; color: var(--display-still); font-size: .8rem; margin-top: var(--r1); }

.ergebnis-bestanden      { border-color: var(--gut); background: var(--gut-tief); }
.ergebnis-bestanden .zeichen { color: var(--gut); }
.ergebnis-nicht_bestanden { border-color: var(--schlecht); background: var(--schlecht-tief); }
.ergebnis-nicht_bestanden .zeichen { color: var(--schlecht); }
.ergebnis-gesperrt        { border-color: var(--schlecht); background: var(--schlecht-tief); }

/* Kein automatisches Ergebnis. Bewusst auffällig und mit Schraffur statt Fläche: Dieser
   Zustand ist KEIN Ergebnis, sondern eine offene Aufgabe — er darf nicht wie ein
   bestandener Wert aussehen (Regel R6). */
.ergebnis-urteil {
  border-color: var(--offen);
  background:
    repeating-linear-gradient(135deg,
      var(--offen-tief) 0 10px,
      rgba(232, 201, 60, .10) 10px 20px);
}
.ergebnis-urteil .zeichen { color: var(--offen); }

.urteilsfeld {
  margin-top: var(--r3); padding: var(--r3);
  border: 1px solid var(--offen); border-radius: var(--radius);
  background: var(--offen-tief);
}
.urteilsfeld > strong {
  font-family: var(--anzeige); font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--offen); font-size: .88rem;
}

/* --------------------------------------------------- Signaturelement: Grenzwert-Skala
 *
 * Zeigt, wie viel Luft zum Grenzwert bleibt. Der Grenzwert sitzt fest in der Mitte, die
 * Marke sitzt beim Verhältnis Messwert zu Grenzwert (0 bis 2, darüber am Anschlag). Die
 * gute Seite ist eingefärbt — bei „höchstens" links, bei „mindestens" rechts.
 * Ohne automatisch bewertbaren Grenzwert wird die Skala NICHT gezeichnet.
 */
.skala { margin-top: var(--r2); }
.skala-bahn {
  position: relative; height: 10px;
  background: var(--panel-tief);
  border: 1px solid var(--kante-hell); border-radius: 1px;
  overflow: hidden;
}
.skala-bahn::before {           /* eingefärbte gute Seite */
  content: ""; position: absolute; top: 0; bottom: 0;
  left: 0; width: 50%;
  background: color-mix(in srgb, var(--gut) 22%, transparent);
}
.skala-min .skala-bahn::before { left: 50%; }
.skala-bahn::after {            /* der Grenzwert selbst */
  content: ""; position: absolute; top: -1px; bottom: -1px; left: 50%;
  width: 2px; background: var(--signal); transform: translateX(-1px);
}
.skala-marke {
  position: absolute; top: -3px; bottom: -3px;
  left: clamp(0%, var(--position, 0%), 100%);
  width: 3px; background: var(--display);
  transform: translateX(-1.5px);
  transition: left .22s ease-out;
}
.skala-ueber .skala-marke { background: var(--schlecht); }
.skala-fuss {
  display: flex; justify-content: space-between; gap: var(--r2);
  margin-top: var(--r1);
  font-family: var(--anzeige); font-weight: 600; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .06em; color: var(--display-still);
}
.skala-grenze { color: var(--signal); }

@media (prefers-reduced-motion: reduce) {
  .skala-marke { transition: none; }
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ------------------------------------------------------------------ Sichtprüfung */

.sichtposition {
  padding: var(--r3) 0; border-bottom: 1px solid var(--kante);
}
.sichtposition:last-child { border-bottom: 0; }
.sichtposition .text { display: block; margin-bottom: var(--r2); }
.punkt {
  font-family: var(--anzeige); font-weight: 700; color: var(--display-still);
  font-variant-numeric: tabular-nums; margin-right: var(--r2);
}
.punkt-letzter { color: var(--signal); }

/* ------------------------------------------------------------------ Schrittleiste
 *
 * Segmente statt Fortschrittsbalken: Eine Prüfung ist eine feste Folge benannter Schritte,
 * keine Prozentzahl. Die Anzahl der Segmente ist damit selbst eine Information.
 */
.schritt-leiste {
  display: flex; gap: 2px; margin-bottom: var(--r4);
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--kante);
}
.schritt-leiste::-webkit-scrollbar { display: none; }
.schritt-leiste > button {
  flex: 1 0 auto; min-height: 42px; padding: var(--r2) var(--r3);
  background: transparent; color: var(--display-still);
  border: 0; border-bottom: 3px solid var(--kante);
  border-radius: 0; cursor: pointer; white-space: nowrap;
  font-family: var(--anzeige); font-weight: 600; font-size: .82rem;
  text-transform: uppercase; letter-spacing: .05em;
}
.schritt-leiste > button:hover { color: var(--display-leise); border-bottom-color: var(--kante-hell); }
/* Der Schritt, auf dem die Prüfperson gerade steht. */
.schritt-leiste > button[aria-current="step"] {
  color: var(--display); border-bottom-color: var(--signal);
}
.erledigt { color: var(--gut); }
.schritt-fuss {
  position: sticky; bottom: calc(4.2rem + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; gap: var(--r2); margin-top: var(--r5); padding: var(--r3);
  background: var(--panel); border: 1px solid var(--kante); border-radius: var(--radius);
}
.schritt-fuss .knopf { flex: 1 1 auto; }

.fortschritt {
  height: 5px; background: var(--kante); border-radius: 1px; overflow: hidden;
}
.fortschritt > * { display: block; height: 100%; background: var(--signal); }

/* ------------------------------------------------------------------ Hinweise */

.hinweis {
  padding: var(--r3) var(--r3); margin-bottom: var(--r4);
  border: 1px solid var(--kante); border-left-width: 3px;
  border-radius: var(--radius); background: var(--panel);
  font-size: .93rem;
}
.hinweis-ok     { border-color: var(--gut); background: var(--gut-tief); }
.hinweis-warn   { border-color: var(--schlecht); background: var(--schlecht-tief); }
.hinweis-signal { border-color: var(--signal); background: var(--offen-tief); }

.meldungen {
  position: fixed; left: .6rem; right: .6rem;
  bottom: calc(4.6rem + env(safe-area-inset-bottom));
  z-index: 50; display: grid; gap: var(--r2); pointer-events: none;
}
.meldung {
  pointer-events: auto;
  padding: var(--r3) var(--r3); border-radius: var(--radius);
  border: 1px solid var(--kante-hell); background: var(--panel-hoch);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .5);
  max-width: var(--spalte); margin: 0 auto; width: 100%;
}
.meldung-erfolg { border-color: var(--gut); background: var(--gut-tief); }
.meldung-fehler { border-color: var(--schlecht); background: var(--schlecht-tief); }

/* ------------------------------------------------------------------ Tabellen */

.tabellen-rahmen { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: var(--r2) var(--r3); text-align: left; border-bottom: 1px solid var(--kante); }
th {
  font-family: var(--anzeige); font-weight: 600; font-size: .74rem;
  text-transform: uppercase; letter-spacing: .07em; color: var(--display-leise);
  background: var(--panel-tief); white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--anzeige); font-weight: 600; }

/* ------------------------------------------------------------------ Sonstiges */

.angaben { display: grid; gap: var(--r2); margin: 0; }
.angaben > div { display: flex; gap: var(--r3); justify-content: space-between; align-items: baseline; }
.angaben dt, .angaben .beschriftung { flex: none; }
.angaben dd { margin: 0; text-align: right; }

.auswahlliste { display: grid; gap: var(--r2); }

.unterschrift-feld {
  width: 100%; height: 170px;
  background: var(--panel-tief);
  border: 1px dashed var(--kante-hell); border-radius: var(--radius);
  touch-action: none; cursor: crosshair; display: block;
}

.sparkline { display: block; width: 100%; height: 42px; overflow: visible; }
.sparkline path { fill: none; stroke: var(--signal); stroke-width: 1.5; }
.sparkline circle { fill: var(--display); }

.scanbild { width: 100%; border-radius: var(--radius); background: #000; display: block; }

.anmeldung { max-width: 24rem; margin: var(--r7) auto; }
.anmeldung-logo { display: block; width: 72px; height: 72px; margin: 0 auto var(--r3); }
.anmeldung h1 { text-align: center; margin-bottom: var(--r2); }
.anmeldung .leise { text-align: center; }


/* --------------------------------------------------------------- Anlegen-Knopf
 *
 * Unten links im Daumenbereich, weil er die einzige Handlung ist, die aus jedem Bereich
 * heraus gebraucht wird. Runde Form als einziges Rundelement der Oberfläche — dadurch
 * ist er auch mit Handschuhen und ohne Hinsehen zu finden.
 */
.neu-bereich {
  position: fixed; z-index: 46;
  left: var(--r3); bottom: calc(5rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--r2);
}
.neu-knopf {
  width: 58px; height: 58px; border-radius: 50%;
  border: 1px solid var(--signal-hell);
  background: var(--signal); color: #14171a;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .55);
}
.neu-knopf:hover { background: var(--signal-hell); }
.neu-knopf:active { transform: translateY(1px); }
.neu-zeichen {
  font-family: var(--anzeige); font-weight: 700; font-size: 2.1rem; line-height: 1;
  /* Das Pluszeichen sitzt in Barlow leicht hoch — optisch ausgleichen. */
  margin-top: -2px;
}
/* Geöffnet dreht sich das Plus zum Kreuz: derselbe Knopf schließt auch wieder. */
.neu-knopf[aria-expanded="true"] .neu-zeichen { transform: rotate(45deg); }
.neu-zeichen { transition: transform .18s ease-out; }

.neu-menue {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 15rem;
  background: var(--kante);
  border: 1px solid var(--kante-hell); border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .6);
  overflow: hidden;
}
.neu-eintrag {
  display: flex; align-items: center; gap: var(--r3);
  padding: var(--r3) var(--r4); min-height: var(--ziel);
  background: var(--panel); color: var(--display);
  text-decoration: none; font-weight: 600;
}
.neu-eintrag:hover { background: var(--panel-hoch); }
.neu-eintrag .nav-zeichen { color: var(--signal); }

@media (prefers-reduced-motion: reduce) {
  .neu-zeichen { transition: none; }
}

/* ------------------------------------------------------------------ Wahlschalter
 *
 * Die Hauptnavigation liegt unten, weil die App einhändig bedient wird — der Daumen
 * erreicht den oberen Bildschirmrand nicht. Der aktive Bereich trägt die gelbe Kante,
 * wie die Raststellung eines Drehschalters.
 */
.navigation {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: flex; justify-content: center; gap: 0;
  background: var(--panel-tief);
  border-top: 1px solid var(--kante);
  padding-bottom: env(safe-area-inset-bottom);
}
.navigation a {
  flex: 1 1 0; max-width: 8rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--r1);
  min-height: 4.1rem; padding: var(--r2) var(--r1);
  text-decoration: none; color: var(--display-still);
  font-family: var(--anzeige); font-weight: 600; font-size: .7rem;
  text-transform: uppercase; letter-spacing: .06em;
  border-top: 3px solid transparent;
}
.navigation a[aria-current="page"] {
  color: var(--display); border-top-color: var(--signal); background: var(--panel);
}
.nav-zeichen { font-size: 1.15rem; line-height: 1; }

/* ------------------------------------------------------------------ Mitteltablet
 *
 * Ab hier ist genug Breite für eine waagerechte Bereichsleiste unter dem Kopf; der
 * Wahlschalter am unteren Rand wird überflüssig, weil nicht mehr einhändig bedient wird.
 */
@media (min-width: 48rem) and (max-width: 63.999rem) {
  body { padding-bottom: var(--r6); }
  .navigation {
    position: sticky; top: 58px; bottom: auto;
    max-width: var(--spalte); margin: 0 auto;
    border-top: 0; border-bottom: 1px solid var(--kante); padding-bottom: 0;
  }
  .navigation a {
    min-height: 3rem; flex-direction: row; gap: var(--r2);
    border-top: 0; border-bottom: 3px solid transparent;
  }
  .navigation a[aria-current="page"] { border-bottom-color: var(--signal); }
  .meldungen { bottom: var(--r4); }
  .schritt-fuss { bottom: var(--r4); }
}

/* ------------------------------------------------------------------ Schreibtisch
 *
 * Am Rechner wird nicht geprüft, sondern verwaltet: Kunden pflegen, Fristen sichten,
 * Protokolle versenden, Etiketten setzen. Der Wechsel zwischen Bereichen ist hier die
 * häufigste Handlung — deshalb eine stehende Bereichsleiste statt einer in die Breite
 * gezogenen Handyspalte.
 *
 * Umgesetzt als Raster auf dem Körper: Kopf und Navigation bilden zusammen die linke
 * Leiste, der Inhalt steht rechts daneben über die volle Höhe. Die Reihenfolge im
 * Dokument bleibt unangetastet (Inhalt vor Navigation) — das ist die Reihenfolge, in
 * der ein Screenreader vorliest, und sie ist inhaltlich richtig.
 */
@media (min-width: 64rem) {
  body {
    display: grid;
    grid-template-columns: var(--seitenleiste) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    min-height: 100vh;
    padding: 0;
  }

  .kopf {
    grid-column: 1; grid-row: 1;
    position: static;
    border-top: 0; border-bottom: 0;
    border-right: 1px solid var(--kante);
    /* Die gelbe Blende wandert an die Oberkante der Leiste. */
    box-shadow: inset 0 3px 0 var(--signal);
  }
  .kopf-innen {
    flex-direction: column; align-items: flex-start; gap: var(--r3);
    padding: var(--r5) var(--r4) var(--r4);
    max-width: none;
  }
  .kopf-marke { font-size: 1.1rem; }
  .kopf-werkzeuge { margin-left: 0; width: 100%; }
  .kopf-werkzeuge .knopf { flex: 1 1 auto; }

  .navigation {
    grid-column: 1; grid-row: 2;
    position: sticky; top: 0; align-self: start;
    flex-direction: column; justify-content: flex-start;
    background: var(--panel-tief);
    border-top: 0; border-right: 1px solid var(--kante);
    min-height: calc(100vh - 1px);
    padding: 0 var(--r2) var(--r4);
  }
  .navigation a {
    flex: 0 0 auto; max-width: none; width: 100%;
    flex-direction: row; justify-content: flex-start; gap: var(--r3);
    min-height: 44px; padding: var(--r2) var(--r3);
    border-top: 0; border-left: 3px solid transparent;
    border-radius: var(--radius); font-size: .82rem;
  }
  .navigation a:hover { background: var(--panel); color: var(--display-leise); }
  .navigation a[aria-current="page"] {
    border-top-color: transparent; border-left-color: var(--signal);
    background: var(--panel);
  }
  .nav-zeichen { width: 1.2rem; text-align: center; }

  main {
    grid-column: 2; grid-row: 1 / span 2;
    max-width: 64rem;
    padding: var(--r6) var(--r6) var(--r7);
  }

  /* Am Schreibtisch ist Platz — Flächen und Tabellen dürfen atmen. */
  .karte, .flaeche, .anmeldung { padding: var(--r5); margin-bottom: var(--r4); }
  .messzeile { padding: var(--r4) var(--r5); }
  th, td { padding: var(--r3) var(--r4); }
  h1 { font-size: 2.2rem; }
  h2 { font-size: 1.5rem; }
  .abschnitt-kopf { margin-bottom: var(--r5); }
  .gitter { gap: var(--r3); }

  .meldungen {
    left: auto; right: var(--r5); bottom: var(--r5);
    width: min(26rem, 40vw);
  }
  .meldung { margin: 0; }
  .schritt-fuss { bottom: var(--r5); }
  .anmeldung { margin: var(--r7) auto; }
  .neu-bereich { left: var(--r4); bottom: var(--r4); }
}

/* Sehr breite Bildschirme: der Inhalt wird nicht breiter, sondern bekommt Luft. */
@media (min-width: 100rem) {
  main { padding-left: var(--r7); padding-right: var(--r7); }
}

@media print {
  .kopf, .navigation, .meldungen, .schritt-fuss, .sprungmarke { display: none; }
  body { background: #fff; color: #000; padding: 0; }
}
