:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1f2933; --muted: #7b8794;
  --line: #e1e5ea; --primary: #2f6fed; --primary-ink: #fff;
  --pending: #b58105; --attention: #c0392b; --done: #1e824c; --total: #334e68;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column; min-height: 100dvh;
}

#topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 12px; position: sticky; top: 0; z-index: 5; }
.title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.net { color: var(--done); }
.net.off { color: var(--attention); }
.counts { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef1f5; color: var(--muted); }
.chip b { color: var(--ink); }
.chip.total b { color: var(--total); }
.chip.pending b { color: var(--pending); }
.chip.attention b { color: var(--attention); }
.chip.done b { color: var(--done); }

main { flex: 1; overflow-y: auto; padding: 12px; padding-bottom: 76px; }
.view { display: none; }
.view.active { display: block; }

#camwrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 3/4; max-height: 46dvh; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; }
#video { width: 100%; height: 100%; object-fit: cover; }
.camhint { position: absolute; color: #cbd2d9; font-size: 13px; padding: 12px; text-align: center; }
.reticle { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.reticle[hidden] { display: none; }
.reticle span { width: 78%; height: 34%; border: 2px solid rgba(255,255,255,.9); border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.28); }

.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
input, select, button { font: inherit; }
input, select { flex: 1; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); min-width: 0; }
button { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); cursor: pointer; white-space: nowrap; }
button.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
button:active { transform: translateY(1px); }
.manual { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 8px; }
.manual label { font-size: 13px; color: var(--muted); }
.filebtn { display: inline-block; padding: 10px 14px; border: 1px dashed var(--line); border-radius: 10px; cursor: pointer; background: var(--card); flex: 0 0 auto; }
.muted { color: var(--muted); font-size: 13px; }

.last { margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--done); border-radius: 10px; padding: 10px; }
.last.dup { border-left-color: var(--pending); }
.last.warn { border-left-color: var(--attention); }

.toolbar { position: sticky; top: 0; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; gap: 10px; }
.item img.cover { width: 46px; height: 64px; object-fit: cover; border-radius: 4px; background: #eee; flex: 0 0 auto; }
.item .meta { flex: 1; min-width: 0; }
.item .t { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 13px; }
.status { font-size: 11px; padding: 1px 7px; border-radius: 999px; display: inline-block; margin-top: 4px; }
.status.pending { background: #fdf2d6; color: var(--pending); }
.status.in_progress { background: #e6eefc; color: var(--primary); }
.status.found { background: #d9f2e4; color: var(--done); }
.status.not_found, .status.error { background: #fbe0dd; color: var(--attention); }
.item .acts { display: flex; flex-direction: column; gap: 6px; }
.item .acts button { padding: 6px 8px; font-size: 13px; }

#tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); }
#tabs button { flex: 1; border: none; border-radius: 0; padding: 14px; background: none; color: var(--muted); }
#tabs button.active { color: var(--primary); font-weight: 600; box-shadow: inset 0 2px 0 var(--primary); }

.toast { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20; max-width: 90%; }
.toast.warn { background: var(--attention); }
