/* 3D Labs Inventory: workshop / industrial theme */
:root {
  --font: "Bahnschrift", "DIN Alternate", "Barlow", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-cond: "Bahnschrift SemiCondensed", "Bahnschrift", "DIN Condensed", "Barlow Semi Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;
  --mono: "Cascadia Mono", "Consolas", "SF Mono", ui-monospace, monospace;
  --r: 2px;
  --tap: 40px;
  --osk-h: 0px;
  --side-w: 228px;
  --hazard: repeating-linear-gradient(-45deg, #f5b800 0 10px, #111 10px 20px);
  --accent: #f5b800;
  --accent-hover: #ffcb2e;
  --accent-ink: #111;
}
[data-theme="dark"] {
  --bg: #111213;
  --surface: #191a1c;
  --surface-2: #1f2023;
  --surface-3: #27292c;
  --plate: #2c2e32;
  --border: #303236;
  --border-strong: #45484d;
  --text: #e7e6e1;
  --text-2: #c4c3bd;
  --muted: #8b8e93;
  --faint: #62656b;
  --ok: #4cc26b; --ok-bg: rgba(76, 194, 107, .12);
  --warn: #f5b800; --warn-bg: rgba(245, 184, 0, .12);
  --bad: #ff5a4f; --bad-bg: rgba(255, 90, 79, .12);
  --img-bg: #0c0d0e;
  --row-hover: #212226;
  --side-bg: #0b0b0c;
  --side-text: #c9c8c2;
  --shadow: 0 2px 0 rgba(0,0,0,.5);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #dddcd6;
  --surface: #f3f2ee;
  --surface-2: #e9e8e3;
  --surface-3: #dedcd5;
  --plate: #d2d0c8;
  --border: #bdbbb3;
  --border-strong: #8f8d86;
  --text: #151515;
  --text-2: #2f2f2d;
  --muted: #5f5e59;
  --faint: #8a8982;
  --ok: #1d7a3a; --ok-bg: rgba(29, 122, 58, .12);
  --warn: #8a5a00; --warn-bg: rgba(245, 184, 0, .22);
  --bad: #c02a1f; --bad-bg: rgba(192, 42, 31, .1);
  --img-bg: #e4e3dd;
  --row-hover: #e8e7e1;
  --side-bg: #1a1a1a;
  --side-text: #d8d7d1;
  --shadow: 0 2px 0 rgba(0,0,0,.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { padding-bottom: var(--osk-h); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono, .code { font-family: var(--mono); }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .04em; }
kbd { font: 600 11px var(--mono); padding: 1px 5px; border: 1px solid currentColor; border-radius: 2px; opacity: .55; }

/* ---------- controls ---------- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r); padding: 8px 10px; min-height: var(--tap); width: 100%;
  box-shadow: inset 0 2px 0 rgba(0,0,0,.18);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; border-color: var(--accent); }
input[type=color] { padding: 2px; width: 44px; flex: none; cursor: pointer; }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 15px center, right 10px center; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }
label { display: block; color: var(--muted); font: 600 12px var(--font-cond); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.big-input { font: 700 26px var(--mono); min-height: 54px; text-align: right; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 14px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface-3); color: var(--text); font: 600 14px var(--font-cond); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
  box-shadow: var(--shadow); text-decoration: none;
}
.btn:hover { background: var(--plate); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--accent); border-color: #c99600; color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.ghost.on, .btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.lg { min-height: 50px; padding: 0 22px; font-size: 16px; }
.btn.xl { min-height: 64px; font-size: 20px; letter-spacing: .1em; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: var(--tap); padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { box-shadow: none; margin-left: -1px; }
.btn-group .btn.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; border-right: 1px solid #000; }
.sidebar::before { content: ""; display: block; height: 8px; background: var(--hazard); flex: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.brand strong { display: block; color: #fff; font: 700 18px var(--font-cond); text-transform: uppercase; letter-spacing: .08em; line-height: 1.1; }
.brand span { display: block; color: #7d7f84; font: 600 11px var(--mono); letter-spacing: .05em; }
.tabs { display: flex; flex-direction: column; overflow-y: auto; }
.nav-label { color: #6f7176; font: 700 11px var(--font-cond); text-transform: uppercase; letter-spacing: .14em; padding: 14px 16px 6px; border-top: 1px solid #222; margin-top: 6px; }
.tabs button { display: flex; align-items: center; gap: 10px; padding: 0 16px; min-height: 40px; border: 0; border-left: 4px solid transparent; background: transparent; color: var(--side-text); font: 600 14px var(--font-cond); text-transform: uppercase; letter-spacing: .07em; text-align: left; }
.tabs button:hover { background: #18191b; color: #fff; }
.tabs button.active { background: #1e1f22; color: #fff; border-left-color: var(--accent); }
.tabs button.active svg { color: var(--accent); }
.tabs button span { flex: 1; }
.tabs .count { font: 600 12px var(--mono); font-style: normal; color: #75777c; }
.tabs .count.alert { color: #111; background: var(--accent); padding: 0 6px; }
.tabs kbd { color: #8a8c91; }
.sidebar-foot { margin-top: auto; padding: 12px 16px; border-top: 1px solid #222; font: 12px var(--mono); }
.status { display: flex; align-items: center; gap: 8px; color: #7d7f84; }
.status .dot { width: 8px; height: 8px; background: #4cc26b; }
.status.off .dot { background: #ff5a4f; }
.clock { color: #9a9ca1; margin-top: 4px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; gap: 8px; align-items: center; padding: 10px 24px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--surface); border-bottom: 2px solid var(--border-strong); }
.searchbox { flex: 1; position: relative; max-width: 760px; }
.searchbox input { padding-left: 36px; padding-right: 110px; font-size: 15px; }
.searchbox .search-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.searchbox .hint { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: 700 11px var(--mono); color: var(--ok); border: 1px solid var(--ok); padding: 1px 6px; pointer-events: none; text-transform: uppercase; opacity: .9; }
main { padding: 20px 24px 48px; width: 100%; max-width: 1560px; }

@media (max-width: 860px) {
  :root { --tap: 44px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; border-right: 0; border-top: 2px solid var(--accent); padding-bottom: env(safe-area-inset-bottom); }
  .sidebar::before, .brand, .nav-label, .sidebar-foot, .tabs .count, .tabs kbd, .tabs .desk { display: none; }
  .tabs { flex-direction: row; width: 100%; overflow-x: auto; }
  .tabs button { flex-direction: column; gap: 2px; padding: 6px 4px; min-height: 56px; font-size: 10px; flex: 1 0 64px; justify-content: center; border-left: 0; border-top: 3px solid transparent; }
  .tabs button.active { border-left: 0; border-top-color: var(--accent); }
  .tabs button span { flex: none; }
  .topbar { padding: 8px 12px; }
  .searchbox .hint, #scanBtn .lbl { display: none; }
  .searchbox input { padding-right: 10px; }
  main { padding: 14px 12px 110px; }
  body.osk-on .sidebar { display: none; }
}

/* ---------- headings, stats ---------- */
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid var(--border-strong); }
.page-head h1 { margin: 0; font-size: 28px; font-weight: 700; line-height: 1; letter-spacing: .05em; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--border-strong); border-left: 4px solid var(--plate); padding: 10px 14px; text-align: left; font: inherit; color: inherit; box-shadow: var(--shadow); }
button.stat { cursor: pointer; }
button.stat:hover { border-left-color: var(--accent); }
.stat .k { color: var(--muted); font: 700 11px var(--font-cond); text-transform: uppercase; letter-spacing: .12em; }
.stat .v { font: 700 26px var(--mono); margin-top: 2px; letter-spacing: -.02em; }
.stat .s { color: var(--muted); font: 12px var(--mono); }
.stat.bad { border-left-color: var(--bad); }
.stat.bad .v { color: var(--bad); }
.stat.hot { border-left-color: var(--accent); }

/* ---------- toolbar + table ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom: 0; }
.toolbar .spacer { flex: 1; }
.toolbar select, .toolbar input { width: auto; min-height: 32px; padding-top: 3px; padding-bottom: 3px; font-size: 13px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { min-height: 30px; padding: 0 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: 600 12px var(--font-cond); text-transform: uppercase; letter-spacing: .06em; }
.chip:hover { border-color: var(--text-2); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.low.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.loc-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #111; padding: 3px 4px 3px 10px; font: 700 13px var(--font-cond); text-transform: uppercase; letter-spacing: .06em; }
.loc-pill button { all: unset; cursor: pointer; width: 20px; height: 20px; display: grid; place-items: center; }
.loc-pill button svg { width: 14px; height: 14px; }

.panel { background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); }
.panel-foot { padding: 7px 12px; color: var(--muted); font: 12px var(--mono); border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font: 700 11px var(--font-cond); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); background: var(--surface-3); padding: 7px 10px; border-bottom: 2px solid var(--border-strong); white-space: nowrap; }
table.data td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
table.data tbody tr:hover { background: var(--row-hover); box-shadow: inset 3px 0 0 var(--accent); }
table.data .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
table.data .item-cell { display: flex; align-items: center; gap: 10px; min-width: 240px; }
table.data.static tbody tr { cursor: default; }
.thumb-sm { width: 40px; height: 40px; background: var(--img-bg) center / cover no-repeat; border: 1px solid var(--border-strong); flex: none; display: grid; place-items: center; color: var(--faint); position: relative; }
.thumb-sm .sw { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border: 2px solid var(--surface); }
.item-name { font-weight: 600; color: var(--text); line-height: 1.25; }
.item-sub { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.code { font-size: 12px; color: var(--muted); }
.locbadge { display: inline-flex; border: 1px solid var(--border-strong); font: 700 12px var(--mono); white-space: nowrap; background: var(--surface); }
.locbadge span { padding: 1px 7px; }
.locbadge span + span { border-left: 1px solid var(--border-strong); background: var(--surface-3); }
.locbadge small { color: var(--muted); font: 600 10px var(--font-cond); margin-right: 4px; letter-spacing: .06em; text-transform: uppercase; }
.swatch { display: inline-block; width: 10px; height: 10px; box-shadow: inset 0 0 0 1px rgba(128,128,128,.6); flex: none; }

.stock { display: inline-flex; align-items: baseline; gap: 4px; font: 700 15px var(--mono); }
.stock small { color: var(--muted); font: 500 11px var(--font); }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font: 700 11px var(--font-cond); text-transform: uppercase; letter-spacing: .08em; padding: 2px 7px; white-space: nowrap; border: 1px solid; }
.status-pill.ok, .status-pill.paid { color: var(--ok); background: var(--ok-bg); }
.status-pill.low, .status-pill.unpaid { color: var(--warn); background: var(--warn-bg); }
.status-pill.out { color: var(--bad); background: var(--bad-bg); }
.status-pill.cancelled { color: var(--muted); }

.stepper { display: inline-flex; border: 1px solid var(--border-strong); background: var(--surface-3); flex: none; box-shadow: var(--shadow); }
.stepper button { width: 32px; height: 30px; border: 0; background: transparent; font: 700 17px var(--mono); color: var(--text); display: grid; place-items: center; }
.stepper button + button { border-left: 1px solid var(--border-strong); }
.stepper button:hover { background: var(--accent); color: #111; }
.stepper.lg button { width: 50px; height: 46px; font-size: 22px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.meter { width: 60px; height: 8px; background: var(--surface-3); border: 1px solid var(--border-strong); display: inline-block; vertical-align: middle; }
.meter > div { height: 100%; background: var(--ok); }
.meter.low > div { background: var(--bad); }

.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); padding: 10px; border-top: 1px solid var(--border-strong); }
.card { background: var(--surface-2); border: 1px solid var(--border-strong); display: flex; flex-direction: column; cursor: pointer; }
.card:hover { border-color: var(--accent); }
.card .img { aspect-ratio: 4 / 3; background: var(--img-bg) center / contain no-repeat; position: relative; border-bottom: 1px solid var(--border-strong); display: grid; place-items: center; color: var(--faint); }
.card .img > svg { width: 40px; height: 40px; }
.card .img .locbadge { position: absolute; left: 6px; top: 6px; }
.card .img .sw { position: absolute; right: 6px; top: 6px; width: 18px; height: 18px; border: 2px solid var(--surface); }
.card .body { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card .row { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.card .price { margin-left: auto; font: 700 14px var(--mono); }

.empty { text-align: center; color: var(--muted); padding: 56px 20px; border-top: 1px solid var(--border-strong); }
.empty > svg { width: 40px; height: 40px; color: var(--faint); margin-bottom: 8px; }
.empty h3 { color: var(--text); margin: 0 0 4px; font-size: 17px; }
.empty .btn { margin-top: 14px; }
.empty.box { border: 1px dashed var(--border-strong); background: var(--surface); }

/* ---------- sections / forms ---------- */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .form-layout { grid-template-columns: 1fr; } }
.form-col { display: grid; gap: 16px; align-content: start; }
.section { background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); }
.section > header { padding: 8px 12px; border-bottom: 1px solid var(--border-strong); display: flex; align-items: center; gap: 10px; background: var(--surface-3); }
.section > header h3 { margin: 0; font-size: 15px; font-weight: 700; }
.section > header p { margin: 0; color: var(--muted); font-size: 12px; }
.section > header .grow { flex: 1; }
.section > header .ico { color: var(--accent); display: grid; place-items: center; flex: none; }
.section > .content { padding: 14px; display: grid; gap: 14px; }
.cols { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.cols .full { grid-column: 1 / -1; }
.inline { display: flex; gap: 6px; align-items: stretch; }
.inline > input { flex: 1; min-width: 0; }
.inline > input[type=color] { flex: none; width: 44px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); background: var(--surface-2); }
.seg button { min-height: 34px; padding: 0 14px; border: 0; background: transparent; color: var(--muted); font: 700 13px var(--font-cond); text-transform: uppercase; letter-spacing: .06em; display: inline-flex; align-items: center; gap: 6px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent); color: #111; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; justify-content: center; min-height: 44px; }
.check { display: flex; align-items: flex-start; gap: 10px; color: var(--text); font: 500 14px var(--font); text-transform: none; letter-spacing: 0; margin: 0; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); margin-top: 2px; flex: none; box-shadow: none; }
.check small { display: block; color: var(--muted); font-size: 12px; }
.sticky-actions { position: sticky; bottom: calc(10px + var(--osk-h)); z-index: 5; display: flex; gap: 8px; justify-content: flex-end; padding: 10px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 6px 20px rgba(0,0,0,.35); flex-wrap: wrap; }
.sticky-actions::before { content: ""; position: absolute; left: -1px; right: -1px; top: -5px; height: 5px; background: var(--hazard); }
.sticky-actions .note { margin-right: auto; color: var(--muted); font-size: 13px; align-self: center; }
@media (max-width: 860px) { .sticky-actions { bottom: calc(70px + var(--osk-h)); } body.osk-on .sticky-actions { bottom: calc(8px + var(--osk-h)); } .sticky-actions .note { display: none; } }

