:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f172a;
  --good: #166534;
  --good-bg: #dcfce7;
  --warn: #92400e;
  --warn-bg: #fef3c7;
  --bad: #991b1b;
  --bad-bg: #fee2e2;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 18px 12px;
  background: rgba(244,246,248,.94); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(226,232,240,.75);
}
.eyebrow { font-size: 10px; letter-spacing: .13em; color: var(--muted); font-weight: 800; }
h1 { font-size: 25px; margin: 2px 0 0; }
h2 { margin: 0; font-size: 21px; }
.markup-badge { background: var(--ink); color: white; padding: 9px 11px; border-radius: 12px; font-weight: 900; }
main { max-width: 720px; margin: 0 auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 6px 22px rgba(15,23,42,.035); }
.panel-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 800; margin-bottom: 8px; }
.formula { font-size: 18px; }
.muted { color: var(--muted); font-size: 13px; }
.action-grid { display: grid; gap: 12px; margin-bottom: 14px; }
.big-action { min-height: 112px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 17px; display: grid; grid-template-columns: 52px 1fr; column-gap: 12px; text-align: left; align-items: center; cursor: pointer; color: var(--ink); }
.big-action strong { font-size: 17px; }
.big-action small { grid-column: 2; color: var(--muted); margin-top: -14px; }
.big-action.primary { background: var(--ink); color: white; border-color: var(--ink); }
.big-action.primary small { color: #cbd5e1; }
.action-icon { grid-row: 1 / span 2; display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid currentColor; border-radius: 14px; font-weight: 900; }
.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: white; border: 1px solid var(--line); border-radius: 15px; padding: 13px; }
.stat b { display: block; font-size: 23px; }
.stat span { color: var(--muted); font-size: 11px; }
.active-doc { background: linear-gradient(135deg, #0f172a, #334155); color: white; border: 0; }
.active-doc .muted { color: #cbd5e1; }
.progress { height: 8px; border-radius: 999px; background: rgba(255,255,255,.2); overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; background: white; }
select, input { width: 100%; border: 1px solid var(--line); border-radius: 13px; background: white; padding: 13px 14px; color: var(--ink); outline: none; }
select:focus, input:focus { border-color: #64748b; box-shadow: 0 0 0 3px rgba(100,116,139,.12); }
.scanner-shell { background: #0b1220; border-radius: 20px; overflow: hidden; padding: 10px; margin-bottom: 12px; }
#reader { width: 100%; border-radius: 14px; overflow: hidden; min-height: 180px; color: white; }
#reader video { border-radius: 14px; }
button { border: 1px solid var(--line); border-radius: 13px; background: white; padding: 12px 15px; font-weight: 800; color: var(--ink); cursor: pointer; }
button.primary { background: var(--ink); color: white; border-color: var(--ink); }
button.wide { width: 100%; margin-top: 8px; }
.manual-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 14px; }
.result-card { background: white; border-radius: 22px; border: 1px solid var(--line); padding: 18px; overflow: hidden; }
.result-card .product-name { font-size: 19px; font-weight: 850; line-height: 1.2; }
.result-card .ean { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; margin-top: 4px; }
.price-hero { text-align: center; padding: 22px 0 16px; }
.price-hero .caption { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .1em; font-weight: 850; }
.price-hero .price { font-size: 58px; line-height: 1; font-weight: 950; letter-spacing: -.04em; margin-top: 7px; }
.cost-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0 16px; }
.cost-cell { background: var(--bg); border-radius: 13px; padding: 11px; }
.cost-cell span { display: block; font-size: 11px; color: var(--muted); }
.cost-cell b { font-size: 17px; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.confirm-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.confirm-row .primary { min-height: 54px; font-size: 17px; }
.alert { padding: 13px 14px; border-radius: 14px; margin-bottom: 12px; font-size: 14px; }
.alert.warning { background: var(--warn-bg); color: var(--warn); }
.alert.danger { background: var(--bad-bg); color: var(--bad); }
.alert.success { background: var(--good-bg); color: var(--good); }
.hidden { display: none !important; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 12px; }
.small-button { display: inline-block; border: 1px solid var(--line); padding: 9px 11px; border-radius: 11px; background: white; font-weight: 800; font-size: 13px; cursor: pointer; }
.list { display: grid; gap: 8px; }
.list-item { background: white; border: 1px solid var(--line); border-radius: 15px; padding: 13px; cursor: pointer; }
.list-item .row { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.list-item b { font-size: 14px; }
.list-item small { color: var(--muted); }
.status-pill { font-size: 10px; border-radius: 999px; padding: 5px 7px; font-weight: 850; white-space: nowrap; background: #e2e8f0; }
.status-pill.active { background: var(--good-bg); color: var(--good); }
.status-pill.credit { background: var(--warn-bg); color: var(--warn); }
.detail-back { margin: 0 0 10px; }
.line-table { display: grid; gap: 7px; margin-top: 12px; }
.line-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; background: white; border: 1px solid var(--line); padding: 11px; border-radius: 13px; }
.line-row .name { font-size: 13px; font-weight: 750; }
.line-row .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.line-row .amount { text-align: right; font-weight: 900; }
.searchbar { position: sticky; top: 84px; z-index: 10; background: var(--bg); padding-bottom: 10px; }
.bottom-nav { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: calc(68px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255,255,255,.95); backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
.bottom-nav button { border: 0; border-radius: 0; background: transparent; padding: 8px 2px; font-size: 10px; color: var(--muted); display: grid; place-items: center; gap: 2px; }
.bottom-nav button span { font-size: 22px; line-height: 1; }
.bottom-nav button.active { color: var(--ink); }
.toast { position: fixed; z-index: 80; left: 16px; right: 16px; bottom: calc(82px + env(safe-area-inset-bottom)); max-width: 560px; margin: auto; background: #0f172a; color: white; border-radius: 14px; padding: 13px 15px; opacity: 0; pointer-events: none; transform: translateY(12px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.busy { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.55); backdrop-filter: blur(4px); display: grid; place-content: center; gap: 10px; text-align: center; color: white; font-weight: 800; }
.spinner { width: 34px; height: 34px; margin: auto; border: 4px solid rgba(255,255,255,.3); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (min-width: 680px) {
  .action-grid { grid-template-columns: 1fr 1fr; }
  .big-action.primary { grid-row: span 2; min-height: 236px; align-content: center; }
}
.backup-row { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.backup-label { text-align:center; display:grid; place-items:center; min-height:46px; }
.empty-state { background:white; border:1px dashed var(--line); border-radius:15px; padding:20px; color:var(--muted); text-align:center; }
.detail-title { font-size:18px; font-weight:850; margin-bottom:3px; }
.detail-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:12px; }
@media (display-mode: standalone) { .topbar { padding-top: calc(10px + env(safe-area-inset-top)); } }
