/* Card Inventory — one stylesheet. Mobile first; sidebar from 900px. */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --text: #171a26;
  --muted: #646b80;
  --line: #e2e4ec;
  --primary: #4338ca;
  --primary-ink: #ffffff;
  --primary-soft: #e8e7fb;
  --accent: #f59e0b;
  --good: #15803d;
  --bad: #c2410c;
  --danger: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 18 30 / 6%), 0 2px 8px rgb(16 18 30 / 5%);
  --nav-w: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1f2330;
    --text: #e8eaf2;
    --muted: #9298ad;
    --line: #2a2f3d;
    --primary: #818cf8;
    --primary-ink: #0f1117;
    --primary-soft: #262a4a;
    --good: #4ade80;
    --bad: #fb923c;
    --danger: #f87171;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .6rem; }
p { margin: .3rem 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.error { color: var(--danger); margin: .4rem 0; }
.error:empty { display: none; }
.mono { font-family: ui-monospace, Consolas, monospace; width: 100%; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */

#shell { min-height: 100vh; }
#app { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 1280px; margin: 0 auto; }
body.bare #app { padding-bottom: 24px; }

#nav { display: none; }
#tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px 4px env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; color: var(--muted); font-size: .72rem; border-radius: 10px;
}
.tab.active { color: var(--primary); }
.tab.pos .icon { background: var(--primary); color: var(--primary-ink); border-radius: 10px; padding: 3px; width: 30px; height: 30px; margin-top: -4px; }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

@media (min-width: 900px) {
  #tabbar { display: none !important; }
  #nav:not([hidden]) {
    display: flex; flex-direction: column; gap: 2px;
    position: fixed; inset: 0 auto 0 0; width: var(--nav-w);
    background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px;
  }
  body:not(.bare) #app { margin-left: var(--nav-w); padding: 24px 32px 48px; }
  body:not(.bare) #app { max-width: calc(1280px + var(--nav-w)); }
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); padding: 4px 8px 16px; }
.brand img { width: 30px; height: 30px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--text); }
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-foot { margin-top: auto; padding: 8px; font-size: .82rem; color: var(--muted); }
.event-pill { color: var(--good); margin-bottom: 6px; }

/* ---------- page furniture ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head .sub { color: var(--muted); margin: 2px 0 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; font-size: .85rem; margin-bottom: 4px; }
.section-title { margin: 20px 0 10px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.totals { color: var(--muted); font-size: .88rem; margin: 0 0 10px; }
.banner { background: var(--primary-soft); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
.card-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.section-head h3 { margin: 0; }
.section-head .btn { margin-left: auto; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 40px; color: var(--muted); }
.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.two-col { display: grid; gap: 14px; }
@media (min-width: 1000px) { .two-col { grid-template-columns: 1fr 1fr; } .two-col > .card-box { margin: 0; } .two-col { margin-bottom: 14px; } }

/* ---------- controls ---------- */

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; min-height: 40px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); border-color: var(--primary); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); padding: 0; }
.filters select { width: auto; }
.search { font-size: 1rem; }
.check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: .9rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; min-height: 40px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.primary.danger, button.danger[type="submit"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: .85rem; }
.btn.wide { width: 100%; }
.btn.big { width: 100%; min-height: 54px; font-size: 1.05rem; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; margin-bottom: 12px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field .label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field .hint, .hint { font-size: .78rem; color: var(--muted); }
.form-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
details summary { cursor: pointer; color: var(--muted); margin: 6px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: .85rem; color: var(--text); }
.chip.small { padding: 1px 7px; font-size: .75rem; }

/* ---------- cards & badges ---------- */

.card-img { display: block; width: 100%; aspect-ratio: 5 / 7; object-fit: contain; background: var(--surface-2); border-radius: 8px; }
.card-img.placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .75rem; }
.card-img.broken { visibility: hidden; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { font-size: .7rem; font-weight: 600; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); }
.badge.graded { background: color-mix(in srgb, var(--accent) 25%, var(--surface)); color: var(--text); }
.badge.variant { background: var(--primary-soft); color: var(--primary); }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .1s; }
.tile:hover { transform: translateY(-2px); }
.tile-img { position: relative; padding: 8px 8px 0; }
.tile .qty { position: absolute; right: 12px; bottom: 6px; background: var(--text); color: var(--bg); font-weight: 700; font-size: .8rem; padding: 1px 7px; border-radius: 6px; }
.pick { position: absolute; left: 12px; top: 12px; }
.tile-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 1px; flex: 1; }
.tile-name { font-weight: 600; line-height: 1.25; }
.tile-set { font-size: .8rem; color: var(--muted); }
.tile-price { margin-top: auto; padding-top: 6px; font-size: .95rem; }
.soldout { opacity: .55; }

