/* ---------------------------------------------------------------
   Abnahme-App, Design "Signal"
   Weiss und Graphit, eine Akzentfarbe Signalorange. Karten mit
   weichen Ecken, hoher Kontrast für Sonnenlicht, alle Touchflächen
   mindestens 48 px, wichtige Aktionen unten.
   Hell und dunkel folgen automatisch der Geräteeinstellung.
   Schrift nur lokal, damit alles offline läuft.
   --------------------------------------------------------------- */

@font-face {
  font-family: "Plex Sans";
  src: url("../fonts/ibm-plex-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Plex Sans";
  src: url("../fonts/ibm-plex-sans-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --bg: #F2F3F5;
  --flaeche: #FFFFFF;
  --flaeche2: #E6E8EC;
  --leiste: #FFFFFF;
  --text: #0E1116;
  --text2: #4B5260;
  --linie: #D5D9DF;

  --akzent: #FF5A14;
  --auf-akzent: #111111;
  --akzent-weich: #FFE6DA;
  --akzent-text: #9A2F00;

  --ok: #0B6B45;
  --ok-weich: #DDF3E8;
  --nok: #C62424;
  --nok-weich: #FDE4E4;
  --auf-status: #FFFFFF;
  --warn-weich: #FFF1CC;
  --warn-text: #6B4A00;
  --warn-rand: #D99A00;

  --schatten: 0 1px 2px rgba(14, 17, 22, 0.06), 0 6px 18px rgba(14, 17, 22, 0.07);
  --karten-rand: 1px solid transparent;

  --r-karte: 18px;
  --r-knopf: 14px;
  --r-gross: 18px;

  --schrift: "Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --leiste-hoehe: 80px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D0F13;
    --flaeche: #1A1D23;
    --flaeche2: #2A2E36;
    --leiste: #14171C;
    --text: #F5F6F8;
    --text2: #B3BAC6;
    --linie: #3A404C;

    --akzent-weich: #3A2114;
    --akzent-text: #FFB28F;

    --ok: #3DD68C;
    --ok-weich: #12301F;
    --nok: #FF6B6B;
    --nok-weich: #3A1616;
    --auf-status: #0B0D12;
    --warn-weich: #3A3010;
    --warn-text: #FFD970;
    --warn-rand: #C79A1E;

    --schatten: none;
    --karten-rand: 1px solid #2A2E36;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--schrift);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button { cursor: pointer; }

:focus-visible { outline: 3px solid var(--akzent); outline-offset: 2px; }

[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: calc(8px + var(--safe-top)) 16px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: calc(64px + var(--safe-top));
  max-width: 672px;
  margin: 0 auto;
}

.topbar-text { flex: 1; min-width: 0; }

#topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-view="liste"] #topbar h1,
body[data-view="einstellungen"] #topbar h1,
body[data-view="gewerk"] #topbar h1,
body[data-view="bereich"] #topbar h1 { font-size: 30px; letter-spacing: -0.02em; }

#topbar p {
  margin: 1px 0 0;
  font-size: 14px;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#topbar p:empty { display: none; }

.icon-btn {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border: var(--karten-rand);
  border-radius: var(--r-knopf);
  background: var(--flaeche);
  color: var(--text);
  box-shadow: var(--schatten);
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-btn:active { transform: scale(0.96); }

/* ---------- Grundfläche ---------- */
main {
  max-width: 672px;
  margin: 0 auto;
  padding: 4px 16px calc(var(--leiste-hoehe) + 32px + var(--safe-bottom));
}

.view.einblenden { animation: einblenden 160ms ease-out; }

@keyframes einblenden {
  /* Nie ganz unsichtbar, falls ein Gerät die Animation anhält */
  from { opacity: 0.6; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.lead { margin: 0 2px 14px; font-size: 16px; color: var(--text2); }

/* ---------- Karten ---------- */
.block {
  background: var(--flaeche);
  border: var(--karten-rand);
  border-radius: var(--r-karte);
  box-shadow: var(--schatten);
  padding: 16px;
  margin-bottom: 14px;
}

.block h2, .abschnitt > h3, .marke {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text2);
  margin: 0 0 12px;
}

.block h2.warn { color: var(--nok); }

.hint { font-size: 14px; color: var(--text2); margin: 10px 0 0; }
.hint.oben { margin: 0 0 8px; }
.hint.warn { color: var(--nok); font-weight: 600; }

.konto-name { margin: 0 0 4px; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 2px solid var(--text);
  border-radius: var(--r-knopf);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  text-align: center;
}

.btn.primary { background: var(--akzent); border-color: var(--akzent); color: var(--auf-akzent); }
.btn.ghost { border-color: transparent; color: var(--text2); }
.btn.big { min-height: 60px; font-size: 17px; margin-top: 4px; margin-bottom: 14px; }
.btn.abmelden { border-color: var(--nok); color: var(--nok); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.4; cursor: default; transform: none; }

.row-btns { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.row-btns .btn { width: auto; flex: 1 1 140px; }

/* Konto: beide Knöpfe volle Breite untereinander, Abmelden gut sichtbar */
#kontoBlock .row-btns { flex-direction: column; }
#kontoBlock .row-btns .btn { flex: none; width: 100%; }

/* ---------- Einleitung Home-Bildschirm ---------- */
.install { border-left: 6px solid var(--akzent); }
.install-titel { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.install-schritte { margin: 12px 0 0; padding: 0; list-style: none; counter-reset: schritt; display: grid; gap: 10px; }
.install-schritte li {
  counter-increment: schritt;
  position: relative;
  min-height: 28px;
  padding: 3px 0 0 38px;
  font-size: 15px;
  line-height: 1.45;
}
.install-schritte li::before {
  content: counter(schritt);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--akzent-weich);
  color: var(--akzent-text);
  font-weight: 600;
  font-size: 14px;
}
.install .row-btns { margin-top: 14px; }
.install > .install-jetzt { margin-top: 14px; }

/* ---------- Auswahl als Karten ---------- */
.choice-list { display: grid; gap: 10px; }

.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  min-height: 60px;
  padding: 14px 16px;
  border: 2px solid var(--linie);
  border-radius: var(--r-knopf);
  background: var(--flaeche);
  color: var(--text);
  text-align: left;
  font-weight: 600;
  font-size: 16px;
}

.choice small {
  display: block;
  font-weight: 400;
  font-size: 14px;
  color: var(--text2);
  margin-top: 2px;
}

.choice.active { border-color: var(--akzent); background: var(--akzent-weich); }
.choice.active small { color: var(--text); }
.choice.vorschlag:not(.active) { border-left: 6px solid var(--ok); }
.choice[disabled] { cursor: default; }

/* Gewerk und Bereich: grosse Karten mit Symbol */
#gewerkAuswahl .choice, #bereichAuswahl .choice {
  border: var(--karten-rand);
  box-shadow: var(--schatten);
  border-radius: var(--r-karte);
  min-height: 84px;
  font-size: 18px;
}

.choice.mit-symbol, .choice.mit-pfeil { flex-direction: row; align-items: center; gap: 16px; }
.choice .choice-text { flex: 1; min-width: 0; }

.choice-symbol {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--akzent-weich);
  color: var(--akzent-text);
}

.choice-pfeil { color: var(--text2); flex-shrink: 0; display: grid; }

.choice.gesperrt { opacity: 0.55; box-shadow: none; }
.choice.gesperrt .choice-symbol { background: var(--flaeche2); color: var(--text2); }

/* ---------- Felder ---------- */
.feld { display: block; margin-bottom: 14px; }
.feld:last-child { margin-bottom: 0; }

.feld > span {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
}

.feld input, .feld select, .feld textarea,
.bemerkung textarea, .mess-row input, .eigen-titel {
  width: 100%;
  min-height: 52px;
  border: 2px solid var(--linie);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--flaeche);
  color: var(--text);
  outline: none;
  font-size: 16px;
}

.feld textarea, .bemerkung textarea { resize: vertical; min-height: 84px; }

.feld input:focus, .feld select:focus, .feld textarea:focus,
.bemerkung textarea:focus, .mess-row input:focus, .eigen-titel:focus { border-color: var(--akzent); }

.feld.pflicht > span::after { content: " *"; color: var(--nok); }

::placeholder { color: var(--text2); opacity: 0.8; }

/* ---------- Übersicht ---------- */
.projekt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px 8px 12px 16px;
  margin-bottom: 10px;
  background: var(--flaeche);
  border: var(--karten-rand);
  border-radius: var(--r-karte);
  box-shadow: var(--schatten);
  cursor: pointer;
}

.projekt:active { transform: scale(0.99); }
.projekt-text { flex: 1; min-width: 0; }
.projekt b { display: block; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.projekt small { color: var(--text2); font-size: 14px; }

.badge {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--flaeche2);
  color: var(--text2);
}

.badge.offen { background: var(--akzent-weich); color: var(--akzent-text); }
.badge.fertig { background: var(--ok-weich); color: var(--ok); }

.zeile-weg, .punkt-weg {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text2);
  font-size: 26px;
  line-height: 1;
}

