:root {
  --bg: #f4f5f7; --surface: #ffffff; --ink: #14171c; --muted: #636b78; --line: #dfe2e8;
  --accent: #0a58ff; --accent-ink: #ffffff; --good: #138a4b; --warn: #b35c00; --bad: #c22b2b;
  --radius: 14px; --tap: 52px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --surface: #181c22; --ink: #eef1f5; --muted: #9aa3b0; --line: #2a303a;
    --accent: #4f8bff; --accent-ink: #06122e; --good: #4cc98a; --warn: #f0a24a; --bad: #ff7a7a; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .2px; flex: 1; }
.sync { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

main { max-width: 640px; margin: 0 auto; padding: 12px 16px; }
button { font: inherit; color: inherit; }
button.primary, button.ghost, button.danger { min-height: var(--tap); border-radius: var(--radius); padding: 0 18px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.danger { color: var(--bad); }
button.ghost { min-height: 40px; padding: 0 14px; }
button.block { width: 100%; margin-top: 12px; }
button:disabled { opacity: .5; }

.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: var(--surface); padding: 5px;
  border-radius: var(--radius); border: 1px solid var(--line); }
.modes button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; color: var(--muted); }
.modes button.on { background: var(--accent); color: var(--accent-ink); }

.ctx { margin: 10px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
.ctx .where b { font-size: 18px; }
.ctx .hint { color: var(--muted); font-size: 13px; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.switch input { width: 22px; height: 22px; }

.cam { position: relative; aspect-ratio: 4 / 3; background: #000; border-radius: var(--radius); overflow: hidden; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.reticle { position: absolute; inset: 18% 22%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.25); }
.camMsg { position: absolute; left: 0; right: 0; bottom: 70px; text-align: center; color: #fff; font-size: 14px; padding: 0 16px; }
.camBtn { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); }
.cam.live .camBtn, .cam.live .camMsg { display: none; }
.cam.flash { outline: 4px solid var(--good); outline-offset: -4px; }

.manual { margin-top: 12px; }
input[type=search], input[type=text], input[type=number], input[type=password], input[type=email], input[type=url], select {
  width: 100%; min-height: var(--tap); padding: 0 14px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); }
input[type=number] { font-size: 28px; font-weight: 700; text-align: center; }
.results { display: grid; gap: 6px; margin-top: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); text-align: left; width: 100%; }
.row .nm { font-weight: 600; } .row .sk { color: var(--muted); font-size: 13px; font-family: ui-monospace, Menlo, monospace; }
.row .qty { font-size: 22px; font-weight: 700; }

.bar { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.shelfchip { display: inline-block; margin: 4px 6px 0 0; padding: 2px 8px; border-radius: 8px; background: var(--bg); font-size: 13px; font-family: ui-monospace, Menlo, monospace; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--muted); font-size: 14px; }
.sum { color: var(--muted); font-size: 14px; margin: 8px 0; }
.stockrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.stockrow .qty { grid-row: span 2; align-self: center; font-size: 26px; font-weight: 800; }
.stockrow.zero .qty { color: var(--muted); }

.logrow { padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.logrow .t { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 2px 7px; border-radius: 6px; background: var(--bg); }
.badge.receive { color: var(--good); } .badge.sale { color: var(--bad); } .badge.move { color: var(--accent); } .badge.undo, .badge.count { color: var(--warn); }
.logrow.undone { opacity: .5; text-decoration: line-through; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.card p { margin: 6px 0; color: var(--muted); font-size: 14px; }
.result { margin-top: 8px; font-size: 14px; }
.result.ok { color: var(--good); } .result.bad { color: var(--bad); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottom button { min-height: 60px; border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.bottom button.on { color: var(--accent); }

.sheetWrap { position: fixed; inset: 0; z-index: 20; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { margin: 0; font-size: 20px; line-height: 1.2; }
.sheet .sub { color: var(--muted); font-size: 13px; font-family: ui-monospace, Menlo, monospace; margin: 2px 0 12px; }
.sheet label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.qchips { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.qchips button { min-height: 44px; min-width: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-weight: 700; }
.warnline { color: var(--warn); font-size: 14px; margin-top: 8px; min-height: 20px; }
.errline { color: var(--bad); font-size: 14px; margin-top: 8px; }
.acts { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 16px; }
.acts.one { grid-template-columns: 1fr; }
.shelfline { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }

.toast { position: fixed; left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top)); z-index: 30; max-width: 616px; margin: 0 auto;
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toast button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 10px; min-height: 36px; padding: 0 12px; font-weight: 700; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; padding: 10px 12px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid var(--warn); font-size: 14px; }
.banner button { min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--warn); background: transparent; font-weight: 700; color: var(--ink); white-space: nowrap; }

.camRow { justify-content: space-between; margin: 10px 0; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 48px; font-size: 16px; color: var(--ink); font-weight: 600; }
.camRow input { width: 28px; height: 28px; }

.teamRow { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; display: grid; gap: 8px; }
.teamRow small { color: var(--muted, #777); margin-left: 6px; }
