/* GroceryPOS v13 — design system
   Mobile-first. Breakpoints: 720px (tablet), 1024px (desktop sidebar), 1400px (wide). */

:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --line: #e4e8f0;
  --line-2: #d5dce7;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --brand: #0b1220;
  --brand-2: #131d33;
  --accent: #2f5bff;
  --accent-2: #2448e0;
  --accent-soft: #ebf0ff;
  --accent-ink: #1d3fbf;
  --success: #16a34a;
  --success-soft: #e7f7ee;
  --success-ink: #166534;
  --warn: #d97706;
  --warn-soft: #fff4e2;
  --warn-ink: #8a3b0a;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --danger-ink: #991b1b;
  --violet: #7c3aed;
  --violet-soft: #f2ecff;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow: 0 10px 30px rgba(15, 23, 42, .07), 0 2px 6px rgba(15, 23, 42, .04);
  --shadow-lg: 0 28px 70px rgba(2, 6, 23, .28);
  --topbar-h: 60px;
  --sidebar-w: 264px;
  --tabbar-h: 66px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

.css-check { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; min-height: 100vh; min-height: 100dvh; }
img, svg, video, canvas { display: block; max-width: 100%; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.02em; color: var(--text); }
h1 { font-size: clamp(24px, 3.2vw, 30px); font-weight: 800; }
h2 { font-size: 18px; font-weight: 750; }
h3, .h3 { font-size: 15px; font-weight: 750; display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
:focus-visible { outline: 3px solid rgba(47, 91, 255, .45); outline-offset: 2px; border-radius: 6px; }

.i { width: 20px; height: 20px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 26px; height: 26px; }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 999; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 16px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); font-weight: 650; font-size: 14px; line-height: 1.2;
  text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.btn:hover { border-color: #c3ccda; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: linear-gradient(180deg, #1a2540, var(--brand)); border-color: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(11, 18, 32, .18); }
.btn-primary:hover { background: #1a2540; border-color: #1a2540; color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(47, 91, 255, .25); }
.btn-accent:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }
.btn-danger { background: var(--surface); border-color: #f3c4c4; color: var(--danger-ink); }
.btn-danger:hover { background: var(--danger-soft); border-color: #eaa; }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn-soft:hover { background: #dfe7ff; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { min-height: 34px; padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: 12px 20px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn .i { width: 18px; height: 18px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 0;
  background: transparent; color: inherit; cursor: pointer; flex: 0 0 auto; padding: 0;
}
.icon-btn:hover { background: rgba(148, 163, 184, .16); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ------------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .label { font-size: 13px; font-weight: 650; color: var(--text-2); }
.field .hint, .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
select.input { padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
textarea.input { min-height: 90px; resize: vertical; }
.input.code { font-family: var(--mono); font-size: 13px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(47, 91, 255, .14); }
.input::placeholder { color: #a3aec0; }
.input[readonly] { background: var(--surface-2); }
.input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(220, 38, 38, .12); }
.input-group { display: flex; align-items: stretch; gap: 0; position: relative; }
.input-group > .input { flex: 1; min-width: 0; }
.input-group > .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; min-height: 44px; }
.input-group > .btn-ghost { border: 1px solid var(--line-2); background: var(--surface-2); }
.input-icon { position: relative; }
.input-icon > .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon > .input { padding-left: 40px; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 16px; grid-template-columns: 1fr; }
.grid-2.tight, .grid-3.tight { gap: 10px; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1200px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 380px) { .form-grid { grid-template-columns: 1fr; } }

.stepper { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; background: var(--surface); }
.stepper button { width: 48px; border: 0; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); }
.stepper button:active { background: var(--surface-3); }
.stepper input { flex: 1; min-width: 0; border: 0; text-align: center; font-size: 18px; font-weight: 700; padding: 8px 4px; outline: none; background: transparent; }

/* ------------------------------------------------------------------- alerts */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; margin: 0 0 14px; background: var(--accent-soft); color: var(--accent-ink); border: 1px solid #d6e0ff; font-size: 14px; transition: opacity .4s; }
.alert .i { margin-top: 1px; }
.alert-success { background: var(--success-soft); color: var(--success-ink); border-color: #c7ecd5; }
.alert-danger { background: var(--danger-soft); color: var(--danger-ink); border-color: #f6caca; }
.alert-warn { background: var(--warn-soft); color: var(--warn-ink); border-color: #fbdcaa; }
.alert.is-fading { opacity: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; line-height: 1.5; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge-ok { background: var(--success-soft); color: var(--success-ink); }
.badge-warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge-danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-dark { background: var(--brand); color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex: 0 0 auto; }
.dot-ok { background: var(--success); box-shadow: 0 0 0 4px rgba(22, 163, 74, .15); }
.dot-warn { background: var(--warn); }
.dot-live { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); } 60% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); } }

/* ---------------------------------------------------------------- app shell */
.nav-toggle { position: fixed; opacity: 0; pointer-events: none; width: 1px; height: 1px; left: -10px; }
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60; height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) max(12px, var(--safe-r)) 0 max(8px, var(--safe-l));
  display: flex; align-items: center; gap: 8px; background: var(--brand); color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06), 0 6px 20px rgba(2, 6, 23, .18);
}
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .09); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 18px; letter-spacing: -.03em; text-decoration: none !important; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #3b6bff, #6d4bff); color: #fff; box-shadow: 0 6px 16px rgba(59, 107, 255, .35); }
.brand-mark .i { width: 19px; height: 19px; }
.brand-name b { color: #8fb0ff; font-weight: 800; }
.topbar-store { color: #94a3b8; font-size: 13px; padding-left: 12px; margin-left: 4px; border-left: 1px solid rgba(255, 255, 255, .12); display: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-spacer { flex: 1; }
.net-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: #7c2d12; color: #fed7aa; font-size: 12px; font-weight: 700; }
.net-pill .i { width: 15px; height: 15px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px; border-radius: 12px; color: #fff; text-decoration: none !important; }
.user-chip:hover { background: rgba(255, 255, 255, .08); }
.avatar { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: #26324d; color: #cfe0ff; font-weight: 800; font-size: 14px; flex: 0 0 auto; }
.user-chip-text { display: none; line-height: 1.15; }
.user-chip-text b { display: block; font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-text small { color: #94a3b8; font-size: 11px; }
.logout-form { margin: 0; display: none; }
.topbar-menu { color: #fff; }

.shell { padding-top: calc(var(--topbar-h) + var(--safe-t)); min-height: 100vh; min-height: 100dvh; }
.main { padding: 18px max(14px, var(--safe-r)) calc(var(--tabbar-h) + var(--safe-b) + 24px) max(14px, var(--safe-l)); max-width: 1480px; margin: 0 auto; min-width: 0; }
.main-bare { min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: fixed; z-index: 80; top: 0; bottom: 0; left: 0; width: min(86vw, 300px);
  background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  transform: translateX(-104%); transition: transform .26s var(--ease); box-shadow: var(--shadow-lg);
  padding: calc(var(--safe-t) + 12px) 12px calc(var(--safe-b) + 12px) max(12px, var(--safe-l)); overflow-y: auto; overscroll-behavior: contain;
}
.sidebar-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(2, 6, 23, .45); opacity: 0; pointer-events: none; transition: opacity .2s; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.nav-toggle:checked ~ .shell .sidebar { transform: none; }
.nav-toggle:checked ~ .shell .sidebar-scrim { opacity: 1; pointer-events: auto; }
html.nav-open, html.nav-open body { overflow: hidden; }
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 6px 4px 14px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.sidebar-head b { display: block; font-size: 14px; }
.sidebar-head small { display: block; color: var(--muted); font-size: 12px; }
.sidebar-head > div { flex: 1; min-width: 0; }
.sidebar-head > div b, .sidebar-head > div small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-close { color: var(--muted); }
.sidebar-nav { flex: 1; }
.nav-label { font-size: 10.5px; letter-spacing: .12em; font-weight: 800; color: var(--faint); text-transform: uppercase; padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 1px 0; border-radius: 11px;
  color: var(--text-2); font-weight: 600; font-size: 14.5px; text-decoration: none !important; position: relative;
  border: 0; background: none; width: 100%; text-align: left;
}
.nav-item .i { color: var(--faint); }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item.is-active .i { color: var(--accent); }
.nav-item.is-active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 11.5px; font-weight: 800; display: grid; place-items: center; }
.nav-pill { margin-left: auto; font-size: 9.5px; font-weight: 800; letter-spacing: .06em; color: var(--success-ink); background: var(--success-soft); border-radius: 999px; padding: 2px 7px; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 10px; }
.sidebar-foot form { margin: 0; }
.sidebar-foot small { display: block; color: var(--faint); font-size: 11px; padding: 6px 12px 0; }
.nav-logout { color: var(--danger-ink); }
.nav-logout .i { color: var(--danger); }

.tabbar {
  position: fixed; z-index: 55; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--safe-b));
  padding: 0 max(4px, var(--safe-r)) var(--safe-b) max(4px, var(--safe-l));
  background: rgba(255, 255, 255, .96); -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line); display: flex; align-items: stretch; justify-content: space-around;
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 650; text-decoration: none !important; cursor: pointer; min-width: 0; -webkit-user-select: none; user-select: none; }
.tab .i { width: 23px; height: 23px; }
.tab.is-active { color: var(--accent-ink); }
.tab-center .tab-icon { width: 56px; height: 56px; margin-top: -26px; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(135deg, #3b6bff, #6d4bff); color: #fff; box-shadow: 0 10px 24px rgba(59, 107, 255, .4); border: 4px solid var(--bg); }
.tab-center .i { width: 26px; height: 26px; }
.tab-center { color: var(--accent-ink); }

@media (min-width: 720px) {
  .main { padding: 24px 24px calc(var(--tabbar-h) + var(--safe-b) + 28px); }
  .topbar-store { display: block; }
  .user-chip-text { display: block; }
}
@media (min-width: 1024px) {
  .topbar { padding-left: 18px; }
  .topbar-menu { display: none; }
  .logout-form { display: block; }
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); background: linear-gradient(90deg, #fbfcfe var(--sidebar-w), var(--line) var(--sidebar-w), var(--line) calc(var(--sidebar-w) + 1px), transparent calc(var(--sidebar-w) + 1px)); }
  .sidebar { position: sticky; top: calc(var(--topbar-h) + var(--safe-t)); height: calc(100dvh - var(--topbar-h) - var(--safe-t)); width: auto; transform: none; box-shadow: none; z-index: 10; padding: 14px 14px 14px; background: #fbfcfe; }
  .sidebar-head { display: none; }
  .sidebar-scrim { display: none; }
  .tabbar { display: none; }
  .main { padding: 30px 34px 48px; width: 100%; }
  html.nav-open, html.nav-open body { overflow: auto; }
}

/* -------------------------------------------------------------- page head */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 20px; }
.page-head > div:first-child { min-width: 0; flex: 1 1 280px; }
.page-head p { margin: 6px 0 0; }
.page-head .btn-row { flex: 0 0 auto; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
@media (max-width: 519px) {
  .page-head .btn-row { width: 100%; }
  .page-head .btn-row > .btn { flex: 1; }
}

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 18px; min-width: 0; }
.card + .card { margin-top: 16px; }
.grid-2 > .card + .card, .grid-3 > .card + .card, .grid-4 > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 9px; }
.card-head h2 .i { color: var(--accent); }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 16px 18px 0; }
@media (min-width: 720px) { .card { padding: 22px; } .card-flush { padding: 0; } .card-flush > .card-head { padding: 20px 22px 0; } }
.section { margin-top: 22px; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; overflow: hidden; }
.stat-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stat-label { font-size: 11px; letter-spacing: .1em; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.stat-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.amber { background: var(--warn-soft); color: var(--warn); }
.stat-icon.violet { background: var(--violet-soft); color: var(--violet); }
.stat-value { font-size: clamp(22px, 5vw, 30px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; overflow-wrap: anywhere; }
.stat-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.stat.is-hero { background: radial-gradient(120% 140% at 0% 0%, #2847c9 0%, #16213d 55%, #0b1220 100%); color: #fff; border-color: #1a2645; }
.stat.is-hero .stat-label, .stat.is-hero .stat-foot { color: #b4c3e6; }
.stat.is-hero .stat-icon { background: rgba(255, 255, 255, .12); color: #fff; }
.stat.is-attn { border-color: #f5d49c; background: linear-gradient(180deg, #fffaf0, #fff); }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 750; }
.trend.up { color: #4ade80; }
.trend.down { color: #fca5a5; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 18px; }
@media (min-width: 1100px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }

.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mini-stats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.mini-stats b { display: block; font-size: 22px; letter-spacing: -.02em; }
.mini-stats span { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 800; padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbff; }
.table tr[data-href] { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.table .col-check { width: 44px; }
.table .empty-row td { text-align: center; color: var(--muted); padding: 40px 16px; }
.cell-product { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.cell-product > div { min-width: 0; }
.cell-product b { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--line); flex: 0 0 auto; display: grid; place-items: center; color: var(--faint); overflow: hidden; }
.thumb .i { width: 20px; height: 20px; }
.thumb-lg { width: 72px; height: 72px; border-radius: 14px; }
.code-chip { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); border-radius: 7px; padding: 2px 7px; white-space: nowrap; }

@media (max-width: 719px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 12px 14px; border-bottom: 1px solid var(--line); position: relative; }
  .table.responsive tbody tr:last-child { border-bottom: 0; }
  .table.responsive td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; align-items: center; text-align: right; }
  .table.responsive td::before { content: attr(data-label); font-size: 12px; color: var(--muted); font-weight: 650; text-align: left; flex: 0 0 auto; }
  .table.responsive td[data-label=""]::before, .table.responsive td.td-main::before { display: none; }
  .table.responsive td.td-main { display: block; text-align: left; padding-bottom: 6px; }
  .table.responsive td.col-check { position: absolute; right: 12px; top: 12px; width: auto; }
  .table.responsive td.col-check::before { display: none; }
  .table.responsive td.td-actions { justify-content: flex-end; padding-top: 8px; }
  .table.responsive td.td-actions::before { display: none; }
  .table.responsive .num { text-align: right; }
  .table.responsive tbody tr:hover td { background: transparent; }
  .table-wrap { border-radius: 0; }
}

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 240px; min-width: 0; }
.toolbar form { display: contents; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 13px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 10px; color: var(--text-2); font-weight: 650; font-size: 13.5px; white-space: nowrap; border: 0; background: none; text-decoration: none !important; }
.tabs .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tabs .count { font-size: 11px; background: var(--warn); color: #fff; border-radius: 999px; padding: 0 6px; font-weight: 800; }
.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--brand); color: #fff; border-radius: 14px; margin-bottom: 12px; position: sticky; top: calc(var(--topbar-h) + var(--safe-t) + 8px); z-index: 20; box-shadow: var(--shadow); }
.bulkbar .btn { min-height: 36px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 16px; }
.pager-info { font-size: 13px; color: var(--muted); }

.empty-state { text-align: center; padding: 42px 18px; color: var(--muted); }
.empty-state .empty-icon { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px; display: grid; place-items: center; background: var(--surface-3); color: var(--faint); }
.empty-state .empty-icon .i { width: 30px; height: 30px; }
.empty-state b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid #eef1f6; min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow b { display: block; font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .grow small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--surface-3); color: var(--text-2); flex: 0 0 auto; }
.rank-1 { background: #fff3c4; color: #8a6100; }
.rank-2 { background: #eef2f7; color: #475569; }
.rank-3 { background: #fde6d6; color: #9a4a16; }
.bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, #3b6bff, #6d4bff); border-radius: 999px; }

/* ---------------------------------------------------------------- dialogs */
dialog { border: 0; padding: 0; background: transparent; color: inherit; max-width: none; max-height: none; }
dialog:not([open]) { display: none !important; }
dialog::backdrop { background: rgba(2, 6, 23, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
html.has-dialog, html.has-dialog body { overflow: hidden; }
.modal {
  width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); margin: auto; background: var(--surface); border-radius: 22px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
}
dialog[open].modal { animation: pop .22s var(--ease); }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.modal-body { padding: 18px 20px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { padding: 14px 20px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); }
.modal-wide { width: min(980px, calc(100vw - 24px)); }
@media (max-width: 719px) {
  .modal { width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  dialog[open].modal { animation: slideup .26s var(--ease); }
  .modal-foot .btn { flex: 1; }
}
@keyframes slideup { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------------ toasts */
.toast-stack { position: fixed; z-index: 400; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); display: flex; flex-direction: column; gap: 8px; width: min(460px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: #0f172a; color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 550; animation: toastin .25s var(--ease); }
.toast span { flex: 1; }
.toast-success .i { color: #4ade80; }
.toast-danger { background: #7f1d1d; }
.toast-danger .i { color: #fecaca; }
.toast-warn .i { color: #fbbf24; }
.toast-action { border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-weight: 750; border-radius: 9px; padding: 6px 10px; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (min-width: 1024px) { .toast-stack { bottom: 24px; left: auto; right: 24px; transform: none; } }

/* ----------------------------------------------------------------- auth */
.auth-body { background: radial-gradient(1200px 600px at 10% -10%, #dfe7ff 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #efe6ff 0%, transparent 55%), var(--bg); }
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b)); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 30px 24px; box-shadow: var(--shadow); text-align: left; }
.auth-card-wide { width: min(560px, 100%); }
.auth-card h1 { font-size: 26px; margin-top: 14px; }
.auth-card > .muted { margin: 6px 0 20px; }
.auth-logo { width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center; background: linear-gradient(135deg, #3b6bff, #6d4bff); color: #fff; box-shadow: 0 12px 26px rgba(59, 107, 255, .35); font-size: 26px; font-weight: 900; }
.auth-logo .i { width: 28px; height: 28px; }
.auth-foot { display: flex; gap: 8px; align-items: center; margin: 18px 0 0; }
.auth-foot .i { width: 16px; height: 16px; }
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 14px 0 18px; counter-reset: s; }
.steps li { flex: 1; font-size: 12.5px; font-weight: 700; color: var(--faint); border-top: 3px solid var(--line); padding-top: 8px; counter-increment: s; }
.steps li::before { content: counter(s) ". "; }
.steps .is-current { color: var(--accent-ink); border-color: var(--accent); }
.steps .is-done { color: var(--success-ink); border-color: var(--success); }

/* ------------------------------------------------------------- dashboard */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.hero h1 { font-size: clamp(24px, 4vw, 32px); }
.hero .btn-row { flex: 0 0 auto; }
@media (max-width: 519px) { .hero .btn-row { width: 100%; display: grid; grid-template-columns: 1fr 1fr; } }
.quick { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 18px; }
@media (min-width: 1100px) { .quick { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.quick-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); color: var(--text); text-decoration: none !important; transition: transform .15s, box-shadow .15s, border-color .15s; min-height: 128px; position: relative; }
.quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #cfd8ea; }
.quick-card .qi { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; }
.quick-card .qi.green { background: var(--success-soft); color: var(--success); }
.quick-card .qi.amber { background: var(--warn-soft); color: var(--warn); }
.quick-card .qi.violet { background: var(--violet-soft); color: var(--violet); }
.quick-card b { font-size: 15px; }
.quick-card small { color: var(--muted); font-size: 12.5px; }
.quick-card.is-primary { background: linear-gradient(135deg, #2f5bff, #6d4bff); color: #fff; border-color: transparent; box-shadow: 0 14px 30px rgba(59, 107, 255, .3); }
.quick-card.is-primary small { color: #dfe6ff; }
.quick-card.is-primary .qi { background: rgba(255, 255, 255, .18); color: #fff; }
.chart { width: 100%; height: auto; overflow: visible; }
.chart .bar-rect { fill: #c9d6ff; }
.chart .bar-rect.is-today { fill: var(--accent); }
.chart text { font-size: 10px; fill: var(--muted); font-family: var(--font); }

/* ------------------------------------------------------------ scan station */
.scan-app { --cam-radius: 22px; }
.scan-cam { position: relative; background: #05070d; overflow: hidden; }
.scan-stage { position: absolute; inset: 0; overflow: hidden; touch-action: manipulation; }
.scan-stage video { width: 100%; height: 100%; object-fit: cover; background: #05070d; }
.scan-stage canvas.scan-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scan-guides { position: absolute; inset: 14% 8% 26%; pointer-events: none; border-radius: 22px; }
.scan-guides::before, .scan-guides::after { content: ""; position: absolute; inset: 0; border-radius: 22px; }
.scan-guides::before { background:
  linear-gradient(#fff, #fff) left top / 34px 4px no-repeat, linear-gradient(#fff, #fff) left top / 4px 34px no-repeat,
  linear-gradient(#fff, #fff) right top / 34px 4px no-repeat, linear-gradient(#fff, #fff) right top / 4px 34px no-repeat,
  linear-gradient(#fff, #fff) left bottom / 34px 4px no-repeat, linear-gradient(#fff, #fff) left bottom / 4px 34px no-repeat,
  linear-gradient(#fff, #fff) right bottom / 34px 4px no-repeat, linear-gradient(#fff, #fff) right bottom / 4px 34px no-repeat; opacity: .85; }
.scan-guides::after { left: 6%; right: 6%; top: 50%; bottom: auto; height: 2px; background: linear-gradient(90deg, transparent, #4ade80, transparent); box-shadow: 0 0 14px #22c55e; animation: laser 2.2s ease-in-out infinite; }
@keyframes laser { 0%, 100% { transform: translateY(-60px); opacity: .25; } 50% { transform: translateY(60px); opacity: 1; } }
.scan-app.is-paused .scan-guides::after, .scan-app:not(.is-live) .scan-guides { display: none; }
.scan-hint { position: absolute; left: 50%; top: calc(14% - 38px); transform: translateX(-50%); color: #fff; font-size: 13px; font-weight: 650; background: rgba(2, 6, 23, .55); padding: 6px 12px; border-radius: 999px; white-space: nowrap; pointer-events: none; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.scan-app:not(.is-live) .scan-hint { display: none; }
.scan-flash { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 0 6px #22c55e; opacity: 0; }
.scan-flash.is-on { animation: flash .5s ease-out; }
.scan-flash.is-new { box-shadow: inset 0 0 0 6px #3b82f6; }
.scan-flash.is-err { box-shadow: inset 0 0 0 6px #ef4444; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.focus-ring { position: absolute; width: 74px; height: 74px; margin: -37px 0 0 -37px; border: 2px solid #facc15; border-radius: 16px; pointer-events: none; opacity: 0; }
.focus-ring.is-on { animation: focusring .9s ease-out; }
@keyframes focusring { 0% { opacity: 1; transform: scale(1.35); } 40% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1); } }

.scan-idle { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: #e2e8f0; background: radial-gradient(80% 60% at 50% 40%, #16213d 0%, #05070d 75%); }
.scan-idle .idle-inner { max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.scan-idle .idle-icon { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; background: linear-gradient(135deg, #3b6bff, #6d4bff); color: #fff; box-shadow: 0 18px 40px rgba(59, 107, 255, .45); }
.scan-idle .idle-icon .i { width: 38px; height: 38px; }
.scan-idle h2 { color: #fff; font-size: 20px; }
.scan-idle p { color: #9fb0cf; font-size: 14px; margin: 0; }
.scan-idle .btn { min-width: 220px; }
.scan-app.is-live .scan-idle { display: none; }
.btn-on-dark { background: transparent; border-color: rgba(255, 255, 255, .18); color: #cbd5e1; }
.btn-on-dark:hover, .btn-on-dark:active { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .3); color: #fff; }
.scan-error { color: #fecaca; background: rgba(127, 29, 29, .5); border: 1px solid rgba(248, 113, 113, .4); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }

.scan-top { position: absolute; left: 0; right: 0; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px; padding: calc(var(--safe-t) + 8px) 10px 24px; background: linear-gradient(rgba(2, 6, 23, .72), rgba(2, 6, 23, 0)); color: #fff; }
.scan-top .icon-btn { color: #fff; background: rgba(15, 23, 42, .45); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); width: 44px; height: 44px; border-radius: 14px; }
.scan-top .icon-btn.is-on { background: #facc15; color: #111; }
.scan-top .spacer { flex: 1; }
.mode-select { position: relative; min-width: 0; flex: 0 1 auto; }
.mode-select select { -webkit-appearance: none; appearance: none; height: 44px; border-radius: 14px; border: 0; padding: 0 36px 0 14px; background: rgba(15, 23, 42, .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; color: #fff; font-weight: 750; font-size: 15px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); max-width: 100%; text-overflow: ellipsis; }
.mode-select select option { color: #0f172a; }
@media (max-width: 430px) { .scan-top #switchBtn { display: none; } .scan-top { gap: 5px; } }
.scan-counter { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border-radius: 999px; background: rgba(34, 197, 94, .2); color: #bbf7d0; font-weight: 800; font-size: 13px; border: 1px solid rgba(74, 222, 128, .35); }

.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 40px 12px calc(var(--safe-b) + 12px); background: linear-gradient(rgba(2, 6, 23, 0), rgba(2, 6, 23, .82) 45%); color: #fff; display: flex; flex-direction: column; gap: 10px; }
.zoom-row { display: flex; justify-content: center; gap: 8px; }
.zoom-row button { min-width: 46px; height: 34px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(15, 23, 42, .5); color: #fff; font-weight: 800; font-size: 13px; }
.zoom-row button.is-active { background: #fff; color: #0f172a; }
.last-scan { display: flex; align-items: center; gap: 12px; background: rgba(255, 255, 255, .96); color: var(--text); border-radius: 18px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); min-height: 64px; cursor: pointer; animation: toastin .25s var(--ease); }
.last-scan .grow { flex: 1; min-width: 0; }
.last-scan b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last-scan small { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last-scan .ls-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--success-soft); color: var(--success); flex: 0 0 auto; }
.last-scan.is-new .ls-icon { background: var(--accent-soft); color: var(--accent); }
.last-scan.is-err .ls-icon { background: var(--danger-soft); color: var(--danger); }
.last-scan .ls-price { font-weight: 800; font-size: 16px; white-space: nowrap; }
.scan-actions { display: flex; gap: 8px; }
.scan-actions > button { flex: 1 1 0; min-width: 0; }
.scan-actions button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 4px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(15, 23, 42, .55); color: #fff; font-size: 12px; font-weight: 700; position: relative; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.scan-actions button .i { width: 22px; height: 22px; }
.scan-actions .count { position: absolute; top: 5px; right: 12%; min-width: 20px; height: 20px; border-radius: 999px; background: #22c55e; color: #052e16; font-size: 11px; font-weight: 900; display: grid; place-items: center; padding: 0 5px; }
.scan-actions .count.is-warn { background: #f59e0b; color: #2a1600; }
.engine-tag { position: absolute; right: 10px; bottom: calc(var(--safe-b) + 150px); font-size: 10px; color: rgba(255, 255, 255, .55); z-index: 4; pointer-events: none; }

/* bottom sheet (mobile) / side panel (desktop) */
.sheet { position: fixed; z-index: 90; left: 0; right: 0; bottom: 0; max-height: 90dvh; background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: 0 -20px 60px rgba(2, 6, 23, .35); transform: translateY(105%); transition: transform .3s var(--ease); display: flex; flex-direction: column; }
.sheet.is-open { transform: none; }
.sheet-grip { width: 42px; height: 5px; border-radius: 999px; background: var(--line-2); margin: 8px auto 2px; flex: 0 0 auto; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 8px 16px 10px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.sheet-head .grow { flex: 1; min-width: 0; }
.sheet-head h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.sheet-head small { display: block; color: var(--muted); font-size: 12.5px; }
.sheet-body { padding: 14px 16px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; }
.sheet-foot { padding: 10px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 10px; flex: 0 0 auto; background: var(--surface); }
.sheet-foot .btn { flex: 1; }
.sheet-foot .btn-primary, .sheet-foot .btn-accent, .sheet-foot .btn-success { flex: 2; }
.sheet-scrim { position: fixed; inset: 0; z-index: 85; background: rgba(2, 6, 23, .25); opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet-scrim.is-on { opacity: 1; pointer-events: auto; }
.bc-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bc-line code { font-size: 15px; font-weight: 700; letter-spacing: .02em; background: var(--surface-3); padding: 3px 9px; border-radius: 8px; }
.photo-row { display: flex; gap: 12px; align-items: center; }
.photo-box { width: 84px; height: 84px; border-radius: 16px; border: 2px dashed var(--line-2); background: var(--surface-2); display: grid; place-items: center; overflow: hidden; flex: 0 0 auto; color: var(--faint); position: relative; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-box.has-img { border-style: solid; border-color: var(--line); }
.photo-actions { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.autofill-note { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--violet); background: var(--violet-soft); padding: 7px 10px; border-radius: 10px; }
.autofill-note .i { width: 16px; height: 16px; }
.details-toggle { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; color: var(--accent-ink); background: none; border: 0; padding: 4px 0; cursor: pointer; }
.details-toggle .i { transition: transform .2s; width: 18px; height: 18px; }
.details-toggle[aria-expanded="true"] .i { transform: rotate(180deg); }
.product-card { display: flex; gap: 14px; align-items: flex-start; }
.product-card .grow { flex: 1; min-width: 0; }
.product-card h3 { font-size: 18px; margin: 0 0 4px; display: block; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.kv > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; min-width: 0; }
.kv span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.kv b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-qty { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.quick-qty button { flex: 1; min-width: 52px; height: 38px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 750; }
.quick-qty button:active { background: var(--surface-3); }

.scan-log { display: none; }
.scan-log.is-open { display: flex; }
.log-panel { position: fixed; z-index: 95; inset: auto 0 0 0; max-height: 85dvh; background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: 0 -20px 60px rgba(2, 6, 23, .35); flex-direction: column; animation: slideup .25s var(--ease); }
.log-list { overflow-y: auto; padding: 4px 16px calc(16px + var(--safe-b)); }
.log-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eef1f6; }
.log-item:last-child { border-bottom: 0; }
.log-item .grow { flex: 1; min-width: 0; }
.log-item .grow b { display: block; font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-item .grow small { display: block; font-size: 12px; color: var(--muted); }
.log-item .thumb { width: 40px; height: 40px; }
.log-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 12px 16px; }
.log-summary > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.log-summary b { display: block; font-size: 20px; }
.log-summary span { font-size: 11.5px; color: var(--muted); }
.count-list .log-item .stepper { width: 132px; flex: 0 0 auto; }
.count-list .log-item .stepper input { font-size: 15px; }
.count-list .log-item .stepper button { width: 38px; }

/* Mobile: the scanner is a full-screen camera app */
@media (max-width: 1023px) {
  body.scan-page .topbar, body.scan-page .tabbar { display: none; }
  body.scan-page .shell { padding-top: 0; }
  body.scan-page .main { padding: 0; max-width: none; }
  body.scan-page .toast-stack { bottom: auto; top: calc(var(--safe-t) + 64px); }
  .scan-app { position: fixed; inset: 0; z-index: 50; background: #05070d; }
  .scan-cam { position: absolute; inset: 0; }
  .scan-side { display: contents; }
  .scan-desk-only { display: none !important; }
}

/* Desktop: camera card + side panel */
@media (min-width: 1024px) {
  .scan-app { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(380px, .85fr); gap: 20px; align-items: start; }
  .scan-cam { border-radius: var(--cam-radius); aspect-ratio: 4 / 3; box-shadow: var(--shadow); max-height: calc(100dvh - 190px); min-height: 420px; width: 100%; }
  .scan-top { border-radius: var(--cam-radius) var(--cam-radius) 0 0; padding-top: 12px; }
  .scan-top .mode-select, .scan-top .scan-back { display: none; }
  .scan-bottom { border-radius: 0 0 var(--cam-radius) var(--cam-radius); }
  .scan-mobile-only { display: none !important; }
  .scan-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--topbar-h) + 24px); max-height: calc(100dvh - var(--topbar-h) - 48px); }
  .sheet { position: static; transform: none; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--line); max-height: none; min-height: 280px; flex: 0 1 auto; overflow: hidden; }
  .sheet .sheet-grip { display: none; }
  .sheet-body { max-height: calc(100dvh - 400px); }
  .sheet-scrim { display: none; }
  .scan-log { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-height: 0; flex: 1 1 auto; overflow: hidden; }
  .log-panel { position: static; box-shadow: none; animation: none; border-radius: var(--radius-lg); max-height: none; }
  .scan-log .log-close { display: none; }
  .scan-log .log-list { max-height: 360px; }
  .scan-modes { display: flex !important; }
  .scan-app:not(.is-live) .scan-idle { padding-bottom: 150px; }
  .scan-app:not(.is-live) .scan-idle p { display: none; }
  .scan-app:not(.is-live) .scan-bottom { background: none; }
  .engine-tag { bottom: 150px; }
}
.scan-modes { display: none; margin-bottom: 14px; }
.scan-sources { display: flex; gap: 8px; flex-wrap: wrap; }
.source-chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 650; color: var(--text-2); }
.source-chip.is-on { border-color: #b7e4c7; background: var(--success-soft); color: var(--success-ink); }

/* pairing QR */
.pair-grid { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 720px) { .pair-grid { grid-template-columns: minmax(0, 1fr) 260px; } }
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 14px; display: grid; place-items: center; box-shadow: var(--shadow-sm); justify-self: center; }
.qr-box img, .qr-box canvas { width: 230px; height: 230px; image-rendering: pixelated; }
.pair-steps { counter-reset: p; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.pair-steps li { display: flex; gap: 12px; align-items: flex-start; counter-increment: p; font-size: 14px; }
.pair-steps li::before { content: counter(p); width: 26px; height: 26px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: 0 0 auto; }
.conn { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-weight: 700; font-size: 13px; }
.conn.is-on { background: var(--success-soft); color: var(--success-ink); }

/* ----------------------------------------------------------------- remote */
.remote-body { background: #05070d; color: #fff; overscroll-behavior: none; }
.remote-app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.remote-app .scan-cam { position: absolute; inset: 0; }
.remote-status { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 14px; }
.remote-status .dot { background: #f59e0b; }
.remote-status.is-on .dot { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, .25); }
.remote-expired { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(5, 7, 13, .94); padding: 24px; text-align: center; }

/* -------------------------------------------------------------------- POS */
.pos { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1024px) { .pos { grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr); } }
.pos-search { position: relative; }
.pos-results { display: grid; gap: 8px; grid-template-columns: 1fr; margin-top: 12px; }
@media (min-width: 720px) { .pos-results { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pos-result { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); width: 100%; }
.pos-result:hover { border-color: #c6d2ea; background: #fafbff; }
.pos-result .grow { flex: 1; min-width: 0; }
.pos-result b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-result small { display: block; color: var(--muted); font-size: 12px; }
.pos-result .price { font-weight: 800; white-space: nowrap; }
.bill { display: flex; flex-direction: column; }
@media (min-width: 1024px) { .bill { position: sticky; top: calc(var(--topbar-h) + 24px); max-height: calc(100dvh - var(--topbar-h) - 48px); } }
.bill-lines { flex: 1 1 auto; overflow-y: auto; min-height: 140px; margin: 0 -4px; padding: 0 4px; }
.bill-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid #eef1f6; }
.bill-line b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-line small { color: var(--muted); font-size: 12px; }
.bill-line .line-total { font-weight: 800; text-align: right; min-width: 70px; font-variant-numeric: tabular-nums; }
.bill-line .stepper { width: 116px; border-radius: 10px; }
.bill-line .stepper button { width: 34px; }
.bill-line .stepper input { font-size: 15px; padding: 5px 2px; }
.bill-line.is-flash { animation: lineflash .8s ease-out; }
@keyframes lineflash { from { background: #e8fbef; } to { background: transparent; } }
.totals { border-top: 1px dashed var(--line-2); margin-top: 8px; padding-top: 10px; }
.totals > div { display: flex; justify-content: space-between; padding: 3px 0; color: var(--text-2); font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 24px; font-weight: 850; color: var(--text); padding-top: 8px; letter-spacing: -.02em; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pay-methods label { position: relative; }
.pay-methods input { position: absolute; opacity: 0; }
.pay-methods span { display: flex; align-items: center; justify-content: center; gap: 6px; height: 42px; border-radius: 11px; border: 1px solid var(--line-2); font-weight: 700; font-size: 14px; cursor: pointer; background: var(--surface); }
.pay-methods input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: 0 0 0 3px rgba(47, 91, 255, .12); }
.pay-methods input:focus-visible + span { outline: 3px solid rgba(47, 91, 255, .45); }
.checkout-btn { height: 56px; font-size: 17px; justify-content: space-between; padding: 0 20px; border-radius: 16px; }
.sale-done { display: grid; gap: 10px; background: var(--success-soft); border: 1px solid #c7ecd5; color: var(--success-ink); border-radius: 16px; padding: 14px; margin-top: 12px; }
.sale-done .btn-row .btn { flex: 1; }
.pos-cam { position: relative; border-radius: 18px; overflow: hidden; background: #05070d; aspect-ratio: 16 / 10; margin-top: 12px; }
.pos-cam video { width: 100%; height: 100%; object-fit: cover; }
.pos-cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pos-cam .scan-guides { inset: 12% 8%; }
.kbd-hint { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.kbd-hint .i { width: 16px; height: 16px; }
@media (max-width: 1023px) { .bill .empty-state { padding: 22px 12px; } }

/* ---------------------------------------------------------------- receipt */
.receipt-body { background: #e9edf3; padding: 20px 12px; }
.receipt { width: min(420px, 100%); margin: 0 auto; background: #fff; border-radius: 16px; padding: 26px 22px; box-shadow: var(--shadow); font-size: 14px; }
.receipt h1 { text-align: center; font-size: 22px; }
.receipt .center { text-align: center; }
.receipt table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.receipt td { padding: 7px 0; border-bottom: 1px dashed #e2e8f0; vertical-align: top; }
.receipt td:last-child { text-align: right; white-space: nowrap; }
.receipt .rt { display: flex; justify-content: space-between; padding: 3px 0; }
.receipt .rt.grand { font-size: 20px; font-weight: 850; border-top: 2px solid #0f172a; margin-top: 6px; padding-top: 8px; }
.receipt-actions { display: grid; gap: 8px; margin-top: 18px; }
@media print {
  .receipt-body { background: #fff; padding: 0; }
  .receipt { box-shadow: none; border-radius: 0; width: 100%; }
  .receipt-actions, .toast-stack { display: none !important; }
}

/* ------------------------------------------------------------- misc bits */
.kpi-inline { display: flex; gap: 16px; flex-wrap: wrap; }
.kpi-inline > div { min-width: 120px; }
.kpi-inline b { display: block; font-size: 22px; letter-spacing: -.02em; }
.kpi-inline span { color: var(--muted); font-size: 12.5px; }
.cred-box { background: var(--brand); color: #e2e8f0; border-radius: 14px; padding: 14px; font-family: var(--mono); font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.role-cards { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .role-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.role-card { position: relative; display: block; cursor: pointer; }
.role-card input { position: absolute; opacity: 0; }
.role-card > span { display: block; border: 1px solid var(--line-2); border-radius: 14px; padding: 12px 14px; background: var(--surface); height: 100%; }
.role-card b { display: block; font-size: 14px; }
.role-card small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; line-height: 1.4; }
.role-card input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(47, 91, 255, .12); }
.role-card input:focus-visible + span { outline: 3px solid rgba(47, 91, 255, .45); }
.log-row-action { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid #eef1f6; }
.setting-row:last-child { border-bottom: 0; }
.setting-row > div { min-width: 0; }
.setting-row b { display: block; }
.setting-row small { color: var(--muted); }
.switch { position: relative; width: 50px; height: 30px; flex: 0 0 auto; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #cbd5e1; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: .2s; }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid rgba(47, 91, 255, .45); }
.chip-select { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-select button { border: 1px solid var(--line-2); background: var(--surface); padding: 6px 11px; border-radius: 999px; font-size: 13px; font-weight: 650; }
.chip-select button.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ------------------------------------------------------ small-screen polish */
@media (max-width: 719px) {
  .toolbar > select.input, .toolbar > .btn { flex: 1 1 calc(50% - 5px); min-width: 0 !important; width: auto !important; }
  .toolbar > .input-icon.grow { flex-basis: 100%; }
  .table.responsive td { flex-wrap: wrap; }
  .table.responsive td > small { flex-basis: 100%; text-align: right; margin-top: 0; }
  .table.responsive td.td-main > small, .table.responsive td.td-main small { text-align: left; }
}