.list { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--text); }
.row .pick { position: static; }
.row-img { width: 44px; flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-num { display: flex; flex-direction: column; align-items: flex-end; font-size: .9rem; min-width: 60px; }
.row-num .muted { font-size: .7rem; }
@media (max-width: 640px) { .hide-sm, .row-num:nth-of-type(4) { display: none; } }

.selbar { position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; background: var(--text); color: var(--bg); padding: 8px 10px 8px 16px; border-radius: 14px; box-shadow: 0 8px 30px rgb(0 0 0 / 25%); }
.selbar .btn.ghost { color: var(--bg); }
@media (min-width: 900px) { .selbar { bottom: 24px; left: calc(50% + var(--nav-w) / 2); } }

/* ---------- item page ---------- */

.item-layout { display: grid; gap: 18px; margin-bottom: 14px; }
@media (min-width: 900px) { .item-layout { grid-template-columns: 300px 1fr; align-items: start; } }
.item-media { display: flex; flex-direction: column; gap: 12px; max-width: 340px; }
.sku-box { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.qr-box { width: 84px; height: 84px; flex: none; background: #fff; padding: 4px; border-radius: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.sku { font: 700 1.2rem ui-monospace, Consolas, monospace; letter-spacing: .08em; }
.stat-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat.bad .stat-value { color: var(--bad); }
.stat-label { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 1.25rem; font-weight: 700; margin-top: 2px; }
.stat-value .big { font-size: 1.5rem; }
.stat-sub { font-size: .8rem; color: var(--muted); }
table.mini { border-collapse: collapse; width: 100%; margin-bottom: 8px; }
table.mini td { padding: 4px 8px 4px 0; font-size: .9rem; }
table.mini tr.hl td { font-weight: 600; }
.audit { margin: 0; padding-left: 18px; font-size: .9rem; }
.audit li { margin: 4px 0; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.data th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.data td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; white-space: nowrap; }
td.warn { color: var(--bad); font-weight: 600; }
tr.voided td, tr.inactive td { opacity: .5; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 4px; }
.cell-card { display: flex; gap: 10px; align-items: center; color: var(--text); min-width: 180px; }
.cell-card .card-img { width: 38px; flex: none; }
.buylist .price { width: 90px; text-align: right; min-height: 34px; padding: 5px 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1.3fr) 1fr auto; gap: 10px; align-items: center; margin: 6px 0; font-size: .9rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { background: var(--surface-2); border-radius: 4px; height: 10px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bar-value { font-variant-numeric: tabular-nums; }
.period-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.period-head .section-title { margin: 0; }
.period-head .segmented { margin: 0; }
.period-head select { width: auto; }

/* ---------- pickers ---------- */

.picker-results { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.picker-results.busy { opacity: .6; }
.pick-row { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; width: 100%; }
.pick-row:hover { border-color: var(--primary); }
.pick-row .card-img { width: 46px; flex: none; }
.pick-main { flex: 1; min-width: 0; }
.pick-prices { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.pick-local { text-align: right; font-weight: 600; white-space: nowrap; }
.add-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.add-head .card-img { width: 90px; flex: none; }
.add-head > div { flex: 1; }
.ref { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; font-size: .9rem; }
.recent h3 { margin-top: 10px; }
.recent-row { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; color: var(--text); }
.recent-row .card-img { width: 36px; }
.recent-row > div { flex: 1; }

/* ---------- POS ---------- */

.scan-bar .scan-input { font: 600 1.05rem ui-monospace, Consolas, monospace; letter-spacing: .03em; }
.pos-section { padding: 12px; }
.pos-line { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.pos-line:first-of-type { border-top: 0; }
.pos-line .card-img { width: 52px; }
.pos-line.has-error { background: color-mix(in srgb, var(--danger) 8%, transparent); border-radius: 8px; }
.pos-line-side { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
@media (min-width: 700px) { .pos-line { grid-template-columns: 52px 1fr auto; } .pos-line-side { grid-column: auto; } }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.stepper button { border: 0; background: var(--surface-2); width: 34px; height: 36px; font-size: 1.1rem; cursor: pointer; }
.stepper span { min-width: 34px; text-align: center; font-weight: 600; }
.price-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; }
.price-wrap .price { width: 96px; text-align: right; font-weight: 600; }
.line-total { min-width: 80px; text-align: right; font-weight: 700; }
.inline-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.inline-controls select, .inline-controls input { width: auto; min-height: 32px; padding: 4px 8px; font-size: .85rem; }
.pos-totals { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .pos-totals { bottom: 12px; } }
.total-grid { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.total-grid > div { display: flex; flex-direction: column; }
.total-grid strong { font-size: 1.15rem; }
.total-grid .net strong { font-size: 1.6rem; color: var(--primary); }
.pos-foot { margin-bottom: 16px; }
.receipt h2 { color: var(--good); }
.big-money { font-size: 1.4rem; font-weight: 700; }
.receipt-lines { list-style: none; padding: 0; margin: 12px 0; }
.receipt-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }

/* ---------- transactions ---------- */

.txn-list { display: flex; flex-direction: column; gap: 6px; }
.txn { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); }
.txn.voided { opacity: .5; text-decoration: line-through; }
.txn-main { flex: 1; min-width: 0; }
.txn-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.txn-money { text-align: right; font-weight: 700; white-space: nowrap; }
.kind { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; text-transform: uppercase; min-width: 82px; text-align: center; background: var(--surface-2); }
.kind.sale { background: color-mix(in srgb, var(--good) 18%, var(--surface)); color: var(--good); }
.kind.purchase { background: var(--primary-soft); color: var(--primary); }
.kind.trade { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }

/* ---------- settings / more ---------- */

.more-list { display: flex; flex-direction: column; gap: 8px; }
.more-link { display: flex; flex-direction: column; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); cursor: pointer; }

/* ---------- auth ---------- */

.auth { min-height: 90vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card form { margin-top: 18px; }
.auth-logo { width: 44px; height: 44px; margin-bottom: 12px; }

/* ---------- public buy list ---------- */

.public-page { max-width: 900px; margin: 0 auto; }
.public-head { margin: 10px 0 16px; }
table.public .cell-card .card-img { width: 44px; }

/* ---------- modal, toast, scanner ---------- */

dialog.modal { border: 0; border-radius: 16px; padding: 22px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 30%); }
dialog.modal::backdrop { background: rgb(10 12 20 / 45%); }
#toasts { position: fixed; z-index: 100; top: 12px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgb(0 0 0 / 20%); max-width: min(520px, calc(100vw - 32px)); transition: opacity .3s, transform .3s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.scanner { position: fixed; inset: 0; z-index: 90; background: #000; color: #fff; display: flex; flex-direction: column; }
.scanner-top { display: flex; justify-content: space-between; align-items: center; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
.scanner-view { position: relative; flex: 1; overflow: hidden; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame { position: absolute; inset: 50% auto auto 50%; width: min(64vw, 300px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid rgb(255 255 255 / 85%); border-radius: 18px; box-shadow: 0 0 0 100vmax rgb(0 0 0 / 35%); }
.scan-status { text-align: center; padding: 14px 14px calc(18px + env(safe-area-inset-bottom)); margin: 0; }

/* ---------- labels ---------- */

.label-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.label-controls h1 { margin-right: auto; }
.label-controls select { width: auto; }
.labels { display: flex; flex-wrap: wrap; gap: 8px; }
.qr-label { background: #fff; color: #000; border: 1px dashed #bbb; display: flex; gap: 2mm; padding: 1.5mm; overflow: hidden; width: 50mm; height: 25mm; }
.qr-label .qr { width: 21mm; height: 21mm; flex: none; }
.label-text { display: flex; flex-direction: column; min-width: 0; flex: 1; font-size: 7pt; line-height: 1.2; }
.label-name { font-weight: 700; font-size: 8pt; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.label-set, .label-cond { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.label-sku { font: 700 7pt ui-monospace, Consolas, monospace; letter-spacing: .05em; }
.label-price { font-weight: 800; font-size: 10pt; }
body[data-labels="thermal-57x32"] .qr-label { width: 57mm; height: 32mm; }
body[data-labels="thermal-57x32"] .qr-label .qr { width: 27mm; height: 27mm; }
body[data-labels="a4-sheet"] .labels { width: 210mm; gap: 0; }
body[data-labels="a4-sheet"] .qr-label { width: 70mm; height: 37mm; border-color: #eee; padding: 3mm; }
body[data-labels="a4-sheet"] .qr-label .qr { width: 28mm; height: 28mm; }

@media print {
  body { background: #fff; color: #000; }
  #nav, #tabbar, #toasts, .no-print, .label-controls, .head-actions, .selbar { display: none !important; }
  #app, body:not(.bare) #app { margin: 0 !important; padding: 0 !important; max-width: none; }
  .card-box, .stat { box-shadow: none; break-inside: avoid; }
  body[data-labels] .labels { gap: 0; }
  body[data-labels] .qr-label { border: 0; break-after: page; }
  body[data-labels="a4-sheet"] .qr-label { break-after: auto; }
}
@page { margin: 12mm; }

/* Phones: filters scroll sideways instead of stacking four rows deep. */
@media (max-width: 640px) {
  .filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .filters > * { flex: none; }
  .page-head h1 { font-size: 1.3rem; }
}
table.public .cell-card { min-width: 0; }
@media (max-width: 640px) { table.public td, table.public th { padding: 8px 4px; } }
