:root {
  --ink: #15202b; --muted: #5b6875; --faint: #8a96a3;
  --bg: #eef0f3; --card: #fff; --line: #d9dee4; --soft: #f6f7f9;
  --head: #1b2530; --head2: #263342;
  --red: #c62828; --red-soft: #fdecec;
  --case: #d1342f; --case-dark: #a3241f; --bin: #e85a4f; --bin-hi: #ffd54a;
  --take: #2f9e55; --take-soft: #e6f5eb;
  --ret: #e07b1f; --ret-soft: #fdf0e3;
  --stock: #cf3e3e; --stock-soft: #fbe9e9;
  --quar: #6d4cc2; --quar-soft: #efeafb;
  --link: #1f63c7;
  --r: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

/* ---------- top bar */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--head); color: #fff; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px; }
.topbar .brand { font-weight: 700; letter-spacing: .01em; display: flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; }
.topbar .brand .dot { width: 22px; height: 22px; border-radius: 6px; background: var(--case); display: grid; place-items: center; font-size: 13px; }
.topbar .sp { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.12); color: #fff; white-space: nowrap; }
.chip.warn { background: #f5b800; color: #2a2100; }
.chip.off { background: #6b7785; }

/* ---------- layout */
.wrap { max-width: 760px; margin: 0 auto; padding: 14px 14px 120px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; }
.card + .card { margin-top: 12px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 2px 8px; }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs b { color: var(--ink); }
.boxhead h1 { font-size: 22px; }
.code { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--head); color: #fff; letter-spacing: .03em; }
.code.light { background: #e7eaee; color: var(--ink); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }

/* ---------- buttons & fields */
.btn { appearance: none; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 11px 16px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; text-decoration: none; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--head); border-color: var(--head); color: #fff; }
.btn.take { background: var(--take); border-color: var(--take); color: #fff; }
.btn.ret { background: var(--ret); border-color: var(--ret); color: #fff; }
.btn.stock { background: var(--stock); border-color: var(--stock); color: #fff; }
.btn.quar { background: var(--quar); border-color: var(--quar); color: #fff; }
.btn.danger { color: var(--red); border-color: #f0c4c4; }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 6px 11px; font-size: 14px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: transparent; }
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; min-height: 44px; font-size: 16px; }
textarea.input { min-height: 74px; resize: vertical; }
.input:focus { outline: 2px solid #9cc0f5; border-color: #6aa0ee; }
.field + .field { margin-top: 12px; }

/* ---------- packout picture */
.packout-wrap { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 10px; }
.packout-svg { width: 100%; height: auto; display: block; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.packout-svg, .packout-svg * { outline: none; }  /* browser focus rings get scaled ~150x inside the viewBox */
.packout-svg .bin { cursor: pointer; }
.packout-svg .bin rect { fill: var(--p-bin); stroke: var(--p-dark); stroke-width: .03px; transition: fill .12s; }
.packout-svg .bin.empty rect { fill: var(--p-empty); }
.packout-svg .bin.sel rect { fill: var(--p-hi); stroke: var(--p-hi-stroke); stroke-width: .07px; }
.packout-svg .bin:focus-visible rect { stroke: #1f63c7; stroke-width: .06px; }
.packout-svg .bin text { fill: var(--p-text); font-weight: 800; pointer-events: none; }
.packout-svg .bin.sel text { fill: var(--p-hi-text); }
.packout-svg .bin .cnt { font-weight: 600; opacity: .9; }
.packout-svg .lowdot { fill: var(--p-low, #ffd54a); stroke: #fff; stroke-width: .02px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- part card (matches the sketch: bin, photo + code, details, + − ∅, dynamic button) */
.part { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 12px; }
.part + .part { margin-top: 10px; }
.part .top { display: flex; gap: 12px; }
.part .ph { width: 84px; flex: 0 0 84px; }
.part .ph .img { width: 84px; height: 84px; border-radius: 10px; background: var(--soft) center/cover no-repeat; border: 1px solid var(--line); display: grid; place-items: center; color: var(--faint); font-size: 26px; }
.part .ph .pcode { font-size: 11px; text-align: center; margin-top: 4px; color: var(--muted); word-break: break-all; }
.part .bin-tag { font-size: 12px; font-weight: 700; color: var(--case-dark); text-transform: uppercase; letter-spacing: .05em; }
.part .name { font-weight: 700; font-size: 16px; margin: 1px 0 4px; }
.part dl { margin: 0; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; row-gap: 1px; font-size: 13px; }
.part dt { color: var(--muted); }
.part dd { margin: 0; overflow-wrap: anywhere; }
.qtyline { margin-top: 6px; font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #e7eaee; color: var(--ink); }
.badge.low { background: #fff1c2; color: #7a5600; }
.badge.out { background: var(--stock-soft); color: var(--stock); }
.badge.take { background: var(--take-soft); color: #1d6b39; }
.badge.ret { background: var(--ret-soft); color: #8a4a0c; }
.badge.quar { background: var(--quar-soft); color: var(--quar); }
.badge.pending { background: #e3ecfb; color: #1f4f9c; }
.acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.act { min-height: 52px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-size: 24px; font-weight: 800; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.act small { font-size: 12px; font-weight: 600; }
.act.take { border-color: var(--take); color: var(--take); }
.act.ret { border-color: var(--ret); color: var(--ret); }
.act.stock { border-color: var(--stock); color: var(--stock); }
.act.on.take { background: var(--take); color: #fff; }
.act.on.ret { background: var(--ret); color: #fff; }
.act.on.stock { background: var(--stock); color: #fff; }
.panel { margin-top: 10px; padding: 12px; border-radius: 10px; }
.panel.take { background: var(--take-soft); }
.panel.ret { background: var(--ret-soft); }
.panel.stock { background: var(--stock-soft); }
.panel.quar { background: var(--quar-soft); }
.stepper { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 10px; }
.stepper button { width: 56px; height: 56px; border-radius: 12px; border: 0; background: #fff; box-shadow: var(--shadow); font-size: 24px; cursor: pointer; }
.stepper input { width: 84px; height: 56px; text-align: center; font-size: 26px; font-weight: 800; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.linkish { background: none; border: 0; padding: 6px 0; color: var(--link); font-weight: 600; cursor: pointer; font-size: 14px; }

/* ---------- cart bar & sheets */
.cartbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: rgba(238,240,243,.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.cartbar .btn { width: 100%; max-width: 736px; margin: 0 auto; display: flex; min-height: 54px; font-size: 17px; }
.sheet-bg { position: fixed; inset: 0; background: rgba(15,22,30,.45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 18px 16px; padding-bottom: max(18px, env(safe-area-inset-bottom)); max-height: 86vh; overflow: auto; animation: up .18s ease-out; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h2 { font-size: 19px; margin-bottom: 4px; }
.toast { position: fixed; left: 50%; top: max(64px, calc(env(safe-area-inset-top) + 54px)); transform: translateX(-50%); background: var(--head); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 80; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 92vw; text-align: center; }
.linkrow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.linkrow:last-child { border-bottom: 0; }
.thumb { width: 44px; height: 44px; border-radius: 8px; background: var(--soft) center/cover no-repeat; border: 1px solid var(--line); flex: 0 0 44px; display: grid; place-items: center; color: var(--faint); }

/* ---------- cart lines */
.line { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.mini-step { display: flex; align-items: center; gap: 4px; }
.mini-step button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 18px; cursor: pointer; }
.mini-step span { min-width: 30px; text-align: center; font-weight: 800; }
.statusbox { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; }
.statusbox.ok { background: var(--take-soft); }
.statusbox.wait { background: #fff6dc; }
.statusbox.out { background: var(--ret-soft); }
.statusbox .ico { font-size: 26px; line-height: 1; }
.check { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.check + .check { margin-top: 8px; }
.check input { width: 22px; height: 22px; }
.heavy { display: inline-block; background: #ffe000; color: #000; font-weight: 800; font-size: 12px; padding: 3px 8px; border-radius: 4px; letter-spacing: .03em; }
.search { position: relative; }
.search input { padding-left: 38px; }
.search::before { content: "⌕"; position: absolute; left: 13px; top: 9px; font-size: 20px; color: var(--faint); }
