/* ScanDesk – dark theme with yellow accents; corner radius max. 6 px */

:root {
  --c-accent: #ffd60a;
  --c-accent-hover: #ffe24d;
  --c-accent-press: #e6c000;
  --c-on-accent: #111111;
  --c-accent-soft: rgba(255, 214, 10, .12);
  --c-accent-line: rgba(255, 214, 10, .45);

  --c-bg: #0a0a0b;
  --c-surface: #151517;
  --c-surface-2: #1c1c1f;
  --c-surface-3: #242428;
  --c-border: #2a2a2f;
  --c-border-strong: #3a3a40;
  --c-text: #f4f4f5;
  --c-muted: #9b9ba3;

  --c-ok: #4ade80;
  --c-warn: #fbbf24;
  --c-err: #f87171;
  --c-info: #7dd3fc;
  --c-ok-bg: rgba(74, 222, 128, .12);
  --c-warn-bg: rgba(251, 191, 36, .13);
  --c-err-bg: rgba(248, 113, 113, .13);
  --c-info-bg: rgba(125, 211, 252, .12);
  --c-corrected: #c4b5fd;
  --c-corrected-bg: rgba(196, 181, 253, .14);

  --radius: 6px;
  --radius-sm: 4px;
  --tap: 44px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); background: var(--c-bg); color: var(--c-text);
  font-size: 16px; line-height: 1.5; min-height: 100vh; -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(1200px 500px at 85% -10%, rgba(255, 214, 10, .07), transparent 60%);
  background-attachment: fixed;
}
a { color: var(--c-accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--c-accent-hover); }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1.05rem; font-weight: 700; margin: 1rem 0 .5rem; }
h4 { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); margin: 1rem 0 .4rem; }
p { margin: .5rem 0; }
small.block { display: block; color: var(--c-muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; }
.muted { color: var(--c-muted); }
.hidden, [hidden] { display: none !important; }
code { background: var(--c-surface-3); color: var(--c-accent); padding: .1rem .4rem; border-radius: 6px; font-size: .9em; }
::selection { background: var(--c-accent); color: var(--c-on-accent); }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 3px; border-radius: 6px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--c-accent); color: var(--c-on-accent); padding: .5rem 1rem; z-index: 100; border-radius: 0 0 6px 6px; }
.skip:focus { left: .5rem; }

/* --- Header (SCANDESK) ----------------------------------------------------- */
#topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(10, 10, 11, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: .7rem 1rem .6rem; padding-top: max(.7rem, env(safe-area-inset-top));
}
#topbar .hdr-row { display: flex; align-items: center; gap: .75rem; max-width: 1400px; margin: 0 auto; padding-bottom: .65rem; border-bottom: 1px solid var(--c-border-strong); }
#topbar .brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--c-text); flex: 1; min-width: 0; }
.logo { width: 46px; height: 46px; border-radius: 6px; background: var(--c-accent); color: #111; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-text strong { font-size: 1.45rem; font-weight: 900; letter-spacing: .01em; }
.brand-text small { color: var(--c-muted); font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .15rem; }
#topbar .brand-text small { text-transform: none; }
#topbar .hdr-btn { width: 46px; height: 46px; min-height: 46px; background: transparent; border: 1px solid var(--c-border-strong); }
#topbar .hdr-btn:hover { border-color: var(--c-accent); }
#topbar nav { display: none; max-width: 1400px; margin: .55rem auto 0; gap: .25rem; flex-wrap: wrap; }
#topbar nav a { padding: .35rem .75rem; border-radius: 6px; text-decoration: none; color: var(--c-muted); font-weight: 600; font-size: .9rem; }
#topbar nav a:hover { color: var(--c-text); background: var(--c-surface-2); }
#topbar nav a[aria-current="page"] { background: var(--c-accent); color: var(--c-on-accent); }
#topbar .net { background: var(--c-warn); color: #111; padding: .1rem .6rem; border-radius: 6px; font-weight: 700; font-size: .85rem; }
#topbar .net:empty { display: none; }
@media (min-width: 900px) { #topbar nav { display: flex; } }

/* --- Layout -------------------------------------------------------------- */
main { padding: 1.25rem; max-width: 1400px; margin: 0 auto; outline: none; padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); }
.card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 1.25rem 1.4rem; margin-bottom: 1rem;
}
.card.narrow { max-width: 460px; margin: 2.5rem auto; box-shadow: var(--shadow); }
.card.accent { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); }
.card > h1:first-child, .card > h2:first-child { margin-top: 0; }
#boot-message .muted { font-size: .9rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.toolbar h1 { margin: 0; }
.toolbar .spacer { flex: 1; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }
td.actions { white-space: nowrap; margin: 0; }

/* --- Forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field label { font-weight: 600; font-size: .9rem; color: #d4d4d8; }
.field .hint { color: var(--c-muted); font-size: .85rem; }
input, select, textarea {
  font: inherit; color: var(--c-text); background: #0f0f11; border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm); padding: .6rem .8rem; min-height: var(--tap); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #6b6b73; }
input:hover, select:hover, textarea:hover { border-color: #4a4a52; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: auto; accent-color: var(--c-accent); transform: scale(1.3); margin: .2rem .55rem .2rem .1rem; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.85); }
select option { background: var(--c-surface-2); color: var(--c-text); }
textarea { min-height: 5rem; resize: vertical; }
input[aria-invalid="true"] { border-color: var(--c-err); }
label { cursor: pointer; }
fieldset { border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: .75rem 1rem; margin: .75rem 0; }
legend { color: var(--c-muted); font-size: .85rem; padding: 0 .4rem; }
details { margin: .75rem 0; }
summary { cursor: pointer; color: var(--c-muted); font-weight: 600; }
summary:hover { color: var(--c-text); }

/* --- Buttons --------------------------------------------------------------- */
button {
  font: inherit; font-weight: 700; border-radius: 6px; padding: .6rem 1.25rem; min-height: var(--tap);
  border: 1px solid transparent; cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .05s;
  color: var(--c-text); background: var(--c-surface-3);
}
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--c-accent); color: var(--c-on-accent); }
button.primary:hover:not(:disabled) { background: var(--c-accent-hover); }
button.primary:active:not(:disabled) { background: var(--c-accent-press); }
button.secondary { background: transparent; color: var(--c-text); border-color: var(--c-border-strong); }
button.secondary:hover:not(:disabled) { border-color: var(--c-accent); color: var(--c-accent); }
button.secondary[aria-pressed="true"], .mode-select button[aria-pressed="true"] { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); }
button.danger { background: transparent; color: var(--c-err); border-color: rgba(248, 113, 113, .5); }
button.danger:hover:not(:disabled) { background: var(--c-err); color: #111; }
button.link { background: none; border: none; padding: 0; min-height: auto; font-weight: 600; color: var(--c-accent); text-decoration: underline; text-underline-offset: 3px; border-radius: 4px; }
button.small { padding: .3rem .8rem; min-height: 34px; font-size: .88rem; }
button.wide { width: 100%; }
button.big { font-size: 1.15rem; padding: 1rem 2.4rem; min-height: 64px; box-shadow: 0 8px 28px rgba(255, 214, 10, .25); }

/* --- Feedback ---------------------------------------------------------------- */
.error { color: var(--c-err); min-height: 1em; margin: .25rem 0; }
.error:empty { min-height: 0; margin: 0; }
.notice { padding: .8rem 1rem; border-radius: var(--radius-sm); margin: .6rem 0; border: 1px solid; }
.notice.info { background: var(--c-info-bg); border-color: rgba(125, 211, 252, .35); }
.notice.warn { background: var(--c-warn-bg); border-color: rgba(251, 191, 36, .4); }
.notice.err { background: var(--c-err-bg); border-color: rgba(248, 113, 113, .45); }
.notice.ok { background: var(--c-ok-bg); border-color: rgba(74, 222, 128, .4); }
.notice ul { margin: .4rem 0 0; padding-left: 1.2rem; }

.badge {
  display: inline-flex; align-items: center; gap: .25rem; padding: .15rem .6rem; border-radius: 6px;
  font-size: .78rem; font-weight: 700; letter-spacing: .01em; background: var(--c-surface-3); color: #d4d4d8; white-space: nowrap;
}
.badge.ok, .badge.matched, .badge.published, .badge.finalized, .badge.accepted { background: var(--c-ok-bg); color: var(--c-ok); }
.badge.warn, .badge.uncertain, .badge.draft, .badge.review, .badge.open, .badge.in_review, .badge.reopened { background: var(--c-warn-bg); color: var(--c-warn); }
.badge.err, .badge.not_found, .badge.invalid, .badge.rejected, .badge.retired { background: var(--c-err-bg); color: var(--c-err); }
.badge.corrected, .badge.manual { background: var(--c-corrected-bg); color: var(--c-corrected); }
.badge.capturing, .badge.request, .badge.superseded { background: var(--c-info-bg); color: var(--c-info); }

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%) translateY(1rem);
  background: var(--c-accent); color: var(--c-on-accent); font-weight: 700;
  padding: .8rem 1.4rem; border-radius: 6px; max-width: min(92vw, 520px); box-shadow: var(--shadow); z-index: 80; text-align: center;
  opacity: 0; visibility: hidden; pointer-events: none; transition: transform .2s, opacity .2s, visibility .2s;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; pointer-events: auto; }
