:root {
  --bg: #f4f4f5;
  --card: #ffffff;
  --text: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --nz: #52525b;
  --nz-bg: #e4e4e7;
  --warn-bg: #fef3c7;
  --warn: #92400e;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f11;
    --card: #1c1c20;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --line: #2e2e33;
    --accent: #ea580c;
    --ok: #4ade80;
    --ok-bg: #14532d;
    --bad: #f87171;
    --bad-bg: #4c1d1d;
    --nz: #d4d4d8;
    --nz-bg: #3f3f46;
    --warn-bg: #422006;
    --warn: #fcd34d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(24px + var(--safe-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: var(--accent); color: var(--accent-text);
}
.topbar h1 { flex: 1; margin: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar button {
  background: none; border: 0; color: inherit; font-size: 26px; line-height: 1;
  min-width: 44px; min-height: 44px; cursor: pointer;
}

main { max-width: 760px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line); padding: 16px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 12px; font-size: 17px; }
.muted { color: var(--muted); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
  font-weight: 600; text-decoration: none;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-danger { color: var(--bad); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

label.feld { display: block; margin-bottom: 12px; }
label.feld span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
textarea { min-height: 70px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

/* Anmeldung */
.login-modus .topbar { display: none; }
.login {
  min-height: calc(100vh - 32px - var(--safe-top) - var(--safe-bottom));
  display: flex; flex-direction: column; justify-content: center;
  max-width: 420px; margin: 0 auto; padding-top: var(--safe-top);
}
.login-logo {
  display: block; width: 100%; max-width: 360px; margin: 0 auto 28px;
  background: #fff; border-radius: var(--radius); padding: 12px;
}
.login-fehler { color: var(--bad); font-size: 14px; min-height: 20px; margin-bottom: 8px; }
.login-fuss { text-align: center; margin-top: 8px; }

/* Startseite: Kopf mit Logo */
.start-kopf { text-align: center; margin: 4px 0 16px; }
.start-kopf img {
  display: block; width: 100%; max-width: 320px; margin: 0 auto 6px;
  background: #fff; border-radius: var(--radius); padding: 8px;
}

/* Startseite: Modul-Kacheln */
.modul-raster { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 600px) { .modul-raster { grid-template-columns: 1fr 1fr; } }
.modul-kachel {
  display: flex; align-items: center; gap: 14px; padding: 18px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: inherit; text-decoration: none; min-height: 88px;
}
.modul-kachel:active { transform: scale(.99); }
.modul-icon {
  flex: 0 0 52px; width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-text);
}
.modul-icon svg { width: 28px; height: 28px; }
.modul-icon.gross { width: 72px; height: 72px; margin: 0 auto 12px; }
.modul-icon.gross svg { width: 40px; height: 40px; }
.modul-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modul-text strong { font-size: 17px; }
.modul-hinweis { font-size: 13px; font-weight: 600; color: var(--warn); }
.modul-hinweis:empty { display: none; }
.modul-kachel.inaktiv .modul-icon { background: var(--nz-bg); color: var(--nz); }
.modul-kachel.inaktiv strong { color: var(--muted); }

/* Liste */
.liste-eintrag {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 8px; color: inherit; text-decoration: none;
}
.liste-eintrag strong { display: block; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px;
  border-radius: 99px; background: var(--nz-bg); color: var(--nz); margin-right: 6px;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.offen { background: var(--warn-bg); color: var(--warn); }
.badge.mangel { background: var(--bad-bg); color: var(--bad); }

.typ-wahl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.typ-wahl label {
  display: flex; align-items: center; min-height: 56px; padding: 8px 12px;
  border: 2px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 15px;
}
.typ-wahl input { position: absolute; opacity: 0; }
.typ-wahl input:checked + span { color: var(--accent); }
.typ-wahl label:has(input:checked) { border-color: var(--accent); }

/* Checkliste */
.fortschritt { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 6px 0 0; }
.fortschritt > div { height: 100%; background: var(--accent); transition: width .2s; }

details.abschnitt { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
details.abschnitt > summary {
  list-style: none; cursor: pointer; padding: 14px 16px;
  display: flex; align-items: center; gap: 8px; font-weight: 700;
}
details.abschnitt > summary::-webkit-details-marker { display: none; }
details.abschnitt > summary .zaehler { margin-left: auto; font-weight: 600; font-size: 14px; color: var(--muted); }
details.abschnitt > summary .zaehler.fertig { color: var(--ok); }
details.abschnitt > summary::after { content: '›'; font-size: 22px; transition: transform .15s; color: var(--muted); }
details.abschnitt[open] > summary::after { transform: rotate(90deg); }
.abschnitt-inhalt { padding: 0 16px 12px; }
.alle-ok { margin-bottom: 8px; font-size: 14px; min-height: 40px; }

.punkt { border-top: 1px solid var(--line); padding: 12px 0; }
.punkt-text { margin-bottom: 8px; }
.punkt-text .pflicht { color: var(--bad); font-weight: 700; }
.punkt-hinweis { font-size: 13px; color: var(--muted); margin-top: 2px; }
.status-wahl { display: grid; grid-template-columns: 1fr 1fr 1fr 48px; gap: 6px; }
.status-wahl button, .wert-zeile button.nz, .foto-btn {
  min-height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; font-weight: 600; font-size: 15px;
}
.status-wahl button[aria-pressed=true][data-status=ok] { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.status-wahl button[aria-pressed=true][data-status=mangel] { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.status-wahl button[aria-pressed=true][data-status=nz],
.wert-zeile button.nz[aria-pressed=true] { background: var(--nz-bg); border-color: var(--nz); color: var(--nz); }
.wert-zeile { display: grid; grid-template-columns: 1fr auto 64px 48px; gap: 6px; align-items: center; }
.wert-zeile .einheit { color: var(--muted); min-width: 36px; }
.bemerkung { margin-top: 8px; }
.punkt.fehlt .punkt-text { color: var(--bad); }

.fotos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.fotos:empty { display: none; }
.foto-mini { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; background: var(--line); }
.foto-mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-mini button {
  position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; cursor: pointer;
}
.foto-punkt .foto-btn { width: 100%; }
.foto-btn input { display: none; }
label.foto-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.foto-punkt.erledigt .foto-btn { border-color: var(--ok); color: var(--ok); }

/* Wartung: Hinweis bei Messwerten außerhalb der VDI 2035 */
.vdi-hinweis {
  background: var(--warn-bg); color: var(--warn); border-radius: 10px;
  padding: 8px 12px; margin-bottom: 8px; font-size: 14px;
}
.vdi-hinweis:empty { display: none; }
.vdi-hinweis::before { content: '⚠ '; }
.vdi-hinweis ul { margin: 4px 0 0; padding-left: 18px; }

/* Demontage: Auswahlknöpfe, Mengen */
.punkt-kopf { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.punkt-kopf .punkt-text { flex: 1; margin: 0; font-weight: 600; }
.punkt-kopf .foto-btn, .nz-knopf { min-width: 48px; min-height: 40px; }
.nz-knopf { border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; cursor: pointer; }
.nz-knopf[aria-pressed=true] { background: var(--nz-bg); border-color: var(--nz); color: var(--nz); }
.wahl-zeile { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.wahl-zeile button {
  flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; font-weight: 600; font-size: 15px;
}
.wahl-zeile .foto-btn { flex: 0 0 48px; }
.wahl-zeile.mit-label > span { flex: 0 0 96px; font-size: 14px; color: var(--muted); }
.wahl-zeile button[aria-pressed=true][data-ton=gut] { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.wahl-zeile button[aria-pressed=true][data-ton=schlecht] { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.wahl-zeile button[aria-pressed=true][data-ton=neutral] { background: var(--nz-bg); border-color: var(--nz); color: var(--nz); }
.grid2.eng { gap: 6px; margin-top: 2px; }
.btn.klein { min-height: 32px; padding: 0 10px; margin-top: 6px; font-size: 13px; font-weight: 500; }
.zwischentitel { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 4px; }
.menge-zeile { display: grid; grid-template-columns: minmax(0, 1fr) 44px 64px 44px; gap: 6px; align-items: center; }
.menge-zeile .punkt-text { margin: 0; }
.menge-zeile input { text-align: center; padding: 8px 4px; }
.menge-zeile .einheit { display: block; font-size: 12px; color: var(--muted); }
.stepper { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 20px; font-weight: 700; cursor: pointer; }

/* Abschluss */
.unterschrift { border: 1px dashed var(--muted); border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 160px; display: block; }
.fehlerliste { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 12px 12px 12px 30px; margin: 0 0 12px; }
.fehlerliste li { margin-bottom: 4px; }
.fehlerliste a { color: inherit; }
.maengel li { margin-bottom: 6px; }

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

#toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%) translateY(120px);
  background: #18181b; color: #fff; padding: 12px 18px; border-radius: 10px; max-width: calc(100% - 32px);
  transition: transform .2s; z-index: 50;
}
#toast.sichtbar { transform: translateX(-50%) translateY(0); }

.fixed-bottom {
  position: sticky; bottom: calc(8px + var(--safe-bottom)); margin-top: 16px;
}
