/* ==========================================================================
   Vor-Ort-Einloeseseite. Eigenes Stylesheet, weil diese Seite bewusst
   unabhaengig von der CRM-Oberflaeche laeuft: eigenes JavaScript, kein Menue,
   eingeschraenkter Zugriff, gedacht fuer ein Geraet im Laden.

   Sie folgt trotzdem demselben Regelwerk wie die Hauptoberflaeche (D-189/D-190).
   Die Skalen sind hier ein zweites Mal aufgeschrieben, weil ein eigenstaendiges
   Stylesheet nichts importieren kann, ohne eine zweite Anfrage zu erzeugen.
   tests/design.test.js prueft beide Dateien gegen dieselben Stufen, damit die
   Werte nicht auseinanderlaufen.

   Der Dunkelmodus richtet sich hier nach der Einstellung des Betriebssystems,
   nicht nach einem Umschalter: die Seite hat bewusst keine Kopfzeile mit
   Bedienelementen.
   ========================================================================== */
:root {
  color-scheme: light;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-8: 32px;
  --text-xs: 12px; --text-sm: 14px; --text-md: 16px; --text-lg: 20px; --text-xl: 24px; --text-2xl: 32px; --text-3xl: 40px;
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px; --radius-pill: 999px;
  --leading-none: 1; --leading-tight: 1.25; --leading-normal: 1.5;
  --control-h: 36px;
  --transition: 180ms ease;

  --bg: #eef4f1; --surface: #fff; --surface-2: #f5f8f7; --text: #17211d;
  /* Dieselben berichtigten Farben wie in styles.css. Vorher standen hier
     --muted #6e7b75 (4,18:1), --amber #a66308 und ein hartes #c05c55 (4,28:1). */
  --muted: #616d67;
  --border: #d8e3de;
  --accent: #0a7c58; --accent-soft: #e3f4ed;
  --amber: #8f5606;
  --danger: #9e3b34;
  /* Text auf einer Akzentflaeche. Fest weiss war im Dunkelmodus 1,87:1. */
  --on-accent: #ffffff;
  --focus: #0a7c58;
  --glow: #2aa37720;
}

/* Neutrale Graustufen wie in der Hauptoberflaeche (D-190). Der Akzent ist
   entfaerbt, Farbe bleibt Warnung und Fehler vorbehalten. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #141417; --surface: #1e1e21; --surface-2: #282a2d; --text: #f0f0f2;
    --muted: #a2a2a8;
    --border: #35353c;
    --accent: #e8e8ea; --accent-soft: #2a2a2f;
    --amber: #ffc167;
    --danger: #ee8a82;
    --on-accent: #1a1a1d;
    --focus: #f0f0f2;
    --glow: #ffffff10;
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; font-family: Inter, ui-sans-serif, system-ui, sans-serif; background: radial-gradient(circle at 50% 0, var(--glow), transparent 44%), var(--bg); color: var(--text); }

/* Jedes bedienbare Element zeigt bei Tastaturbedienung, wo der Fokus steht.
   Vorher gab es auf dieser Seite keine einzige Fokusregel. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Ein Feld und ein Knopf haben dieselbe Hoehe wie in der Hauptoberflaeche. */
input, textarea, button, .back-to-crm { font: inherit; line-height: var(--leading-tight); }
input:not([type=checkbox]):not([type=radio]), textarea { min-height: var(--control-h); }

.store-shell { width: min(760px, 100%); min-height: 100vh; min-height: 100dvh; margin: auto; padding: var(--space-6); padding-top: max(var(--space-6), env(safe-area-inset-top)); padding-bottom: max(var(--space-6), env(safe-area-inset-bottom)); padding-left: max(var(--space-6), env(safe-area-inset-left)); padding-right: max(var(--space-6), env(safe-area-inset-right)); display: flex; flex-direction: column; justify-content: center; }
header { display: flex; gap: var(--space-3); align-items: center; padding: 0 var(--space-1) var(--space-4); }
.mark-icon { width: 26px; height: 26px; fill: currentColor; }
.store-mark { flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: var(--radius-lg); background: var(--accent); color: var(--on-accent); font-weight: 800; flex: 0 0 auto; }
.store-title { flex: 1; min-width: 0; }
header b, header small { display: block; }
header small { margin-top: var(--space-1); color: var(--muted); font-size: var(--text-xs); }
.header-actions { display: flex; gap: var(--space-2); align-items: center; flex: 0 0 auto; }
.back-to-crm, header button { min-height: var(--control-h); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); background: var(--surface); color: var(--muted); font-size: var(--text-xs); text-decoration: none; white-space: nowrap; cursor: pointer; }
.back-to-crm { display: inline-grid; place-items: center; color: var(--accent); font-weight: 700; }
.back-to-crm:hover, header button:hover { border-color: var(--accent); }

