:root {
  --bg: #f4f5f7; --panel: #ffffff; --text: #1d2330; --muted: #5d6677; --line: #dfe3ea;
  --brand: #c2410c; --brand-ink: #ffffff; --brand-soft: #fff1e8;
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fdf3e1; --bad: #b91c1c; --bad-soft: #fde8e8;
  --info-soft: #eaf1fb; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --panel: #1b2029; --text: #e6e9ef; --muted: #9aa3b2; --line: #2c3340;
    --brand: #f97316; --brand-soft: #2d1d12; --ok-soft: #12291b; --warn-soft: #2e2311; --bad-soft: #321618; --info-soft: #172235;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }

/* Kopf */
header.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 10px 16px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; color: var(--text); }
.logo b { width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; }
nav.main { display: flex; gap: 4px; flex-wrap: wrap; }
nav.main a { padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
nav.main a.on, nav.main a:hover { background: var(--brand-soft); color: var(--brand); }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }

/* Bausteine */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.sticky { position: sticky; top: 76px; }
@media (max-width: 960px) { .split { grid-template-columns: 1fr; } .sticky { position: static; } .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 64px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
input[type=range] { padding: 0; accent-color: var(--brand); }
label.c { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--brand); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.big { padding: 13px 22px; font-size: 16px; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); } .btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--info-soft); }
.chip.ok, .amp-go { background: var(--ok-soft); color: var(--ok); } .chip.warn, .amp-pruefen { background: var(--warn-soft); color: var(--warn); } .chip.bad, .amp-nogo { background: var(--bad-soft); color: var(--bad); }
.note { padding: 10px 12px; border-radius: 8px; background: var(--info-soft); margin: 8px 0; }
.note.warn { background: var(--warn-soft); } .note.bad { background: var(--bad-soft); } .note.ok { background: var(--ok-soft); }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.t td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t td input, table.t td select { padding: 5px 6px; }
table.t tr.off td { opacity: .5; }
.tw { overflow-x: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; } .kpi .l { color: var(--muted); font-size: 12px; }
.sum { width: 100%; } .sum td { padding: 4px 0; font-variant-numeric: tabular-nums; } .sum td:last-child { text-align: right; } .sum tr.tot td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--text); padding-top: 6px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
input.n { text-align: right; max-width: 100px; }

