:root {
  --bg: #f4f2ec; --card: #fff; --ink: #1d2a20; --muted: #6b746c; --line: #e3e0d6;
  --brand: #2f6b3a; --brand-2: #e7f0e5;
  --prosle: #b42318; --m1: #d9480f; --m3: #e8890c; --m6: #b8a200; --ok: #2f8a3f; --unch: #5b6770;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 20px; } h3 { font-size: 17px; }
.muted { color: var(--muted); } .small, small { font-size: 13px; } .center { text-align: center; }
.err, .neg { color: var(--prosle); } .pos { color: var(--ok); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff; }
.top h1 { flex: 1; font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .back { color: #fff; text-decoration: none; font-size: 32px; line-height: 1; padding: 0 6px; }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: #fff; color: var(--brand); font-weight: 800; font-size: 14px; }
.logo.big { width: 64px; height: 64px; font-size: 24px; border-radius: 16px; background: var(--brand); color: #fff; }
.user { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.main { max-width: 760px; margin: 0 auto; padding: 14px 14px 96px; }
.outbox { background: #fff4e5; color: #8a4b00; padding: 6px 14px; font-size: 14px; text-align: center; }

.bottom { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.bottom a { flex: 1; text-align: center; padding: 8px 0 10px; text-decoration: none; color: var(--muted); font-size: 12px; }
.bottom a span { display: block; font-size: 20px; }
.bottom a.on { color: var(--brand); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card.hl { border: 2px solid var(--brand); }
.card.warn, .banner.warn { background: #fff4e5; border-color: #f3c98b; }
.banner { background: var(--brand-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.banner.ok { background: #e3f4e6; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { color: var(--prosle); border-color: #f0b8b3; }
.btn.ghost { background: transparent; }
.btn.block { display: flex; width: 100%; margin-top: 10px; }
.btn.sm { min-height: 34px; padding: 4px 10px; font-size: 14px; font-weight: 500; }
.btn.huge { flex-direction: column; min-height: 88px; font-size: 19px; width: 100%; }
.btn.huge small { font-weight: 400; opacity: .85; }
.btn.grow { flex: 1; }
.btn:focus-visible, .inp:focus-visible { outline: 3px solid #8cc097; outline-offset: 1px; }

.inp { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #cfcabd; border-radius: 10px; font: inherit; background: #fff; color: var(--ink); }
.inp.big { font-size: 24px; text-align: center; font-weight: 600; letter-spacing: .5px; }
textarea.inp { min-height: 80px; }
label { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
label.chk { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.chk input { width: 22px; height: 22px; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; }
.row .inp { flex: 1; }

.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; }
.tile { border-radius: 12px; padding: 12px 4px; text-align: center; color: #fff; text-decoration: none; }
.tile b { display: block; font-size: 28px; line-height: 1.1; }
.tile span { font-size: 12px; }
@media (max-width: 520px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.actions { display: grid; gap: 10px; }
@media (min-width: 620px) { .actions { grid-template-columns: 1fr 1fr; } }
.links { justify-content: center; }

.lv-prosle { background: var(--prosle); } .lv-m1 { background: var(--m1); } .lv-m3 { background: var(--m3); }
.lv-m6 { background: var(--m6); } .lv-ok { background: var(--ok); } .lv-unchecked { background: var(--unch); } .lv-none { background: #a0a69f; }
.pill { display: inline-block; color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; white-space: nowrap; }

.modebar { display: flex; gap: 4px; background: #e6e2d7; padding: 4px; border-radius: 12px; margin-bottom: 10px; }
.modebar.scroll { overflow-x: auto; }
.modebar a { flex: 1; text-align: center; padding: 8px 10px; border-radius: 9px; text-decoration: none; color: var(--ink); font-weight: 600; white-space: nowrap; font-size: 14px; }
.modebar a.on { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.1); }

.scanbox .cam { display: none; position: relative; border-radius: var(--r); overflow: hidden; background: #000; aspect-ratio: 4/3; max-height: 46vh; margin: 0 auto 8px; }
.scanbox.cam-on .cam { display: block; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; }
.scanbox .aim { position: absolute; left: 10%; right: 10%; top: 38%; bottom: 38%; border: 3px solid rgba(255,255,255,.85); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.scanbox .cam-btn { white-space: nowrap; }
.results { margin-top: 6px; }

.list { display: grid; gap: 6px; }
.li { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; text-decoration: none; color: var(--ink); font: inherit; cursor: pointer; margin-bottom: 6px; }
.li-name { display: block; font-weight: 600; }
.li-sub { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }

.prod .kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 10px 0; }
.prod .kv span { color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0; }
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.batch { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.batch.gone { opacity: .55; }
.batch-act { display: flex; gap: 6px; flex-wrap: wrap; }
.hist { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); align-items: center; font-size: 14px; }
.hist.gone { opacity: .5; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details > summary.btn { margin-top: 10px; }

.qty { display: grid; grid-template-columns: 60px 1fr 60px; gap: 8px; }
.qty .btn { font-size: 24px; }
.quick { justify-content: flex-start; }
.exp-preview { min-height: 24px; margin-top: 6px; }

.login { max-width: 420px; margin: 0 auto; padding: 40px 16px; }
.brand { text-align: center; margin-bottom: 20px; }
.brand h1 { margin-top: 10px; }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.names .btn { min-height: 60px; font-size: 18px; }
.pin-dots { text-align: center; font-size: 30px; letter-spacing: 10px; color: var(--brand); margin: 6px 0 14px; }
.pin-dots span { color: #c9c4b6; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad .key { min-height: 62px; font-size: 24px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: #1d2a20; color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; transition: .25s; z-index: 50; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--prosle); } .toast.warn { background: #8a4b00; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal .card { width: 100%; max-width: 380px; }

#print { display: none; }
@media print {
  body > *:not(#print) { display: none !important; }
  #print { display: block; color: #000; font: 12pt/1.3 Arial, sans-serif; }
  #print h1 { font-size: 20pt; }
  #print table { width: 100%; border-collapse: collapse; }
  #print th, #print td { border-bottom: 1px solid #999; padding: 5px 4px; text-align: left; }
  #print td:last-child { width: 30px; border: 1px solid #999; }
}
.row.wrap .inp { min-width: 120px; }
.update { position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 30; background: #1d2a20; color: #fff; padding: 10px 14px; border-radius: 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.inp-wrap { position: relative; flex: 1; display: flex; }
.inp-wrap .inp { padding-right: 40px; }
.clr-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: transparent; font-size: 24px; color: var(--muted); cursor: pointer; }
.li-wrap { display: flex; gap: 6px; align-items: stretch; margin-bottom: 6px; }
.li-wrap .li { margin-bottom: 0; flex: 1; min-width: 0; }
.li-wrap .ne { align-self: center; white-space: nowrap; }
.ne.on { background: #a0a69f; color: #fff; border-color: #a0a69f; }
.li-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px; margin-bottom: 8px; }
.li-card .li { border: 0; padding: 6px 6px; }
.li-card .li-wrap { margin-bottom: 0; }
.qe { display: grid; grid-template-columns: 1fr 70px auto; gap: 6px; align-items: center; padding: 4px 6px 4px; }
.qe .inp { min-height: 40px; padding: 6px 8px; text-align: center; font-weight: 600; }
.qe .qe-msg { grid-column: 1 / -1; min-height: 0; }
.qe.done .qe-msg { color: var(--ok); font-weight: 600; }
.qi { grid-template-columns: 80px auto 1fr; }
.qi .qe-s { justify-self: start; }
.qi.with-exp { grid-template-columns: 80px 1fr auto; }
