:root {
  --green: #17644F; --green-dark: #0F4A3A; --green-soft: #DDEEE7;
  --ink: #15201C; --muted: #55625D; --line: #D5DCD8; --ground: #F3F5F4;
  --ok-bg: #E2F2EA; --ok-fg: #14513A; --warn-bg: #FCEFD2; --warn-fg: #6B4600;
  --err-bg: #FBE3DF; --err-fg: #A1261A; --info-bg: #E3ECF7; --info-fg: #183F72;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body.dark { background: #0F1A16; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff; border-bottom: 1px solid #E1E6E3; padding: 12px 16px; }
.title { font-size: 18px; font-weight: 800; }
.subtitle { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.conn { border: 0; display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: 18px;
  font-size: 12px; font-weight: 800; background: var(--ok-bg); color: var(--ok-fg); }
.conn .dot { width: 8px; height: 8px; border-radius: 4px; background: #2F8F65; }
.conn.off { background: var(--warn-bg); color: var(--warn-fg); }
.conn.off .dot { background: #D99A1E; }

main { max-width: 520px; margin: 0 auto; padding: 16px 16px 40px; }
.step { display: flex; flex-direction: column; gap: 14px; }
.step[hidden] { display: none; }
h2 { margin: 6px 0 0; font-size: 15px; font-weight: 800; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: #E4E9E6; border-radius: 14px; padding: 4px; }
.seg button { border: 0; height: 46px; border-radius: 11px; font-size: 14.5px; font-weight: 800; background: transparent; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.cam { position: relative; height: 260px; border-radius: 22px; overflow: hidden; background: #0A1210; }
.cam.tall { height: 52vh; min-height: 300px; border: 2px solid rgba(255,255,255,.15); }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame { position: absolute; inset: 0; pointer-events: none; }
.frame i { position: absolute; width: 30px; height: 30px; border: 4px solid #6FE0B4; }
.frame i:nth-child(1) { left: 14%; top: 22%; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.frame i:nth-child(2) { right: 14%; top: 22%; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.frame i:nth-child(3) { left: 14%; bottom: 22%; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.frame i:nth-child(4) { right: 14%; bottom: 22%; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.frame b { position: absolute; left: 17%; right: 17%; top: 50%; height: 2px; background: #6FE0B4; box-shadow: 0 0 12px #6FE0B4; }
.cam-msg { position: absolute; left: 12px; right: 12px; bottom: 12px; text-align: center; font-size: 12.5px; font-weight: 600; color: #DCE6E1; text-shadow: 0 1px 2px #000; }

.manual { display: flex; gap: 8px; }
.manual input { flex: 1; min-width: 0; height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: #fff; }
.manual button { border: 0; width: 64px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 800; }

.log { list-style: none; margin: 0; padding: 2px 14px; background: #fff; border-radius: 16px; }
.log li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid #EDF0EE; font-size: 13.5px; font-weight: 600; }
.log li:last-child { border-bottom: 0; }
.log li span:first-child { flex: 1; line-height: 1.35; }
.log .st { font-size: 11px; font-weight: 800; border-radius: 8px; padding: 3px 8px; white-space: nowrap; }
.st.ok { background: var(--ok-bg); color: var(--ok-fg); }
.st.wait { background: var(--warn-bg); color: var(--warn-fg); }
.st.err { background: var(--err-bg); color: var(--err-fg); }
.log .empty { color: var(--muted); font-weight: 500; }

.card { background: #fff; border-radius: 18px; padding: 16px; }
.prod { display: flex; gap: 14px; align-items: center; }
.thumb { width: 64px; height: 64px; border-radius: 16px; background: var(--green-soft); color: var(--green); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 800; overflow: hidden; background-size: cover; background-position: center; }
.thumb.photo { width: 84px; height: 84px; font-size: 11px; color: var(--muted); background-color: #fff; border: 2px dashed #B9C4BF; }
.thumb.has { border: 0; font-size: 0; }
.pname { font-size: 18px; font-weight: 800; }
.pinfo { font-size: 13px; color: var(--muted); line-height: 1.4; margin: 2px 0 0; }
.light { color: #fff; }
.pinfo.light { color: #B9C7C1; }

.hint { background: var(--info-bg); color: var(--info-fg); border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 600; line-height: 1.4; }
.label { font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .04em; }
.label small { font-weight: 600; }
.chips { display: grid; gap: 6px; }
.chips.locs { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
.chips.qty { grid-template-columns: repeat(6, 1fr); }
.chips button { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; min-height: 46px; font-weight: 800; font-size: 14px; padding: 4px 2px; }
.chips.qty button { font-size: 16px; }
.chips.locs button.on { background: var(--green-soft); color: var(--green-dark); border-color: var(--green); }
.chips.qty button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips small { display: block; font-size: 11px; font-weight: 600; opacity: .8; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field input { height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: #fff; font-size: 15px; min-width: 0; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.mic { border: 0; width: 48px; height: 48px; border-radius: 12px; background: var(--green-soft); color: var(--green); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mic.rec { background: var(--err-bg); color: var(--err-fg); }

.primary { border: 0; background: var(--green); color: #fff; font-weight: 800; border-radius: 16px; }
.primary.out { background: var(--ink); }
.big { height: 56px; font-size: 15.5px; }
.link { border: 0; background: none; color: var(--green); font-weight: 700; font-size: 14px; padding: 10px 0; align-self: flex-start; }
.link.light { color: #fff; text-decoration: underline; align-self: center; font-size: 15px; }
.shutter-row { display: flex; justify-content: center; }
.shutter { width: 78px; height: 78px; border-radius: 39px; background: #fff; border: 5px solid rgba(255,255,255,.35); background-clip: padding-box; }

.toast { position: fixed; left: 16px; right: 16px; bottom: 20px; max-width: 488px; margin: 0 auto; z-index: 5;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 13px 16px; font-size: 13.5px; font-weight: 700; line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); }