.toast.error { background: var(--c-err); color: #111; }
.toast.success { background: var(--c-ok); color: #0a0a0a; }
@media (max-width: 760px) { .toast { bottom: calc(5.5rem + env(safe-area-inset-bottom)); } }

.dialog { background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border-strong); border-radius: var(--radius); padding: 1.4rem; max-width: 500px; width: 92vw; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, .7); backdrop-filter: blur(3px); }
.dialog h2 { margin-top: 0; }
.dialog .actions { justify-content: flex-end; margin-top: 1.2rem; }

.spinner { display: flex; align-items: center; gap: .7rem; padding: 1.2rem; color: var(--c-muted); }
.spinner .dot { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--c-border-strong); border-top-color: var(--c-accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner .dot { animation: none; } .toast, button { transition: none; } }

.progress { height: 8px; background: var(--c-surface-3); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--c-accent); transition: width .2s; }

.qr { display: flex; justify-content: center; }
.qr canvas { width: 220px; height: 220px; image-rendering: pixelated; display: block; margin: 1rem auto; border-radius: 6px; border: 6px solid #fff; }

/* --- Tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--radius-sm); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--c-border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
th { background: var(--c-surface-2); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); }
tr.clickable { cursor: pointer; transition: background .12s; }
tr.clickable:hover, tr.clickable:focus-visible { background: var(--c-surface-2); }

/* --- Template tiles (home) -------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .85rem; }
.tile {
  display: flex; flex-direction: column; gap: .35rem; padding: 1rem; min-height: 120px; text-align: left;
  background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--radius); color: var(--c-text);
  font-weight: 400; position: relative; overflow: hidden;
}
.tile::after {
  content: "→"; position: absolute; right: 1rem; bottom: .8rem; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: var(--c-accent); color: var(--c-on-accent); font-weight: 800;
  transform: scale(.85); opacity: .85; transition: transform .15s, opacity .15s;
}
.tile:hover, .tile:focus-visible { border-color: var(--c-accent); background: var(--c-surface-3); }
.tile:hover::after, .tile:focus-visible::after { transform: scale(1); opacity: 1; }
.tile .title { font-weight: 800; font-size: 1.05rem; color: var(--c-text); padding-right: 2.5rem; }
.tile .muted { font-size: .9rem; }
.tile img { max-width: 100%; max-height: 120px; object-fit: contain; background: #fff; border-radius: 6px; }

/* --- Scanner -------------------------------------------------------------- */
.scanner { display: flex; flex-direction: column; gap: .9rem; }
.camera-box { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; min-height: 50vh; display: flex; align-items: center; justify-content: center; border: 1px solid var(--c-border); }
.camera-box video { width: 100%; max-height: 70vh; object-fit: contain; display: block; }
.camera-box canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.camera-hint { position: absolute; left: 50%; top: 1rem; transform: translateX(-50%); background: rgba(0, 0, 0, .7); color: #fff; padding: .45rem 1rem; border-radius: 6px; font-weight: 700; border: 1px solid rgba(255, 255, 255, .15); }
.camera-hint.ok { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); }
.mode-select { display: flex; flex-wrap: wrap; gap: .4rem; }
.capture-actions { display: flex; gap: .75rem; justify-content: center; align-items: center; flex-wrap: wrap; }

.editor-stage { position: relative; touch-action: none; user-select: none; background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--c-border); }
.editor-stage canvas { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.corner {
  position: absolute; width: 38px; height: 38px; margin: -19px 0 0 -19px; padding: 0; min-height: 0; border-radius: 50%;
  border: 3px solid #111; background: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft), 0 4px 14px rgba(0, 0, 0, .6); cursor: grab; touch-action: none;
}
.quality { display: flex; flex-wrap: wrap; gap: .4rem; }

.pages-strip { display: flex; gap: .7rem; overflow-x: auto; padding: .25rem 0 .5rem; }
.page-thumb { position: relative; flex: 0 0 auto; width: 104px; margin: 0; border: 1px solid var(--c-border-strong); border-radius: 6px; background: var(--c-surface-2); padding: 4px; }
.page-thumb img { width: 100%; height: 128px; object-fit: contain; display: block; background: #fff; border-radius: 6px; }
.page-thumb .num { position: absolute; top: 8px; left: 8px; background: var(--c-accent); color: var(--c-on-accent); border-radius: 6px; padding: 0 .45rem; font-size: .78rem; font-weight: 800; }
.page-thumb .state { position: absolute; bottom: 38px; right: 8px; }
.page-thumb .tools { display: flex; justify-content: space-between; margin-top: 4px; }
.page-thumb .tools button { padding: 0 .4rem; min-height: 28px; font-size: .8rem; background: none; color: var(--c-muted); border-radius: 6px; }
.page-thumb .tools button:hover:not(:disabled) { color: var(--c-accent); background: var(--c-surface-3); }
.page-thumb figcaption { font-size: .75rem; padding: .2rem; }
.page-thumb .thumb-open { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 6px; }
.page-thumb .thumb-open:focus-visible { outline: 3px solid var(--c-accent); outline-offset: 2px; }
.page-thumb .state.local { background: rgba(20, 20, 20, .78); color: #fff; }
.page-thumb .state.busy { background: var(--c-accent); color: var(--c-on-accent); }
.page-thumb .state.ok { background: var(--c-ok); color: #06290f; }
.page-thumb .state.err { background: var(--c-err); color: #2a0505; }
.page-thumb.sending { border-color: var(--c-accent); box-shadow: 0 0 0 2px var(--c-accent-soft); }
.page-thumb.sending img { opacity: .75; }
.send-bar { position: absolute; left: 8px; right: 8px; bottom: 40px; height: 6px; border-radius: 3px; background: rgba(0, 0, 0, .25); overflow: hidden; }
.send-bar[hidden] { display: none; }
.send-bar i, .send-progress i { display: block; height: 100%; width: 0; background: var(--c-accent); transition: width .2s ease; }
.page-thumb .state { bottom: 50px; }
.send-info { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-height: 1.5rem; margin: .25rem 0 .5rem; font-size: .88rem; }
.send-progress { flex: 1 1 180px; max-width: 320px; height: 8px; border-radius: 4px; background: var(--c-surface-3); overflow: hidden; }
.package-hint { margin: 0 0 .25rem; font-size: .85rem; }
.replace-note { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.page-viewer { display: flex; flex-direction: column; gap: .75rem; }
.page-viewer .viewer-img { background: #fff; border: 1px solid var(--c-border-strong); border-radius: 6px; display: flex; justify-content: center; align-items: center; min-height: 240px; }
.page-viewer .viewer-img img { max-width: 100%; max-height: 62vh; object-fit: contain; display: block; }
.viewer-tools { flex-wrap: wrap; align-items: center; gap: .35rem; }
.viewer-count { font-weight: 700; min-width: 3.5rem; text-align: center; }

/* --- Review / mapping editor ------------------------------------------------ */
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 1fr); gap: 1.25rem; align-items: start; }
.tabs { display: none; }
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .tabs { display: flex; gap: .25rem; margin-bottom: .75rem; background: var(--c-surface-2); padding: .25rem; border-radius: 6px; }
  .tabs button { flex: 1; background: transparent; color: var(--c-muted); }
  .tabs button[aria-selected="true"] { background: var(--c-accent); color: var(--c-on-accent); }
  .split > [data-pane][hidden-mobile] { display: none; }
}
.doc-viewer { position: relative; background: #050506; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: auto; max-height: 80vh; padding: .5rem; }
.doc-viewer .page-wrap { position: relative; margin: 0 auto; width: fit-content; }
.doc-viewer img.page-img { display: block; max-width: 100%; height: auto; border-radius: 6px; }
.doc-viewer svg.ocr-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.ocr-layer rect.word { fill: rgba(255, 214, 10, .04); stroke: rgba(255, 214, 10, .35); stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; }
.ocr-layer rect.word:hover { fill: rgba(255, 214, 10, .15); }
.ocr-layer rect.word.selected { fill: rgba(255, 214, 10, .4); stroke: #c9a800; stroke-width: 2; }
.ocr-layer rect.word.used { fill: rgba(74, 222, 128, .18); stroke: rgba(34, 160, 80, .8); }
.ocr-layer rect.anchor { fill: rgba(196, 181, 253, .18); stroke: #8b5cf6; stroke-width: 2; vector-effect: non-scaling-stroke; }
.ocr-layer rect.region { fill: rgba(17, 17, 17, .06); stroke: #111; stroke-width: 2; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.ocr-layer rect.region.active, .ocr-layer rect.highlight { fill: rgba(255, 214, 10, .3); stroke: #e0b800; stroke-width: 3; stroke-dasharray: none; vector-effect: non-scaling-stroke; }
.ocr-layer rect.drawing { fill: rgba(255, 214, 10, .25); stroke: #e0b800; stroke-width: 2; vector-effect: non-scaling-stroke; }

.fields-list { display: flex; flex-direction: column; gap: .6rem; }
.field-row { border: 1px solid var(--c-border); border-radius: 6px; padding: .75rem .9rem; background: var(--c-surface-2); transition: border-color .15s, box-shadow .15s; }
.field-row[role="button"] { cursor: pointer; }
.field-row:hover { border-color: var(--c-border-strong); }
.field-row.active { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }
.field-row .head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.field-row .head label { font-weight: 700; }
.field-row .msg { font-size: .85rem; color: var(--c-err); margin-top: .3rem; }
.field-row .meta { font-size: .8rem; color: var(--c-muted); margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .25rem .75rem; }
.field-row fieldset { background: var(--c-surface); }

.form-editor .field-def { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr auto auto; gap: .6rem; align-items: end; padding: .75rem 0 .25rem; border-bottom: 1px solid var(--c-border); }
@media (max-width: 900px) { .form-editor .field-def { grid-template-columns: 1fr 1fr; } }
.chip-list { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: .35rem 0; }
.chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--c-surface-3); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: .2rem .7rem; font-size: .85rem; }
.chip button { background: none; border: none; padding: 0 .1rem; min-height: auto; color: var(--c-muted); font-weight: 800; }
.chip button:hover { color: var(--c-err); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0; }
.kv dt { color: var(--c-muted); }
.kv dd { margin: 0; font-weight: 600; }

ul.checks { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .4rem; }
ul.checks li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
ul.checks .badge { min-width: 4.8rem; justify-content: center; }
select.small { min-height: 34px; padding: .2rem .5rem; width: auto; }

@media print {
  #topbar, .toolbar, button { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: none; background: #fff; }
}

/* --- Drawer (slide-over from the right) ------------------------------------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); opacity: 0; transition: opacity .2s; z-index: 60; }
.drawer-backdrop.open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(460px, 100vw);
  display: flex; flex-direction: column; background: var(--c-surface); border-left: 1px solid var(--c-border-strong);
  box-shadow: -20px 0 50px rgba(0, 0, 0, .55); transform: translateX(105%); transition: transform .22s cubic-bezier(.2, .8, .2, 1); outline: none;
}
.drawer.drawer-lg { width: min(620px, 100vw); }
.drawer.drawer-sm { width: min(380px, 100vw); }
.drawer.open { transform: translateX(0); }
.drawer.busy .drawer-body { opacity: .6; pointer-events: none; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.25rem .9rem; padding-top: max(1.1rem, env(safe-area-inset-top)); border-bottom: 1px solid var(--c-border);
}
.drawer-head h2 { margin: 0; font-size: 1.2rem; }
.drawer-head p { margin: .2rem 0 0; font-size: .9rem; }
.drawer-close { flex: 0 0 auto; width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; font-size: 1.5rem; line-height: 1; background: var(--c-surface-3); color: var(--c-text); }
.drawer-close:hover { background: var(--c-accent); color: var(--c-on-accent); }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.1rem 1.25rem 1.5rem; overscroll-behavior: contain; }
.drawer-body h3:first-child { margin-top: 0; }
.drawer-error { color: var(--c-err); padding: 0 1.25rem; }
.drawer-error:not(:empty) { padding: .75rem 1.25rem; background: var(--c-err-bg); border-bottom: 1px solid rgba(248, 113, 113, .35); }
.drawer-footer {
  display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; padding: .9rem 1.25rem;
  padding-bottom: max(.9rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--c-border); background: var(--c-surface);
}
.drawer-footer button.danger { margin-right: auto; }
body.drawer-open-modal { overflow: hidden; }
/* Non-modal drawer (template editor): leave room so the page stays usable next to it */
@media (min-width: 1100px) { body.drawer-open:not(.drawer-open-modal) main { margin-right: 460px; max-width: none; } }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 1.25rem 0 .5rem; }
.section-title h3, .section-title h4 { margin: 0; }

/* --- Page header + lists ---------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--c-muted); flex-basis: 100%; margin: -.25rem 0 0; }
.page-head .spacer { flex: 1; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--c-muted); }
.empty strong { display: block; color: var(--c-text); font-size: 1.1rem; margin-bottom: .35rem; }
.empty button { margin-top: 1rem; }

.item-list { display: flex; flex-direction: column; gap: .5rem; }
.item {
  display: flex; align-items: center; gap: .9rem; width: 100%; text-align: left; font-weight: 400;
  background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: 6px; padding: .8rem 1rem; color: var(--c-text);
  min-height: 60px; border-radius: 6px;
}
.item:hover, .item:focus-visible { border-color: var(--c-accent); background: var(--c-surface-3); }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--c-muted); font-size: .88rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .chev { color: var(--c-muted); font-size: 1.3rem; }
.item .handle { display: flex; flex-direction: column; gap: 2px; }
.item .handle button { min-height: 24px; height: 24px; width: 28px; padding: 0; border-radius: 6px; font-size: .75rem; background: var(--c-surface-3); color: var(--c-muted); }
.item .handle button:hover:not(:disabled) { color: var(--c-accent); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--c-surface-3); color: var(--c-accent); font-weight: 800; flex: 0 0 auto; }
.avatar.inactive { color: var(--c-muted); }

.segmented { display: inline-flex; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: 6px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { background: transparent; color: var(--c-muted); min-height: 34px; padding: .25rem .9rem; font-size: .88rem; }
.segmented button[aria-pressed="true"] { background: var(--c-accent); color: var(--c-on-accent); }
.switch { display: flex; align-items: center; gap: .6rem; margin: .5rem 0 1rem; font-weight: 600; }
.validator-row { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--c-border); }
.validator-row .params { grid-column: 1 / -1; display: flex; gap: .5rem; flex-wrap: wrap; }
.validator-row .params input { flex: 1; min-width: 120px; }

.item .row-main { all: unset; flex: 1; min-width: 0; cursor: pointer; border-radius: 6px; }
.item .row-main:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 4px; }
.region-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; }
.region-grid input { padding: .5rem .45rem; text-align: center; }

/* ---- Full-screen scanner (1.5.1) ------------------------------------------ */
body.cam-open { overflow: hidden; }
.camfs { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; height: 100vh; height: 100dvh; overscroll-behavior: contain; }
.camfs.flash::after { content: ""; position: absolute; inset: 0; background: #fff; opacity: .55; pointer-events: none; animation: cam-flash .18s ease-out forwards; }
@keyframes cam-flash { to { opacity: 0; } }
.cam-live { position: absolute; inset: 0; }
.cam-live video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.cam-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam-top, .cam-bottom { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: .6rem; padding: .75rem max(.9rem, env(safe-area-inset-right)) .75rem max(.9rem, env(safe-area-inset-left)); }
.cam-top { top: 0; padding-top: max(.75rem, env(safe-area-inset-top)); background: linear-gradient(rgba(0,0,0,.72), rgba(0,0,0,0)); padding-bottom: 1.6rem; }
.cam-title { flex: 1; text-align: center; font-weight: 800; font-size: 1rem; text-shadow: 0 1px 3px rgba(0,0,0,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-top-right { display: flex; gap: .4rem; align-items: center; }
.cam-icon { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); color: #fff; border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.cam-icon:hover { background: rgba(0,0,0,.65); }
.cam-icon[aria-pressed="true"] { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); }
.cam-icon.lg { width: 56px; height: 56px; min-height: 56px; }
.cam-chip { min-height: 34px; padding: .25rem .8rem; border-radius: 6px; font-size: .85rem; font-weight: 700; background: rgba(0,0,0,.5); color: #fff; border: 1px solid rgba(255,255,255,.22); white-space: nowrap; }
.cam-chip[aria-pressed="true"] { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); }
.cam-formats { position: absolute; left: 0; right: 0; bottom: calc(118px + env(safe-area-inset-bottom)); display: flex; gap: .45rem; justify-content: center; overflow-x: auto; padding: 0 1rem; scrollbar-width: none; }
.cam-formats::-webkit-scrollbar { display: none; }
.cam-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,.62); color: #fff; padding: .6rem 1.2rem; border-radius: 6px; font-weight: 700; font-size: 1rem; border: 1px solid rgba(255,255,255,.15); pointer-events: none; white-space: nowrap; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: background .2s, color .2s; }
.cam-hint.ok { background: rgba(255,214,10,.92); color: var(--c-on-accent); border-color: var(--c-accent); }
.cam-bottom { bottom: 0; justify-content: space-between; padding-bottom: max(1.1rem, env(safe-area-inset-bottom)); padding-top: 2.2rem; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.78)); }
.cam-bottom > * { flex: 0 0 auto; }
.shutter { position: relative; width: 80px; height: 80px; min-height: 80px; padding: 0; border-radius: 50%; background: none; border: 0; display: inline-flex; align-items: center; justify-content: center; }
.shutter:disabled { opacity: .5; }
.shutter-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.shutter-ring circle { fill: none; stroke-width: 5; }
.shutter-ring .track { stroke: #fff; }
.shutter-ring .progress { opacity: 0; stroke: var(--c-accent); stroke-dasharray: 100; stroke-dashoffset: 100; stroke-linecap: round; transition: stroke-dashoffset .12s linear; }
.shutter-core { width: 62px; height: 62px; border-radius: 50%; background: #fff; transition: transform .12s, background .2s; }
.shutter:active .shutter-core { transform: scale(.9); }
.shutter.holding .shutter-core { background: var(--c-accent); }
.cam-pages { position: relative; width: 56px; height: 56px; min-height: 56px; padding: 0; border-radius: 6px; overflow: visible; background: #222; border: 2px solid #fff; }
.cam-pages img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; display: block; }
.cam-pages.is-empty { visibility: hidden; }
.cam-count { position: absolute; right: -8px; bottom: -8px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 6px; background: var(--c-accent); color: var(--c-on-accent); font-weight: 800; font-size: .8rem; line-height: 24px; text-align: center; }
.cam-panel { position: absolute; inset: 0; overflow-y: auto; background: var(--c-bg); color: var(--c-text); padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom)); }
.cam-panel-inner { max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: .9rem; }
.cam-panel-inner .actions { position: sticky; bottom: 0; background: linear-gradient(rgba(10,10,11,0), var(--c-bg) 35%); padding: 1.2rem 0 .3rem; }
.preview-img { max-width: 100%; max-height: 62vh; display: block; margin: 0 auto; background: #fff; border-radius: 6px; }
@media (min-width: 900px) { .cam-formats { bottom: auto; top: calc(4.2rem + env(safe-area-inset-top)); } }
@media (prefers-reduced-motion: reduce) { .camfs.flash::after { display: none; } .shutter-ring .progress { transition: none; } }
.shutter.holding .shutter-ring .progress { opacity: 1; }
body.cam-open .toast { bottom: calc(172px + env(safe-area-inset-bottom)); }

/* ---- Icons & compact controls (1.6.0) -------------------------------------- */
.icon { flex: 0 0 auto; display: block; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 6px; background: var(--c-surface-3); color: var(--c-text); border: 1px solid transparent; flex: 0 0 auto; }
.icon-btn:hover:not(:disabled) { color: var(--c-accent); border-color: var(--c-border-strong); }
.icon-btn.with-text { width: auto; padding: 0 1.1rem 0 .85rem; }
.icon-btn.primary { background: var(--c-accent); color: var(--c-on-accent); }
.icon-btn.primary:hover:not(:disabled) { background: var(--c-accent-hover); color: var(--c-on-accent); }
.icon-btn.ghost { background: transparent; border-color: var(--c-border-strong); }
.icon-btn.danger { color: var(--c-err); background: transparent; border-color: rgba(248, 113, 113, .4); }
.icon-btn.small { width: 36px; height: 36px; min-height: 36px; }
.icon-btn.small .icon { width: 18px; height: 18px; }
.icon-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: nowrap; }
.icon-bar .spacer { flex: 1; }
@media (max-width: 760px) {
  .icon-btn.with-text:not(.primary) .btn-text { display: none; }
  .icon-btn.with-text:not(.primary) { width: 44px; padding: 0; }
}
.chips { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; padding: .1rem 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { min-height: 36px; padding: .3rem .85rem; border-radius: 6px; font-size: .88rem; white-space: nowrap; background: var(--c-surface-2); color: var(--c-text); border: 1px solid var(--c-border-strong); display: inline-flex; align-items: center; gap: .35rem; }
.chip[aria-pressed="true"] { background: var(--c-accent); color: var(--c-on-accent); border-color: var(--c-accent); }
.chip .count { font-size: .75rem; opacity: .75; font-weight: 800; }
.step-head { display: flex; align-items: baseline; gap: .6rem .9rem; flex-wrap: wrap; }
.step-head h2 { margin: 0; }
.step-head p { margin: 0; font-size: .9rem; }
.preview-box { position: relative; display: flex; justify-content: center; }
.preview-box .preview-img { max-height: calc(100dvh - 230px); }
.preview-box.busy .preview-img { opacity: .45; }
.preview-box.busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; margin: -18px; border-radius: 50%; border: 4px solid rgba(255,255,255,.25); border-top-color: var(--c-accent); animation: spin .8s linear infinite; }
.cam-panel-inner { gap: .7rem; }
.cam-panel-inner .actions.icon-bar { flex-wrap: nowrap; }
a.icon-btn { text-decoration: none; }
.icon-btn.active { background: var(--c-accent); color: var(--c-on-accent); }
.icon-bar.wrap { flex-wrap: wrap; }
.capture-bar { justify-content: flex-start; }
.card.compact .page-head { margin-bottom: .6rem; }
.card.compact .page-head h1, .card.compact .page-head h2 { font-size: 1.35rem; }

/* search + filter */
.search-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.search-box { flex: 1; display: flex; align-items: center; gap: .5rem; background: var(--c-surface-2); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: 0 .9rem; color: var(--c-muted); min-height: 44px; }
.search-box:focus-within { border-color: var(--c-accent); }
.search-box input { flex: 1; border: 0; background: transparent; min-height: 42px; padding: 0; color: var(--c-text); outline: none; box-shadow: none; }

/* folder navigation */
.folder-bar { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .7rem; }
.folder-bar .chips.sub { padding-left: .9rem; border-left: 2px solid var(--c-border-strong); align-items: center; }
.folder-label { display: inline-flex; align-items: center; gap: .4rem; color: var(--c-text); font-weight: 700; font-size: .92rem; background: var(--c-surface-2); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: .3rem .8rem; min-height: 36px; max-width: 100%; }
.folder-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.folder-label:hover { border-color: var(--c-accent); color: var(--c-accent); }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; margin: .2rem 0 .4rem; }
.file-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .6rem 0 .8rem; }
.case-box { flex: 1 1 220px; display: flex; align-items: center; gap: .45rem; background: var(--c-surface-2); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: 0 .85rem; color: var(--c-muted); min-height: 40px; }
.case-box:focus-within { border-color: var(--c-accent); }
.case-box input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; min-height: 38px; color: var(--c-text); outline: none; box-shadow: none; }

/* document rows */
.doc-row { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem .35rem .35rem; }
.doc-row .doc-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: .7rem; background: none; border: 0; padding: .35rem; text-align: left; color: inherit; min-height: 44px; border-radius: 6px; }
.doc-ico { width: 38px; height: 38px; border-radius: 6px; background: var(--c-surface-3); display: inline-flex; align-items: center; justify-content: center; color: var(--c-accent); flex: 0 0 auto; }
.pager { margin-top: .7rem; margin-bottom: 0; }
.empty .icon { margin: 0 auto .5rem; color: var(--c-muted); }
.page-thumb .tools { gap: 2px; }
.page-thumb .tools .icon-btn { width: 30px; height: 30px; min-height: 30px; background: none; }
.page-thumb .tools .icon-btn .icon { width: 16px; height: 16px; }
.page-thumb .tools .icon-btn:disabled { opacity: .3; }

@media (max-width: 760px) {
  main { padding: .7rem; }
  .card { padding: .9rem; margin-bottom: .7rem; }
  .doc-row .badge { display: none; }
  .doc-row .doc-ico { width: 34px; height: 34px; }
  .card.compact .page-head h1 { font-size: 1.2rem; }
}

/* ===== SCANDESK 1.7.0 ======================================================== */
main { max-width: 980px; }
.toast { bottom: max(1.25rem, env(safe-area-inset-bottom)); }

/* start page */
.home { max-width: 560px; margin: 0 auto; }
.eyebrow { color: var(--c-accent); font-weight: 800; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; margin: .6rem 0 .3rem; }
.eyebrow.section { margin-top: 1.6rem; }
.hero { font-size: 2.3rem; line-height: 1.08; font-weight: 900; letter-spacing: -.02em; margin: 0 0 .25rem; }
.lead { color: var(--c-muted); margin: 0 0 1.1rem; }
.hero-card { position: relative; display: flex; flex-direction: column; gap: .2rem; padding: 1.1rem 1.1rem 1.2rem; min-height: 160px; justify-content: flex-end;
  background: var(--c-accent); color: #111; border-radius: 6px; text-decoration: none; margin-bottom: .75rem; }
.hero-card:hover { background: var(--c-accent-hover); color: #111; }
.hero-card strong { font-size: 1.9rem; font-weight: 800; letter-spacing: -.01em; }
.hero-card small { font-size: .95rem; }
.hero-ico { position: absolute; top: 1rem; left: 1rem; width: 48px; height: 48px; border-radius: 6px; background: #111; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.hero-arrow { position: absolute; top: 1rem; right: 1rem; }
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.tile-grid.small .tile-link { min-height: 104px; }
.tile-link { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 132px; padding: 1rem; border-radius: 6px;
  background: var(--c-surface); border: 1px solid var(--c-border-strong); color: var(--c-text); text-decoration: none; }
.tile-link:hover { border-color: var(--c-accent); color: var(--c-text); }
.tile-ico { color: var(--c-accent); }
.tile-text { display: flex; flex-direction: column; gap: .15rem; }
.tile-text strong { font-size: 1.05rem; }
.tile-text small { color: var(--c-muted); font-size: .82rem; }
.tile-badge { position: absolute; top: .8rem; right: .8rem; min-width: 22px; height: 22px; border-radius: 6px; background: var(--c-accent); color: #111; font-weight: 800; font-size: .78rem; display: inline-flex; align-items: center; justify-content: center; padding: 0 .35rem; }
.draft-hint { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; margin-bottom: .75rem; border: 1px dashed var(--c-accent-line); border-radius: 6px; color: var(--c-text); text-decoration: none; }
.draft-hint span { flex: 1; }
.home-foot { display: flex; align-items: center; gap: .5rem; margin-top: 1.4rem; padding-top: .9rem; border-top: 1px solid var(--c-border); color: var(--c-muted); font-size: .85rem; }
.home-foot .icon { color: var(--c-accent); }
.home-foot .spacer { flex: 1; }
.type-row { width: 100%; text-align: left; }
.type-row .thumb { width: 48px; height: 60px; object-fit: cover; border-radius: 4px; background: #fff; flex: 0 0 auto; }
.type-row.unknown { margin-top: .6rem; border-style: dashed; }

/* lists: chips, cards, pills */
.list-page { max-width: 900px; margin: 0 auto; }
.chips.big .chip { min-height: 44px; padding: .4rem .95rem; font-size: .95rem; font-weight: 700; gap: .45rem; }
.chips.big { margin-bottom: .8rem; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-accent); margin-left: -.2rem; align-self: flex-start; }
.chip[aria-pressed="true"] .dot { background: #111; }
.chip.danger { color: var(--c-err); border-color: rgba(248, 113, 113, .45); }
.chip.small { min-height: 32px; font-size: .82rem; padding: .2rem .7rem; }
.card-list { display: flex; flex-direction: column; gap: .7rem; }
.doc-card, .req-card { position: relative; display: flex; align-items: center; gap: .6rem; padding: .7rem .6rem .7rem 1.1rem; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 6px; color: var(--c-text); text-align: left; width: 100%; }
.doc-card:hover, .req-card:hover { border-color: var(--c-accent-line); }
.accent-bar { position: absolute; left: .45rem; top: 22%; bottom: 22%; width: 4px; border-radius: 2px; background: var(--c-accent); }
.doc-card .doc-open { flex: 1; min-width: 0; display: flex; gap: .85rem; align-items: center; background: none; border: 0; padding: 0; color: inherit; text-align: left; min-height: 0; }
.thumb-box { position: relative; width: 62px; height: 76px; flex: 0 0 auto; border-radius: 4px; background: #f4f4f4; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; color: #777; }
.thumb-box img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.pdf-badge { position: absolute; right: 3px; bottom: 3px; background: #e5383b; color: #fff; font-size: .62rem; font-weight: 800; padding: 1px 4px; border-radius: 3px; letter-spacing: .03em; }
.doc-main, .req-main { display: flex; flex-direction: column; gap: .3rem; min-width: 0; flex: 1; }
.doc-title { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: .3rem; }
.doc-title .icon { color: var(--c-accent); }
.doc-meta { display: flex; align-items: center; gap: .35rem; color: var(--c-muted); font-size: .88rem; flex-wrap: wrap; }
.doc-meta .icon:nth-of-type(2) { margin-left: .5rem; }
.tags { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.tag { border: 1px solid var(--c-accent-line); color: var(--c-accent); background: var(--c-accent-soft); border-radius: 6px; padding: .05rem .55rem; font-size: .8rem; font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: .35rem; border-radius: 6px; padding: .3rem .7rem; font-weight: 700; font-size: .85rem; border: 1px solid var(--c-accent-line); color: var(--c-accent); background: transparent; white-space: nowrap; }
.pill.new { background: var(--c-accent); color: #111; border-color: var(--c-accent); }
.pill.done, .pill.st-finalized { color: var(--c-ok); border-color: rgba(74, 222, 128, .45); background: var(--c-ok-bg); }
.pill.rejected { color: var(--c-err); border-color: rgba(248, 113, 113, .45); background: var(--c-err-bg); }
.pill.st-request { color: var(--c-info); border-color: rgba(125, 211, 252, .45); background: var(--c-info-bg); }
.doc-card .kebab { width: 36px; min-width: 36px; border: 0; background: none; }
.req-card { padding-right: .8rem; }
.req-head { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.req-head strong { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-head small { color: var(--c-muted); white-space: nowrap; }
.req-msg { display: flex; gap: .45rem; align-items: flex-start; color: var(--c-text); font-size: .92rem; }
.req-msg .icon { color: var(--c-muted); margin-top: .1rem; }
.req-msg.note { color: var(--c-muted); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin: .9rem 0; color: var(--c-muted); }
.list-foot { display: flex; align-items: center; gap: .7rem; margin-top: 1rem; padding: .8rem 0; color: var(--c-muted); }
.list-foot span { display: flex; flex-direction: column; }
.list-foot strong { color: var(--c-text); font-weight: 600; }
.list-foot .spacer { flex: 1; }
.with-fab { padding-bottom: 6rem; }
.fab-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; justify-content: center; padding: .9rem 1rem max(.9rem, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--c-bg) 40%); pointer-events: none; }
.fab-bar .fab { pointer-events: auto; width: min(100%, 520px); height: 58px; min-height: 58px; font-size: 1.15rem; font-weight: 800; justify-content: center; }
.fab-bar .fab .btn-text { display: inline !important; }
.data-table td.warn { color: var(--c-warn); }
.data-table td.warn .icon { display: inline; vertical-align: -2px; margin-left: .2rem; }
.data-table td.empty-val { color: var(--c-muted); }
.nowrap { white-space: nowrap; }
.menu-list { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: .8rem; padding: .85rem .5rem; background: none; border: 0; border-bottom: 1px solid var(--c-border); color: var(--c-text); text-align: left; text-decoration: none; border-radius: 0; font-weight: 600; min-height: 50px; }
.menu-item:hover { color: var(--c-accent); background: var(--c-surface-2); }
.menu-item.danger { color: var(--c-err); }
@media (max-width: 560px) {
  .doc-card .pill { display: none; }
  .hero { font-size: 2rem; }
}

/* settings */
.settings { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: .9rem; padding-bottom: 5.5rem; }
.set-card { background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: .4rem 1rem .3rem; }
.set-title { display: flex; align-items: center; gap: .8rem; font-size: 1.25rem; margin: .7rem 0 .4rem; }
.set-title .icon { color: var(--c-accent); }
.set-row { display: flex; align-items: center; gap: .8rem; padding: .65rem 0; border-top: 1px solid var(--c-border); min-height: 54px; }
.set-row:first-child { border-top: 0; }
.set-ico { color: var(--c-muted); display: inline-flex; width: 26px; justify-content: center; flex: 0 0 auto; }
.set-label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.set-label label { font-weight: 600; }
.set-label small { color: var(--c-muted); font-size: .8rem; }
.set-row > select, .set-row > input:not(.switch) { width: auto; max-width: 52%; min-width: 150px; }
.set-value { color: var(--c-accent); font-weight: 600; text-align: right; }
.set-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; align-items: center; gap: .6rem; padding: .8rem max(1rem, calc((100vw - 760px) / 2)) max(.8rem, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--c-bg) 35%); color: var(--c-muted); }
.set-foot .spacer { flex: 1; }
.set-foot .icon-btn.primary { height: 52px; min-height: 52px; padding: 0 1.4rem; font-size: 1.05rem; }
input.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 30px; min-height: 30px; border-radius: 15px; background: var(--c-surface-3); border: 1px solid var(--c-border-strong); position: relative; cursor: pointer; flex: 0 0 auto; padding: 0; transition: background .15s; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #d4d4d8; transition: transform .15s; }
input.switch:checked { background: var(--c-accent); border-color: var(--c-accent); }
input.switch:checked::after { transform: translateX(22px); background: #fff; }
input.switch:disabled { opacity: .45; }

/* scanner (SCANDESK) */
.cam-head { position: absolute; left: 0; right: 0; top: 0; padding: max(.6rem, env(safe-area-inset-top)) .8rem .5rem; background: linear-gradient(rgba(0,0,0,.85), rgba(0,0,0,.55) 75%, transparent); }
.cam-top { position: static; display: flex; align-items: center; gap: .6rem; padding: 0; background: none; }
.cam-brand { flex: 1; display: flex; align-items: center; justify-content: center; gap: .6rem; color: #fff; min-width: 0; }
.cam-brand .logo { width: 42px; height: 42px; }
.cam-brand .brand-text strong { font-size: 1.3rem; }
.cam-brand .brand-text small { color: #c9c9cf; }
.cam-icon { border-radius: 6px; }
.cam-icon.sq { width: 46px; height: 46px; min-height: 46px; background: rgba(0,0,0,.55); }
.cam-icon:disabled { opacity: .4; }
.cam-page { display: block; text-align: center; color: #e5e5e5; font-weight: 700; margin-top: .25rem; }
.steps { list-style: none; display: flex; justify-content: space-between; gap: .4rem; margin: .55rem 0 0; padding: .45rem 0; border-top: 1px solid rgba(255,255,255,.18); border-bottom: 1px solid rgba(255,255,255,.18); }
.steps li { display: flex; align-items: center; gap: .45rem; color: #bdbdc4; font-weight: 600; font-size: .95rem; }
.step-no { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #8a8a92; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .95rem; }
.steps li.active { color: var(--c-accent); }
.steps li.active .step-no { background: var(--c-accent); border-color: var(--c-accent); color: #111; }
.steps li.done .step-no { border-color: var(--c-accent); color: var(--c-accent); }
.cam-panel .steps { border-color: var(--c-border-strong); }
.cam-panel .steps li { color: var(--c-muted); }
.cam-tools { position: absolute; right: .6rem; top: calc(150px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: .5rem; }
.cam-tool { width: 74px; min-height: 66px; padding: .4rem .2rem; display: flex; flex-direction: column; align-items: center; gap: .1rem; border-radius: 6px;
  background: rgba(12,12,14,.72); border: 1px solid rgba(255,255,255,.2); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.cam-tool .tool-label { font-size: .78rem; font-weight: 600; }
.cam-tool .tool-val { font-size: .7rem; font-weight: 800; color: #bdbdc4; padding: 0 .4rem; border-radius: 4px; }
.cam-tool.on .tool-val { background: var(--c-accent); color: #111; }
.cam-tool:disabled { opacity: .45; }
.cam-bottom { flex-direction: column; align-items: stretch; gap: .6rem; padding-top: 2.5rem; }
.cam-seg { display: flex; background: rgba(12,12,14,.8); border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 3px; align-self: center; width: min(100%, 420px); }
.cam-seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 42px; border-radius: 4px; background: transparent; color: #fff; font-weight: 700; padding: 0 .6rem; border: 0; }
.cam-seg button[aria-pressed="true"] { background: var(--c-accent); color: #111; }
.cam-strip { display: flex; align-items: center; gap: .55rem; background: rgba(12,12,14,.78); border: 1px solid rgba(255,255,255,.18); border-radius: 6px; padding: .45rem .55rem; }
.cam-thumbs { display: flex; gap: .4rem; }
.cam-thumb { position: relative; width: 42px; height: 54px; border-radius: 4px; background: #333; overflow: hidden; border: 2px solid transparent; }
.cam-thumb:last-child { border-color: var(--c-accent); }
.cam-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cam-thumb .no { position: absolute; right: 0; bottom: 0; background: #111; color: #fff; font-size: .7rem; font-weight: 800; padding: 0 4px; border-top-left-radius: 4px; }
.cam-pagecount { background: none; border: 0; color: #fff; font-weight: 700; padding: 0 .3rem; min-height: 40px; white-space: nowrap; }
.cam-strip .spacer { flex: 1; }
.cam-controls { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.cam-gallery { background: none; border: 0; color: #fff; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: 0; min-height: 0; width: 84px; }
.cam-gallery .cam-icon { width: 54px; height: 54px; }
.cam-gallery small { font-size: .8rem; }
.shutter { width: 92px; height: 92px; min-height: 92px; }
.shutter-ring .track { stroke: var(--c-accent); }
.shutter-core { width: 72px; height: 72px; background: var(--c-accent); color: #111; display: inline-flex; align-items: center; justify-content: center; }
.shutter.holding .shutter-core { background: #fff; }
.shutter-ring .progress { stroke: #fff; }
.cam-done { min-width: 84px; min-height: 50px; padding: 0 1rem; border-radius: 6px; background: var(--c-accent); color: #111; font-weight: 800; display: inline-flex; align-items: center; gap: .4rem; border: 0; }
.cam-done:disabled { opacity: .45; }
.cam-hint { top: 46%; }
.cam-help { position: absolute; left: 1rem; right: 1rem; top: calc(150px + env(safe-area-inset-top)); z-index: 3; background: rgba(12,12,14,.94); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: 1rem 1.1rem; color: #fff; }
.cam-help h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
.cam-help ul { margin: 0 0 .8rem; padding-left: 1.1rem; }
.cam-help li { margin: .25rem 0; }
@media (max-width: 380px) { .cam-tool { width: 64px; } .cam-done { padding: 0 .7rem; } .steps .step-label { font-size: .85rem; } }

/* light theme ("Dunkles Design" off) */
[data-theme="light"] {
  --c-bg: #f3f3f1; --c-surface: #ffffff; --c-surface-2: #f6f6f4; --c-surface-3: #ececea;
  --c-border: #e2e2de; --c-border-strong: #d2d2cd; --c-text: #141416; --c-muted: #5e5e66;
  --c-accent-soft: rgba(255, 214, 10, .22); --c-accent-line: rgba(176, 140, 0, .55);
  --shadow: 0 8px 24px rgba(0, 0, 0, .12);
  color-scheme: light;
}
[data-theme="light"] body { background-image: none; }
[data-theme="light"] #topbar { background: rgba(243, 243, 241, .94); }
[data-theme="light"] a, [data-theme="light"] .tag, [data-theme="light"] .pill, [data-theme="light"] .set-value, [data-theme="light"] .eyebrow, [data-theme="light"] .tile-ico, [data-theme="light"] .set-title .icon { color: #8a6d00; }
[data-theme="light"] .pill.new, [data-theme="light"] .hero-card { color: #111; }
[data-theme="light"] .thumb-box { background: #e9e9e6; }

/* compact lists */
body.compact .doc-card, body.compact .req-card { padding-top: .4rem; padding-bottom: .4rem; }
body.compact .thumb-box { width: 44px; height: 54px; }
body.compact .card-list { gap: .4rem; }
body.compact .doc-meta { font-size: .8rem; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
main:focus, main:focus-visible { outline: none; }
.toast { bottom: calc(6rem + env(safe-area-inset-bottom)); }
.set-label { flex: 1 1 45%; }
.set-value { flex: 0 1 auto; max-width: 55%; overflow-wrap: anywhere; }
.set-row > .chip { flex: 0 0 auto; }
.set-ver { font-size: .85rem; }
@media (max-width: 420px) { .set-ver { display: none; } }
.list-foot small { white-space: nowrap; }
[data-theme="light"] .tile-link, [data-theme="light"] .draft-hint, [data-theme="light"] .menu-item, [data-theme="light"] #topbar .brand { color: var(--c-text); }
[data-theme="light"] .hero-card, [data-theme="light"] .hero-card:hover { color: #111; }

/* installation screen */
.install-gate { max-width: 520px; margin: 1.5rem auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.inst-logo { width: 96px; height: 96px; border-radius: 6px; background: var(--c-accent); color: #111; display: inline-flex; align-items: center; justify-content: center; }
.install-gate h1 { font-size: 2rem; font-weight: 900; margin: .4rem 0 0; }
.inst-btn { height: 60px; min-height: 60px; padding: 0 2rem; font-size: 1.15rem; font-weight: 800; }
.inst-steps { list-style: none; padding: 0; margin: .4rem 0; display: flex; flex-direction: column; gap: .6rem; text-align: left; width: 100%; }
.inst-step { display: flex; gap: .8rem; align-items: center; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: .8rem 1rem; }
.inst-step .step-no { border-color: var(--c-accent); color: var(--c-accent); flex: 0 0 auto; }
.inst-step .icon { display: inline; vertical-align: -3px; color: var(--c-accent); }
.inst-done { display: flex; gap: .8rem; align-items: flex-start; text-align: left; background: var(--c-ok-bg); border: 1px solid rgba(74, 222, 128, .45); border-radius: 6px; padding: 1rem; color: var(--c-text); }
.inst-done .icon { color: var(--c-ok); flex: 0 0 auto; }
.inst-done p { margin: .3rem 0 0; }
#topbar span.brand { display: flex; align-items: center; gap: .7rem; }

/* 1.8.0: settings links, folder administration, guide */
.set-link { color: var(--c-text); text-decoration: none; }
.set-link:hover { color: var(--c-accent); }
.set-link-title { font-weight: 600; }
.section-head { display: flex; align-items: center; gap: .6rem; margin: 1.2rem 0 .6rem; }
.section-head h2 { margin: 0; }
.section-head .spacer { flex: 1; }
.admin-folders .notice { display: flex; gap: .5rem; align-items: flex-start; }
.folder-card { position: relative; display: flex; align-items: center; gap: .8rem; padding: .7rem .8rem .7rem 1.1rem; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 6px; color: var(--c-text); text-align: left; width: 100%; min-height: 0; }
.folder-card:hover { border-color: var(--c-accent-line); }
.folder-card code { font-size: .78rem; }
.type-pick { border: 1px solid var(--c-border-strong); border-radius: 6px; padding: .5rem .8rem; margin: .8rem 0; }
.type-pick legend { font-weight: 700; padding: 0 .3rem; }
.check-row { display: flex; gap: .7rem; align-items: flex-start; padding: .45rem 0; cursor: pointer; }
.check-row input { margin-top: .25rem; width: 20px; height: 20px; min-height: 20px; flex: 0 0 auto; }
.check-row span { display: flex; flex-direction: column; }
.check-row small { color: var(--c-muted); }
.guide { max-width: 760px; margin: 0 auto; }
.guide h1 { font-size: 1.8rem; margin-bottom: .3rem; }
.guide-overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 1rem 0 1.2rem; }
.guide-overview div { background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 6px; padding: .7rem; display: flex; flex-direction: column; gap: .2rem; }
.guide-overview .icon { color: var(--c-accent); }
.guide-overview small { color: var(--c-muted); }
@media (max-width: 560px) { .guide-overview { grid-template-columns: 1fr 1fr; } }
.guide-step { background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: 6px; margin-bottom: .6rem; }
.guide-step summary { list-style: none; display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; cursor: pointer; font-weight: 700; }
.guide-step summary::-webkit-details-marker { display: none; }
.guide-step summary > .icon:first-of-type { color: var(--c-accent); }
.guide-step summary > .icon:last-child { margin-left: auto; color: var(--c-muted); transition: transform .15s; }
.guide-step[open] summary > .icon:last-child { transform: rotate(90deg); }
.guide-step .step-no { border-color: var(--c-accent); color: var(--c-accent); flex: 0 0 auto; }
.g-title { flex: 1; }
.g-body { padding: 0 1rem .9rem 1rem; border-top: 1px solid var(--c-border); }
.g-body ol, .g-body ul { padding-left: 1.3rem; }
.g-body li { margin: .35rem 0; }
.g-body h3 { margin-top: 1rem; }
.ui { color: var(--c-accent); font-weight: 700; }
[data-theme="light"] .ui { color: #8a6d00; }
.tip { display: flex; gap: .5rem; align-items: flex-start; background: var(--c-accent-soft); border-left: 3px solid var(--c-accent); border-radius: 4px; padding: .6rem .8rem; margin: .7rem 0 0; }
.tip .icon { color: var(--c-accent); flex: 0 0 auto; margin-top: .15rem; }
.tip.warn { background: var(--c-warn-bg); border-left-color: var(--c-warn); }
.tip.warn .icon { color: var(--c-warn); }
.guide-check { margin-top: 1.2rem; background: var(--c-surface); border: 1px solid var(--c-accent-line); border-radius: 6px; padding: .4rem 1rem .8rem; }
.guide-check h2 { display: flex; align-items: center; gap: .5rem; }
.guide-check .icon { color: var(--c-accent); }
.folder-card .doc-title { white-space: normal; }
.folder-card code { word-break: break-all; }
@media (max-width: 560px) { .folder-card .pill { display: none; } }
.qr svg { width: min(260px, 80vw); height: auto; display: block; margin: 1rem auto; background: #fff; padding: 8px; border-radius: 6px; }
/* start screen while the modules load (diagnostics from boot-check.js only if loading fails) */
.splash { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; text-align: center; }
.splash-logo { width: 84px; height: 84px; animation: splash-pulse 1.2s ease-in-out infinite; }
.splash-name { font-size: 1.6rem; font-weight: 900; letter-spacing: .02em; margin: .6rem 0 0; }
.splash-sub { color: var(--c-muted); margin: 0; }
@keyframes splash-pulse { 50% { transform: scale(.94); opacity: .8; } }
@media (prefers-reduced-motion: reduce) { .splash-logo { animation: none; } }

/* ---- Document-type wizard ------------------------------------------------ */
.wiz-steps { list-style: none; display: flex; gap: .35rem; margin: .4rem 0 1rem; padding: 0; counter-reset: none; }
.wiz-steps li { flex: 1 1 0; min-width: 0; }
.wiz-steps button, .wiz-steps .wiz-stepbox { width: 100%; display: flex; align-items: center; gap: .45rem; padding: .45rem .5rem; min-height: 40px; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--radius-sm); color: var(--c-muted); font-weight: 700; font-size: .9rem; text-align: left; }
.wiz-steps button:disabled, .wiz-steps .wiz-stepbox.off { opacity: .55; }
.wiz-steps .step-no { flex: 0 0 auto; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 1.5px solid currentColor; font-size: .8rem; }
.wiz-steps .step-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiz-steps li.active button, .wiz-steps li.active .wiz-stepbox { color: var(--c-accent); border-color: var(--c-accent-line); background: var(--c-accent-soft); }
.wiz-steps li.active .step-no { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.wiz-steps li.done button, .wiz-steps li.done .wiz-stepbox { color: var(--c-text); }
.wiz-steps li.done .step-no { border-color: var(--c-ok); color: var(--c-ok); }
.wiz-body h2 { margin: .2rem 0 .6rem; font-size: 1.15rem; }
.wiz-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.wiz-preset { display: flex; align-items: center; gap: .7rem; padding: .75rem .85rem; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--radius); color: var(--c-text); text-align: left; min-height: 60px; }
.wiz-preset span { display: flex; flex-direction: column; }
.wiz-preset small { color: var(--c-muted); font-weight: 500; }
.wiz-preset svg { color: var(--c-accent); flex: 0 0 auto; }
.wiz-preset[aria-checked="true"] { border-color: var(--c-accent); background: var(--c-accent-soft); }
.wiz-switch { align-self: end; padding-bottom: .7rem; }
.wiz-fields { display: flex; flex-direction: column; gap: .45rem; margin-bottom: .5rem; }
.wiz-field { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.wiz-field > input[type=text] { flex: 1 1 180px; min-width: 0; }
.wiz-field > select { flex: 0 0 150px; }
.wiz-field > select.wiz-page { flex-basis: 105px; }
.wiz-field input[type=text], .wiz-field select { margin: 0; }
.wiz-req { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--c-muted); }
.wiz-chip { cursor: pointer; border: 1px dashed var(--c-border-strong); background: transparent; color: var(--c-text); min-height: 34px; }
.wiz-chip:hover { border-color: var(--c-accent); color: var(--c-accent); }
.wiz-options { display: flex; flex-direction: column; gap: .45rem; margin-bottom: .6rem; }
.wiz-option { display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface-2); cursor: pointer; }
.wiz-option:has(input:checked) { border-color: var(--c-accent); background: var(--c-accent-soft); }
.wiz-option span { display: flex; flex-direction: column; }
.wiz-option small { color: var(--c-muted); }
.wiz-summary { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 .8rem; }
.wiz-summary dt { color: var(--c-muted); }
.wiz-summary dd { margin: 0; font-weight: 600; }
.wiz-nav { display: flex; align-items: center; gap: .6rem; margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--c-border); flex-wrap: wrap; }
.wiz-nav .spacer { flex: 1; }
@media (max-width: 560px) {
  .wiz-steps .step-label { display: none; }
  .wiz-steps li.active .step-label { display: inline; }
  .wiz-steps li.active { flex: 3 1 0; }
  .wiz-field > input[type=text] { flex-basis: 100%; }
  .wiz-field > select { flex: 1 1 120px; }
  .wiz-req span { display: none; }
}

/* wizard bar inside the template editor */
.wizbar { position: sticky; top: var(--hdr-h, 0px); z-index: 5; background: var(--c-surface); box-shadow: 0 6px 16px rgba(0,0,0,.35); border-color: var(--c-accent-line); }
.wizbar .wiz-steps { margin: 0 0 .6rem; }
.wizbar .wiz-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.wizbar .wiz-hint { flex: 1 1 260px; margin: 0; }
.wizbar .wiz-hint small { display: block; color: var(--c-muted); }
.wiz-done { text-align: center; padding: 2rem 1rem; }
.wiz-done .big-check { width: 64px; height: 64px; margin: 0 auto .8rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--c-ok-bg); color: var(--c-ok); }
.wiz-done .actions { justify-content: center; flex-wrap: wrap; }
.wiz button, .wizbar button { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; white-space: nowrap; }
.wiz .wiz-steps button { justify-content: flex-start; }
.ref-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .45rem; min-height: 240px; padding: 1.5rem; text-align: center; border: 1px dashed var(--c-border-strong); border-radius: var(--radius); background: var(--c-surface-2); color: var(--c-text); }
.ref-empty svg { color: var(--c-accent); }
.ref-empty[hidden] { display: none; }
.badge.auto-orient { background: var(--c-accent-soft); color: var(--c-accent); display: inline-flex; align-items: center; gap: .25rem; }

/* "Zu sortieren": unsorted documents (without type) */
.sort-banner { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; margin-bottom: 1rem; border: 1px solid var(--c-accent-line); background: var(--c-accent-soft); border-radius: var(--radius); color: var(--c-text); text-decoration: none; }
.sort-banner[hidden] { display: none; }
.sort-banner small { display: block; color: var(--c-muted); }
.sort-banner .sort-ico { color: var(--c-accent); display: inline-flex; }
.sort-banner .sort-count { min-width: 30px; height: 30px; padding: 0 .5rem; border-radius: 15px; background: var(--c-accent); color: var(--c-on-accent); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.sort-banner .grow { flex: 1; }
.wiz-done .similar { text-align: left; margin-top: 1.5rem; }
.mini-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: var(--radius-sm); background: #fff; flex: 0 0 auto; }
label.item { display: flex; align-items: center; gap: .7rem; cursor: pointer; }
.sort-list { display: flex; flex-direction: column; gap: .4rem; max-height: 340px; overflow: auto; }
.sort-item { display: flex; align-items: center; gap: .7rem; text-align: left; }
.sort-item.active { border-color: var(--c-accent); background: var(--c-accent-soft); }
.sort-item .thumb-box { width: 56px; height: 56px; flex: 0 0 auto; }
.sort-work .doc-viewer, .sort-work .page-wrap { max-width: 100%; }
.sort-section h3 { display: flex; align-items: center; gap: .35rem; margin: .2rem 0 .4rem; }
.wiz-field.live { display: grid; grid-template-columns: minmax(0, 1fr) 130px minmax(0, 120px) auto; }
.live-state { display: inline-flex; align-items: center; gap: .25rem; font-size: .8rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.live-state span { overflow: hidden; text-overflow: ellipsis; }
.live-state.ok { color: var(--c-ok); }
.live-state.miss { color: var(--c-muted); }
@media (max-width: 560px) { .wiz-field.live { display: grid; grid-template-columns: minmax(0, 1fr) auto; } .wiz-field.live select, .wiz-field.live .live-state { grid-column: 1 / -1; } }
.tag.untyped { border-color: rgba(251, 191, 36, .4); color: var(--c-warn); background: var(--c-warn-bg); }
.notice.untyped { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* buttons with icon + text: always in one row (no icon stacked above the label) */
button:has(> svg) { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
/* template editor: one tool bar above the scan */
.editor-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .5rem; }
.editor-tools .tool-group { display: flex; flex-wrap: wrap; gap: .4rem; }
.editor-tools .tool { white-space: nowrap; }
.editor-tools kbd, .sel-kbd { font: 600 .7rem/1 var(--font); padding: .15rem .3rem; border-radius: 3px; border: 1px solid currentColor; opacity: .55; margin-left: .15rem; }
@media (max-width: 700px) { .editor-tools kbd { display: none; } }
.sel-text { font-weight: 600; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* fields per page (template editor + review) */
.fields-head { display: flex; align-items: center; gap: .5rem; margin: .8rem 0 .4rem; }
.other-fields { margin-top: .9rem; border-top: 1px solid var(--c-border); padding-top: .6rem; }
.other-fields summary { cursor: pointer; color: var(--c-muted); font-weight: 600; margin-bottom: .4rem; }
.page-fields { border-left: 3px solid transparent; padding-left: .55rem; margin-bottom: .9rem; transition: border-color .15s; }
.page-fields.current { border-left-color: var(--c-accent); }
.page-fields-head { display: flex; align-items: center; gap: .45rem; width: 100%; background: none; border: none; padding: .3rem 0; min-height: 36px; color: var(--c-text); font-weight: 800; font-size: 1rem; justify-content: flex-start; }
button.page-fields-head:hover { color: var(--c-accent); }
.page-fields:not(.current) .page-fields-head { color: var(--c-muted); }
.readiness { display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin: .2rem 0 .4rem; font-size: .9rem; }
.ready-item { display: inline-flex; align-items: center; gap: .3rem; color: var(--c-warn); }
.ready-item.ok { color: var(--c-ok); }
.ready-item button.link { font-size: .85rem; margin-left: .2rem; }
.chip.anchor-miss { border-color: rgba(251, 191, 36, .55); color: var(--c-warn); background: var(--c-warn-bg); }
.scans-list { margin-top: 1rem; }
.scans-list summary { cursor: pointer; font-weight: 700; margin-bottom: .5rem; }
.scan-item { display: flex; align-items: center; gap: .6rem; }
.sugg-row { display: flex; align-items: stretch; gap: .4rem; }
.sugg-row > .item { flex: 1; min-width: 0; }
.sugg-row > .icon-btn { align-self: center; }
.del-row { display: flex; align-items: stretch; gap: .4rem; }
.del-row > .item { flex: 1; min-width: 0; }
.del-row > .del-btn { align-self: center; }
.del-btn:disabled { opacity: .35; }
.danger-zone { margin-top: 1.2rem; padding-top: .8rem; border-top: 1px solid var(--c-border); }
.danger-zone h4 { color: var(--c-err); margin: 0 0 .3rem; }
.del-spacer { width: 44px; flex: 0 0 44px; }
.cases-box { margin-top: 1rem; }
