/* ============================================================================
   3Faktur Leads — Corporate Design (Stand 10.11.2026)
   ----------------------------------------------------------------------------
   Werte wie das freigegebene Keycloak-Theme (infrastructure/keycloak/
   keycloak.corporate-design-theme.md § 2), dort aus dem Website-CSS von
   3faktur.com ausgezaehlt:
     Schwarz/Weiss tragen die Flaeche, Akzent #0073d8 markiert NUR, was anklickbar
     oder aktiv ist. Kantige Ecken, versale fette Knoepfe, Fokus 2px Akzent.
     Hausschrift D-DIN lokal (kein externer Font-Request, App laeuft offline).
   Darstellung: Auto (System) | Hell | Dunkel — data-theme am <html>, gesetzt von
   theme.js vor dem ersten Zeichnen. Dunkel tauscht Schwarz und Weiss, das Blau
   hellt auf #4d9ce8 auf (lesbar auf dunklem Grund).
   ============================================================================ */

@font-face {
  font-family: "D-DIN";
  src: url("fonts/d-din-webfont.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "D-DIN";
  src: url("fonts/d-din_bold-webfont.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f8f8f8;
  --surface: #ffffff;
  --fg: #000000;
  --muted: #707070;
  --line: #d8d8d8;
  --field: #ffffff;
  --accent: #0073d8;
  --on-accent: #ffffff;
  --primary: #000000;
  --on-primary: #ffffff;
  --soft: #eef1f4;
  --bad: #c62828;
  --good: #1e7f49;
  --warn: #9a5c00;
  --on-status: #ffffff;
  --logo-filter: none;
  --font: "D-DIN", Arial, Helvetica, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101112;
  --surface: #1b1d1f;
  --fg: #f2f2f2;
  --muted: #a0a6ab;
  --line: #33383d;
  --field: #101112;
  --accent: #4d9ce8;
  --on-accent: #000000;
  --primary: #f2f2f2;
  --on-primary: #000000;
  --soft: #26292c;
  --bad: #ef6b6b;
  --good: #4cc07d;
  --warn: #e2a23a;
  --on-status: #000000;
  --logo-filter: invert(1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101112;
    --surface: #1b1d1f;
    --fg: #f2f2f2;
    --muted: #a0a6ab;
    --line: #33383d;
    --field: #101112;
    --accent: #4d9ce8;
    --on-accent: #000000;
    --primary: #f2f2f2;
    --on-primary: #000000;
    --soft: #26292c;
    --bad: #ef6b6b;
    --good: #4cc07d;
    --warn: #e2a23a;
  --on-status: #000000;
    --logo-filter: invert(1);
  }
}

/* --- Grundgeruest ---------------------------------------------------------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.45 var(--font);
  background: var(--bg);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header {
  position: sticky; top: 0; z-index: 9;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { height: 30px; width: auto; display: block; filter: var(--logo-filter); }
.brand .app {
  border-left: 1px solid var(--line); padding-left: 10px; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand .app b { display: block; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; }
.brand .app span { font-size: 12.5px; color: var(--muted); }
.hdr-right { display: flex; align-items: center; gap: 10px; }
.status { text-align: right; font-size: 13px; line-height: 1.25; }
#whoami { color: var(--muted); }
#queue { color: var(--muted); }
#queue.warn { color: var(--bad); font-weight: 700; }
.iconbtn {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--fg);
  cursor: pointer; padding: 0;
}
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn:hover { border-color: var(--fg); }

main { max-width: 640px; margin: 0 auto; padding: 18px 16px 120px; }
main.wide { max-width: 900px; }

h1, h2 {
  margin: 0 0 4px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .02em;
}
h1 { font-size: 24px; }
h2 { font-size: 20px; }
.lede { color: var(--muted); font-size: 15px; margin: 0 0 18px; }
.small { font-size: 13px; }
.mt { margin-top: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.mb { margin-bottom: 16px; }

/* --- Karten und Felder ----------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 16px;
}
.card + .card { margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field > .lab {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
input[type=text], input[type=email], input[type=tel], input[type=url], textarea, select {
  width: 100%; font: inherit; color: var(--fg);
  padding: 11px 12px; min-height: 48px;
  background: var(--field);
  border: 1px solid var(--line); border-radius: 0;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 92px; resize: vertical; }
::placeholder { color: var(--muted); opacity: .8; }
.hint { color: var(--muted); font-size: 13px; margin: -10px 0 16px; }
.hint b { color: var(--fg); font-weight: 700; }

/* --- Auswahl-Chips: kantig, aktiv = Akzent --------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: 15px; min-height: 46px; padding: 9px 14px;
  border: 1px solid var(--line); border-radius: 0;
  background: var(--surface); color: var(--fg);
  cursor: pointer; touch-action: manipulation;
}
.chip:hover { border-color: var(--fg); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }

/* --- Knoepfe: versal, fett, kantig (Website-Stil) -------------------------- */
.btn {
  font: inherit; font-size: 15px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
  min-height: 48px; padding: 10px 18px;
  border: 1px solid var(--fg); border-radius: 0;
  background: transparent; color: var(--fg);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
  touch-action: manipulation;
}
.btn:hover { background: var(--fg); color: var(--surface); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover, .btn.primary:active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.big { width: 100%; min-height: 56px; font-size: 17px; }
.btn.ghost { border-color: transparent; color: var(--accent); padding-inline: 4px; }
.btn.ghost:hover { background: transparent; text-decoration: underline; color: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* --- Fortschritt + Fussleiste des Assistenten ------------------------------ */
.rail {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  height: 14px; padding: 0 16px 10px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.rail i { display: block; background: var(--line); }
.rail i.done { background: var(--accent); }
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 10px; align-items: center;
}
.bar .step {
  flex: 1; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* --- Meldungen ------------------------------------------------------------- */
.errs { border: 1px solid var(--bad); border-left-width: 4px; padding: 10px 12px; font-size: 15px; margin-bottom: 14px; color: var(--fg); background: var(--surface); }
.info { border: 1px solid var(--accent); border-left-width: 4px; padding: 10px 12px; font-size: 15px; margin-bottom: 14px; background: var(--surface); }
.note-warn { color: var(--warn); font-size: 14px; margin: 8px 0 0; }
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 40;
  background: var(--fg); color: var(--surface);
  padding: 11px 16px; font-size: 15px; max-width: calc(100% - 32px);
}
.fatal pre { white-space: pre-wrap; font-size: 12.5px; color: var(--bad); }

/* --- Listen, Badges, Zusammenfassung --------------------------------------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.lead { cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; }
.lead:hover { border-color: var(--fg); }
.lead .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 0; background: var(--soft); color: var(--fg); vertical-align: 2px;
}
.badge.A { background: var(--good); color: var(--on-status); }
.badge.B { background: var(--warn); color: var(--on-status); }
.badge.ocr { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.badge.removed { background: transparent; border: 1px solid var(--muted); color: var(--muted); margin-left: 4px; }
.lead.removed { opacity: .6; }
.profil p { margin: 8px 0 0; }
.profil a { color: var(--accent); }
.scanvideo { width: 100%; max-height: 60vh; background: #000; display: block; margin: 12px 0; }
.profil .meta { color: var(--muted); margin-top: 6px; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 16px; }
.check + .check { margin-top: 12px; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--accent); margin: 0; }
.sum { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 6px 12px; font-size: 15px; margin: 8px 0 0; }
.sum dt { color: var(--muted); }
.sum dd { margin: 0; overflow-wrap: anywhere; }
.sub { padding-left: 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.card > b, .sub > b { text-transform: uppercase; letter-spacing: .04em; font-size: 14px; }
details.roh { margin-top: 14px; }
details.roh summary { cursor: pointer; color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: 13px; letter-spacing: .04em; }
details.roh pre { white-space: pre-wrap; font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* --- Foto und Kamera ------------------------------------------------------- */
.photo { display: flex; gap: 12px; align-items: flex-start; }
.photo img { width: 140px; aspect-ratio: 85.6 / 54; object-fit: cover; border: 1px solid var(--line); display: block; }
.photo .acts { display: flex; flex-direction: column; gap: 8px; }
.fullphoto { max-width: 100%; display: block; margin-bottom: 14px; border: 1px solid var(--line); }
.mic {
  position: absolute; right: 8px; top: 8px; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--fg); cursor: pointer;
  font-size: 18px;
}
.mic.rec { background: var(--bad); border-color: var(--bad); color: #fff; }
.ta { position: relative; }
.pending { font-size: 13px; color: var(--accent); margin-top: 6px; }
.pending:empty { display: none; }
.ta textarea { padding-right: 54px; }

.camOverlay {
  position: fixed; inset: 0; z-index: 30; background: #000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.camBox { width: 100%; max-width: 640px; color: #fff; }
.camView { position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000; overflow: hidden; }
.camView.hoch { aspect-ratio: 3 / 4; max-height: 70vh; margin: 0 auto; }
.camView video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Kartenrahmen: aussen abgedunkelt, nur das Innere wird gespeichert (+4 % Rand) */
.camFrame {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 88%; aspect-ratio: 85.6 / 54;
  border: 2px solid #fff; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .55);
}
.camView.hoch .camFrame { width: auto; height: 90%; aspect-ratio: 54 / 85.6; }
.camFrame::before, .camFrame::after {
  content: ""; position: absolute; width: 22px; height: 22px; border: 4px solid #4d9ce8;
}
.camFrame::before { left: -4px; top: -4px; border-right: 0; border-bottom: 0; }
.camFrame::after { right: -4px; bottom: -4px; border-left: 0; border-top: 0; }
.camHint { margin: 10px 0 0; font-size: 15px; color: #d8d8d8; }
.camActs { display: flex; gap: 10px; margin-top: 12px; }
.camActs .btn { flex: 1; color: #fff; border-color: #fff; }
.camActs .btn.primary { background: #fff; color: #000; border-color: #fff; }
.camActs .btn.primary:hover { background: #4d9ce8; border-color: #4d9ce8; color: #000; }
.camActs .btn:hover { background: #fff; color: #000; }
.camTop { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.camTop .btn { min-height: 40px; font-size: 13px; color: #fff; border-color: #777; }

/* --- Buero-Ansicht: Foto neben dem Formular, OCR-Hinweise je Feld ---------- */
.detail { display: grid; gap: 18px; }
@media (min-width: 860px) {
  .detail { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; }
  .detail-foto { position: sticky; top: 84px; }
}
.ocrhint { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 13px; color: var(--muted); }
.ocrhint:empty { display: none; }
.ocrhint b { color: var(--fg); }
.ocrhint .btn.ghost { min-height: 28px; padding: 0 4px; font-size: 13px; }
.field > .ocrhint { margin-top: -2px; }