.store-card { min-height: 440px; display: grid; align-content: center; padding: clamp(var(--space-6), 6vw, var(--space-8)); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 25px 80px #123a2a18; text-align: center; }
.eyebrow { color: var(--accent); font-size: var(--text-xs); font-weight: 800; letter-spacing: .09em; }
.store-card h1 { margin: var(--space-2) 0; font-size: clamp(var(--text-xl), 5vw, var(--text-3xl)); }
.store-card p { margin: var(--space-1) auto var(--space-4); max-width: 500px; color: var(--muted); line-height: var(--leading-normal); }

form { display: grid; gap: var(--space-3); max-width: 470px; width: 100%; margin: 0 auto; text-align: left; }
label { display: grid; gap: var(--space-1); color: var(--muted); font-size: var(--text-xs); }
input, textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-2) var(--space-3); background: var(--surface-2); color: var(--text); font-size: var(--text-xs); }
textarea { font-size: var(--text-sm); }
/* Der Einloesecode wird abgelesen und abgetippt: bewusst gross und gesperrt. */
input[name="code"] { height: auto; text-align: center; text-transform: uppercase; letter-spacing: .08em; font-size: var(--text-xl); font-weight: 750; }
textarea { min-height: 75px; resize: vertical; }

button.primary, .handover-form button, .defer-form button { min-height: var(--control-h); border: 0; border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); background: var(--accent); color: var(--on-accent); font-weight: 750; cursor: pointer; }
.defer-form button { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }

.result-symbol { width: 90px; height: 90px; margin: 0 auto var(--space-4); display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: var(--text-3xl); }
.result-card.loss .result-symbol { background: var(--surface-2); color: var(--muted); }
.result-card h1 { margin: var(--space-1) 0; }
.result-code { display: inline-block; margin: var(--space-2) 0 var(--space-4); padding: var(--space-2); border-radius: var(--radius-md); background: var(--surface-2); color: var(--muted); font-size: var(--text-xs); }
.result-notice { padding: var(--space-3); border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent); font-size: var(--text-xs); }
.handover-form, .defer-form { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.handover-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.new-code { min-height: var(--control-h); margin-top: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2); background: transparent; color: var(--text); cursor: pointer; }

.error-box { padding: var(--space-3); border-radius: var(--radius-md); background: #9e3b3418; color: var(--danger); }
.loading { color: var(--muted); }
footer { padding: var(--space-3); color: var(--muted); font-size: var(--text-xs); text-align: center; }

/* --------------------------------------------------------------------------
   Oeffentliche Rechtstexte (D-204). Sie liegen in dieser Datei und nicht in einer
   dritten: die Skalen und Farben stehen schon zweimal, und tests/design.test.js
   prueft beide Dateien gegeneinander. Eine dritte Quelle waere eine dritte
   Stelle, die auseinanderlaufen kann.

   Die Zeilenlaenge ist begrenzt: ueber etwa 80 Zeichen verliert das Auge beim
   Ruecksprung die Zeile, und ein Rechtstext wird tatsaechlich gelesen.
   -------------------------------------------------------------------------- */
.legal-shell { width: min(680px, 100%); margin: auto; padding: var(--space-6) var(--space-4) var(--space-8); padding-top: max(var(--space-6), env(safe-area-inset-top)); padding-bottom: max(var(--space-8), env(safe-area-inset-bottom)); padding-left: max(var(--space-4), env(safe-area-inset-left)); padding-right: max(var(--space-4), env(safe-area-inset-right)); }
.legal-head h1 { margin: 0; font-size: var(--text-xl); }
.legal-head p { margin: var(--space-1) 0 var(--space-6); color: var(--muted); font-size: var(--text-sm); }
.legal-card { padding: var(--space-6); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.legal-card h2 { margin: var(--space-6) 0 var(--space-2); font-size: var(--text-md); }
.legal-card h2:first-child { margin-top: 0; }
.legal-card p, .legal-card li { color: var(--text); font-size: var(--text-md); line-height: var(--leading-normal); }
.legal-card p { margin: 0 0 var(--space-2); }
.legal-card ul { margin: 0 0 var(--space-2); padding-left: var(--space-6); }
.legal-card li { margin-bottom: var(--space-1); }
.legal-missing { color: var(--danger); font-weight: 700; }
/* Verweise folgen dem Akzent statt der Browservorgabe. Die Unterstreichung bleibt: im Dunkelmodus
   liegt der entfaerbte Akzent dicht an der Textfarbe, dort traegt allein sie die Information
   "anklickbar" (D-190). */
.legal-shell a { color: var(--accent); text-decoration: underline; }
.legal-foot { margin-top: var(--space-4); font-size: var(--text-xs); }
.legal-foot p { margin: var(--space-1) 0; }
.legal-meta { color: var(--muted); font-size: var(--text-xs); }

@media (max-width:760px) {
  .legal-shell { padding: var(--space-4) var(--space-2) var(--space-6); }
  .legal-card { padding: var(--space-4); }
  /* Ein Finger braucht mindestens 44px. */
  :root { --control-h: 44px; }
  button, summary, [role="button"], .back-to-crm { min-height: var(--control-h); }
  .store-shell { padding: var(--space-2); justify-content: flex-start; }
  header { padding-top: var(--space-1); align-items: flex-start; flex-wrap: wrap; }
  .header-actions { width: 100%; justify-content: flex-end; }
  .back-to-crm, header button { padding: var(--space-2); }
  .store-card { min-height: calc(100vh - 165px); min-height: calc(100dvh - 165px); border-radius: var(--radius-lg); padding: var(--space-4); }
  .handover-actions { grid-template-columns: 1fr; }
}
