:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1b1f24; --muted: #5d6673; --line: #e3e6ea;
  --accent: #0f6e66; --accent-ink: #fff; --accent-soft: #e5f2f0;
  --warn: #8a5a00; --warn-bg: #fff4d6; --err: #a3242b; --err-bg: #fde8e8; --ok: #1d6b35; --ok-bg: #e3f5e8;
  --r: 14px; --tap: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(32px + var(--safe-b)); }
header.top { position: sticky; top: 0; z-index: 5; background: rgba(246,247,249,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
header.top .in { max-width: 1100px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; display: flex; align-items: center; gap: 10px; min-height: 56px; }
header.top h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 650; letter-spacing: -.01em; }
.iconbtn { min-width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; color: var(--ink); padding: 0 10px; }
.iconbtn:hover { background: #eceef1; }
.iconbtn svg { width: 22px; height: 22px; }
h2 { font-size: 22px; margin: 6px 0 14px; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.btn { min-height: var(--tap); padding: 0 20px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink); }
.btn:active { transform: scale(.99); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { min-height: 72px; font-size: 20px; width: 100%; border-radius: 16px; }
.btn.danger { color: var(--err); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 22px; height: 22px; }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.s-ok { background: var(--ok-bg); color: var(--ok); }
.s-warn { background: var(--warn-bg); color: var(--warn); }
.s-err { background: var(--err-bg); color: var(--err); }
.s-info { background: var(--accent-soft); color: var(--accent); }
.areas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.area { text-align: left; padding: 18px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; cursor: pointer; min-height: 96px; }
.area b { display: block; font-size: 18px; }
.area.p b::before, .area.t b::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; }
.area.p b::before { background: #5b6cff; } .area.t b::before { background: var(--accent); }
.list { display: flex; flex-direction: column; gap: 8px; }
.doc { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: center; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; text-align: left; width: 100%; }
.doc .no { font-weight: 700; font-variant-numeric: tabular-nums; }
.doc .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .m { grid-column: 2 / 4; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.tag.P { background: #eceeff; color: #3c48c9; } .tag.T { background: var(--accent-soft); color: var(--accent); }
label.f { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 15px; }
.input, select.input { width: 100%; min-height: var(--tap); border: 1px solid #cfd4da; border-radius: 12px; padding: 0 14px; background: #fff; }
.input:focus, .btn:focus-visible, .area:focus-visible { outline: 3px solid rgba(15,110,102,.25); border-color: var(--accent); }
.input.need { border-color: #e2b13c; background: #fffcf2; }
.hint { font-size: 13px; margin-top: 5px; color: var(--muted); }
.hint.warn { color: var(--warn); font-weight: 600; }
.hint.err { color: var(--err); font-weight: 600; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: #eceef1; padding: 4px; border-radius: 12px; }
.seg button { min-height: 46px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-weight: 600; }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); color: var(--accent); }
.seg.need { outline: 2px solid #e2b13c; }
.chk { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.chk input { width: 22px; height: 22px; accent-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
#toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); background: #1b1f24; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: min(92vw, 520px); font-size: 15px; display: none; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
#toast.on { display: flex; gap: 12px; align-items: center; }
#toast button { background: #fff; color: #1b1f24; border: 0; border-radius: 8px; padding: 8px 12px; font-weight: 700; cursor: pointer; }
.banner { padding: 12px 14px; border-radius: 12px; margin: 10px 0; font-size: 15px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.err { background: var(--err-bg); color: var(--err); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }

/* Kamera */
.cam { position: fixed; inset: 0; background: #000; color: #fff; z-index: 20; display: flex; flex-direction: column; }
.cam video { flex: 1; width: 100%; min-height: 0; object-fit: contain; background: #000; }
.cam .bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px)); gap: 10px; }
.cam .bottom { padding: 12px 16px calc(18px + var(--safe-b)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.cam .strip { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 8px; min-height: 76px; }
.cam .strip img, .cam .strip .ph { height: 68px; width: 50px; object-fit: cover; border-radius: 6px; border: 2px solid rgba(255,255,255,.6); flex: none; background: #333; }
.cam .strip .ph { display: grid; place-items: center; font-size: 11px; }
.shutter { width: 84px; height: 84px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.25); cursor: pointer; }
.shutter:active { background: #fff; }
.cam .cbtn { color: #fff; background: rgba(255,255,255,.14); border: 0; border-radius: 12px; min-height: 48px; padding: 0 14px; font-weight: 600; cursor: pointer; }
.cam .cbtn.primary { background: #fff; color: #000; }
.cam .count { font-weight: 700; font-size: 17px; }
.cam .nocam { flex: 1; display: grid; place-items: center; text-align: center; padding: 20px; }

/* Seiten */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pg { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.pg.drag { opacity: .35; } .pg.over { outline: 3px dashed var(--accent); }
.pg img { width: 100%; aspect-ratio: 3/4; object-fit: contain; background: #f0f2f4; border-radius: 8px; display: block; pointer-events: none; }
.pg .n { position: absolute; top: 14px; left: 14px; background: rgba(0,0,0,.65); color: #fff; font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.pg .handle { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 8px; background: rgba(255,255,255,.9); border: 1px solid var(--line); display: grid; place-items: center; cursor: grab; touch-action: none; }
.pg .acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 6px; }
.pg .acts button { min-height: 44px; border: 0; border-radius: 8px; background: #f1f3f5; cursor: pointer; display: grid; place-items: center; }
.pg .acts svg { width: 20px; height: 20px; }
.pg .w { font-size: 12px; color: var(--warn); font-weight: 600; margin-top: 4px; }
.ghost { position: fixed; pointer-events: none; z-index: 60; width: 120px; opacity: .9; box-shadow: 0 10px 30px rgba(0,0,0,.25); border-radius: 10px; }
.stickybar { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, rgba(246,247,249,0)); padding: 16px 0 calc(8px + var(--safe-b)); margin-top: 16px; display: flex; gap: 10px; }
.stickybar .btn { flex: 1; }

/* Zuschnitt */
.crop { position: fixed; inset: 0; background: #111; z-index: 30; display: flex; flex-direction: column; color: #fff; }
.crop .stage { flex: 1; position: relative; min-height: 0; display: grid; place-items: center; padding: 24px; touch-action: none; }
.crop .box { position: relative; }
.crop .box img { display: block; max-width: 100%; max-height: 100%; user-select: none; -webkit-user-select: none; pointer-events: none; }
.crop svg.ov { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.crop .hd { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; border: 3px solid #fff; background: rgba(15,110,102,.55); touch-action: none; cursor: grab; }
.crop .tools { padding: 10px 16px calc(14px + var(--safe-b)); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.crop .tools .cbtn { color: #fff; background: rgba(255,255,255,.14); border: 0; border-radius: 12px; min-height: 48px; padding: 0 14px; font-weight: 600; cursor: pointer; }
.crop .tools .cbtn.primary { background: #fff; color: #000; }
.crop .seg { background: rgba(255,255,255,.12); width: 100%; max-width: 560px; }
.crop .seg button { color: #fff; } .crop .seg button.on { color: #000; }

/* Pruefen */
.review { display: grid; gap: 16px; }
@media (min-width: 820px) { .review { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } .review .pv { position: sticky; top: 72px; } }
.pv .imgs { max-height: 70vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: #eef0f2; border-radius: 12px; padding: 10px; }
.pv .imgs img { width: 100%; border-radius: 6px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.fname { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: #f1f3f5; border-radius: 8px; padding: 10px; word-break: break-all; }

/* Abschluss */
.done { text-align: center; padding: 28px 16px; }
.bignum { font-size: clamp(48px, 14vw, 96px); font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; margin: 10px 0; }
.spinner { width: 22px; height: 22px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: sp 0.9s linear infinite; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.filters { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr 1fr; } }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dl.meta dt { color: var(--muted); } dl.meta dd { margin: 0; word-break: break-word; }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet .card { width: min(640px, 100%); border-radius: 18px 18px 0 0; padding-bottom: calc(20px + var(--safe-b)); max-height: 90vh; overflow: auto; }
@media (min-width: 720px) { .sheet { align-items: center; } .sheet .card { border-radius: 18px; } }
.login { max-width: 400px; margin: 10vh auto; }
.catrow { display: flex; gap: 8px; margin-bottom: 8px; }
.catrow .input { flex: 1; }
.busy { position: fixed; inset: 0; background: rgba(246,247,249,.85); z-index: 45; display: grid; place-items: center; text-align: center; font-weight: 600; }
