:root {
  --navy: #1a1a2e;
  --rot: #b01c1c;
  --rot-dunkel: #8c1414;
  --bg: #f6f6f7;
  --karte: #fff;
  --text: #14141f;
  --grau: #6b7280;
  --hell: #9ca3af;
  --linie: #ececf0;
  --feld: #f3f3f5;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.sub { color: var(--grau); font-size: 13px; margin-top: 4px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.rot { color: var(--rot); }
.muted { color: var(--hell); }
.hidden { display: none !important; }

/* ---------- Anmeldung ---------- */
.login { min-height: 100%; display: grid; place-items: center; background: var(--navy); padding: 20px; }
.login-box { background: #fff; border-radius: 18px; padding: 36px 32px; width: 100%; max-width: 380px; }
.login-box .marke { font-size: 24px; font-weight: 700; }
.login-box .produkt { color: var(--rot); font-weight: 600; margin-bottom: 26px; }

/* ---------- Büro-Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 224px; flex: none; background: var(--navy); color: #fff; padding: 22px 12px 18px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side .marke { font-weight: 700; font-size: 17px; padding: 0 8px; }
.side .bereich { font-size: 10px; letter-spacing: 0.12em; color: #8b8ba7; padding: 2px 8px 22px; text-transform: uppercase; }
.side nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-btn {
  display: flex; align-items: center; gap: 12px; background: none; border: 0; color: #b6b6cc;
  padding: 12px 14px; border-radius: 10px; text-align: left; font-size: 14px; width: 100%;
}
.nav-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-btn.aktiv { background: linear-gradient(135deg, var(--rot), var(--rot-dunkel)); color: #fff; font-weight: 600; }
.nav-btn svg { width: 16px; height: 16px; flex: none; }
.side .wer { font-size: 11px; color: #8b8ba7; padding: 0 14px 4px; }
main.inhalt { flex: 1; min-width: 0; padding: 26px 28px 60px; }
.kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }

/* ---------- Bausteine ---------- */
.karte { background: var(--karte); border-radius: var(--radius); padding: 18px 20px; }
.karte + .karte { margin-top: 14px; }
.label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--hell); margin-bottom: 8px; display: block;
}
.btn {
  border: 1px solid var(--linie); background: #fff; border-radius: 10px; padding: 10px 16px;
  font-weight: 600; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { background: #fafafa; }
.btn.primaer { background: linear-gradient(135deg, var(--rot), var(--rot-dunkel)); color: #fff; border-color: transparent; }
.btn.primaer:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.grau { background: var(--feld); border-color: transparent; justify-content: flex-start; font-weight: 500; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; color: var(--hell); }
.icon-btn:hover { background: var(--feld); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; display: block; }

.feld { margin-bottom: 14px; }
.feld input, .feld select, .feld textarea, .eingabe {
  width: 100%; border: 1px solid var(--linie); background: #fff; border-radius: 10px; padding: 11px 12px; outline: none;
}
.feld textarea { min-height: 96px; resize: vertical; }
.feld input:focus, .feld select:focus, .feld textarea:focus, .eingabe:focus { border-color: var(--rot); }

.kacheln { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kachel { background: #fff; border: 0; border-radius: var(--radius); padding: 16px 18px; text-align: left; }
.kachel:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.kachel .zahl { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kachel .name { color: var(--grau); font-size: 13px; margin-top: 4px; }
.z-OFFEN { color: #f59e0b; } .z-GEPRUEFT { color: #3b82f6; }
.z-ABGERECHNET { color: #16a34a; } .z-STORNIERT { color: #dc2626; }

.suche { position: relative; }
.suche input { width: 100%; border: 0; background: #fff; border-radius: var(--radius); padding: 18px 18px 18px 46px; outline: none; }
.suche svg { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--hell); }
.suche.klein input { border: 1px solid var(--linie); border-radius: 10px; padding: 10px 12px 10px 34px; }
.suche.klein svg { left: 12px; }

.filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { border: 0; background: #ececef; color: var(--grau); border-radius: 10px; padding: 10px 16px; font-weight: 600; }
.chip span { font-weight: 400; }
.chip.aktiv { background: linear-gradient(135deg, var(--rot), var(--rot-dunkel)); color: #fff; }

.tabelle-wrap { background: #fff; border-radius: var(--radius); overflow-x: auto; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--hell);
  font-weight: 600; padding: 14px 16px; background: #f1f1f3; white-space: nowrap;
}
td { padding: 16px; border-top: 1px solid var(--linie); vertical-align: middle; }
tr.klick { cursor: pointer; }
tr.klick:hover td { background: #fafafb; }
td.nr { font-family: ui-monospace, Consolas, monospace; color: var(--rot); font-size: 12.5px; white-space: nowrap; }
td.fett { font-weight: 600; }
td.klein { font-size: 12px; color: var(--hell); }
td.rechts, th.rechts { text-align: right; }
td.aktionen { white-space: nowrap; text-align: right; }
.leer { padding: 40px; text-align: center; color: var(--hell); }

.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.b-OFFEN { background: #fef3c7; color: #b45309; } .b-GEPRUEFT { background: #dbeafe; color: #1d4ed8; }
.b-ABGERECHNET, .b-aktiv { background: #dcfce7; color: #15803d; } .b-STORNIERT { background: #fee2e2; color: #b91c1c; }
.b-inaktiv { background: #ececef; color: var(--grau); } .b-ADMIN { background: #fee2e2; color: #b91c1c; }
.b-TECHNIKER { background: #dbeafe; color: #1d4ed8; }

/* ---------- Detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); gap: 16px; align-items: start; }
.zurueck { display: flex; align-items: center; gap: 12px; }
.zurueck h1 { font-family: ui-monospace, Consolas, monospace; color: var(--rot); font-size: 20px; }
.zeiten { display: flex; gap: 28px; flex-wrap: wrap; }
.zeiten .wert { font-size: 16px; font-weight: 700; }
.zeiten .wert.gross { font-size: 18px; color: var(--rot); }
.zeiten small { display: block; font-size: 10px; letter-spacing: 0.08em; color: var(--hell); text-transform: uppercase; }
.sig { background: var(--feld); border-radius: 10px; max-width: 290px; height: 96px; display: grid; place-items: center; }
.sig img { max-width: 100%; max-height: 96px; }
.stapel { display: grid; gap: 8px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.pos { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--linie); }
.pos:first-of-type { border-top: 0; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20,20,31,0.45); display: grid; place-items: center; padding: 16px; z-index: 50; overflow-y: auto; }
.dialog { background: #fff; border-radius: 16px; width: 100%; max-width: 860px; }
.dialog.schmal { max-width: 460px; }
.dialog-kopf { display: flex; justify-content: space-between; align-items: center; padding: 22px 26px; border-bottom: 1px solid var(--linie); }
.dialog-kopf h2 { margin: 0; font-size: 19px; }
.dialog-body { padding: 22px 26px 8px; }
.dialog-body.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.dialog-fuss { display: flex; gap: 10px; padding: 16px 26px 22px; border-top: 1px solid var(--linie); }

/* ---------- Suchvorschläge & Material ---------- */
.auswahl { position: relative; }
.vorschlaege {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--linie);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.12); max-height: 240px; overflow-y: auto; z-index: 20;
}
.vorschlag { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 11px 12px; }
.vorschlag:hover { background: var(--feld); }
.vorschlag small { color: var(--hell); margin-left: 6px; }
.mat-liste { border: 1px dashed var(--linie); background: #fafafb; border-radius: 12px; min-height: 120px; margin-top: 10px; padding: 6px 12px; }
.mat-liste .leer { padding: 44px 0; }
.mat-pos { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--linie); }
.mat-pos:first-child { border-top: 0; }
.mat-pos .bez { flex: 1; min-width: 0; }
.schritt { display: inline-flex; align-items: center; gap: 6px; }
.schritt button { width: 30px; height: 30px; border: 0; border-radius: 8px; background: #ececef; font-size: 16px; }
.schritt b { min-width: 28px; text-align: center; }

/* ---------- Techniker ---------- */
.t-kopf {
  background: var(--navy); color: #fff; padding: 10px 14px; display: flex; justify-content: space-between;
  align-items: center; position: sticky; top: 0; z-index: 10;
}
.t-kopf .marke { font-weight: 700; font-size: 15px; }
.t-kopf .bereich { font-size: 9.5px; letter-spacing: 0.12em; color: #8b8ba7; text-transform: uppercase; }
.t-kopf .rechts { display: flex; gap: 4px; }
.t-kopf .nav-btn { width: auto; padding: 8px 10px; color: #e5e5f0; font-size: 13px; gap: 6px; }
.t-inhalt { max-width: 640px; margin: 0 auto; padding: 14px 12px 110px; }
.t-inhalt .feld-grau { background: var(--feld); border: 0; border-radius: 10px; padding: 14px 12px; width: 100%; outline: none; }
.t-inhalt textarea.feld-grau { min-height: 130px; resize: vertical; }
.zeit-raster { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stepper button { width: 46px; height: 46px; border: 0; border-radius: 10px; background: #ececef; font-size: 20px; }
.stepper .wert { font-size: 22px; font-weight: 700; }
.stepper.kurz { justify-content: flex-start; gap: 22px; }
canvas.pad { width: 100%; height: 150px; background: var(--feld); border-radius: 10px; touch-action: none; display: block; }
.pad-hinweis { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--hell); margin-top: 8px; }
.link { background: none; border: 0; color: var(--rot); padding: 0; font-size: 12px; }
.t-fuss {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--linie);
  padding: 12px; display: grid; grid-template-columns: 1fr 2fr; gap: 10px;
}
.t-fuss .btn { padding: 14px; }
.auftrag-box { background: #fff7ed; border-radius: 10px; padding: 12px; }
.t-zeile { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

#toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 12px 18px; border-radius: 10px; z-index: 100; display: none; max-width: 90vw;
}
#toast.zeigen { display: block; }
#toast.fehler { background: #b91c1c; }

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .side { width: auto; height: auto; position: static; padding: 14px 12px; }
  .side .bereich { padding-bottom: 10px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side nav .nav-btn { width: auto; padding: 9px 12px; }
  main.inhalt { padding: 18px 14px 50px; }
  .kacheln { grid-template-columns: repeat(2, 1fr); }
  .detail, .dialog-body.zwei { grid-template-columns: 1fr; }
}

.t-eintrag { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.karte h2 { margin: 0 0 6px; font-size: 16px; }
.btn svg { width: 16px; height: 16px; flex: none; }
a.btn { text-decoration: none; color: var(--text); }
@media (max-width: 520px) {
  .t-kopf .nav-btn { padding: 8px 6px; font-size: 12px; gap: 4px; }
  .t-kopf .nav-btn svg { width: 14px; height: 14px; }
}
.overlay.oben { z-index: 60; }
.hinweis { margin: 0 0 16px; }
.vorschlag small { display: block; margin: 2px 0 0; }
.vorschlag.neu { display: flex; align-items: center; gap: 8px; color: var(--rot); font-weight: 600; border-top: 1px solid var(--linie); }
.vorschlag.neu svg { width: 14px; height: 14px; flex: none; }
.aehnlich { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.aehnlich .chip { padding: 8px 12px; color: var(--text); }

/* ---------- Version 1.5 ---------- */
.mitte { text-align: center; margin: 14px 0 0; }
.code-feld { font-size: 20px; letter-spacing: 0.2em; text-align: center; font-variant-numeric: tabular-nums; }
.raster-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin-top: 12px; }
.raster-2 .voll { grid-column: 1 / -1; }
.knopfzeile { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.knopfzeile .eingabe { flex: 1; min-width: 200px; }
.schmal-feld { max-width: 260px; }
.trenner { border-top: 1px solid var(--linie); margin: 18px 0 14px; }
.warnung { background: #fef3c7; color: #92400e; border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.hinweis-karte { background: #fff7ed; }
.hinweis-karte p { margin: 6px 0 0; }
table.kv { width: auto; margin-top: 8px; }
table.kv th { background: none; padding: 6px 18px 6px 0; }
table.kv td { border: 0; padding: 6px 0; }
.nowrap { white-space: nowrap; }
.schritte { padding-left: 20px; margin: 14px 0; }
.schritte li { margin-bottom: 12px; }
.qr { margin: 10px 0; }
.qr img { display: block; border: 1px solid var(--linie); border-radius: 10px; padding: 6px; background: #fff; }
.geheim { font-size: 13px; letter-spacing: 0.05em; user-select: all; }
details summary { cursor: pointer; display: inline-block; margin-top: 4px; }
.abstand { margin-top: 12px; }
.stapel-form { max-width: 420px; }
.stapel-form .sub { margin-top: 8px; }
@media (max-width: 820px) { .raster-2 { grid-template-columns: 1fr; } }
