:root {
  --bg: #0f172a;
  --bg2: #16213a;
  --card: #1c2a48;
  --line: #2b3b5e;
  --text: #f1f5f9;
  --muted: #9fb0cc;
  --accent: #f5a623;
  --accent-ink: #1a1200;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: rgba(15,23,42,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: .5px; }
.brand-mark { width: 22px; height: 26px; background: var(--accent); border-radius: 4px 4px 2px 2px; clip-path: polygon(0 0,100% 0,100% 88%,88% 100%,75% 88%,62% 100%,50% 88%,38% 100%,25% 88%,12% 100%,0 88%); }
.top-right { display: flex; align-items: center; gap: 10px; }
.iconbtn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--bg2); font-size: 18px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--bg2); color: var(--muted); border: 1px solid var(--line); }
.pill.on { color: var(--ok); border-color: rgba(52,211,153,.4); }
.pill.off { color: var(--warn); border-color: rgba(251,191,36,.4); }

.view { padding: 16px 16px calc(120px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
h1 { font-size: 26px; margin: 6px 0 14px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 10px; }
.sub { color: var(--muted); margin: -8px 0 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.card.link { display: block; }
.card.link:active { background: var(--bg2); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.name { font-weight: 700; font-size: 17px; }
.meta { color: var(--muted); font-size: 14px; }
.amt { font-weight: 800; font-size: 18px; white-space: nowrap; }
.amt.ok { color: var(--ok); }
.chev { color: var(--muted); font-size: 22px; }

.hero { background: linear-gradient(160deg, #1f2f55, #16213a); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.hero .big { font-size: 34px; font-weight: 900; letter-spacing: -.5px; }
.hero .big small { font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 6px; }
.hero .split { display: flex; gap: 18px; margin-top: 8px; color: var(--muted); font-size: 14px; }
.hero .split b { color: var(--text); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); font-weight: 700; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 10px; margin: 12px 0; }
.btns .btn { flex: 1; }

label.f { display: block; margin: 12px 0; }
label.f span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=date], select, textarea { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); }
textarea { min-height: 80px; }
input[type=checkbox] { width: 22px; height: 22px; }

.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* receipt */
.receipt-img { width: 100%; max-height: 320px; object-fit: contain; background: #000; border-radius: var(--radius); border: 1px solid var(--line); }
.status { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.status.queued { background: rgba(251,191,36,.15); color: var(--warn); }
.status.read { background: rgba(159,176,204,.15); color: var(--muted); }
.status.confirmed { background: rgba(52,211,153,.15); color: var(--ok); }
.conf { font-size: 13px; color: var(--muted); }
.conf b.hi { color: var(--ok); } .conf b.mid { color: var(--warn); } .conf b.lo { color: var(--bad); }

table.lines { width: 100%; border-collapse: collapse; }
table.lines th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.lines td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.lines td.num, table.lines th.num { text-align: right; white-space: nowrap; }
table.lines input { min-height: 40px; padding: 6px 8px; border-radius: 8px; }
table.lines input.qty { width: 62px; text-align: right; }
table.lines input.cost { width: 90px; text-align: right; }
table.lines .del { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 4px 6px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin-top: 12px; font-size: 15px; }
.totals .k { color: var(--muted); }
.totals .v { text-align: right; font-weight: 700; }
.totals .sell { font-size: 20px; color: var(--ok); }

.group { margin-bottom: 14px; }
.group .ghead { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.li .d { flex: 1; min-width: 0; }
.li .d small { display: block; color: var(--muted); }
.li .p { text-align: right; white-space: nowrap; }
.li .p small { display: block; color: var(--muted); }

/* snap bar */
.snapbar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + var(--safe-b)); background: linear-gradient(to top, rgba(15,23,42,1) 60%, rgba(15,23,42,0)); z-index: 6; display: flex; justify-content: center; }
.snap { width: min(100%, 608px); height: 64px; border: 0; border-radius: 18px; background: var(--accent); color: var(--accent-ink); font-size: 20px; font-weight: 900; display: flex; align-items: center; justify-content: center; gap: 12px; box-shadow: 0 10px 30px rgba(245,166,35,.35); }
.snap:active { transform: scale(.98); }
.snap-icon { width: 26px; height: 22px; border: 3px solid var(--accent-ink); border-radius: 6px; position: relative; }
.snap-icon::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; border: 3px solid var(--accent-ink); }

.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); background: #fff; color: #111; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 9; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: 90vw; }

.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--muted); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes sp { to { transform: rotate(360deg); } }

.auth { max-width: 420px; margin: 24px auto 0; }
.auth .hero .big { font-size: 40px; }
.banner { background: rgba(245,166,35,.12); border: 1px solid rgba(245,166,35,.4); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.banner.err { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.4); }
code { background: var(--bg2); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
