/* MiBo Office – Handy-Oberfläche des verschlüsselten Briefkastens (Etappe 52).
   Mobile-first ab 320 px, dunkles und helles Farbschema, Touchflächen ab 44 px, reduzierte Bewegung. */
:root {
  --bg: #0b1622; --surface: #132232; --surface-2: #1b2d40; --line: #33485f;
  --text: #eef3f9; --muted: #b7c6d6; --accent: #2f6bf0; --accent-text: #9cbcff; --on-accent: #fff;
  --focus: #9cc0ff; --ok: #6ad69a; --warn: #ffd27a; --danger-text: #ff9a90; --danger-bg: #b3261e;
  --radius: 14px; --nav-h: 64px;
  color-scheme: dark;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f5f9; --surface: #fff; --surface-2: #e9eef5; --line: #c9d3de;
    --text: #0f1c2b; --muted: #475a6e; --accent: #1f56cc; --accent-text: #1a4bb4; --on-accent: #fff;
    --focus: #1a4bb4; --ok: #17703f; --warn: #7a4f00; --danger-text: #a3221b; --danger-bg: #b3261e;
    color-scheme: light;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
main {
  max-width: 720px; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(var(--nav-h) + 140px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
h1 { font-size: 1.55rem; margin: 0; }
h2 { font-size: 1.3rem; margin: 0 0 10px; }
h3 { font-size: 1.08rem; margin: 0 0 8px; }
h4 { font-size: 1rem; margin: 18px 0 6px; }
h2, h3, h4, p, dd, pre { overflow-wrap: anywhere; }
p { margin: 8px 0; }
ul { list-style: none; margin: 0; padding: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted, .hint, .field-hint, .lock-footer { color: var(--muted); }
.hint, .field-hint, .lock-footer { font-size: .92rem; }
.field-hint { display: block; margin-top: 4px; }
.eyebrow { margin: 0; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.big { margin: 2px 0 6px; font-size: 1.3rem; font-weight: 700; }
.full { width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* Kopf, Karten, Hinweise */
.hero { display: flex; align-items: center; gap: 14px; margin: 6px 0 18px; }
.hero > div { min-width: 0; }
.brand { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 13px; background: var(--accent); color: #fff; font-size: 1.4rem; font-weight: 800; }
.hero .brand { width: 58px; height: 58px; border-radius: 17px; font-size: 1.9rem; }
.card, .lock { margin: 14px 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.notice { padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.banner { margin: 10px 0; padding: 12px 14px; background: var(--surface-2); border: 2px solid var(--warn); border-radius: 12px; font-weight: 600; }
.draft-flag { display: inline-block; padding: 4px 12px; border: 2px dashed var(--warn); border-radius: 999px; color: var(--warn); font-weight: 700; }
.lock-footer { margin-top: 20px; line-height: 1.6; }

/* Formulare */
label { display: block; margin: 14px 0 6px; font-weight: 600; }
fieldset { min-width: 0; margin: 14px 0 0; padding: 4px 14px 14px; border: 1px solid var(--line); border-radius: 12px; }
legend { padding: 0 6px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
textarea { min-height: 130px; resize: vertical; }
input[type=file] { padding: 9px; }
input[type=checkbox] { flex: none; width: 24px; height: 24px; min-height: 24px; margin: 2px 0 0; accent-color: var(--accent); }
input:user-invalid, select:user-invalid, textarea:user-invalid { border: 2px solid var(--danger-text); }
label.check { display: flex; align-items: flex-start; gap: 12px; min-height: 48px; padding: 12px; font-weight: 500; border: 1px solid var(--line); border-radius: 10px; }
.req { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--surface-2); color: var(--warn); font-size: .75rem; font-weight: 700; vertical-align: middle; }

/* Schaltflächen */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 16px; font: inherit; font-weight: 600; text-align: center; text-decoration: none;
  color: var(--on-accent); background: var(--accent); border: 0; border-radius: 12px; cursor: pointer;
}
button.secondary, .button.secondary { color: var(--text); background: var(--surface-2); border: 1px solid var(--line); }
button.danger { color: #fff; background: var(--danger-bg); }
button.compact { min-height: 44px; padding: 8px 14px; }
button:disabled { opacity: .5; cursor: default; }
form button[type=submit] { width: 100%; margin-top: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.actions > * { flex: 1 1 150px; }
.actions button[type=submit] { margin-top: 0; }
button.icon { flex: none; width: 48px; min-width: 48px; padding: 0; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Arbeitsbereich */
.appbar { padding: 4px 0 10px; border-bottom: 1px solid var(--line); }
.appbar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.appbar-title { flex: 1; min-width: 0; margin: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view-title { margin: 16px 0 8px; }
.view-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.dot-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.dot-label::before { content: ""; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); }
.dot-label[data-state=offline]::before { background: var(--danger-text); }
.quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { justify-content: flex-start; min-height: 64px; padding: 12px; text-align: left; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); }
.hints li { position: relative; padding: 8px 0 8px 18px; }
.hints li::before { content: ""; position: absolute; left: 2px; top: 1.05em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-text); }
.receipts li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.receipts strong, .receipts span { display: block; overflow-wrap: anywhere; }
.receipts .chip, .chip { display: inline-block; margin: 4px 0; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: .82rem; font-weight: 700; }
.chip[data-state=waiting] { color: var(--warn); }
.chip[data-state=accepted] { color: var(--ok); }
.chip[data-state=rejected] { color: var(--danger-text); }
.receipts span:last-child { color: var(--muted); font-size: .92rem; }

/* Listen und Details */
.entries li { border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.entries.static li { padding: 10px 0; }
.entries strong, .entries span { display: block; }
.entries span { color: var(--muted); font-size: .92rem; }
.entry { display: block; width: 100%; min-height: 56px; padding: 12px 4px; color: var(--text); background: transparent; border-radius: 10px; text-align: left; font-weight: 500; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.pager span { color: var(--muted); font-size: .9rem; text-align: center; }
.facts { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 6px 14px; margin: 12px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.install-help h3 { margin-top: 12px; font-size: 1rem; }

/* Aufklappbare Karten */
details.panel { padding: 0; }
details.panel > summary { position: relative; display: block; min-height: 56px; padding: 14px 52px 14px 16px; list-style: none; cursor: pointer; border-radius: var(--radius); }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: ""; position: absolute; right: 22px; top: 50%; width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); }
details.panel[open] > summary::after { transform: translateY(-30%) rotate(-135deg); }
.panel-title { display: block; font-weight: 700; }
.panel-sub { display: block; color: var(--muted); font-size: .9rem; }
.panel-body { padding: 0 16px 16px; }

/* Ablaufanzeige */
.steps { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 0 0 12px; padding: 0; list-style: none; counter-reset: step; font-size: .82rem; }
.steps li { display: flex; align-items: center; gap: 6px; color: var(--muted); counter-increment: step; }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 50%; }
.steps li.done::before { content: "✓"; background: var(--surface-2); }
.steps li[aria-current=step] { color: var(--text); font-weight: 700; }
.steps li[aria-current=step]::before { color: #fff; background: var(--accent); border-color: var(--accent); }

/* Postfach */
pre { margin: 10px 0; padding: 12px; white-space: pre-wrap; font: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
iframe { width: 100%; min-height: 280px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }

/* Prüfdialog */
dialog#review {
  width: min(640px, 100vw); max-width: 100vw; max-height: 92vh; max-height: 92dvh; margin: auto auto 0; overflow: auto;
  padding: 18px max(16px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 18px 18px 0 0;
}
dialog#review::backdrop { background: rgb(0 0 0 / .6); }
.table-wrap { margin: 10px 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 8px 6px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th { color: var(--muted); font-weight: 600; }

/* Untere Leiste mit Status und Hauptnavigation */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 0 max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left)); pointer-events: none; }
.dock > * { max-width: 720px; margin-left: auto; margin-right: auto; pointer-events: auto; }
#status { margin-bottom: 8px; padding: 10px 14px; max-height: 30vh; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 20px rgb(0 0 0 / .35); }
#status:empty { display: none; }
.bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
.bottom-nav button { flex-direction: column; gap: 2px; min-width: 0; min-height: var(--nav-h); padding: 6px 2px; color: var(--muted); background: transparent; border-radius: 12px; font-size: .72rem; }
.bottom-nav span { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bottom-nav button[aria-current=page] { color: var(--accent-text); background: var(--surface-2); }

@media (min-width: 560px) {
  .quick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 700px) {
  dialog#review { margin: auto; border-radius: 18px; }
}
@media (max-width: 360px) {
  main { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .card, .lock { padding: 14px; }
  .dock { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .bottom-nav { border-radius: 0; }
  .bottom-nav button { font-size: .68rem; }
  .appbar-title { visibility: hidden; }
}
@media (max-height: 480px) and (orientation: landscape) {
  :root { --nav-h: 48px; }
  .bottom-nav button { flex-direction: row; gap: 6px; font-size: .8rem; }
  .hero { margin: 4px 0 10px; }
}
@media (display-mode: standalone) {
  .install-only { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  button, .button, .entry, details.panel > summary::after { transition: background-color .15s ease, color .15s ease, transform .15s ease; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Beleg-Scanner (Etappe 78): Aufnahme, Ecken ziehen, Seiten. Nur Canvas, keine Bild-URLs (CSP img-src 'self'). */
.scan-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.scan-actions button { flex: 1 1 150px; }
.scan-editor { margin-top: 14px; }
.scan-canvas { display: block; width: 100%; height: auto; max-height: 62vh; object-fit: contain; background: #000; border-radius: 10px; touch-action: none; }
.scan-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.scan-tools button { flex: 1 1 100px; }
.scan-filter { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.scan-filter label { display: inline-flex; align-items: center; gap: 8px; margin: 8px 0 0; font-weight: 500; min-height: 44px; }
.scan-filter input[type=radio] { width: 22px; height: 22px; min-height: 22px; margin: 0; accent-color: var(--accent); }
.scan-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-top: 14px; }
.scan-page { position: relative; margin: 0; }
.scan-page canvas { display: block; width: 100%; height: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.scan-page figcaption { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.scan-page button { width: 100%; min-height: 44px; margin-top: 4px; padding: 6px 8px; }
.scan-original { margin-top: 16px; }
.scan-original > summary { cursor: pointer; min-height: 44px; padding: 10px 0; color: var(--accent-text); font-weight: 600; }