.leer {
  text-align: center;
  padding: 56px 16px;
  color: var(--text2);
  font-size: 16px;
}

/* ---------- Fortschritt ---------- */
.progress-wrap {
  position: sticky;
  top: calc(64px + var(--safe-top));
  z-index: 15;
  background: var(--bg);
  padding: 4px 0 14px;
}

.progress-text {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  height: 12px;
  border-radius: 6px;
  background: var(--flaeche2);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: var(--akzent);
  transition: width 0.2s ease-out;
}

/* ---------- Abschnitte und Punkte ---------- */
.abschnitt { margin-bottom: 22px; }
.abschnitt > h3 { margin: 6px 2px 10px; }
.abschnitt .hinweis { font-size: 14px; color: var(--text2); margin: -4px 2px 10px; }

.liste { display: grid; gap: 10px; }

.punkt {
  background: var(--flaeche);
  border: var(--karten-rand);
  border-left: 6px solid transparent;
  border-radius: var(--r-karte);
  box-shadow: var(--schatten);
  padding: 14px 14px 16px;
}

.punkt.erfuellt { border-left-color: var(--ok); }
.punkt.mangel { border-left-color: var(--nok); }
.punkt.entfaellt { border-left-color: var(--linie); }
.punkt.eigen { border-left-color: var(--akzent); }

