:root {
  --bg: #f3f5f8; --card: #ffffff; --head: #eef2f7; --line: #c9d2dd; --line-soft: #e1e6ed;
  --text: #17202a; --muted: #5b6776; --accent: #1f4e79; --accent-text: #ffffff; --accent-soft: #e3edf7;
  --ok: #1e7a46; --ok-soft: #e3f4ea; --warn: #8a5a00; --warn-soft: #fff3cd; --bad: #b42318; --bad-soft: #fde8e6;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --card: #1b2129; --head: #232b35; --line: #3a4552; --line-soft: #2c3540;
    --text: #e8edf2; --muted: #a3afbd; --accent: #4f8fd0; --accent-text: #0b1220; --accent-soft: #1d3147;
    --ok: #5cc98b; --ok-soft: #173325; --warn: #f0c14b; --warn-soft: #3a2f12; --bad: #f2867a; --bad-soft: #3d1c19;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
#app { max-width: 760px; margin: 0 auto; padding: 0 12px 40px; }
h1 { font-size: 20px; margin: 0; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 12px 0; background: var(--bg); border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 14px 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); font-weight: 600; }
.back::before { content: "←"; font-size: 20px; }

.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 12px; overflow: hidden; }
.box > .head { background: var(--head); border-bottom: 1px solid var(--line); padding: 8px 12px; display: flex; align-items: center; gap: 8px; }
.box > .head h2 { flex: 1; }
.box > .body { padding: 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); font-weight: 600; text-decoration: none; text-align: center; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.big { min-height: 72px; font-size: 20px; }
.btn:disabled { opacity: .55; }
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack > * + * { margin-top: 10px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile { text-align: left; min-height: 74px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.tile b { display: block; font-size: 16px; line-height: 1.25; }
.tile span { font-size: 14px; color: var(--muted); }
.tile.has span { color: var(--ok); }

.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { min-height: 46px; border: 0; background: var(--card); font-weight: 600; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-text); }

.cam { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 62vh; width: 100%; }
.cam video, .cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .aim { position: absolute; left: 10%; right: 10%; top: 38%; height: 24%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; pointer-events: none; }
.cam .label { position: absolute; left: 0; right: 0; top: 0; padding: 10px 12px; background: rgba(0,0,0,.55); color: #fff; font-weight: 600; }
.cam .label .src { font-weight: 400; font-size: 14px; opacity: .9; }
.cam .label.warn { background: rgba(160,90,0,.85); }
.shutter { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.35); }
.shutter:active { background: rgba(255,255,255,.8); }

.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line-soft); }
.list li:first-child { border-top: 0; }
.list li.tap { cursor: pointer; }
.list .no { width: 28px; flex: none; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.list .thumb { width: 46px; height: 46px; flex: none; border-radius: 6px; object-fit: cover; background: var(--head); border: 1px solid var(--line-soft); }
.list .main { flex: 1; min-width: 0; }
.list .main b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.list .main span { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--head); color: var(--muted); margin: 2px 4px 0 0; }
.badge.must { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--head); border-radius: 8px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }

label.field { display: block; margin: 0 0 10px; }
label.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=password], input[type=search], select { width: 100%; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
input.unsure { background: var(--warn-soft); border-color: var(--warn); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters input[type=search] { grid-column: 1 / -1; }
@media (max-width: 480px) { .filters { grid-template-columns: 1fr; } }
.cam.review { aspect-ratio: auto; max-height: 48vh; }
.cam.review img { max-height: 48vh; object-fit: contain; }

.users { display: grid; gap: 10px; }
.users button { min-height: 64px; font-size: 22px; font-weight: 600; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.users button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.error { color: var(--bad); font-weight: 600; margin: 8px 0 0; }
.preview { font-size: 18px; font-weight: 700; padding: 10px 12px; background: var(--head); border-radius: 8px; overflow-wrap: anywhere; }
.photo-big { width: 100%; max-height: 46vh; object-fit: contain; background: #000; border-radius: 8px; display: block; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.codes li input { width: 84px; min-height: 42px; text-transform: uppercase; text-align: center; font-weight: 700; }

.dialog-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 12px; }
.dialog { width: 100%; max-width: 520px; background: var(--card); border-radius: 14px; border: 1px solid var(--line); overflow: hidden; }
.dialog .body { padding: 14px; }
#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%); background: var(--ok); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 700; transition: transform .2s, opacity .2s; z-index: 60; max-width: 92vw; text-align: center; opacity: 0; pointer-events: none; }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.bad { background: var(--bad); }
@media (min-width: 700px) { .dialog-wrap { align-items: center; } .cam { aspect-ratio: 4 / 3; } }