.img-slots { display: grid; gap: 14px; }
.img-slot { display: grid; gap: 6px; }
.img-slot .preview { aspect-ratio: 4/3; background: var(--img-bg) center / contain no-repeat; border: 1px dashed var(--border-strong); display: grid; place-items: center; color: var(--faint); font: 12px var(--mono); text-align: center; }
.img-slot .preview.has { border-style: solid; }
.img-slot .inline .btn { flex: 1; }
.slot-label { font: 700 11px var(--font-cond); color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }

.lookup-bar { display: flex; gap: 6px; }
.lookup-bar .searchbox { max-width: none; }
.lookup-bar .searchbox input { padding-right: 10px; }
.auto-state { font: 12px var(--mono); color: var(--muted); display: flex; gap: 8px; align-items: center; min-height: 18px; }
.auto-state.ok { color: var(--ok); }
.results { display: grid; border: 1px solid var(--border-strong); }
.result { display: flex; gap: 10px; background: var(--surface-2); padding: 8px 10px; align-items: center; }
.result + .result { border-top: 1px solid var(--border); }
.result .t { font-weight: 600; }
.result .d { color: var(--muted); font-size: 13px; max-height: 2.9em; overflow: hidden; }
.result .u { color: var(--faint); font: 11px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .grow { flex: 1; min-width: 0; }
.subhead { font: 700 11px var(--font-cond); color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin: 0 0 6px; display: flex; justify-content: space-between; gap: 10px; }
.subhead span { text-transform: none; letter-spacing: 0; font: 12px var(--font); }
.thumbs { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.thumb { position: relative; aspect-ratio: 1; background: #fff center / contain no-repeat; border: 1px solid var(--border-strong); }
.thumb .pick { position: absolute; inset: auto 0 0 0; display: flex; gap: 1px; }
.thumb .pick button { flex: 1; min-height: 26px; border: 0; background: rgba(0,0,0,.78); color: #fff; font: 700 12px var(--mono); }
.thumb .pick button:hover { background: var(--accent); color: #111; }
.thumb.sel1, .thumb.sel2 { outline: 3px solid var(--accent); outline-offset: -3px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; gap: 10px; align-items: center; color: var(--muted); font: 13px var(--mono); }

/* ---------- POS ---------- */
.unit-in input { padding-right: 34px; text-align: right; font-family: var(--mono); }
.unit-in .big-input { padding-right: 44px; }

/* ---------- modal + drawer ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px calc(40px + var(--osk-h)); overflow-y: auto; }
.modal-card { position: relative; background: var(--surface); border: 1px solid var(--border-strong); width: min(640px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-close { position: absolute; right: 10px; top: 10px; z-index: 2; }
.modal.drawer { padding: 0; justify-content: flex-end; align-items: stretch; overflow: hidden; }
.modal.drawer .modal-card { width: min(540px, 100%); height: 100%; overflow-y: auto; border-width: 0 0 0 4px; border-color: var(--accent); padding-bottom: var(--osk-h); display: flex; flex-direction: column; }
.modal.drawer #modalBody { flex: 1; display: flex; flex-direction: column; }
.modal-pad { padding: 20px; }
.modal-pad h2 { margin: 0 0 14px; font-size: 20px; }
.dh { padding: 16px 20px 14px; border-bottom: 2px solid var(--border-strong); padding-right: 60px; background: var(--surface-2); }
.dh .eyebrow { font: 700 11px var(--font-cond); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.dh h2 { margin: 0; font-size: 22px; line-height: 1.15; text-transform: none; letter-spacing: .01em; }
.dh .item-sub { margin-top: 6px; font-size: 13px; }
.dsec { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.dsec h4 { margin: 0 0 10px; font-size: 12px; letter-spacing: .14em; color: var(--muted); }
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gallery.one { grid-template-columns: 1fr; }
.gallery div { aspect-ratio: 4/3; background: var(--img-bg) center / contain no-repeat; border: 1px solid var(--border-strong); }
.stockbox { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stockbox .big { font: 700 40px var(--mono); letter-spacing: -.03em; line-height: 1; }
.stockbox .big small { font: 500 14px var(--font); color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.stockbox .grow { flex: 1; }
.adjust-row { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.adjust-row input { width: 130px; flex: none; font-family: var(--mono); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); font: 600 12px var(--font-cond); text-transform: uppercase; letter-spacing: .08em; padding-top: 2px; }
.kv dd { margin: 0; display: flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.desc { color: var(--text-2); white-space: pre-wrap; font-size: 14px; margin: 0; }
.dfoot { margin-top: auto; padding: 12px 20px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; position: sticky; bottom: 0; background: var(--surface-2); border-top: 2px solid var(--border-strong); }
.dfoot .spacer { flex: 1; }
.dfoot input { width: 54px; text-align: center; padding: 6px; font-family: var(--mono); }
.timeline { font: 12px var(--mono); display: grid; gap: 5px; }
.timeline div { display: flex; gap: 10px; color: var(--text-2); }
.timeline time { color: var(--muted); min-width: 125px; }
.delta-pos { color: var(--ok); font-weight: 700; }
.delta-neg { color: var(--bad); font-weight: 700; }

/* ---------- locations ---------- */
.loc-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.loc-card { background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); }
.loc-card header { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 2px solid var(--border-strong); background: var(--surface-3); }
.loc-card header .tag { min-width: 44px; height: 40px; padding: 0 8px; background: var(--accent); color: #111; display: grid; place-items: center; font: 700 18px var(--mono); }
.loc-card header h3 { margin: 0; font-size: 15px; }
.loc-card header p { margin: 0; font: 12px var(--mono); color: var(--muted); }
.loc-card header .grow { flex: 1; }
.loc-card ul { list-style: none; margin: 0; padding: 0; }
.loc-card li { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.loc-card li:last-child { border-bottom: 0; }
.loc-card li .grow { flex: 1; font: 700 13px var(--mono); }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border-strong); width: min(380px, 100%); display: grid; gap: 16px; text-align: center; justify-items: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); padding: 0 26px 26px; position: relative; }
.login-card::before { content: ""; display: block; height: 10px; margin: 0 -26px; align-self: stretch; justify-self: stretch; background: var(--hazard); }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 4px 0 0; }
.login-card .fieldset, .login-card .btn { width: 100%; }
.fieldset { text-align: left; }
.error { color: var(--bad); min-height: 1em; margin: 0; font-size: 13px; }

/* ---------- toast ---------- */
.toast { position: fixed; right: 20px; bottom: calc(20px + var(--osk-h)); background: #0b0b0c; color: #fff; padding: 12px 16px; border-left: 5px solid var(--ok); font: 600 14px var(--font); z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: min(440px, 90vw); }
.toast.bad { border-left-color: var(--bad); }
@media (max-width: 860px) { .toast { left: 12px; right: 12px; bottom: calc(76px + var(--osk-h)); } }

/* ---------- on-screen keyboard ---------- */
.osk { position: fixed; left: 0; right: 0; bottom: 0; z-index: 200; background: #0b0b0c; padding: 16px 10px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.osk::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--hazard); }
.osk .rows { max-width: 1100px; margin: 0 auto; display: grid; gap: 6px; }
.osk .r { display: flex; gap: 6px; }
.osk button { flex: 1 1 0; min-height: 56px; border: 1px solid #2c2e32; border-radius: 2px; background: #1f2023; color: #eee; font: 600 20px var(--font); box-shadow: 0 3px 0 #000; }
.osk button:active { background: var(--accent); color: #111; transform: translateY(2px); box-shadow: none; }
.osk button.w15 { flex-grow: 1.5; }
.osk button.w2 { flex-grow: 2; }
.osk button.w6 { flex-grow: 6; }
.osk button.fn { background: #2c2e32; font: 700 14px var(--font-cond); text-transform: uppercase; letter-spacing: .06em; }
.osk button.on { background: #eee; color: #111; }
.osk button.go { background: var(--accent); color: #111; font: 700 16px var(--font-cond); text-transform: uppercase; }
.osk .numpad { max-width: 420px; }

#reader { width: 100%; overflow: hidden; background: #000; }
.print-frame { position: fixed; width: 0; height: 0; border: 0; right: 0; bottom: 0; visibility: hidden; }
.m-only { display: none; }

@media (max-width: 860px) {
  table.data.items th:nth-child(2), table.data.items td:nth-child(2),
  table.data.items th:nth-child(3), table.data.items td:nth-child(3),
  table.data.items th:nth-child(4), table.data.items td:nth-child(4),
  table.data.items th:nth-child(6), table.data.items td:nth-child(6),
  table.data.sales th:nth-child(4), table.data.sales td:nth-child(4),
  table.data.sales th:nth-child(5), table.data.sales td:nth-child(5) { display: none; }
  table.data .item-cell { min-width: 0; }
  table.data .row-actions [data-print] { display: none; }
  .m-only { display: inline-flex; }
  .toolbar select { flex: 1; }
  .dfoot input { display: none; }
  .dh, .dsec { padding-left: 14px; padding-right: 14px; }
}

/* ---------- drawer units ---------- */
.unit { margin-bottom: 18px; scroll-margin-top: 80px; }
.unit > header .tag { min-width: 44px; height: 40px; padding: 0 8px; background: var(--accent); color: #111; display: grid; place-items: center; font: 700 20px var(--mono); }
.unit.flash { outline: 3px solid var(--accent); outline-offset: 2px; }
.drawer-grid { display: grid; gap: 6px; padding: 10px; background: #c8341f; border: 2px solid #9c2614; }
[data-theme="light"] .drawer-grid { background: #d9442c; }
.drawer { position: relative; min-height: 104px; padding: 16px 8px 6px; text-align: left; display: flex; flex-direction: column; gap: 3px; cursor: pointer;
  background: linear-gradient(#8d9196, #7a7e83); border: 1px solid #55585c; color: #111; font: inherit; overflow: hidden; }
.drawer .handle { position: absolute; top: 4px; left: 22%; right: 22%; height: 6px; background: #5d6166; border-radius: 0 0 3px 3px; box-shadow: inset 0 -1px 0 rgba(255,255,255,.2); }
.drawer .dcode { position: absolute; top: 2px; right: 5px; font: 700 10px var(--mono); color: #222; opacity: .8; }
.drawer .dbody { display: flex; gap: 6px; align-items: flex-start; min-height: 0; cursor: grab; }
.drawer .dimg { flex: none; width: 34px; height: 34px; background: #fff center/contain no-repeat; border: 1px solid #555; }
.drawer .dname { background: #f4f1e8; color: #111; padding: 2px 5px; font: 700 12px/1.2 var(--font-cond); text-transform: uppercase; letter-spacing: .02em;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; flex: 1; border: 1px solid #333; }
.drawer .dqty { margin-top: auto; font: 700 12px var(--mono); color: #111; }
.drawer .dqty em { font-style: normal; font-weight: 400; opacity: .8; }
.drawer.empty { background: linear-gradient(#55585c, #4a4d51); }
.drawer .dempty { margin: auto; font: 300 28px var(--mono); color: #c9ccd0; opacity: .6; }
.drawer.empty:hover .dempty { opacity: 1; color: var(--accent); }
.drawer:hover { filter: brightness(1.08); }
.drawer.low { box-shadow: inset 0 -4px 0 var(--accent); }
.drawer.out { box-shadow: inset 0 -4px 0 #ff5a4f; }
.drawer.dim { opacity: .25; }
.drawer.hit { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
.drawer.drop { outline: 3px dashed #fff; outline-offset: -5px; }
.locbadge.drw { border-color: #c8341f; }
.mini-grid { display: grid; gap: 3px; padding: 6px; background: #c8341f; max-width: 360px; }
.mini-grid button { min-height: 34px; border: 1px solid #55585c; background: #4a4d51; color: #ddd; font: 700 11px var(--mono); cursor: pointer; }
.mini-grid button.taken { background: #8d9196; color: #111; }
.mini-grid button.on { background: var(--accent); color: #111; outline: 2px solid #fff; outline-offset: -2px; }
@media (max-width: 760px) {
  .drawer { min-height: 78px; padding: 14px 4px 4px; }
  .drawer .dimg { display: none; }
  .drawer .dname { font-size: 10px; -webkit-line-clamp: 3; padding: 1px 3px; }
  .drawer .dqty { font-size: 10px; }
  .drawer-grid { gap: 4px; padding: 6px; }
  .unit > header { flex-wrap: wrap; }
}
.cat-results { max-height: 420px; overflow: auto; }
.cat-results > .muted { padding: 10px 12px; }
.cat-results .result:hover { background: var(--row-hover); }

/* ---------- overview, projects, weigh-in ---------- */
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.home-grid .section { margin: 0; }
.content.tight { padding: 6px 12px 12px; display: grid; gap: 0; }
.hrow { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.hrow:last-child { border-bottom: 0; }
.hrow:hover { background: var(--row-hover); }
.hrow .grow { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hrow .grow b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow small { color: var(--muted); font-size: 12px; }
.hbar { display: grid; grid-template-columns: 90px 1fr 70px; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.hbar div { height: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.hbar i { display: block; height: 100%; background: var(--accent); }
.hbar b { font: 700 12px var(--mono); text-align: right; }
.proj-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.proj-card { text-align: left; padding: 14px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; font: inherit; color: inherit; border-left: 4px solid var(--accent); }
.proj-card:hover { filter: brightness(1.06); }
.proj-card .pc-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.proj-card h3 { margin: 0; font-size: 17px; }
.proj-card p { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.proj-card .pc-foot { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font: 12px var(--mono); margin-top: auto; }
.crumbs { font: 700 12px var(--font-cond); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 2px; }
.weigh { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border-strong); }
.weigh .wl { font: 700 12px var(--font-cond); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; }
@media (max-width: 760px) { .home-grid { grid-template-columns: 1fr; } .hbar { grid-template-columns: 70px 1fr 60px; } }
.proj-grid { padding: 0; border: 0; }
.stats.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stats.five { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .stats.five { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