/* Stepper */
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 16px; }
.steps a { flex: 1 1 140px; text-decoration: none; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.steps a span.n { width: 22px; height: 22px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 12px; color: var(--text); }
.steps a.done span.n { background: var(--ok); color: #fff; } .steps a.on { border-color: var(--brand); color: var(--brand); } .steps a.on span.n { background: var(--brand); color: #fff; }

/* Assistent / Kacheln */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; background: var(--panel); }
.card.on { border-color: var(--brand); background: var(--brand-soft); }
.card small { display: block; color: var(--muted); }
.wiz-steps { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.wiz-steps span { padding: 5px 12px; border-radius: 99px; background: var(--line); font-size: 12px; font-weight: 600; }
.wiz-steps span.on { background: var(--brand); color: #fff; } .wiz-steps span.done { background: var(--ok-soft); color: var(--ok); }
.gw { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.gw > .gh { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg); font-weight: 600; flex-wrap: wrap; }
.log li { margin: 6px 0; } .log .st { display: inline-block; min-width: 70px; }
.ampel { font-size: 26px; font-weight: 800; padding: 10px 16px; border-radius: 10px; text-align: center; }
.radios { display: flex; gap: 6px; flex-wrap: wrap; }
.radios label { border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; cursor: pointer; font-size: 13px; }
.radios label.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.radios input { display: none; }

/* Dokument (A4) – immer hell */
.doc { background: #fff; color: #111; width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto; padding: 18mm 18mm 10mm 22mm; box-shadow: 0 4px 24px rgba(0,0,0,.15); font-size: 10pt; line-height: 1.4; position: relative; display: flex; flex-direction: column; }
.doc .kopf { display: flex; justify-content: space-between; border-bottom: 2px solid #c2410c; padding-bottom: 8px; margin-bottom: 14px; }
.doc .kopf .fn { font-size: 15pt; font-weight: 700; color: #c2410c; }
.doc .abs { font-size: 7.5pt; color: #555; border-bottom: 1px solid #999; display: inline-block; margin-bottom: 4px; }
.doc .anschrift { min-height: 30mm; }
.doc .meta { font-size: 9pt; } .doc .meta td { padding: 1px 0 1px 12px; }
.doc h2 { font-size: 13pt; margin: 14px 0 8px; color: #111; }
.doc table.pos { width: 100%; border-collapse: collapse; font-size: 9pt; margin: 8px 0; }
.doc table.pos th { background: #f2f2f2; text-align: left; padding: 5px 4px; border-bottom: 1px solid #999; }
.doc table.pos td { padding: 5px 4px; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
.doc table.pos .r { text-align: right; white-space: nowrap; }
.doc table.pos .sub { color: #666; font-size: 8pt; }
.doc .summen { width: 62%; margin-left: auto; border-collapse: collapse; font-size: 9.5pt; }
.doc .summen td { padding: 2px 4px; } .doc .summen td:last-child { text-align: right; white-space: nowrap; }
.doc .summen tr.tot td { font-weight: 700; border-top: 1.5px solid #111; font-size: 11pt; }
.doc .hinweis { font-size: 8.5pt; color: #333; margin-top: 8px; }
.doc .unterschrift { display: grid; grid-template-columns: 1fr 1fr; gap: 20mm; margin-top: 18mm; margin-bottom: 8mm; font-size: 8.5pt; }
.doc .unterschrift div { border-top: 1px solid #111; padding-top: 3px; }
.doc .fuss { margin-top: auto; padding-top: 4px; border-top: 1px solid #ccc; padding-top: 4px; font-size: 7pt; color: #666; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.doc + .doc { margin-top: 24px; }
.doc .logo-img { max-height: 20mm; max-width: 75mm; display: block; }
.doc .formular { line-height: 2; }
.doc .linie { display: block; border-bottom: 1px solid #555; height: 7mm; margin-bottom: 2mm; }
.doc table.pos tr.rest td { border-top: 1.5px solid #111; background: #f6f6f6; }
.doc .wm.ok { color: rgba(21,128,61,.12); }
table.t tr.sel td { background: var(--brand-soft); }
.doc .wm { position: absolute; inset: 0; display: grid; place-items: center; font-size: 72pt; font-weight: 800; color: rgba(185,28,28,.10); transform: rotate(-30deg); pointer-events: none; }

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  header.top, .no-print, .steps, .panel { display: none !important; }
  main { padding: 0; max-width: none; }
  .doc { box-shadow: none; width: 210mm; min-height: 297mm; margin: 0; }
  .doc + .doc { break-before: page; page-break-before: always; margin-top: 0; }
  .doc .wm { color: rgba(185,28,28,.14); }
}

/* Suche & Filter */
input.suche { flex: 1 1 320px; min-width: 220px; padding: 10px 12px; font-size: 15px; }
.chip-btn { font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 99px; padding: 4px 12px; cursor: pointer; }
.chip-btn span { color: var(--muted); font-weight: 500; margin-left: 2px; }
.chip-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; } .chip-btn.on span { color: #fff; }
mark { background: #fde68a; color: #111; border-radius: 3px; padding: 0 1px; }

/* Rücksprache / KLÄREN */
.amp-klaeren, .chip.klaeren { background: #ffedd5; color: #9a3412; }
.note.klaeren { background: #ffedd5; color: #7c2d12; border-left: 4px solid #ea580c; }
.klaer { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.klaer.offen { border-color: #ea580c; background: rgba(234, 88, 12, .06); }
.klaer.ok { border-color: var(--ok); background: var(--ok-soft); }
a.kpi-link { text-decoration: none; color: inherit; display: block; }
a.kpi-link:hover { border-color: var(--brand); }
.kpi-klaeren { border-color: #ea580c; background: rgba(234, 88, 12, .08); }
.kpi-klaeren .v { color: #ea580c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .note.klaeren { color: #fed7aa; background: #3b1d0a; } :root:not([data-theme="light"]) .amp-klaeren, :root:not([data-theme="light"]) .chip.klaeren { background: #3b1d0a; color: #fdba74; } }

/* Server-Betrieb: Anmeldung, Hinweise, Nachrichten */
.login { min-height: 70vh; display: grid; place-items: center; }
.login .panel { width: 100%; max-width: 420px; }
.toast { position: fixed; right: 16px; bottom: 16px; max-width: 460px; z-index: 50; padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-weight: 600; display: none; }
.toast.ok { background: var(--ok); color: #fff; } .toast.bad { background: var(--bad); color: #fff; } .toast a { color: #fff; }
.nachr { border-left: 3px solid var(--line); padding: 6px 10px; margin: 8px 0; }
.nachr.vertrieb { border-color: var(--brand); background: var(--brand-soft); }
.nachr.kunde { border-color: var(--ok); }
#syncStatus { font-weight: 600; }
