:root {
  --bg: #16130f; --panel: #211d18; --panel2: #2b261f; --line: #3a332a; --text: #f3ede4; --muted: #a69b8c;
  --accent: #ff7a1a; --accent2: #ffb36b; --ok: #6ccf8e; --warn: #ffcc4d; --bad: #ff6b5e; --printer: #66b7ff;
  --r: 14px; --safe-b: env(safe-area-inset-bottom); --safe-t: env(safe-area-inset-top);
  color-scheme: dark;
}
:root[data-theme="light"] { --bg: #f6f2ec; --panel: #fffdf9; --panel2: #f0e9df; --line: #e2d8ca; --text: #211b14; --muted: #7c705f;
    --accent: #e8620a; --accent2: #b9520f; color-scheme: light; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --bg: #f6f2ec; --panel: #fffdf9; --panel2: #f0e9df; --line: #e2d8ca; --text: #211b14; --muted: #7c705f;
    --accent: #e8620a; --accent2: #b9520f; color-scheme: light; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; padding-bottom: calc(72px + var(--safe-b)); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top h1 { flex: 1; margin: 0; font-size: 20px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { border: 0; background: none; font-size: 34px; line-height: 1; padding: 0 8px 4px 0; color: var(--accent); }
.top-right { display: flex; gap: 8px; }

main { padding: 14px 14px 24px; max-width: 720px; margin: 0 auto; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + var(--safe-b)); background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabs a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 11px; color: var(--muted); padding: 4px 0; }
.tabs a .ic { font-size: 21px; line-height: 24px; }
.tabs a.on { color: var(--accent); }
.tabs b { position: absolute; top: 0; left: 55%; min-width: 17px; height: 17px; border-radius: 9px; padding: 0 5px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 17px; text-align: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card h2, .sec { margin: 0 0 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sec { margin: 18px 4px 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sw { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--text) 18%, transparent);
  box-shadow: inset 0 -6px 10px rgba(0,0,0,.18), inset 0 4px 8px rgba(255,255,255,.2); }
.sw.big { width: 76px; height: 76px; border-width: 3px; }
.sw.sm { width: 22px; height: 22px; }

.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item:active { background: var(--panel2); }
.item .name { font-weight: 600; }
.item .chev { color: var(--muted); font-size: 22px; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); color: var(--muted); white-space: nowrap; }
.pill.sealed { color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.pill.opened { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.pill.printer { color: var(--printer); background: color-mix(in srgb, var(--printer) 15%, transparent); }
.pill.pending, .pill.low { color: var(--bad); background: color-mix(in srgb, var(--bad) 15%, transparent); }
.pill.empty { color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 6px 13px; font-size: 14px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.search { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); margin-bottom: 10px; }
input.f, select.f, textarea.f { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
textarea.f { min-height: 160px; }
label.l { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px;
  padding: 12px 16px; background: var(--panel2); font-weight: 600; min-height: 46px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: color-mix(in srgb, var(--bad) 18%, var(--panel)); color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btns { display: grid; gap: 10px; margin-top: 12px; }
.btns.two { grid-template-columns: 1fr 1fr; }
.icon-btn { border: 0; background: var(--panel2); border-radius: 10px; padding: 6px 10px; font-weight: 600; font-size: 14px; }

.tiles { display: grid; gap: 12px; }
.tile { display: flex; gap: 14px; align-items: center; padding: 18px 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); text-align: left; width: 100%; }
.tile .big { font-size: 30px; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.tile b { display: block; font-size: 17px; }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.slot { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: var(--panel2); min-width: 0; }
.slot.emptyslot { opacity: .5; }

.bar { height: 8px; border-radius: 4px; background: var(--panel2); overflow: hidden; margin: 6px 0 2px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.banner { border-radius: var(--r); padding: 14px; margin-bottom: 12px; background: color-mix(in srgb, var(--bad) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.banner.info { background: color-mix(in srgb, var(--printer) 12%, var(--panel)); border-color: color-mix(in srgb, var(--printer) 30%, transparent); }

.review { position: relative; }
.review .x { position: absolute; top: 10px; right: 10px; }
.badge-ok { font-size: 12px; color: var(--ok); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { border: 0; background: var(--panel2); width: 40px; height: 40px; font-size: 20px; }
.stepper span { min-width: 40px; text-align: center; font-weight: 600; }

.scanner { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 3/4; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); z-index: 9;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: 90vw; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 30px auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 20px; }
.login { max-width: 360px; margin: 12vh auto 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; }
input[type=color].sw { -webkit-appearance: none; appearance: none; padding: 0; overflow: hidden; cursor: pointer; }
input[type=color].sw::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color].sw::-webkit-color-swatch { border: 0; border-radius: 50%; }

/* colour tools */
.ctools { margin-top: 10px; }
.cchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; max-height: 132px; overflow-y: auto; padding: 2px; }
.cchip { width: 30px; height: 30px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--text) 18%, transparent); cursor: pointer; padding: 0; }
.cchip.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.sample { position: relative; margin-top: 10px; border-radius: 12px; overflow: hidden; cursor: crosshair; background: #000; }
.sample img { display: block; width: 100%; max-height: 320px; object-fit: contain; }
.sample .hint { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 8px 14px; font-weight: 600; }
.seg button.on { background: var(--accent); color: #fff; }
.side-title { display: none; }

/* laptop / desktop */
@media (hover: hover) {
  .item:hover, .slot:hover, .tile:hover { background: var(--panel2); }
  .btn:hover { filter: brightness(1.08); }
  a.item, .tile, .chip, .btn, .cchip { cursor: pointer; }
}
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 232px; }
  .tabs { top: 0; bottom: 0; right: auto; width: 232px; display: flex; flex-direction: column; gap: 4px;
    padding: 22px 14px; border-top: 0; border-right: 1px solid var(--line); }
  .side-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; padding: 0 10px 18px; color: var(--text); }
  .side-title img { width: 30px; height: 30px; border-radius: 8px; }
  .tabs a { flex-direction: row; gap: 12px; font-size: 15px; padding: 10px 12px; border-radius: 10px; }
  .tabs a .ic { font-size: 18px; width: 22px; text-align: center; }
  .tabs a.on { background: color-mix(in srgb, var(--accent) 14%, transparent); }
  .tabs b { position: static; margin-left: auto; }
  .top { padding: 16px 28px; }
  .top h1 { font-size: 24px; }
  main { max-width: 1180px; padding: 20px 28px 40px; }
  .toast { bottom: 28px; }
  .stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 0 22px; align-items: start; }
  .split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 20px; align-items: start; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile { flex-direction: column; align-items: flex-start; min-height: 170px; }
  .review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 0 16px; align-items: start; }
  .scanner { max-width: 440px; margin: 0 auto; }
  .login { margin-top: 18vh; }
}
