:root {
  --paper: #F4F6F5;
  --surface: #FFFFFF;
  --ink: #17212B;
  --muted: #5B6770;
  --line: #D5DCDA;
  --field: #B9C4C2;
  --petrol: #1D5C63;
  --petrol-soft: #E3EEEF;
  --ok: #2F7D4F;
  --ok-soft: #E3F1E8;
  --warn: #9A6210;
  --warn-soft: #F7ECD9;
  --err: #A33A3A;
  --err-soft: #F5E1E1;
  --mono: "OCR-B", "OCR B", Consolas, "Liberation Mono", "Courier New", monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--petrol); }
h1 { font-size: 1.35rem; margin: 0 0 16px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 32px 0 12px; font-weight: 650; }
main { padding: 24px clamp(16px, 4vw, 40px) 48px; max-width: 1400px; margin: 0 auto; }
main.narrow { max-width: 460px; }
main.narrow-wide { max-width: 640px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hint { color: var(--muted); font-size: .85rem; margin: 12px 0 0; }
.hint.right { text-align: right; margin-top: -8px; margin-bottom: 12px; }
.sub { color: var(--muted); font-size: .82rem; }
.notice { font-size: .82rem; color: var(--muted); margin-top: 12px; max-width: 90ch; }
.empty { color: var(--muted); padding: 14px 12px; }
.hash { font-family: var(--mono); font-size: .75rem; overflow-wrap: anywhere; }

.page-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-head h1 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.h-sub { font-weight: 400; color: var(--muted); }
.crumbs { font-size: .88rem; color: var(--muted); margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.pager-inline { margin-left: auto; display: flex; gap: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; }

/* ---------- Schaltflächen ---------- */
button, .btn {
  font: inherit; font-size: .9rem; font-weight: 600; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--petrol); background: var(--petrol); color: #fff; text-decoration: none; display: inline-block; line-height: 1.3;
}
.btn.secondary, button.secondary { background: var(--surface); color: var(--petrol); }
button.small, .btn.small { padding: 5px 10px; font-size: .84rem; }
button:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #9CC5CA; outline-offset: 2px; }
button[disabled] { opacity: .45; cursor: not-allowed; }
button.linkish { background: none; border: 0; padding: 0; font-weight: 400; text-decoration: underline; color: var(--petrol); cursor: pointer; }

/* ---------- Kopfzeile ---------- */
header.site {
  display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: center;
  padding: 14px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
header.site nav { display: flex; gap: 4px; flex-wrap: wrap; }
header.site nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
header.site nav a:hover { color: var(--ink); background: var(--paper); }
header.site nav a[aria-current="page"] { color: var(--petrol); background: var(--petrol-soft); font-weight: 600; }
.account { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: .9rem; flex-wrap: wrap; }
.account .who small { color: var(--muted); }
.account form { margin: 0; }

/* ---------- Meldungen ---------- */
.flashes { max-width: 1400px; margin: 16px auto 0; padding: 0 clamp(16px, 4vw, 40px); }
.flash { margin: 0 0 12px; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.flash-ok, .flash-hoch { border-color: #BFDCC9; background: #EEF7F1; }
.flash-mittel { border-color: #E8D2AC; background: #FDF6EA; }
.flash-niedrig, .flash-error { border-color: #E6C2C2; background: #FBEFEF; }
.flash-error { color: var(--err); }
.flash-secret { border-color: var(--petrol); background: var(--petrol-soft); font-family: var(--mono); overflow-wrap: anywhere; }

/* ---------- Status ---------- */
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.s-ok, .s-geprueft { background: var(--ok-soft); color: var(--ok); }
.s-pruefen, .s-warn, .s-offen { background: var(--warn-soft); color: var(--warn); }
.s-auffaellig, .s-fehler, .s-error { background: var(--err-soft); color: var(--err); }
.s-kein_ausweis, .s-info, .s-archiviert { background: #ECEFEF; color: var(--muted); }
.s-exportiert, .s-laeuft { background: var(--petrol-soft); color: var(--petrol); }

/* Konfidenz: Balken + Wert + Stufe */
.conf { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: .88rem; }
.meter { width: 56px; height: 6px; border-radius: 3px; background: #E2E8E7; overflow: hidden; display: inline-block; }
.meter > span { display: block; height: 100%; border-radius: 3px; }
.conf-hoch .meter > span { background: var(--ok); }
.conf-mittel .meter > span { background: #C7891F; }
.conf-niedrig .meter > span { background: var(--err); }
.conf-num { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 2ch; text-align: right; }
.conf-hoch .conf-label { color: var(--ok); }
.conf-mittel .conf-label { color: var(--warn); }
.conf-niedrig .conf-label { color: var(--err); font-weight: 600; }
.m-0{width:0}.m-5{width:5%}.m-10{width:10%}.m-15{width:15%}.m-20{width:20%}.m-25{width:25%}.m-30{width:30%}
.m-35{width:35%}.m-40{width:40%}.m-45{width:45%}.m-50{width:50%}.m-55{width:55%}.m-60{width:60%}.m-65{width:65%}
.m-70{width:70%}.m-75{width:75%}.m-80{width:80%}.m-85{width:85%}.m-90{width:90%}.m-95{width:95%}.m-100{width:100%}

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 900px; }
table.compact { min-width: 640px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: .8rem; font-weight: 600; color: var(--muted); background: #FAFBFB; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.names { max-width: 320px; }
td.row-action { text-align: right; white-space: nowrap; }
.case-link { font-weight: 650; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #FAFCFC; }
table.docs tr.needs-niedrig td:first-child { box-shadow: inset 3px 0 0 var(--err); }
table.docs tr.needs-mittel td:first-child { box-shadow: inset 3px 0 0 #C7891F; }
tr.inactive td { color: var(--muted); }

/* ---------- Formulare ---------- */
input:not([type=checkbox]):not([type=file]), select, textarea {
  font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid var(--field); border-radius: 6px; background: var(--surface); color: var(--ink); width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--petrol-soft); border-color: var(--petrol); }
input:disabled, select:disabled, textarea:disabled { background: #F7F9F9; color: var(--ink); }
.form { display: grid; gap: 14px; max-width: 460px; }
.form label, .filters label, .upload .field { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; }
.form small, .roles small, .upload .field small { display: inline; font-weight: 400; color: var(--muted); font-size: .82rem; }
.form button { justify-self: start; }
.roles { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; display: grid; gap: 8px; margin: 0; }
.roles legend { font-size: .9rem; font-weight: 600; padding: 0 4px; }
.roles small { display: block; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { margin-top: 4px; }
.two-col { display: grid; grid-template-columns: minmax(280px, 460px) 1fr; gap: 40px; align-items: start; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .9rem; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.facts { margin-bottom: 8px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ref-form input { width: 18rem; max-width: 100%; padding: 5px 8px; }

/* Filterleiste */
.filters { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: end; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.filters label { font-size: .82rem; }
.filters .grow { flex: 1 1 300px; }
.filters select { min-width: 11rem; }
.more-filters { flex: 1 1 100%; order: 10; }
.more-filters summary { cursor: pointer; font-size: .86rem; color: var(--petrol); width: max-content; }
.filters-inner { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: end; margin-top: 12px; }
.filters-inner input[type=date] { width: auto; }
.filters-inner label.check { align-self: center; font-size: .88rem; }
.filter-actions { display: flex; gap: 14px; align-items: center; }
.pager { display: flex; gap: 16px; margin-top: 12px; }

/* ---------- Neuer Vorgang ---------- */
.upload { display: grid; gap: 16px; }
.card {
  position: relative; aspect-ratio: 85.6 / 54; width: 100%; max-width: 480px;
  border: 2px dashed #9FB3B5; border-radius: 14px; background: var(--surface);
  display: grid; grid-template-rows: 1fr auto; cursor: pointer; overflow: hidden;
  transition: border-color .15s, background-color .15s;
}
.card:hover { border-color: var(--petrol); }
.card.drag { border-color: var(--petrol); border-style: solid; background: var(--petrol-soft); }
.card-body { display: grid; grid-template-columns: 26% 1fr; gap: 6%; padding: 7% 7% 0; align-items: start; }
.photo { aspect-ratio: 35 / 45; border: 1.5px solid var(--line); border-radius: 6px; display: grid; place-items: center; color: #9FB3B5; font-size: 1.8rem; }
.card-text strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.card-text span { color: var(--muted); font-size: .88rem; }
.mrz { font-family: var(--mono); font-size: clamp(.62rem, 1.6vw, .8rem); letter-spacing: .12em; color: #7C9294;
  padding: 0 7% 6%; white-space: nowrap; overflow: hidden; line-height: 1.35; }
.upload .hint { margin: -6px 0 0; }
.queue { list-style: none; margin: 0; padding: 0; }
.queue:not(:empty) { border-top: 1px solid var(--line); }
.queue li { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; padding: 9px 2px; border-bottom: 1px solid var(--line); align-items: baseline; }
.queue .name { overflow-wrap: anywhere; }
.queue .meta { color: var(--muted); font-size: .85rem; }
.queue .meta.err { color: var(--err); }
.upload .actions .hint { margin: 0; }

/* ---------- Vorgang ---------- */
.case-meta { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }

/* ---------- Bearbeitungsdialog ---------- */
.head-status { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.id-images { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 4px 0 24px; }
.id-image { margin: 0; background: #E7ECEB; border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; align-content: start; }
.id-image a { display: grid; place-items: center; min-height: 180px; }
.id-image img { display: block; max-width: 100%; max-height: 360px; width: auto; height: auto; border-radius: 6px; background: #fff;
  box-shadow: 0 1px 2px rgba(23, 33, 43, .18); cursor: zoom-in; }
.id-image figcaption { font-size: .84rem; color: var(--muted); }
.id-image figcaption strong { color: var(--ink); margin-right: 6px; }
.id-image .placeholder { aspect-ratio: 85.6 / 54; max-height: 360px; border: 2px dashed #B7C3C1; border-radius: 10px;
  display: grid; place-items: center; color: var(--muted); font-size: .9rem; }

.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.doc-form { display: grid; gap: 18px; }
fieldset.group { margin: 0; padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
fieldset.group legend { font-weight: 650; font-size: .92rem; padding: 0 6px; }
.field { display: grid; gap: 4px; align-content: start; }
.field label { font-size: .84rem; font-weight: 600; }
.field.wide, .field.f-mrz { grid-column: 1 / -1; }
.field small { font-size: .78rem; }
.field small.orig { color: var(--muted); }
.field small.err { color: var(--err); font-weight: 600; }
.field.unclear input, .field.unclear select, .field.unclear textarea { border-color: #D4A24C; background: #FFF9EE; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--err); background: #FFF6F6; }
.tag { font-size: .72rem; font-weight: 600; color: var(--warn); background: var(--warn-soft); padding: 1px 6px; border-radius: 4px; margin-left: 4px; }
input.upper { text-transform: uppercase; }
textarea.mrz-input { font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; white-space: pre; overflow-x: auto; resize: vertical; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; position: sticky; bottom: 0;
  background: var(--paper); padding: 12px 0; border-top: 1px solid var(--line); }

.side { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px 16px 16px; position: sticky; top: 16px; }
.side h2 { margin: 16px 0 8px; font-size: .95rem; }
.checks { list-style: none; margin: 0; padding: 0; font-size: .86rem; }
.checks li { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 5px 0; border-bottom: 1px solid #EDF1F0; }
.checks li:last-child { border-bottom: 0; }
ul.plain { margin: 0; padding-left: 18px; font-size: .86rem; }
.history { list-style: none; margin: 8px 0 0; padding: 0; font-size: .82rem; display: grid; gap: 8px; }
.history .sub { display: block; }
.history del { color: var(--err); }
.history ins { color: var(--ok); text-decoration: none; }
details summary { cursor: pointer; font-size: .86rem; color: var(--petrol); }

@media (max-width: 1080px) {
  .edit-grid { grid-template-columns: 1fr; }
  .side { position: static; }
}
@media (max-width: 720px) {
  .id-images { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .account { margin-left: 0; }
  .hint.right { text-align: left; margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Feinschliff */
button, .btn { white-space: nowrap; }
.tag { white-space: nowrap; }
.upload .field small { display: inline; }
