/* Geräteverwaltung — mobile-first, große Tippziele, Arbeitshandschuh-tauglich.
   Corporate Design nach Spec Abschnitt 13 (CL - Haus & Handwerkerservice). */

/* ---------------------------------------------------------------------------
   CI-Farbtoken. Arbeitswerte [S], aus einem Foto des Rückenprints abgelesen.
   Das hier ist die EINZIGE Stelle im ganzen Projekt mit Markenfarbwerten
   (zweite und letzte: scripts/icons_erzeugen.py für die PNG-Icons). Kommt die
   Originaldatei vom Betreiber, werden hier acht Zeilen getauscht — sonst nichts.
   --------------------------------------------------------------------------- */
:root {
  --cl-navy:      #1E2C4E;  /* Emblem-Grund, Primärfarbe UI */
  --cl-blau:      #5FA8DC;  /* Kontur/Schriftzug, Akzent + Links */
  --cl-verlauf-1: #C6D355;  /* Logo-Verlauf gelbgrün — NUR im Logo */
  --cl-verlauf-2: #4FC3C0;  /* Logo-Verlauf türkis  — NUR im Logo */
  --cl-verlauf-3: #3B7EC2;  /* Logo-Verlauf blau    — NUR im Logo */
  --cl-grund:     #F4F6F8;  /* heller neutraler App-Grund */
  --cl-text:      #22262B;  /* Fließtext */
  --cl-grau:      #6E747C;  /* Sekundärtext */
}

/* ---------------------------------------------------------------------------
   Rollen-Token. Die Oberfläche benutzt ausschließlich diese, nie die CI-Werte
   direkt — Ausnahme ist das Logo selbst.

   Die Ampelfarben stehen bewusst neben der CI und nicht in ihr: eine Warnung
   darf nie mit der Marke konkurrieren. Das Ampelgrün ist ein tiefes Waldgrün
   und damit deutlich vom Gelbgrün des Logo-Verlaufs abgesetzt.
   --------------------------------------------------------------------------- */
