:root {
  --bg: #f3f5f8; --card: #ffffff; --text: #14202b; --muted: #5b6b7a; --line: #dbe2ea;
  --brand: #0e3a5c; --brand-2: #1d6fa5; --accent: #0a8f6a; --warn: #b7791f; --danger: #c0392b;
  --frozen: #2563eb; --cooler: #0891b2; --dry: #a16207; --flex: #6b7280;
  --radius: 12px; --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0d141b; --card: #16212c; --text: #e7edf3; --muted: #93a4b5; --line: #263544;
    --brand: #0b2c46; --brand-2: #4aa3df; }
}
:root[data-theme="dark"] { --bg: #0d141b; --card: #16212c; --text: #e7edf3; --muted: #93a4b5; --line: #263544; --brand: #0b2c46; --brand-2: #4aa3df; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { padding-top: calc(56px + var(--safe-t)); padding-bottom: calc(68px + var(--safe-b)); }
a { color: var(--brand-2); }
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; height: calc(56px + var(--safe-t));
  padding: var(--safe-t) 8px 0; display: flex; align-items: center; gap: 8px; background: var(--brand); color: #fff; }
.topbar h1 { flex: 1; font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; color: #fff; font-size: 22px; border-radius: 10px; }
.icon-btn:active { background: rgba(255,255,255,.15); }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60px;
  text-decoration: none; color: var(--muted); font-size: 12px; }
.tabbar a span { font-size: 22px; line-height: 1; margin-bottom: 2px; }
.tabbar a.active { color: var(--brand-2); font-weight: 600; }
.tabbar a.scan-tab span { background: var(--brand-2); color: #fff; border-radius: 50%; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center; margin-top: -14px; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.page { max-width: 1100px; margin: 0 auto; padding: 12px 16px 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 17px; margin: 0 0 10px; }
.card h3 { font-size: 15px; margin: 14px 0 8px; }
.grid { display: grid; gap: 12px; }
.grid.kpis { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .grid.kpis { grid-template-columns: repeat(4, 1fr); } .grid.two { grid-template-columns: 1fr 1fr; } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 700; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--brand-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
  padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.success { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.bigbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bigbtns .btn { min-height: 72px; flex-direction: column; font-size: 15px; }
.bigbtns .btn span { font-size: 24px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; min-height: var(--tap); padding: 10px 12px; font-size: 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
textarea { min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 420px) { .form-grid { grid-template-columns: 1fr; } }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a, .list .item { display: flex; gap: 10px; align-items: center; padding: 12px 2px; text-decoration: none; color: inherit; min-height: 56px; }
.list .main { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .meta { color: var(--muted); font-size: 13px; }
.chev { color: var(--muted); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; background: var(--flex); }
.tag.frozen { background: var(--frozen); } .tag.cooler { background: var(--cooler); } .tag.dry { background: var(--dry); }
.tag.ok { background: var(--accent); } .tag.warn { background: var(--warn); } .tag.bad { background: var(--danger); }
.tag.outline { background: transparent; color: var(--muted); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.seg button { flex: 1; min-height: 42px; border: 0; background: var(--card); color: var(--text); font-size: 14px; font-weight: 600; }
.seg button.on { background: var(--brand-2); color: #fff; }
.locmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 3px; }
.locmap a { display: block; height: 30px; border-radius: 4px; background: var(--line); font-size: 9px; color: var(--muted);
  text-decoration: none; text-align: center; line-height: 30px; overflow: hidden; }
.locmap a.full { background: var(--brand-2); color: #fff; }
.locmap a.frozen.full { background: var(--frozen); } .locmap a.cooler.full { background: var(--cooler); } .locmap a.dry.full { background: var(--dry); }
.aisle { margin-bottom: 12px; }
.aisle h4 { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
#reader { width: 100%; max-width: 480px; margin: 0 auto; border-radius: 12px; overflow: hidden; background: #000; min-height: 60px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); background: #14202b; color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: .95; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.check input { width: 24px; height: 24px; min-height: 0; }
.pill-list { display: flex; gap: 6px; flex-wrap: wrap; }
.notice { background: #fff7e0; color: #5c4400; border: 1px solid #f0d58a; padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
@media (prefers-color-scheme: dark) { .notice { background: #3a2f10; color: #f3df9f; border-color: #6b5520; } }
.print-only { display: none; }

/* ---------- print ---------- */
@media print {
  body { padding: 0; background: #fff; color: #000; }
  .no-print, .page, .tabbar, .topbar, .toast { display: none !important; }
  .print-only { display: block !important; }
}
.label4x6 { width: 4in; height: 6in; padding: .2in; page-break-after: always; font-family: Arial, sans-serif; color: #000;
  display: flex; flex-direction: column; border: 1px dashed #bbb; }
@media print { .label4x6 { border: 0; } }
.label4x6 .co { font-size: 11pt; font-weight: 700; border-bottom: 2px solid #000; padding-bottom: 4px; display: flex; justify-content: space-between; }
.label4x6 .lpn { font-size: 30pt; font-weight: 800; text-align: center; letter-spacing: 1px; margin: 4px 0; }
.label4x6 .qr { text-align: center; }
.label4x6 .qr svg { width: 2.3in; height: 2.3in; }
.label4x6 table { font-size: 11pt; margin-top: 4px; }
.label4x6 td { padding: 3px 2px; border-bottom: 1px solid #000; color: #000; }
.label4x6 td:first-child { width: 34%; font-weight: 700; }
.label4x6 .zone { margin-top: auto; text-align: center; font-size: 22pt; font-weight: 800; border: 3px solid #000; padding: 2px; }
.loclabel { width: 4in; height: 2in; padding: .12in; page-break-after: always; display: flex; align-items: center; gap: .15in;
  font-family: Arial, sans-serif; color: #000; border: 1px dashed #bbb; }
@media print { .loclabel { border: 0; } }
.loclabel svg { width: 1.7in; height: 1.7in; }
.loclabel .code { font-size: 28pt; font-weight: 800; }
.doc { font-family: Arial, sans-serif; color: #000; padding: .4in; font-size: 10.5pt; max-width: 8.5in; }
.doc h1 { font-size: 18pt; margin: 0 0 4px; }
.doc table { font-size: 10pt; }
.doc th, .doc td { border: 1px solid #000; padding: 4px 6px; color: #000; }
.doc th { background: #eee; text-transform: none; font-size: 9.5pt; }
.doc .boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.doc .box { border: 1px solid #000; padding: 6px 8px; min-height: 70px; }
.doc .box b { display: block; font-size: 9pt; text-transform: uppercase; margin-bottom: 3px; }
.doc .sig { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 24px; }
.doc .sig div { border-top: 1px solid #000; padding-top: 4px; font-size: 9pt; }
.doc .right { text-align: right; }
.list .title a, .list .meta a { display: inline; padding: 0; min-height: 0; color: var(--brand-2); }

/* ---------- v2 ---------- */
.tabbar a.desk { display: none; }
@media (min-width: 1000px) {
  body { padding-left: 220px; padding-bottom: 24px; }
  .tabbar { top: calc(56px + var(--safe-t)); bottom: 0; right: auto; width: 210px; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 8px 0; overflow-y: auto; }
  .tabbar a, .tabbar a.desk { display: flex; flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; height: 46px; padding: 0 18px; font-size: 15px; }
  .tabbar a span { width: 22px; text-align: center; margin: 0; font-size: 18px; }
  .tabbar a.scan-tab span { width: 22px; height: auto; margin: 0; background: none; color: inherit; box-shadow: none; border-radius: 0; }
  .tabbar a.mob { display: none; }
  .tabbar a.active { background: var(--bg); }
  .page { padding: 20px 28px; }
  .bigbtns { grid-template-columns: repeat(3, 1fr); }
  .toast { bottom: 24px; }
}
.notice.bad-notice { background: #fde8e6; color: #7a1c12; border-color: #f2b8b0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .notice.bad-notice { background: #3d1612; color: #f6c3bc; border-color: #6e2a22; } }
details.paste { background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; }
details.paste summary { cursor: pointer; min-height: 32px; }
details.paste textarea { margin-top: 8px; min-height: 120px; }
.svc .check { min-height: 40px; font-size: 15px; color: var(--text); margin: 0; }
.todo .instr { background: #fff7e0; color: #5c4400; border-left: 4px solid #e0a800; padding: 10px 12px; border-radius: 6px; margin-bottom: 8px; font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .todo .instr { background: #3a2f10; color: #f3df9f; } }
.check.task { margin: 0; padding: 6px 0; color: var(--text); font-size: 16px; }
.check.task .grow { flex: 1; }
.check.task.done .grow { text-decoration: line-through; color: var(--muted); }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.doc-thumb { border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.doc-thumb img, .doc-thumb .pdf { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--muted); }
.doc-thumb .btn { position: absolute; top: 8px; right: 8px; min-height: 28px; padding: 0 8px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--card); border-radius: 14px; padding: 14px; width: 100%; max-width: 520px; }
#reader2 { width: 100%; min-height: 120px; background: #000; border-radius: 10px; overflow: hidden; margin-top: 10px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.palette button { display: flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; font-size: 13px; }
.palette button.on { border-color: var(--brand-2); box-shadow: 0 0 0 2px var(--brand-2) inset; }
.sw { display: inline-block; width: 16px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); vertical-align: middle; margin-right: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; color: var(--muted); }
.fmap-wrap { overflow: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; max-height: 70vh; background: var(--bg); }
.fmap { --cs: 14px; display: grid; gap: 1px; padding: 6px; width: max-content; }
@media (min-width: 1000px) { .fmap { --cs: 15px; } }
.fmap > div { width: var(--cs); height: var(--cs); border-radius: 2px; display: flex; flex-direction: column-reverse; gap: 1px; padding: 1px; }
.fmap.editing { touch-action: none; cursor: crosshair; }
.fmap:not(.editing) [title] { cursor: pointer; }
.c-e { background: transparent; outline: 1px dotted var(--line); }
.c-W { background: #4b5563; }
.c-A { background: var(--card); }
.c-O { background: repeating-linear-gradient(45deg, #f59e0b66 0 3px, transparent 3px 6px); outline: 1px solid #f59e0b; }
.c-K { background: #111827; }
.c-R.z-f, .c-P.z-f { background: var(--frozen); }
.c-R.z-c, .c-P.z-c { background: var(--cooler); }
.c-R.z-d, .c-P.z-d { background: var(--dry); }
.c-P.z-x { background: var(--flex); }
.fmap .c-P, .sw.c-P { border-radius: 50%; }
.fmap > div i { flex: 1; background: rgba(255,255,255,.45); border-radius: 1px; }
.fmap > div i.on { background: #0b1f33; }
.fmap .c-P i { border-radius: 50%; }
.tabbar a[hidden]{display:none!important}
#cloudGate .gate{position:fixed;inset:0;z-index:200;background:var(--bg);display:flex;align-items:center;justify-content:center;padding:16px;overflow:auto}
#cloudGate .gate-card{width:100%;max-width:420px}
/* v6: freezer glove mode */
body.glove { font-size: 19px; }
body.glove .btn { min-height: 62px; font-size: 19px; padding: 0 22px; }
body.glove .btn.small { min-height: 52px; font-size: 17px; }
body.glove input, body.glove select, body.glove textarea { min-height: 58px; font-size: 20px; }
body.glove .tabbar a { min-height: 64px; font-size: 14px; }
body.glove .check input[type=checkbox], body.glove .check.task input { width: 30px; height: 30px; }
body.glove .list li { min-height: 60px; }
body.glove .bigbtns .btn { min-height: 96px; font-size: 21px; }
.fmap > div { position: relative; }
.fmap .rlab { position: absolute; top: 2px; left: 3px; font-size: 10px; line-height: 13px; white-space: nowrap; background: rgba(255,255,255,.9); color: #111; padding: 0 4px; border-radius: 3px; z-index: 2; pointer-events: none; font-weight: 700; }
