:root {
  --bg: #0E1113; --bar: #0B0D0F; --s1: #171B1F; --s2: #1F252B; --line: #2A3138; --line2: #3A434C;
  --text: #F2F4F5; --text2: #C9D1D8; --muted: #9AA4AD;
  --accent: #FF7A1A; --accent-ink: #0E1113; --accent-bg: #2A1C10;
  --info: #8CC4FF; --info-bg: #13263A; --info-line: #24486E; --dot-online: #4DA3FF;
  --paper: #F2F4F5; --paper-ink: #0E1113; --paper-muted: #3D454C; --paper-line: #C9D1D8;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --display: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: 'Barlow', system-ui, -apple-system, sans-serif; -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: contain; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); height: 60px; padding: 0 16px;
  padding-top: env(safe-area-inset-top); box-sizing: content-box;
  display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--s2); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-family: var(--display); font-size: 23px; font-weight: 700; letter-spacing: .02em; line-height: 1; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.pill { height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line); background: var(--s1);
  font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 5px; background: var(--dot-online); }
.dot.off { background: var(--accent); }

main { flex: 1; padding: 16px 16px 110px; display: flex; flex-direction: column; gap: 12px; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--bar);
  border-top: 1px solid var(--s2); padding-bottom: env(safe-area-inset-bottom); }
.tabbar-inner { max-width: 560px; margin: 0 auto; height: 72px; display: grid; grid-template-columns: repeat(4, 1fr); }
.tab { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; font-size: 13px; font-weight: 600; position: relative; }
.tab[aria-current="page"] { color: var(--accent); }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 20px; height: 20px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: flex;
  align-items: center; justify-content: center; padding: 0 5px; }

.card { background: var(--s1); border: 1px solid var(--line); border-radius: 16px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px; }
.card.focus { border: 2px solid var(--accent); }
.card.done { border-color: var(--info-line); }
.kicker { font-size: 13px; font-weight: 600; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.h-display { font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1.08; margin: 0; }
.sub { font-size: 15px; color: var(--text2); line-height: 1.35; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 7px; background: var(--s2); border: 1px solid var(--line2); }
.chip.info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 3px 7px; border-radius: 6px; background: var(--line); color: var(--text2); }
.tag.sig { background: var(--accent); color: var(--accent-ink); }
.tag.add { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-line); }
.tag.warn { background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent); }

.btn { min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--s1); font-size: 17px;
  font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 16px; }
.btn.primary { border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 18px; min-height: 56px; }
.btn.dashed { border-style: dashed; background: transparent; }
.btn.small { min-height: 44px; font-size: 15px; border-radius: 12px; padding: 0 14px; }
.btn.tiny { min-height: 44px; width: 46px; padding: 0; border-radius: 12px; background: var(--s2); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--s1); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--display); font-size: 24px; font-weight: 700; }
.stat .mono { font-size: 22px; font-weight: 600; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }
.accent { color: var(--accent); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--s1); border: 1px solid var(--line); }
.seg button { height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--text2); font-size: 15px; font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.part-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.part-name { font-size: 17px; font-weight: 600; line-height: 1.2; }
.part-net { font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1; text-align: right; }
.part-rate { font-size: 13px; font-weight: 700; color: var(--accent); text-align: right; margin-top: 3px; }
.note { padding: 9px 11px; border-radius: 10px; font-size: 14px; background: var(--s2); border: 1px solid var(--line2); }
.note.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.note.warn { background: var(--accent-bg); border-color: var(--accent); }
.timer { flex: 1; border-radius: 12px; border: 2px solid var(--accent); background: var(--accent-bg); padding: 6px 12px; }
.timer .mono { font-size: 24px; font-weight: 600; }
.pulled { flex: 1; min-width: 0; min-height: 46px; border-radius: 12px; background: var(--info-bg); border: 1px solid var(--info-line);
  color: var(--info); display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 14px; font-weight: 600; }
.pulled small { color: var(--text2); font-weight: 500; display: block; }