:root {
  --grund: var(--cl-grund);
  --karte: #ffffff;
  --rand: #d9dee4;
  --text: var(--cl-text);
  --gedaempft: var(--cl-grau);

  --akzent: var(--cl-navy);        /* trägt Header, Primärknöpfe, aktive Navigation */
  --akzent-text: #ffffff;
  --hervor: var(--cl-blau);        /* Links, aktive Zustände, Start-Knopf-Rahmen */
  --hervor-text: #0d1522;

  --rot: #b3261e;
  --rot-flaeche: #fdecea;
  --gelb: #8a6100;
  --gelb-flaeche: #fdf4e0;
  --gruen: #2f6f45;
  --gruen-flaeche: #e9f3ec;

  --radius: 12px;
  --tippziel: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Neutrale Dunkelwerte, bewusst keine erfundenen Markenfarben. Navy und
       Hellblau bleiben die einzigen Markenträger, alles andere ist Grau. */
    --grund: #16181b;
    --karte: #1f2226;
    --rand: #343a40;
    --text: #e8eaed;
    --gedaempft: #9aa1a9;

    /* Navy hätte auf dunklem Grund zu wenig Kontrast — auf Dunkel trägt das
       Hellblau die Primäraktion, der Header bleibt Navy. */
    --akzent: var(--cl-blau);
    --akzent-text: #0d1522;
    --hervor: var(--cl-blau);
    --hervor-text: #0d1522;

    --rot: #f2857c;
    --rot-flaeche: #3a1f1d;
    --gelb: #e5b65c;
    --gelb-flaeche: #362c15;
    --gruen: #7cc496;
    --gruen-flaeche: #1d2f23;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* Systemgrotesk, wie in der Spec vorgesehen. Keine Hausschrift raten. */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--grund);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

#app { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.lade { padding: 2rem; text-align: center; color: var(--gedaempft); }

a { color: var(--hervor); }

/* --- Kopf und Navigation --- */

header.kopf {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1rem; padding-top: calc(.7rem + env(safe-area-inset-top));
  /* Der Header ist die Markenfläche und bleibt in beiden Themes Navy. */
  background: var(--cl-navy); color: #ffffff;
}
header.kopf h1 { margin: 0; font-size: 1.05rem; font-weight: 600; flex: 1; }
header.kopf .marke-logo { flex: 0 0 auto; width: 32px; height: 32px; display: block; }

/* Firmenname als schmale Zeile ueber dem Seitentitel: erkennbar, aber ohne
   dem Titel den Platz wegzunehmen (Spec 13: kein Overbranding). */
header.kopf .kopftexte { flex: 1; min-width: 0; }
header.kopf .kopftexte h1 { font-size: 1rem; line-height: 1.25; }
header.kopf .firma {
  display: block; font-size: .66rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: rgba(255, 255, 255, .72); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
header.kopf .zurueck,
header.kopf .abmelden {
  background: rgba(255,255,255,.16); color: inherit; border: 0;
  border-radius: 999px; padding: .45rem .8rem; font-size: .9rem; cursor: pointer;
}

nav.leiste {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--karte); border-top: 1px solid var(--rand);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.leiste a {
  flex: 1; text-align: center; padding: .55rem .2rem; text-decoration: none;
  color: var(--gedaempft); font-size: .72rem; min-height: var(--tippziel);
}
nav.leiste a .zeichen { display: block; font-size: 1.25rem; line-height: 1.3; }
nav.leiste a[aria-current="page"] { color: var(--akzent); font-weight: 600; }
nav.leiste a[aria-current="page"] .zeichen { filter: none; }
nav.leiste a .blase {
  display: inline-block; min-width: 18px; margin-left: .2rem; padding: 0 .3rem;
  border-radius: 999px; background: var(--rot); color: #fff; font-size: .7rem;
}

main { padding: 1rem; max-width: 900px; margin: 0 auto; }

/* --- Bausteine --- */

.karte {
  background: var(--karte); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 1rem; margin-bottom: .8rem;
}
.karte h2 { margin: 0 0 .6rem; font-size: 1rem; }
.karte h3 { margin: 1rem 0 .4rem; font-size: .9rem; color: var(--gedaempft); }

.zeile { display: flex; align-items: center; gap: .75rem; }
.zeile .fuellt { flex: 1; min-width: 0; }
.klein { font-size: .82rem; color: var(--gedaempft); }
.abschnitt { margin: 1.4rem 0 .5rem; font-size: .78rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--gedaempft); }
.leer { padding: 1.5rem 1rem; text-align: center; color: var(--gedaempft); }
.trennlinie { border: 0; border-top: 1px solid var(--rand); margin: .8rem 0; }

button, .knopf {
  font: inherit; min-height: var(--tippziel); padding: .6rem 1rem;
  border-radius: var(--radius); border: 1px solid var(--rand);
  background: var(--karte); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  text-decoration: none;
}
button:disabled { opacity: .5; cursor: progress; }
.haupt { background: var(--akzent); color: var(--akzent-text); border-color: transparent;
  font-weight: 600; }
/* Spec 13: "Hellblau ... für den Start-Button-Rahmen." */
[data-aktion="start"].haupt { border: 2px solid var(--hervor); }
.gefahr { background: var(--rot-flaeche); color: var(--rot); border-color: transparent; }
.breit { width: 100%; }
.gross { min-height: 60px; font-size: 1.1rem; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: .5rem; }
.knopfreihe > * { flex: 1 1 auto; }

button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--hervor); outline-offset: 2px;
}

/* --- Ampel --- */

.ampel {
  flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid transparent;
}
.ampel.rot { background: var(--rot); }
.ampel.gelb { background: var(--gelb); }
.ampel.gruen { background: var(--gruen); }

.marke {
  display: inline-block; padding: .12rem .5rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; white-space: nowrap;
}
.marke.rot { background: var(--rot-flaeche); color: var(--rot); }
.marke.gelb { background: var(--gelb-flaeche); color: var(--gelb); }
.marke.gruen { background: var(--gruen-flaeche); color: var(--gruen); }
.marke.grau { background: var(--grund); color: var(--gedaempft); }

.balken { height: 6px; border-radius: 3px; background: var(--rand); overflow: hidden;
  margin-top: .35rem; }