.punkt-kopf { display: flex; gap: 10px; align-items: flex-start; }

.punkt-nr {
  font-size: 13px;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
  padding-top: 3px;
  min-width: 22px;
}

.punkt-text { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; line-height: 1.3; }

.punkt-hilfe {
  display: block;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text2);
  margin-top: 4px;
}

.punkt-norm {
  display: block;
  font-weight: 400;
  font-size: 13px;
  color: var(--text2);
  margin-top: 4px;
}

/* Statuswahl: grosse, klar getrennte Knöpfe */
.status-row {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 8px;
  margin-top: 12px;
}

.status-btn {
  min-height: 52px;
  border: 2px solid var(--linie);
  border-radius: var(--r-knopf);
  background: var(--flaeche);
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  padding: 8px 4px;
}

.status-btn.on-ok { background: var(--ok); border-color: var(--ok); color: var(--auf-status); }
.status-btn.on-mangel { background: var(--nok); border-color: var(--nok); color: var(--auf-status); }
.status-btn.on-entfaellt { background: var(--text2); border-color: var(--text2); color: var(--bg); }
.status-btn[disabled], .chip[disabled] { cursor: default; }

/* Messwert und Zahl */
.mess-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.mess-row input { flex: 1; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mess-row .einheit { font-size: 16px; font-weight: 600; color: var(--text2); min-width: 32px; }

.soll { font-size: 14px; color: var(--text2); margin-top: 8px; }

.ergebnis { font-size: 15px; font-weight: 600; margin-top: 8px; }
.ergebnis:empty { display: none; }
.ergebnis.ok { color: var(--ok); }
.ergebnis.nok { color: var(--nok); }

/* Druckprobe */
.druck-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  /* Felder auf einer Linie, auch wenn eine Beschriftung umbricht */
  align-items: end;
}

.druck-grid .feld { margin: 0; }
.druck-grid .feld > span { font-size: 13px; }
.druck-grid input { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 10px; }

/* Warnungen: Hinweis, blockiert nichts */
.warnung, .foto-hinweis {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border-left: 4px solid var(--warn-rand);
  background: var(--warn-weich);
  color: var(--warn-text);
  font-size: 15px;
  font-weight: 600;
}

/* ---------- Fotos ---------- */
.cam-btn {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border: 0;
  border-radius: var(--r-knopf);
  background: var(--akzent-weich);
  color: var(--akzent-text);
  display: grid;
  place-items: center;
  position: relative;
}

.cam-btn.pflicht { background: var(--nok); color: var(--auf-status); }
.cam-btn[disabled] { opacity: 0.4; cursor: default; }

.cam-btn .zaehler {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.foto-galerie { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.foto-galerie img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--linie);
  cursor: pointer;
  background: var(--flaeche2);
}

.foto-mit-text { display: flex; flex-direction: column; gap: 4px; width: 88px; }
.foto-mit-text span { font-size: 12px; line-height: 1.3; color: var(--text2); }

.foto-auftrag .btn, .verweis .btn { margin-top: 10px; }

