/* Stockroom — clean, calm and touch-friendly. Phone first; sidebar on wider screens. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --line: #e3e6eb;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --good: #059669;
  --good-soft: #e7f7f0;
  --warn: #b45309;
  --warn-soft: #fff6e6;
  --bad: #dc2626;
  --bad-soft: #fdeceb;
  --nav: #0f172a;
  --nav-ink: #cbd5e1;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, .22);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
  --tap: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020; --surface: #121a2e; --surface-2: #19223a; --line: #253050; --text: #e7ecf5; --muted: #8b97b0;
    --accent: #7c83ff; --accent-ink: #0b1020; --accent-soft: #1e2350; --good: #34d399; --good-soft: #0f2e27;
    --warn: #fbbf24; --warn-soft: #33270b; --bad: #f87171; --bad-soft: #3a1717; --nav: #070b16; --nav-ink: #9aa6c1;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; margin-bottom: 12px; }
a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.ico { width: 20px; height: 20px; flex: none; }

/* ---- controls ---- */
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  min-height: var(--tap); padding: 10px 14px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); margin: 0; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 550; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; font-weight: 500; min-height: var(--tap); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px;
  border-radius: 12px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  background: var(--surface-2); color: var(--text); transition: transform .06s, background .15s, opacity .15s; text-decoration: none; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ghost.danger, .btn.danger.ghost { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.big { min-height: 58px; font-size: 17px; }
.icon-btn { display: inline-grid; place-items: center; min-width: 40px; min-height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.cam { color: var(--accent); background: var(--accent-soft); min-width: var(--tap); min-height: var(--tap); }
.icon-btn.cam .ico { width: 24px; height: 24px; }
.input-with-btn { display: flex; gap: 8px; align-items: center; }
.file-btn { display: inline-flex; color: var(--text); font-size: 15px; }

/* ---- app shell: bottom tabs on phones, sidebar from 900px ---- */
.boot { display: grid; place-items: center; min-height: 100vh; }
.boot-mark, .auth-mark, .brand-mark { width: 44px; height: 44px; border-radius: 12px; background: url(/icon.svg) center / cover; }
.shell { min-height: 100vh; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.nav { position: fixed; z-index: 20; inset: auto 0 0 0; background: var(--nav); color: var(--nav-ink); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.nav .brand, .nav .nav-foot { display: none; }
.nav nav { display: flex; justify-content: space-around; }
.nav nav a { flex: 1; display: grid; justify-items: center; gap: 3px; padding: 8px 4px; border-radius: 12px; color: var(--nav-ink); font-size: 11px; font-weight: 600; }
.nav nav a.active { color: #fff; background: rgba(255, 255, 255, .08); }
.nav nav a.active .ico { color: #a5b4fc; }
main { min-width: 0; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; padding-bottom: 0; }
  .nav { position: sticky; top: 0; inset: auto; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; }
  .nav .brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; color: #fff; font-weight: 700; font-size: 16px; }
  .nav .brand img { max-width: 44px; max-height: 44px; border-radius: 10px; background: #fff; object-fit: contain; }
  .nav nav { flex-direction: column; gap: 4px; }
  .nav nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; font-size: 14.5px; }
  .nav nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
  .nav .nav-foot { display: grid; gap: 12px; margin-top: auto; }
  .nav .who { display: grid; font-size: 13px; padding: 0 8px; }
  .nav .who strong { color: #fff; }
  .nav .nav-foot .btn { color: var(--nav-ink); border-color: rgba(255, 255, 255, .12); }
}
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 6px 10px; border-radius: 999px; background: rgba(255, 255, 255, .06); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .2); }
.status.offline i { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .2); }
.status.warn { color: #fbbf24; }

/* Phones also need to see whether they are offline: a slim bar above the tabs. */
@media (max-width: 899px) {
  .nav .nav-foot { display: block; position: absolute; bottom: 100%; left: 0; right: 0; pointer-events: none; }
  .nav .nav-foot > :not(.status) { display: none; }
  .nav .status { display: none; margin: 0 auto 8px; width: max-content; pointer-events: auto; background: var(--nav); color: var(--nav-ink); }
  .nav .status.offline, .nav .status.warn { display: flex; }
}

/* ---- pages ---- */
.page { padding: 18px 16px 28px; display: grid; gap: 16px; max-width: 1240px; margin: 0 auto; }
.page.narrow { max-width: 860px; }
@media (min-width: 900px) { .page { padding: 32px 36px; gap: 20px; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.sub-card { padding: 14px 0; }
.split { display: grid; gap: 16px; }
@media (min-width: 900px) { .split { grid-template-columns: 1fr 1fr; } }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1 1 260px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.banner { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner .queued { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; color: var(--text); }
.pill { font-size: 13px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.void, .tag.sale { background: var(--bad-soft); color: var(--bad); }
.tag.receive { background: var(--good-soft); color: var(--good); }
.tag.count { background: var(--accent-soft); color: var(--accent); }
.low, .neg { color: var(--bad); font-weight: 650; }
.pos { color: var(--good); font-weight: 650; }
.error { color: var(--bad); min-height: 1.2em; margin: 0; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin: 0; }

/* ---- forms ---- */
.form { display: grid; gap: 14px; }
.form.grid { grid-template-columns: 1fr; }
@media (min-width: 640px) { .form.grid { grid-template-columns: repeat(2, 1fr); } .form.grid.compact { grid-template-columns: repeat(3, 1fr); } .form.grid .full { grid-column: 1 / -1; } }
.form.inline { display: flex; gap: 8px; }
.form .checks { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: center; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.actions.end { align-items: end; }
.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented label { flex: 1; display: block; color: var(--text); font-size: 14px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span, .segmented.links a { display: grid; place-items: center; min-height: 40px; padding: 0 12px; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--muted); }
.segmented input:checked + span, .segmented.links a.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(15, 23, 42, .12); }
.segmented.links { flex: 0 1 auto; overflow-x: auto; }
.date-range { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.date-range input { width: auto; }
.copy-row { display: flex; gap: 8px; }
.logo-row { display: flex; gap: 18px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.logo-preview { width: 160px; height: 90px; border: 1px dashed var(--line); border-radius: var(--radius-sm); display: grid; place-items: center; background: #fff; }
.logo-preview img { max-width: 92%; max-height: 80px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; padding: 0; }
.card.table-wrap { padding: 4px 0; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-id] { cursor: pointer; }
.table tbody tr[data-id]:hover { background: var(--surface-2); }
.table .num { text-align: right; white-space: nowrap; }
.table tr.inactive { opacity: .55; }
.table .empty-row { text-align: center; color: var(--muted); padding: 28px; }
.count-input { width: 96px; min-height: 40px; text-align: right; padding: 6px 10px; }
@media (max-width: 640px) { .hide-sm { display: none; } .table th, .table td { padding: 10px 12px; } }

/* ---- stats and lists ---- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 4px; box-shadow: var(--shadow); }
.card .stat { box-shadow: none; background: var(--surface-2); border: 0; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat strong { font-size: 22px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.stat.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.stat.accent span { color: inherit; opacity: .8; }
.pick-list { display: grid; gap: 6px; }
.pick { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; min-height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.pick:hover { border-color: var(--accent); }
.pick span { display: grid; min-width: 0; }
.pick small { color: var(--muted); }
.pick b { font-variant-numeric: tabular-nums; }
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; gap: 12px; align-items: center; font-size: 14px; }
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.picked-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; }
.picked-head > div:first-child { display: grid; }
.picked-head small { color: var(--muted); }
.big-num { font-size: 32px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.big-num small { font-size: 14px; font-weight: 500; color: var(--muted); }

/* ---- checkout ---- */
.checkout { display: grid; gap: 14px; padding: 14px 12px; min-height: calc(100vh - 80px); align-content: start; }
@media (min-width: 900px) { .checkout { grid-template-columns: minmax(0, 1fr) 360px; padding: 24px; gap: 20px; min-height: 100vh; align-items: start; } }
.sale-pane { display: grid; gap: 12px; align-content: start; min-width: 0; }
.scanbar { position: relative; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 6px 6px 16px; box-shadow: var(--shadow); }
.scanbar > .ico { color: var(--muted); }
.scanbar input { border: 0; box-shadow: none; padding: 10px 0; font-size: 17px; min-height: 52px; background: transparent; }
.scanbar input:focus { box-shadow: none; }
.scanbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.suggest { position: absolute; z-index: 15; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: grid; gap: 2px; max-height: 60vh; overflow: auto; }
.suggest button { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; min-height: 52px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.suggest button span { display: grid; }
.suggest button small { color: var(--muted); }
.suggest button.on, .suggest button:hover { background: var(--accent-soft); }
.cart { display: grid; gap: 8px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px 8px 4px; }
.line.flash { animation: flash .7s ease-out; }
@keyframes flash { from { background: var(--accent-soft); border-color: var(--accent); } }
tr.flash td { animation: flash .9s ease-out; }
.line-main { display: grid; text-align: left; border: 0; background: transparent; color: var(--text); font: inherit; padding: 8px; cursor: pointer; min-width: 0; border-radius: 10px; }
.line-main strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.line-main small { color: var(--muted); font-size: 12.5px; }
.line .amount { font-variant-numeric: tabular-nums; font-size: 16px; min-width: 72px; text-align: right; }
.stepper { display: flex; align-items: center; background: var(--surface-2); border-radius: 12px; }
.stepper button { width: 40px; height: 40px; border: 0; background: transparent; color: var(--text); font-size: 20px; cursor: pointer; border-radius: 12px; }
.stepper button:active { background: var(--line); }
.stepper span { min-width: 30px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.empty-cart { text-align: center; padding: 48px 20px; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }
.empty-cart h2 { color: var(--text); margin: 14px 0 4px; }
.scan-art { width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; background: var(--accent-soft); position: relative; }
.scan-art::after { content: ""; position: absolute; inset: 18px 14px; background: repeating-linear-gradient(90deg, var(--accent) 0 3px, transparent 3px 6px, var(--accent) 6px 8px, transparent 8px 11px); }
.pay-pane { display: grid; gap: 12px; position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .pay-pane { top: 24px; bottom: auto; } }
.totals { display: grid; gap: 8px; }
.totals .row { display: flex; justify-content: space-between; color: var(--muted); font-variant-numeric: tabular-nums; }
.totals .grand { color: var(--text); font-size: 26px; font-weight: 750; letter-spacing: -.02em; padding-top: 10px; border-top: 1px solid var(--line); margin-top: 4px; }
.pay-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn.pay { min-height: 64px; font-size: 16px; border-radius: 14px; color: #fff; }
.btn.pay.cash { background: var(--good); }
.btn.pay.card-btn { background: var(--accent); }
.btn.pay.other { background: #475569; }
/* On phones the cart scrolls and the total + pay buttons stay docked above the tab bar. */
@media (max-width: 899px) {
  .pay-pane { background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); margin: 0 -12px; padding: 10px 12px; border-top: 1px solid var(--line); }
  .pay-pane .totals { padding: 12px 14px; gap: 2px; }
  .pay-pane .totals .row:not(.grand) { display: none; }
  .pay-pane .totals .grand { border: 0; padding: 0; margin: 0; font-size: 22px; }
  .pay-pane #clear, .pay-pane .hint { display: none; }
}

/* ---- dialogs ---- */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(8, 12, 24, .5); backdrop-filter: blur(3px); display: grid; align-items: end; justify-items: center; opacity: 0; transition: opacity .18s; }
.modal-back.show { opacity: 1; }
.modal { width: 100%; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg); transform: translateY(20px); transition: transform .2s; padding-bottom: env(safe-area-inset-bottom); }
.modal-back.show .modal { transform: none; }
@media (min-width: 640px) { .modal-back { align-items: center; } .modal { width: min(460px, calc(100vw - 32px)); border-radius: 22px; } .modal.wide { width: min(720px, calc(100vw - 32px)); } }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 18px 18px 0 22px; }
.modal header h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 16px 22px 22px; display: grid; gap: 14px; }
.modal-body p { margin: 0; }
.due { font-size: 15px; color: var(--muted); }
.due strong { display: block; font-size: 34px; color: var(--text); letter-spacing: -.03em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 650; cursor: pointer; }
.change { font-size: 18px; font-weight: 700; }
.change.ok { color: var(--good); }
.change.short { color: var(--bad); }
.change-due { text-align: center; padding: 18px; border-radius: var(--radius); background: var(--good-soft); color: var(--good); font-weight: 600; }
.change-due strong { display: block; font-size: 40px; letter-spacing: -.03em; }
.change-due.paid { background: var(--accent-soft); color: var(--accent); }
.receipt-actions { display: grid; grid-auto-flow: column; gap: 8px; }
.card-wait { display: grid; justify-items: center; gap: 14px; padding: 16px; text-align: center; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.camera-box { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 62vh; }
@media (min-width: 640px) { .camera-box { aspect-ratio: 4 / 3; } }
.camera { width: 100%; height: 100%; object-fit: cover; display: block; }
.aim { position: absolute; inset: 32% 10%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
.aim::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #f43f5e; box-shadow: 0 0 12px #f43f5e; animation: sweep 1.6s ease-in-out infinite alternate; }
@keyframes sweep { from { transform: translateY(-28px); } to { transform: translateY(28px); } }
.camera-bar { display: flex; align-items: center; gap: 10px; }
.camera-status { flex: 1; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
[data-torch].on { background: #fde68a; color: #111; border-color: #fde68a; }

/* ---- sign-in ---- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px 28px; box-shadow: var(--shadow-lg); display: grid; gap: 16px; }
.auth-card h1 { margin-top: 4px; }
.auth-card p { margin: -8px 0 4px; }

/* ---- toasts ---- */
#toasts { position: fixed; z-index: 60; left: 50%; top: max(16px, env(safe-area-inset-top)); transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 14px; background: #0f172a; color: #fff; box-shadow: var(--shadow-lg); font-weight: 550; opacity: 0; transform: translateY(-8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.good { background: #047857; }
.toast.error { background: #b91c1c; }
.toast.warn { background: #b45309; }

/* ---- receipts (screen preview and 80mm print) ---- */
.receipt-card { display: grid; justify-items: center; background: var(--surface-2); }
.receipt { width: 72mm; max-width: 100%; background: #fff; color: #111; padding: 16px 14px; font-size: 13px; border-radius: 6px; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td { padding: 2px 0; vertical-align: top; }
.receipt td:last-child { text-align: right; white-space: nowrap; padding-left: 8px; }
.r-logo { display: block; max-width: 48mm; max-height: 22mm; margin: 0 auto 6px; }
.r-name { text-align: center; font-weight: 700; font-size: 16px; }
.r-center { text-align: center; color: #333; }
.r-meta { margin: 10px 0; color: #444; font-size: 12px; }
.r-sub { color: #555; font-size: 12px; }
.r-void { text-align: center; font-weight: 800; letter-spacing: .1em; margin-bottom: 6px; }
.r-totals { border-top: 1px dashed #999; margin-top: 6px; padding-top: 4px; }
.r-grand td { font-weight: 800; font-size: 15px; }
.r-foot { margin-top: 12px; }
#print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 4mm; }
  body { background: #fff; }
  body > :not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area .receipt { box-shadow: none; width: 100%; padding: 0; }
}

/* ---- inventory count scan log ---- */
.scan-log { padding: 4px 0; }
.scan-entry { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.scan-entry:last-child { border-bottom: 0; }
.scan-entry.flash { animation: flash .8s ease-out; }
.scan-qty { min-width: 52px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 750; font-variant-numeric: tabular-nums; background: var(--good-soft); color: var(--good); }
.scan-qty.set { background: var(--accent-soft); color: var(--accent); }
.scan-info { display: grid; min-width: 0; }
.scan-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-info small { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.icon-btn.del { color: var(--bad); min-width: var(--tap); min-height: var(--tap); }
.icon-btn.del:hover { background: var(--bad-soft); }

/* ---- product photos ---- */
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; background: #fff; border: 1px solid var(--line); flex: none; display: block; }
.thumb.none { background: var(--surface-2) url(/icon.svg) center / 18px no-repeat; opacity: .5; }
.thumb.big { width: 132px; height: 132px; border-radius: 14px; object-fit: contain; }
.thumb-cell { width: 60px; padding-right: 0 !important; }
.gallery { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.gallery figure { margin: 0; display: grid; gap: 6px; justify-items: center; }
.gallery figcaption { display: flex; align-items: center; gap: 4px; }
.line { grid-template-columns: auto minmax(0, 1fr) auto auto; padding-left: 10px; }
.suggest button .grow, .pick .grow { flex: 1; }
.suggest button, .pick { justify-content: flex-start; }
.scan-entry { grid-template-columns: auto auto minmax(0, 1fr) auto; }
.scan-info strong { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.scan-info .desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.segmented.links a { white-space: nowrap; }
@media (max-width: 640px) {
  .scan-entry { gap: 10px; padding: 12px 10px; }
  .scan-qty { min-width: 44px; }
  .page-head h1 { font-size: 22px; }
}
.segmented.links a { display: flex; align-items: center; justify-content: center; gap: 4px; }
.show-sm { display: none; }
@media (max-width: 640px) {
  .show-sm { display: block; color: var(--muted); font-weight: 500; }
  .line { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "img main main" "img step amt"; row-gap: 4px; padding: 10px 12px; }
  .line > .thumb { grid-area: img; align-self: start; }
  .line > .line-main { grid-area: main; padding: 2px 4px; }
  .line > .stepper { grid-area: step; justify-self: start; margin-left: 4px; }
  .line > .amount { grid-area: amt; }
}
@media (max-width: 640px) {
  .table th, .table td { padding: 10px 8px; }
  .thumb-cell { width: 48px; }
  .thumb-cell .thumb { width: 38px; height: 38px; }
}
