:root { --navy: #1F3A5F; --ink: #1b1d21; --muted: #6b7280; --line: #e3e6eb; --bg: #f5f6f8; --card: #fff;
  --good: #1e7b4a; --bad: #b42318; --warn: #b54708; --accent: #2563eb; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
header { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 5; }
header a { color: #fff; } .brand { font-weight: 600; } .gear { font-size: 13px; opacity: .85; }
.demo { background: #f59e0b; color: #111; font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-left: 6px; }
.demo:empty { display: none; }
nav { display: flex; gap: 2px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 44px; z-index: 4; }
nav a { padding: 10px 14px; color: var(--ink); white-space: nowrap; border-bottom: 3px solid transparent; }
nav a.on { border-bottom-color: var(--navy); font-weight: 600; }
main { max-width: 980px; margin: 0 auto; padding: 14px 16px 80px; }
h2 { margin: 6px 0 12px; } h3 { margin: 22px 0 8px; font-size: 16px; }
.muted { color: var(--muted); } .bad { color: var(--bad); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 10px 0; }
.bar { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.bar input, .bar select { flex: 1 1 200px; }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid #cfd4dc; border-radius: 8px; background: #fff; width: 100%; }
textarea { min-height: 70px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0; }
label > input, label > select, label > textarea, label > .inline { margin-top: 4px; color: var(--ink); }
.inline { display: flex; gap: 6px; } .inline input { flex: 1; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 10px 0; padding: 4px 12px 8px; }
legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; align-items: end; }
@media (max-width: 600px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border: 0; border-radius: 8px;
  padding: 10px 14px; background: var(--navy); color: #fff; cursor: pointer; white-space: nowrap; }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid #c9d1dc; }
.btn.warn { background: var(--warn); } .btn.sm { padding: 6px 10px; font-size: 13px; } .btn.big { padding: 16px 18px; font-size: 17px; width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.list { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.list.short { max-height: 280px; overflow-y: auto; }
.row { display: grid; grid-template-columns: 110px 1fr 90px 70px auto; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--ink); }
.row:last-child { border-bottom: 0; } .row:hover { background: #f8fafc; }
.btnrow { width: 100%; background: #fff; border: 0; border-bottom: 1px solid var(--line); text-align: left; font: inherit; cursor: pointer; grid-template-columns: 110px 1fr 90px; }
.row .id { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; font-size: 13px; }
.row small { display: block; color: var(--muted); font-size: 12px; } .row .loc { font-family: ui-monospace, monospace; font-size: 13px; color: var(--muted); }
.row .qty { text-align: right; font-weight: 600; } .row .qty.low { color: var(--bad); } .row .q { color: var(--warn); }
@media (max-width: 600px) { .row { grid-template-columns: 96px 1fr 56px; } .row .loc, .row .tag { display: none; } }
.tag { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: #eef2f7; color: #334155; }
.tag.bad { background: #fde8e8; color: var(--bad); }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: 14px; }
th { text-align: left; background: #f1f4f8; font-weight: 600; font-size: 13px; } th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
td input.sm { width: 90px; padding: 6px; }
tr.short td { background: #fff4ed; } tr.done td { color: var(--muted); }
.part { display: grid; grid-template-columns: 170px 1fr; gap: 16px; align-items: start; }
@media (max-width: 600px) { .part { grid-template-columns: 110px 1fr; } }
.qrbox svg { width: 100%; height: auto; display: block; }
.part h2 { margin: 0; font-family: ui-monospace, Menlo, monospace; } .part .big { font-size: 17px; margin: 4px 0; }
dl { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; margin: 10px 0 0; font-size: 14px; } dt { color: var(--muted); } dd { margin: 0; }
.idpreview { font-size: 16px; margin: 4px 0 10px; } .idpreview b { font-family: ui-monospace, monospace; color: var(--navy); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; } .chip { background: #eef2f7; border-radius: 16px; padding: 4px 6px 4px 10px; font: 13px ui-monospace, monospace; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(120px); background: #111827; color: #fff; padding: 10px 16px;
  border-radius: 10px; transition: transform .2s; z-index: 50; max-width: 92vw; }
.toast.show { transform: translateX(-50%); } .toast.bad { background: var(--bad); }
dialog#scanner { border: 0; border-radius: 14px; padding: 12px; width: min(520px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.55); }
.scanhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#scanVideo { width: 100%; border-radius: 10px; background: #000; } #scanH5 { width: 100%; }
#scanForm { display: flex; gap: 8px; }
.pickcard { background: #fff; border: 2px solid var(--navy); border-radius: 16px; padding: 18px; text-align: center; }
.pickloc { font: 700 56px/1.1 ui-monospace, Menlo, monospace; color: var(--navy); }
.pickname { font-size: 20px; font-weight: 600; margin-top: 8px; } .pickqty { font-size: 22px; margin-top: 8px; }
.steps { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; margin: 14px 0; }
.check { font-weight: 700; min-width: 40px; } .check.good { color: var(--good); } .check.bad { color: var(--bad); }
.login { max-width: 420px; margin: 40px auto; }

/* ---------------- fill a box / photos / label images ---------------- */
.boxhead { display: flex; gap: 14px; align-items: center; } .qrmini svg { width: 84px; height: 84px; display: block; }
.boxrow { grid-template-columns: 64px 1fr 70px; } .thumb { width: 56px; height: 56px; border-radius: 8px; background: #eef2f7; overflow: hidden; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; } .pad { padding: 12px; margin: 0; }
.photorow { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; }
.preview { width: 120px; height: 120px; border-radius: 10px; background: #eef2f7; display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 12px; }
.preview img { width: 100%; height: 100%; object-fit: cover; } .photobtn { margin: 0; cursor: pointer; display: inline-block; } .photobtn .btn { pointer-events: none; }
.qtybox { display: flex; gap: 8px; } .qtybox input { text-align: center; font-size: 20px; font-weight: 700; } .qtybox .btn { width: 56px; font-size: 22px; }
.photo-big { margin: 4px 0 10px; } .photo-big img { width: 100%; max-height: 360px; object-fit: contain; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.lblprev { display: flex; flex-wrap: wrap; gap: 10px; } .lblprev img { max-width: 100%; width: 320px; border: 1px solid #c9d1dc; border-radius: 4px; image-rendering: pixelated; background: #fff; }
.btn:disabled { opacity: .5; }

/* ---------------- printing ---------------- */
#printArea { display: none; }
@media print {
  body { background: #fff; } header, nav, main, .toast, dialog { display: none !important; }
  #printArea { display: block; }
  .fmt-img img { display: block; page-break-after: always; break-after: page; }
  .lbl { page-break-after: always; break-after: page; overflow: hidden; font-family: Arial, Helvetica, sans-serif; color: #000; }
  .fmt-eq .lbl, .sheet .lbl { width: 50mm; height: 80mm; padding: 4mm 3mm; display: flex; flex-direction: column; align-items: center; text-align: center; }
  .lbl.eq svg { width: 40mm; height: 40mm; }
  .lbl.eq .n { font-weight: 700; font-size: 10pt; margin-top: 2mm; line-height: 1.15; max-height: 14mm; overflow: hidden; }
  .lbl.eq b { font-size: 12pt; margin-top: 1.5mm; letter-spacing: .3px; } .lbl.eq em { font-style: normal; font-size: 8pt; margin-top: 1mm; }
  .fmt-bin .lbl { width: 62mm; height: 29mm; padding: 1.5mm; display: flex; gap: 2mm; align-items: center; }
  .lbl.bin svg { width: 25mm; height: 25mm; flex: none; }
  .lbl.bin div { display: flex; flex-direction: column; min-width: 0; } .lbl.bin b { font-size: 11pt; }
  .lbl.bin span { font-size: 7pt; line-height: 1.15; max-height: 16mm; overflow: hidden; } .lbl.bin em { font-style: normal; font-weight: 700; font-size: 8pt; margin-top: 1mm; }
  .fmt-a4 .sheet { width: 210mm; height: 297mm; padding: 13.5mm 5mm; display: grid; grid-template-columns: repeat(4, 50mm); grid-template-rows: repeat(3, 80mm);
    gap: 10mm 0; justify-content: center; page-break-after: always; break-after: page; }
  .fmt-a4 .sheet .lbl { page-break-after: auto; break-after: auto; outline: 0.2mm dashed #999; }
  .fmt-quar .lbl { width: 100mm; height: 62mm; padding: 0; }
  .lbl.quar .qh { background: #c62828; color: #fff; font: 700 15pt Arial; text-align: center; padding: 3mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .lbl.quar .ql { display: flex; align-items: flex-end; gap: 3mm; padding: 1.2mm 4mm; font-size: 8pt; } .lbl.quar .ql span { width: 26mm; }
  .lbl.quar .ql i { flex: 1; border-bottom: 0.3mm solid #000; height: 4mm; }
}