.balken i { display: block; height: 100%; }
.balken i.rot { background: var(--rot); }
.balken i.gelb { background: var(--gelb); }
.balken i.gruen { background: var(--gruen); }

/* --- Geräteliste --- */

.geraeteliste { display: grid; gap: .6rem; }
.geraetezeile {
  display: flex; align-items: center; gap: .75rem; padding: .7rem;
  background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius);
}
.geraetezeile.rot { border-left: 5px solid var(--rot); }
.geraetezeile.gelb { border-left: 5px solid var(--gelb); }
.geraetezeile.gruen { border-left: 5px solid var(--gruen); }
.miniatur {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 8px; object-fit: cover;
  background: var(--grund); border: 1px solid var(--rand);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: var(--gedaempft);
}
.geraetezeile .titel { font-weight: 600; }
.geraetezeile a.oeffnen { color: inherit; text-decoration: none; flex: 1; min-width: 0; }
.geraetezeile .startknopf { flex: 0 0 auto; min-width: 84px; }

/* --- Formulare --- */

.feld { margin-bottom: .85rem; }
.feld label { display: block; font-size: .85rem; margin-bottom: .25rem; color: var(--gedaempft); }
.feld input, .feld select, .feld textarea {
  font: inherit; width: 100%; min-height: var(--tippziel);
  padding: .55rem .7rem; border: 1px solid var(--rand); border-radius: var(--radius);
  background: var(--karte); color: var(--text);
}
.feld textarea { min-height: 96px; resize: vertical; }
.feld .hilfe { font-size: .78rem; color: var(--gedaempft); margin-top: .25rem; }
.feld.ankreuzen { display: flex; align-items: center; gap: .6rem; }
.feld.ankreuzen input { width: 24px; height: 24px; min-height: 0; accent-color: var(--akzent); }
.feld.ankreuzen label { margin: 0; }
.spalten2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .7rem; }
@media (max-width: 420px) { .spalten2 { grid-template-columns: 1fr; } }

/* --- Kennzahlen --- */

.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: .5rem; }
.kachel { background: var(--karte); border: 1px solid var(--rand); border-radius: var(--radius);
  padding: .6rem; text-align: center; }
.kachel .zahl { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.kachel .beschriftung { font-size: .72rem; color: var(--gedaempft); }
.kachel.rot .zahl { color: var(--rot); }
.kachel.gelb .zahl { color: var(--gelb); }
.kachel.gruen .zahl { color: var(--gruen); }

table.daten { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.daten th, table.daten td {
  text-align: left; padding: .45rem .3rem; border-bottom: 1px solid var(--rand);
  vertical-align: top;
}
table.daten th { color: var(--gedaempft); font-weight: 500; width: 46%; }
table.daten td.zahl { text-align: right; font-variant-numeric: tabular-nums; }
.tabellenrahmen { overflow-x: auto; }

.bildgitter { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: .5rem; }
.bildgitter figure { margin: 0; }
.bildgitter img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--rand); }
.bildgitter figcaption { font-size: .72rem; color: var(--gedaempft); }

/* --- Laufender Einsatz --- */

