:root {
  --bg: #f3f5f6; --card: #fff; --ink: #14201f; --muted: #65747a; --line: #e2e8ea;
  --brand: #0f766e; --brand-ink: #fff; --danger: #b42318; --ok: #15803d; --warn: #b45309;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1415; --card: #162022; --ink: #e8f0ef; --muted: #8da0a4; --line: #263436;
    --brand: #2dd4bf; --brand-ink: #062f2a; --danger: #f97066; --ok: #4ade80; --warn: #fbbf24;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-top: env(safe-area-inset-top);
}
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.pad { padding: 12px 16px; } .error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }

.screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); border-radius: 16px; padding: 28px 22px; width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow); }
.login-card h1 { margin: 10px 0 2px; font-size: 22px; }
.login-card input { margin: 14px 0 10px; text-align: center; font-size: 18px; }

input, select {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.btn { font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 13px 16px; cursor: pointer; background: var(--line); color: var(--ink); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .5; }
.icon-btn { background: none; border: 0; font-size: 20px; color: var(--ink); padding: 8px; cursor: pointer; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; background: var(--brand); color: var(--brand-ink); }
.topbar .icon-btn { color: var(--brand-ink); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; margin-left: 8px; }
.dot.ok { background: #4ade80; } .dot.bad { background: #f87171; }

main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.searchbar { position: sticky; top: 44px; z-index: 4; padding: 10px 12px; background: var(--bg); }
.list { list-style: none; margin: 0; padding: 0 12px; display: grid; gap: 8px; }
.item { background: var(--card); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; }
.item .ref { font-weight: 700; font-size: 15px; word-break: break-all; }
.item .des { color: var(--muted); font-size: 14px; margin: 2px 0 8px; }
.row { display: flex; align-items: center; gap: 10px; } .between { justify-content: space-between; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--muted); }
.qty { font-weight: 700; padding: 2px 10px; border-radius: 99px; font-size: 13px; }
.qty.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.qty.low { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.qty.zero { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.price { font-weight: 700; margin-left: auto; font-variant-numeric: tabular-nums; }
.big { font-size: 20px; }

.card { background: var(--card); border-radius: 12px; padding: 14px; margin: 12px; box-shadow: var(--shadow); }
.lbl { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; } .card .lbl:first-child { margin-top: 0; }
.pick { width: 100%; text-align: left; font: inherit; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); cursor: pointer; display: grid; }
.pick small { color: var(--muted); }

.cart-line { cursor: default; }
.cart-line .controls { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 38px; height: 38px; border: 0; background: var(--line); font-size: 20px; color: var(--ink); cursor: pointer; }
.stepper input { width: 56px; border: 0; border-radius: 0; text-align: center; padding: 6px 2px; }
.cart-line .pu { width: 96px; text-align: right; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
.tabs button { position: relative; border: 0; background: none; padding: 8px 0 10px; font: inherit; font-size: 12px; color: var(--muted); display: grid; justify-items: center; gap: 2px; cursor: pointer; }
.tabs button span { font-size: 20px; } .tabs button.active { color: var(--brand); font-weight: 700; }
.badge { position: absolute; top: 4px; left: calc(50% + 8px); background: var(--danger); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 6px; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 88vh; background: var(--bg); z-index: 21; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.sheet-body { overflow: auto; padding: 12px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 4px 4px; font-variant-numeric: tabular-nums; }
.kv span:nth-child(odd) { color: var(--muted); } .kv span:nth-child(even) { text-align: right; font-weight: 600; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); background: #111; color: #fff; padding: 12px 14px; border-radius: 12px; z-index: 30; text-align: center; }
.toast.bad { background: var(--danger); }
