:root {
  --rot: #b3141c; --rot-dunkel: #8a0f15; --rot-hell: #fdecec;
  --gelb: #b86e00; --gelb-hell: #fff4e0; --gruen: #1e7a3c; --gruen-hell: #e6f4ea;
  --text: #1d1f23; --muted: #6a6f78; --linie: #e3e5e9; --flaeche: #f5f6f8; --karte: #fff;
  --radius: 10px; --schatten: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--flaeche);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 15px; line-height: 1.45; }
a { color: var(--rot); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .75rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }

/* Kopfzeile */
.topbar { display: flex; align-items: center; gap: 1.25rem; padding: .6rem 1.25rem; background: var(--rot); color: #fff; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand img { width: 30px; height: 30px; border-radius: 7px; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.brand:hover { text-decoration: none; }
nav { display: flex; gap: .25rem; }
nav a { color: rgba(255,255,255,.85); padding: .4rem .75rem; border-radius: 7px; font-weight: 500; }
nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
nav a.aktiv { background: rgba(255,255,255,.2); color: #fff; }
.topright { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.topright input { width: 220px; padding: .45rem .7rem; border-radius: 7px; border: none; font: inherit; }
.topright .btn-hell { background: rgba(255,255,255,.15); color: #fff; border: none; }

main { max-width: 1150px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* Bausteine */
.kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.krumen { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.krumen a { color: var(--muted); }
.aktionen { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--linie); background: #fff; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--flaeche); text-decoration: none; }
.btn-primaer { background: var(--rot); border-color: var(--rot); color: #fff; }
.btn-primaer:hover { background: var(--rot-dunkel); }
.btn-gefahr { color: var(--rot); }
.btn-klein { padding: .25rem .6rem; font-size: .85rem; }
.btn-link { background: none; border: none; color: var(--rot); padding: 0; cursor: pointer; font: inherit; }

.karte { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); box-shadow: var(--schatten); padding: 1.1rem 1.25rem; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; }
.kachel { background: #fff; border: 1px solid var(--linie); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--schatten); }
.kachel .zahl { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.kachel .label { color: var(--muted); font-size: .9rem; }
.kachel.rot .zahl { color: var(--rot); } .kachel.gelb .zahl { color: var(--gelb); }

.fz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .9rem; }
.fz { display: block; background: #fff; border: 1px solid var(--linie); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--schatten); color: var(--text); border-top: 4px solid var(--rot); transition: transform .08s, box-shadow .08s; }
.fz:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.fz .kurz { font-size: 1.5rem; font-weight: 800; letter-spacing: .02em; }
.fz .bez { color: var(--muted); font-size: .9rem; min-height: 1.3em; }
.fz .meta { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }
.fz.neu { border: 2px dashed var(--linie); border-top: 2px dashed var(--linie); box-shadow: none; display: flex; align-items: center; justify-content: center; color: var(--muted); min-height: 120px; background: transparent; cursor: pointer; font: inherit; }
.fz.neu:hover { border-color: var(--rot); color: var(--rot); }
.kat-kopf { display: flex; align-items: center; gap: .75rem; margin: 1.75rem 0 .75rem; }
.kat-kopf h2 { margin: 0; }

.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--flaeche); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.rot { background: var(--rot-hell); color: var(--rot); }
.pill.gelb { background: var(--gelb-hell); color: var(--gelb); }
.pill.gruen { background: var(--gruen-hell); color: var(--gruen); }
.pill.grau { background: #eceef1; color: #50555d; }
.pill.ohne::before { display: none; }

table { width: 100%; border-collapse: collapse; background: #fff; }
.tabelle { border: 1px solid var(--linie); border-radius: var(--radius); overflow: hidden; box-shadow: var(--schatten); overflow-x: auto; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--linie); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr.klickbar { cursor: pointer; }
tr.klickbar:hover td { background: #fafbfc; }
.leer { padding: 1.5rem; text-align: center; color: var(--muted); }

.zwei { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 1.25rem; align-items: start; }
.daten { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
.daten dt { color: var(--muted); }
.daten dd { margin: 0; overflow-wrap: anywhere; }
.qrbox { text-align: center; }
.qrbox img { width: 100%; max-width: 220px; image-rendering: pixelated; }
.qrbox .code { font-family: ui-monospace, monospace; font-size: .85rem; color: var(--muted); }

.plan { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1rem; border: 1px solid var(--linie); border-left: 4px solid var(--linie); border-radius: 8px; background: #fff; margin-bottom: .6rem; flex-wrap: wrap; }
.plan.rot { border-left-color: var(--rot); } .plan.gelb { border-left-color: var(--gelb); } .plan.gruen { border-left-color: var(--gruen); }
.plan .titel { font-weight: 600; }

/* Formulare & Dialog */
dialog { border: none; border-radius: 14px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,22,26,.45); }
dialog form { padding: 1.4rem 1.5rem 1.2rem; }
dialog h3 { margin: 0 0 1rem; font-size: 1.15rem; }
.felder { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; }
.feld { display: flex; flex-direction: column; gap: .25rem; }
.feld.voll { grid-column: 1 / -1; }
.feld label { font-size: .85rem; font-weight: 600; color: #3b3f46; }
input, select, textarea { font: inherit; padding: .5rem .65rem; border: 1px solid #cfd3d9; border-radius: 7px; background: #fff; color: inherit; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(179,20,28,.25); border-color: var(--rot); }
textarea { min-height: 70px; resize: vertical; }
.dialog-fuss { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
.fehler { color: var(--rot); font-size: .9rem; margin-top: .75rem; min-height: 1.2em; }
.ergebnis-wahl { display: flex; gap: .5rem; }
.ergebnis-wahl label { flex: 1; border: 1px solid var(--linie); border-radius: 8px; padding: .55rem; text-align: center; cursor: pointer; font-weight: 600; font-size: .9rem; }
.ergebnis-wahl input { display: none; }
.ergebnis-wahl input:checked + span { color: inherit; }
.ergebnis-wahl label:has(input:checked).ok { background: var(--gruen-hell); border-color: var(--gruen); color: var(--gruen); }
.ergebnis-wahl label:has(input:checked).mg { background: var(--gelb-hell); border-color: var(--gelb); color: var(--gelb); }
.ergebnis-wahl label:has(input:checked).nb { background: var(--rot-hell); border-color: var(--rot); color: var(--rot); }

.login { max-width: 380px; margin: 3rem auto; }
.login h1 { margin-bottom: .25rem; }
.login .feld { margin-top: .9rem; }
.login .btn { width: 100%; justify-content: center; margin-top: 1.25rem; padding: .65rem; }

#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; visibility: hidden; background: #1d1f23; color: #fff; padding: .65rem 1.1rem; border-radius: 9px; transition: transform .2s, opacity .2s, visibility .2s; z-index: 100; font-weight: 500; }
#toast.zeigen { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }

.suchergebnis { position: absolute; top: 3.2rem; right: 1.25rem; width: 360px; background: #fff; color: var(--text); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-height: 60vh; overflow: auto; }
.suchergebnis a { display: block; padding: .6rem .9rem; color: var(--text); border-bottom: 1px solid var(--linie); }
.suchergebnis a:hover { background: var(--flaeche); text-decoration: none; }

/* Öffentliche QR-Ansicht */
.oeffentlich .status-gross { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; border-radius: var(--radius); font-weight: 700; font-size: 1.1rem; margin: 1rem 0; }
.status-gross.gruen { background: var(--gruen-hell); color: var(--gruen); }
.status-gross.gelb { background: var(--gelb-hell); color: var(--gelb); }
.status-gross.rot { background: var(--rot-hell); color: var(--rot); }
.status-gross.keine { background: #eceef1; color: #50555d; }

/* Schwere-Auswahl beim Reparaturschein */
.schwere-wahl { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.schwere-wahl label { display: flex; flex-direction: column; gap: .15rem; border: 1px solid var(--linie); border-radius: 8px; padding: .55rem .65rem; cursor: pointer; font-size: .88rem; font-weight: 400; }
.schwere-wahl label span { color: var(--muted); font-size: .78rem; line-height: 1.25; }
.schwere-wahl input { display: none; }
.schwere-wahl label:has(input:checked).gruen { background: var(--gruen-hell); border-color: var(--gruen); color: var(--gruen); }
.schwere-wahl label:has(input:checked).gelb { background: var(--gelb-hell); border-color: var(--gelb); color: var(--gelb); }
.schwere-wahl label:has(input:checked).rot { background: var(--rot-hell); border-color: var(--rot); color: var(--rot); }
.schwere-wahl label:has(input:checked) span { color: inherit; }
@media (max-width: 760px) { .schwere-wahl { grid-template-columns: 1fr; } }

/* Navigation-Zähler, Hinweise */
.nav-zahl:not(:empty) { display: inline-block; margin-left: .35rem; background: #fff; color: var(--rot); border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 0 .4rem; line-height: 1.35; }
.hinweis-box { display: block; margin: 1rem 0; padding: .75rem 1rem; border-radius: var(--radius); background: #eef3fb; color: #1d3d6b; border: 1px solid #d3e0f3; }
.hinweis-box.gelb { background: var(--gelb-hell); color: #7a4900; border-color: #f3dcb0; }
a.hinweis-box:hover, a.kachel:hover { text-decoration: none; filter: brightness(.98); }
a.kachel { color: var(--text); }
.fz .zust { margin-top: .55rem; font-size: .82rem; color: var(--muted); }

/* Reparaturschein (Druck) */
.rep-blatt { background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 14mm 15mm; box-shadow: var(--schatten); font-size: 10.5pt; color: #000; }
.rep-kopf { display: flex; align-items: flex-start; gap: 6mm; border-bottom: 2px solid var(--rot); padding-bottom: 4mm; }
.rep-kopf img { width: 24mm; height: 24mm; }
.rep-org { font-weight: 600; color: var(--rot); }
.rep-titel { font-size: 20pt; font-weight: 800; }
.rep-nr { margin-left: auto; text-align: right; font-size: 10pt; }
.rep-nr b { font-size: 13pt; }
.rep-dringend { display: inline-block; margin-top: 2mm; border: 2px solid var(--rot); color: var(--rot); font-weight: 800; padding: .5mm 3mm; }
.rep-blatt h3 { font-size: 10.5pt; margin: 4.5mm 0 1.5mm; text-transform: uppercase; letter-spacing: .04em; color: #444; }
.rep-tab { border: 1px solid #999; }
.rep-tab th, .rep-tab td { border: 1px solid #bbb; padding: 1.1mm 2.5mm; text-transform: none; letter-spacing: 0; font-size: 10pt; color: #000; background: none; }
.rep-tab th { width: 45mm; font-weight: 600; background: #f3f3f3; }
.rep-feld { border: 1px solid #999; margin-top: 2mm; }
.rep-label { background: #f3f3f3; padding: 1.2mm 2.5mm; font-weight: 600; border-bottom: 1px solid #bbb; }
.rep-text { padding: 2mm 2.5mm; min-height: 17mm; white-space: pre-wrap; }
.rep-text.gross { min-height: 26mm; }
.rep-check { display: flex; gap: 8mm; margin: 5mm 0 2mm; flex-wrap: wrap; }
.rep-unterschriften { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8mm; margin-top: 10mm; break-inside: avoid; }
.rep-unterschriften div { border-top: 1px solid #000; padding-top: 1.5mm; font-size: 8.5pt; color: #333; }
.rep-fuss { margin-top: 4mm; font-size: 8pt; color: #777; text-align: center; }

/* Etiketten-Designer */
.designer { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.designer-panel { padding: .9rem 1rem; position: sticky; top: 4.2rem; max-height: calc(100vh - 5.2rem); overflow: auto; }
.panel-gruppe { padding: .75rem 0; border-bottom: 1px solid var(--linie); }
.panel-gruppe:first-child { padding-top: 0; } .panel-gruppe:last-child { border-bottom: none; }
.panel-titel { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .5rem; }
.mini-felder { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .6rem; }
.mini-felder label { display: flex; flex-direction: column; gap: .15rem; font-size: .78rem; font-weight: 600; color: #3b3f46; }
.mini-felder .voll { grid-column: 1 / -1; }
.mini-felder input, .mini-felder select, .designer-panel > .panel-gruppe > select { padding: .35rem .5rem; font-size: .88rem; }
.checkliste { display: flex; flex-direction: column; gap: .3rem; margin-top: .65rem; font-size: .88rem; }
.checkliste input, .geraeteliste input { width: auto; margin-right: .35rem; }
.geraeteliste { max-height: 300px; overflow: auto; font-size: .86rem; border: 1px solid var(--linie); border-radius: 8px; padding: .4rem .6rem; }
.geraeteliste label { display: flex; align-items: center; padding: .12rem 0 .12rem 1.2rem; }
.geraeteliste .gl-kopf { padding-left: 0; font-weight: 700; margin-top: .35rem; }
.vorschau { background: #e3e5e9; border-radius: var(--radius); padding: 12px; min-height: 400px; overflow: auto; }
.seiten { display: flex; flex-direction: column; align-items: center; gap: 8mm; }
.seiten.einzeln { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 4mm; }
.seite { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); overflow: hidden; flex: none; }
.etk-platz { position: absolute; outline: .2mm dashed #c9ccd2; }
.etk { position: absolute; display: flex; align-items: center; overflow: hidden; color: #000; line-height: 1.15; }
.etk img { flex: none; image-rendering: pixelated; }
.etk-rechts { flex-direction: row-reverse; }
.etk-oben { flex-direction: column; justify-content: center; text-align: center; }
.etk-nur { justify-content: center; }
.etk-text { min-width: 0; overflow: hidden; }
.etk-kopf { font-size: .72em; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.etk-fz { font-weight: 800; color: var(--rot); }
.etk-name { font-weight: 700; font-size: 1.05em; overflow-wrap: anywhere; }
.etk-klein { font-size: .8em; color: #222; }
.etk-mono { font-family: ui-monospace, monospace; }
.etk.mitrahmen { outline: .2mm solid #000; outline-offset: -.1mm; }
.nur-druck { display: none; }

@media (max-width: 760px) {
  .topbar { gap: .5rem; padding: .5rem .8rem; }
  .topright { width: 100%; margin-left: 0; }
  .topright input { flex: 1; width: auto; }
  nav { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  nav a { white-space: nowrap; padding: .35rem .6rem; }
  main { padding: 1rem .8rem 3rem; }
  .zwei { grid-template-columns: minmax(0, 1fr); }
  .plan .aktionen { width: 100%; }
  .felder { grid-template-columns: 1fr; }
  .suchergebnis { left: .8rem; right: .8rem; width: auto; top: 6rem; }
  .versteckt-mobil { display: none; }
  .designer { grid-template-columns: minmax(0, 1fr); }
  .designer-panel { position: static; max-height: none; }
  .rep-blatt { width: auto; min-height: 0; padding: 6mm; }
}

@media print {
  .topbar, .kein-druck, #toast, dialog { display: none !important; }
  .nur-druck { display: block; }
  body, :root { background: #fff; }
  main { max-width: none; padding: 0; margin: 0; }
  .designer { display: block; }
  .vorschau { background: none; padding: 0; border-radius: 0; overflow: visible; min-height: 0; }
  .seiten { zoom: 1 !important; display: block; }
  .seite { box-shadow: none; margin: 0; break-after: page; page-break-after: always; }
  .seite:last-child { break-after: auto; page-break-after: auto; }
  .etk-platz { display: none; }
  .rep-blatt { box-shadow: none; margin: 0; width: auto; min-height: 0; padding: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