.laufend { border-left: 5px solid var(--hervor); }
.laufzeit { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.warnbalken {
  background: var(--gelb-flaeche); color: var(--gelb); border-radius: var(--radius);
  padding: .6rem .8rem; margin-bottom: .8rem; font-size: .88rem;
}
.fehlerbalken {
  background: var(--rot-flaeche); color: var(--rot); border-radius: var(--radius);
  padding: .6rem .8rem; margin-bottom: .8rem; font-size: .88rem;
}

/* --- Anmeldung --- */

.anmeldung { max-width: 380px; margin: 10vh auto; padding: 1rem; }
.anmeldung .firma { font-size: 1.2rem; font-weight: 700; text-align: center;
  margin: .9rem 0 .1rem; }
.anmeldung .anwendungsname { text-align: center; margin: 0 0 1.3rem;
  color: var(--gedaempft); font-size: .92rem; }
.anmeldung .logo { display: flex; justify-content: center; }
.anmeldung .logo svg { width: 96px; height: 96px; }

/* --- Hinweise (Toasts) --- */

.hinweise { position: fixed; left: 0; right: 0; bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: .4rem; z-index: 40;
  pointer-events: none; padding: 0 1rem; }
.hinweis {
  background: var(--cl-navy); color: #ffffff; padding: .6rem 1rem;
  border-radius: 999px; font-size: .88rem; max-width: 100%;
}
.hinweis.fehler { background: var(--rot); color: #fff; }

@media (prefers-color-scheme: dark) {
  .hinweis { background: var(--text); color: var(--grund); }
  .hinweis.fehler { background: var(--rot); color: #2a0f0d; }
}

/* --- Vorschlagsliste Einsatzort --- */
datalist { display: none; }

/* --- Scan-Einstieg: der wichtigste Knopf der App ------------------------- */

.scanknopf {
  width: 100%; min-height: 84px; margin-bottom: .9rem;
  background: var(--akzent); color: var(--akzent-text);
  border: 2px solid var(--hervor); border-radius: var(--radius);
  font-size: 1.05rem; font-weight: 600; gap: .8rem;
}
.scanknopf .scanzeichen { font-size: 1.9rem; line-height: 1; }
.scanknopf.zweit { min-height: 60px; background: var(--karte); color: var(--text);
  border: 1px solid var(--rand); font-weight: 500; margin-top: -.3rem; }

/* --- Dialoge statt prompt()/confirm() ------------------------------------ */

dialog.formdialog, dialog.scandialog {
  border: 0; border-radius: var(--radius); padding: 1.1rem;
  width: min(94vw, 460px); max-height: 88vh; overflow-y: auto;
  background: var(--karte); color: var(--text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(10, 14, 22, .62); }
dialog.formdialog h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
.dialogtext { margin: 0 0 .9rem; font-size: .88rem; color: var(--gedaempft);
  white-space: pre-line; }
dialog .knopfreihe { margin-top: 1rem; }

.mehrfachliste {
  max-height: 42vh; overflow-y: auto;
  border: 1px solid var(--rand); border-radius: var(--radius); padding: .3rem;
}
.mehrfachzeile {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .4rem;
  border-bottom: 1px solid var(--rand); font-size: .92rem;
}
.mehrfachzeile:last-child { border-bottom: 0; }
.mehrfachzeile input { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--akzent); }

/* --- Kamerasucher -------------------------------------------------------- */

.scanrahmen { position: relative; border-radius: var(--radius); overflow: hidden;
  background: #000; aspect-ratio: 4 / 3; }
.scanrahmen video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanziel {
  position: absolute; inset: 22% 10%; border: 3px solid var(--hervor);
  border-radius: 8px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
}

/* --- Listen und Zeilen --------------------------------------------------- */

.listenzeile { padding: .55rem 0; border-bottom: 1px solid var(--rand); }
.listenzeile:last-child { border-bottom: 0; }
.wartungszeile { padding: .55rem 0; border-bottom: 1px solid var(--rand); }
.wartungszeile:last-child { border-bottom: 0; }
.zeilenaktionen { margin-top: .45rem; }
.zeilenaktionen button { min-height: 38px; padding: .3rem .7rem; font-size: .84rem; }

.leise { background: transparent; border-color: var(--rand); color: var(--gedaempft); }
.winzig { min-height: auto; padding: .1rem .4rem; font-size: .72rem; border: 0;
  background: transparent; color: var(--gedaempft); text-decoration: underline; }

.offenzeit { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums;
  margin: .2rem 0 .5rem; }

a.warnbalken.block { display: block; text-decoration: none; }

/* --- Update 04.09.2026 ---------------------------------------------------- */

header.kopf .home { background: transparent; border: 0; padding: 0; min-height: 0;
  cursor: pointer; flex: 0 0 auto; }
header.kopf .home .marke-logo { width: 32px; height: 32px; display: block; }
header.kopf .zurueck { min-width: 40px; padding: .35rem .6rem; font-size: 1.3rem; line-height: 1; }

.auswahlliste { max-height: 48vh; overflow-y: auto; border: 1px solid var(--rand);
  border-radius: var(--radius); }
.auswahlzeile { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem;
  width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--rand);
  border-radius: 0; background: transparent; }
.auswahlzeile:last-child { border-bottom: 0; }

.verlaufzeile { display: grid; grid-template-columns: 7.2rem auto 1fr; gap: .5rem;
  align-items: baseline; padding: .35rem 0; border-bottom: 1px solid var(--rand); font-size: .92rem; }
.verlaufzeile:last-child { border-bottom: 0; }
.verlaufzeit { font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .verlaufzeile { grid-template-columns: 1fr; gap: .15rem; } }
.behebung { margin-top: .2rem; color: var(--gruen); }

/* --- Scanner: Startfreigabe und Statuszeile (Redmi-14C-Befund 04.09.) --- */
.scanstart { position: absolute; inset: 0; width: 100%; height: 100%;
  background: rgba(10, 14, 22, .75); color: #fff; border: 0; border-radius: 0;
  font-size: 1.05rem; font-weight: 600; }
.scanstatus { display: block; margin-top: .25rem; color: var(--gedaempft); }

/* --- Versionszeile unten auf der Startseite (unauffaellig, fuer Update-Kontrolle) --- */
.version { margin: 1.6rem 0 0; text-align: center; font-size: .72rem; color: var(--gedaempft);
  font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* --- Arbeitsschutz (GBU) ------------------------------------------------- */
a.listenzeile { display: flex; }
form[data-formular="gbu-version"] textarea { min-height: 72px; }

/* --- Betriebsanweisung ---------------------------------------------------- */
.ba-band { background: var(--navy, #1E2C4E); color: #fff; padding: .25rem .6rem; border-radius: 4px;
           font-size: .95rem; margin: .8rem 0 .3rem; }
.ba-liste { margin: .2rem 0 .4rem 1.2rem; padding: 0; }
.ba-liste li { margin: .15rem 0; }
details.aufklapp summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
details.aufklapp[open] summary { margin-bottom: .5rem; }

/* --- Signatur und Sicherheitskennzeichen ---------------------------------- */
.signaturfeld { width: 100%; height: auto; border: 1px dashed var(--navy, #1E2C4E); border-radius: 8px;
                background: #fff; touch-action: none; display: block; margin: .4rem 0; }
.signaturdialog { max-width: 720px; }
.signaturbild { max-width: 260px; max-height: 90px; display: block; border-bottom: 1px solid #1E2C4E; margin: .4rem 0 .2rem; }
.piktoleiste { display: flex; flex-wrap: wrap; gap: .35rem; margin: .2rem 0 .3rem; }
.piktochip { display: inline-flex; align-items: center; gap: .35rem; background: #EAF3FA; border-radius: 999px;
             padding: .15rem .6rem .15rem .3rem; font-size: .85rem; }
.piktomarke { width: 14px; height: 14px; display: inline-block; flex: none; }
.piktomarke.gebot { background: #005BBB; border-radius: 50%; }
.piktomarke.warn { width: 0; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent;
                   border-bottom: 14px solid #F9C500; background: none; }
.piktomarke.verbot { background: #fff; border: 3px solid #CC0000; border-radius: 50%; box-sizing: border-box; }
.piktomarke.rettung { background: #009639; border-radius: 2px; }
.piktomarke.ghs { background: #fff; border: 3px solid #CC0000; transform: rotate(45deg) scale(.8); box-sizing: border-box; }
.piktowahl { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .25rem .8rem; }
.piktooption { display: flex; align-items: center; gap: .4rem; font-size: .9rem; padding: .15rem 0; }
.piktooption input { margin: 0; }

/* --- Arbeitsanweisungen ---------------------------------------------------- */
.aa-dokument h3 { margin: 1rem 0 .3rem; color: var(--navy, #1E2C4E); }
.aa-dokument p { margin: .3rem 0; }
.aa-dokument ul { margin: .2rem 0 .5rem 1.2rem; padding: 0; }
.aa-hinweis { background: #EAF3FA; border-left: 3px solid #5FA8DC; padding: .4rem .6rem; font-weight: 600; }
.aa-editor { min-height: 320px; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }

/* --- Originallogo im Kopf --------------------------------------------------- */
header.kopf .home img.marke-logo { width: auto; height: 38px; display: block; }

.ampel.grau { background: #9aa3ad; }