.viewfinder { position: relative; height: 280px; border-radius: 20px; background: #07090A; border: 1px solid var(--line); overflow: hidden; }
#reader { position: absolute; inset: 0; }
/* Live camera: let the scanner library size the video itself, so its scan
   box (the only guide shown) sits exactly over the region it decodes. */
.viewfinder.live { height: auto; min-height: 200px; }
.viewfinder.live #reader { position: relative; inset: auto; }
#reader video { display: block; width: 100% !important; height: auto !important; }
#reader #qr-shaded-region { border-color: rgba(7, 9, 10, 0.55) !important; }
#reader #qr-shaded-region > div { background-color: var(--accent) !important; }
.vf-idle { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 14px; text-align: center; padding: 20px; }
.vf-frame { position: absolute; left: 50%; top: 50%; width: min(86%, 320px); height: 112px; transform: translate(-50%, -50%); pointer-events: none; }
.vf-frame i { position: absolute; width: 26px; height: 26px; border: 0 solid var(--accent); }
.vf-frame i:nth-child(1) { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 8px; }
.vf-frame i:nth-child(2) { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 8px; }
.vf-frame i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 8px; }
.vf-frame i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 8px; }
.vf-tools { position: absolute; right: 10px; top: 10px; display: flex; gap: 8px; z-index: 2; }
.vf-tools button { height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: rgba(14,17,19,.8); font-size: 14px; font-weight: 600; }

label.lbl { font-size: 13px; font-weight: 600; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.input { height: 52px; width: 100%; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg); padding: 0 12px; font-size: 17px; }
.input.mono { font-family: var(--mono); letter-spacing: .05em; }
select.input { appearance: none; }
.field { display: flex; flex-direction: column; gap: 6px; }

.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--s1); border: 1px solid var(--s2); text-align: left; width: 100%; }
.group { background: var(--s1); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.group-h { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.group-r { padding: 12px 14px; border-bottom: 1px solid var(--s2); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.group-r:last-child { border-bottom: 0; }

.paper { background: var(--paper); color: var(--paper-ink); border-radius: 16px; padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.paper .pm { color: var(--paper-muted); }
.paper .times { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 10px 12px; border-radius: 10px; background: #E2E6E9; font-size: 14px; }
.paper .times span { display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--paper-muted); }
.paper .lines { display: grid; grid-template-columns: minmax(0, 1fr) 64px 88px; gap: 6px 6px; align-items: center; }
.paper .lines .hd { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--paper-muted); border-bottom: 1px solid var(--paper-line); padding-bottom: 6px; }
.paper input { width: 88px; height: 40px; border: 1px solid #9AA4AD; border-radius: 8px; background: #fff; color: var(--paper-ink); text-align: right; padding: 0 8px; font-family: var(--mono); font-size: 15px; }
.paper .tot { border-top: 2px solid var(--paper-ink); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.paper .tot div { display: flex; justify-content: space-between; }
.r { text-align: right; }
.state-sent { color: #1E5A9C; font-weight: 700; font-size: 12px; }
.state-error { color: #B54708; font-weight: 700; font-size: 12px; }

.toast { position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(528px, calc(100% - 32px));
  z-index: 40; background: var(--paper); color: var(--paper-ink); border-radius: 12px; padding: 12px 14px; font-size: 15px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.sheet-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(5,7,8,.66); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--s1); border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line2); align-self: center; }
.sku-box { border-radius: 14px; border: 2px solid var(--accent); padding: 12px 14px; }
.sku-box .mono { font-size: 26px; font-weight: 600; letter-spacing: .04em; word-break: break-all; }
.conds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.conds button { height: 64px; border-radius: 12px; border: 1px solid var(--line); background: var(--s2); color: var(--text2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-weight: 600; font-size: 13px; }
.conds button b { font-family: var(--display); font-size: 22px; line-height: 1; }
.conds button[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-bg); color: var(--text); }
.photo-prev { width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }

.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 24px; max-width: 460px; margin: 0 auto; }