/* ---------- Eigene Punkte ---------- */
.eigen-titel { font-weight: 600; font-size: 17px; }

.add-punkt {
  width: 100%;
  min-height: 52px;
  margin-top: 10px;
  border: 2px dashed var(--linie);
  border-radius: var(--r-knopf);
  background: transparent;
  color: var(--text2);
  font-weight: 600;
  font-size: 15px;
}

.add-punkt[disabled], .punkt-weg[disabled] { display: none; }

/* ---------- Bemerkung ---------- */
.bemerkung { margin-top: 12px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.chip {
  min-height: 48px;
  padding: 10px 16px;
  border: 2px solid var(--linie);
  border-radius: 999px;
  background: var(--flaeche);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}

.chip.on { background: var(--akzent); border-color: var(--akzent); color: var(--auf-akzent); }

.feld-inline { margin: 12px 0 0; }

/* ---------- Gesperrt nach Unterschrift ---------- */
.gesperrt-hinweis { border-left: 6px solid var(--ok); }
.gesperrt-hinweis h2 { color: var(--ok); }
.gesperrt-hinweis .btn { margin-top: 12px; }

.punkt input[disabled], .punkt textarea[disabled], .sig-slot input[disabled] {
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  opacity: 1;
  background: var(--flaeche2);
}

/* ---------- Abschluss ---------- */
.offen-item {
  font-size: 15px;
  padding: 12px 0;
  border-bottom: 1px solid var(--linie);
  color: var(--nok);
}

.offen-item:last-child { border-bottom: 0; }

.sig-slot {
  border: 2px solid var(--linie);
  border-radius: var(--r-knopf);
  padding: 14px;
  margin-bottom: 12px;
}

.sig-slot b { display: block; font-size: 16px; font-weight: 600; margin-bottom: 10px; }

.sig-slot img {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  margin-bottom: 8px;
}

/* ---------- Einstellungen ---------- */
.logo-feld { margin-top: 16px; }

#logoVorschau {
  display: block;
  max-width: 220px;
  max-height: 80px;
  object-fit: contain;
  margin-top: 8px;
  background: #fff;
  border: 1px solid var(--linie);
  border-radius: 10px;
  padding: 6px;
}

/* ---------- Untere Leisten ---------- */
.tabbar, .aktionsleiste {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--leiste);
  border-top: 1px solid var(--linie);
  padding: 8px max(12px, calc((100% - 672px) / 2 + 12px)) calc(10px + var(--safe-bottom));
}

.tabbar {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 6px;
  align-items: center;
}

.tab {
  min-height: 60px;
  border: 0;
  border-radius: var(--r-knopf);
  background: transparent;
  color: var(--text2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 13px;
  font-weight: 600;
  padding: 4px;
}

.tab.an { color: var(--text); }
.tab.an svg { color: var(--akzent); }

.tab.neu {
  flex-direction: row;
  gap: 8px;
  background: var(--akzent);
  color: var(--auf-akzent);
  font-size: 16px;
  white-space: nowrap;
  border-radius: var(--r-gross);
}

.tab.neu.an { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--akzent); }
.tab.neu svg, .tab.neu.an svg { color: var(--auf-akzent); }
.tab[disabled] { opacity: 0.4; }

.aktionsleiste { display: flex; gap: 10px; }

.cam-gross {
  flex: 1.4;
  min-height: 64px;
  border: 0;
  border-radius: var(--r-gross);
  background: var(--akzent);
  color: var(--auf-akzent);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
}

.cam-gross[disabled] { opacity: 0.4; cursor: default; }
.cam-gross:active { transform: scale(0.98); }

.aktionsleiste .btn { flex: 1; width: auto; min-height: 64px; border-radius: var(--r-gross); }

.leiste-platz { height: 24px; }

/* ---------- Meldung ---------- */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--leiste-hoehe) + 16px + var(--safe-bottom));
  z-index: 60;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--r-knopf);
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

#toastUndo {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--akzent);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

/* ---------- Unterschrift ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.5); }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  max-width: 672px;
  margin: 0 auto;
  background: var(--flaeche);
  border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(18px + var(--safe-bottom));
}

.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--linie); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 2px; font-size: 18px; font-weight: 600; }

#sigCanvas {
  display: block;
  width: 100%;
  height: 200px;
  margin-top: 12px;
  background: #fff;
  border: 2px solid var(--linie);
  border-radius: 14px;
  touch-action: none;
}

/* ---------- Ruhe für alle, die weniger Bewegung wünschen ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
