/* Kwiz POS for iPhone: plain HTML, the look of the Android app (lib/ui/theme.dart). */
:root {
    --brand: #1D4ED8; --dark: #1E3A8A; --accent: #F5B301; --ink: #1F2937; --muted: #6B7280; --line: #E5E7EB;
    --bg: #F1F3F7; --card: #fff; --ok: #16A34A; --warn: #B45309; --bad: #DC2626; --soft: #EEF2FF;
    --safe-top: env(safe-area-inset-top); --safe-bottom: env(safe-area-inset-bottom);
    --shadow: 0 1px 2px rgba(16,24,40,.05), 0 6px 18px -10px rgba(16,24,40,.18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg);
       -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
.i { width: 22px; height: 22px; flex: none; }
.hidden, [hidden] { display: none !important; }

/* Screens fill the window: header, scrolling body, footer bars. */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px 24px; }
.body.flush { padding: 0; }
.wrap { max-width: 640px; margin: 0 auto; width: 100%; }

header.bar { background: var(--brand); color: #fff; padding: calc(10px + var(--safe-top)) 8px 10px 16px; display: flex; align-items: center; gap: 4px; min-height: 56px; flex: none; }
header.bar h1 { font-size: 19px; font-weight: 600; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.bar .back { margin-left: -8px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 0; border-radius: 12px; background: none; color: inherit; position: relative; }
.icon-btn:active { background: rgba(255,255,255,.15); }
.badge { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.spin { animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }

.banner { padding: 8px 14px; font-size: 14px; font-weight: 600; text-align: center; }
.banner.warn { background: #FEF3C7; color: #78350F; } .banner.bad { background: #FEE2E2; color: #991B1B; } .banner.info { background: var(--soft); color: var(--dark); }

/* Bottom tabs, Counter raised in the middle (as on Android). */
nav.tabs { flex: none; display: grid; grid-template-columns: repeat(5, 1fr); background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-bottom)); }
nav.tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; color: #4B5563; padding: 4px 0; }
nav.tabs button .i { width: 24px; height: 24px; }
nav.tabs button.on { color: var(--brand); }
nav.tabs button.on:not(.mid) .i { background: var(--soft); border-radius: 12px; padding: 2px 14px; box-sizing: content-box; }
nav.tabs .mid .pill { margin-top: -18px; background: var(--brand); color: #fff; border-radius: 18px; padding: 10px 22px; box-shadow: 0 8px 18px -8px rgba(29,78,216,.7); }
nav.tabs .mid:not(.on) .pill { background: var(--dark); }

/* Cards, lists, fields */
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.pad { padding: 16px; }
.card h2 { font-size: 16px; margin: 0 0 10px; }
.list .row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); background: none; width: 100%; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.list .row:first-child { border-top: 0; }
.row .t { flex: 1; min-width: 0; } .row .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t small { color: var(--muted); font-size: 13px; }
.row .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); } .ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.empty .i { width: 48px; height: 48px; color: #CBD5E1; display: block; margin: 0 auto 10px; }

label.f { display: block; font-size: 14px; font-weight: 600; color: #374151; margin: 12px 0 6px; }
.field, select.field, textarea.field { width: 100%; border: 1.5px solid #CBD5E1; border-radius: 12px; padding: 13px 14px; font-size: 17px; background: #fff; outline: none; -webkit-appearance: none; appearance: none; }
.field:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,.12); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > div > label.f { margin-top: 12px; }
.check { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.check small { display: block; color: var(--muted); font-size: 13px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #CBD5E1; border-radius: 16px; transition: .2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); } .switch input:checked + span::after { transform: translateX(20px); }
.err { color: var(--bad); font-weight: 600; font-size: 14px; margin-top: 8px; } .err:empty { display: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px; border: 0; border-radius: 26px; font-weight: 700; font-size: 17px; text-decoration: none; }
.btn.full { width: 100%; }
.btn.main { background: var(--brand); color: #fff; } .btn.ok { background: var(--ok); color: #fff; } .btn.accent { background: var(--accent); color: #2A1E00; }
.btn.danger { background: var(--bad); color: #fff; } .btn.line { background: #fff; color: var(--brand); border: 1.5px solid #9CA3AF; }
.btn.ghost { background: none; color: var(--brand); } .btn.small { min-height: 40px; font-size: 15px; padding: 0 14px; }
.btn:disabled { opacity: .5; }
.btn:active:not(:disabled), .tile:active, .pay:active { transform: scale(.98); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid #CBD5E1; background: #fff; border-radius: 18px; padding: 7px 14px; font-weight: 600; font-size: 15px; }
.chip.on { background: var(--soft); border-color: var(--brand); color: var(--dark); }

/* Sign in / setup */
.hero { background: var(--brand); color: #fff; padding: calc(36px + var(--safe-top)) 24px 28px; text-align: center; flex: none; }
.hero img { height: 64px; } .hero p { margin: 8px 0 0; letter-spacing: .2em; font-size: 13px; font-weight: 600; opacity: .9; }
.hero small { display: block; margin-top: 6px; opacity: .7; }
.setup { flex: 1; overflow-y: auto; background: var(--brand); padding: 0 16px calc(24px + var(--safe-bottom)); }
.setup .card { max-width: 440px; margin: 0 auto 16px; padding: 20px; }
.setup h2 { font-size: 22px; margin: 0 0 6px; }
.setup .links { text-align: center; color: rgba(255,255,255,.85); font-size: 14px; }
.setup .links a { color: #fff; }

/* Lock (who is selling + PIN) */
.lock { flex: 1; overflow-y: auto; background: var(--brand); color: #fff; text-align: center; padding: calc(40px + var(--safe-top)) 24px calc(24px + var(--safe-bottom)); }
.lock img.glyph { height: 72px; } .lock h1 { font-size: 24px; margin: 14px 0 4px; }
.people { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 18px 0; }
.person { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.12); color: #fff; border: 2px solid transparent; border-radius: 14px; padding: 8px 14px 8px 8px; font-weight: 600; }
.person.on { background: #fff; color: var(--ink); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #DBE4FF; color: var(--dark); display: grid; place-items: center; font-weight: 800; flex: none; }
.dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 8px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.3); }
.dots i.on { background: #fff; }
.pin-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.lock .err { color: #FECACA; }

/* Counter */
.today { flex: none; background: var(--dark); color: #fff; display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: 8px 6px 10px; }
.today small { display: block; font-size: 12px; letter-spacing: .06em; opacity: .75; text-transform: uppercase; }
.today b { font-size: 18px; font-variant-numeric: tabular-nums; }
.search { flex: none; display: flex; gap: 10px; padding: 12px; background: #fff; }
.search .box { flex: 1; display: flex; align-items: center; gap: 8px; border: 1.5px solid #9CA3AF; border-radius: 12px; padding: 0 12px; }
.search input { flex: 1; border: 0; outline: none; padding: 12px 0; font-size: 17px; background: none; min-width: 0; }
.search .scan { width: 52px; border: 0; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { position: relative; text-align: left; background: #fff; border: 2px solid transparent; border-radius: 14px; padding: 12px; min-height: 104px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.tile.in { border-color: var(--brand); }
.tile b { font-weight: 600; font-size: 16px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-right: 30px; }
.tile .price { margin-top: auto; color: var(--brand); font-weight: 800; font-size: 17px; padding-top: 8px; }
.tile small { color: var(--muted); font-size: 13px; } .tile small.low { color: var(--warn); font-weight: 600; }
.tile .qty { position: absolute; top: 8px; right: 8px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 800; border-radius: 10px; padding: 2px 8px; }
.cartbar { flex: none; display: flex; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid var(--line); align-items: center; }
.cartbar .btn { min-height: 50px; padding: 0 14px; font-size: 16px; }
.cartbar .clear { width: 54px; padding: 0; border: 1.5px solid var(--bad); color: var(--bad); background: #fff; border-radius: 14px; }
.cartbar .hold { background: #F59E0B; color: #fff; flex: 1; }
.cartbar .charge { background: var(--ok); color: #fff; flex: 1.3; }

/* Cart / checkout */
.line { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line .t { flex: 1; min-width: 0; } .line .t b { display: block; font-weight: 600; }
.line .t small { color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 38px; height: 38px; border-radius: 50%; border: 1.5px solid #9CA3AF; background: #fff; font-size: 22px; line-height: 1; display: grid; place-items: center; color: #374151; }
.stepper span { min-width: 30px; text-align: center; font-weight: 700; }
.line .amt { min-width: 70px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.totals { padding: 14px 16px; }
.totals .r { display: flex; justify-content: space-between; padding: 3px 0; color: #4B5563; }
.totals .big { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; font-size: 18px; }
.totals .big b { color: var(--brand); font-size: 30px; font-weight: 800; }
.pays { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pay { background: #fff; border: 0; border-radius: 14px; padding: 16px 6px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; box-shadow: var(--shadow); }
.pay .i { width: 34px; height: 34px; }
.amount-big { text-align: center; padding: 18px 12px; }
.amount-big small { display: block; color: var(--muted); }
.amount-big b { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; }
.change { background: var(--soft); text-align: center; padding: 14px; border-radius: 0 0 16px 16px; }
.change b { font-size: 30px; font-weight: 800; }
.notes { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; }
.notes { scrollbar-width: none; } .notes::-webkit-scrollbar { display: none; }
.notes button { flex: none; border: 1.5px solid #86EFAC; background: #F0FDF4; color: #166534; border-radius: 12px; padding: 10px 14px; font-weight: 800; font-size: 16px; }
.notes button.q { border-color: #C7D2FE; background: var(--soft); color: var(--dark); }

/* Sale done */
.done { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #fff; text-align: center; padding: 24px; }
.done .tick { width: 120px; height: 120px; color: var(--ok); }
.done .total { font-size: 40px; font-weight: 800; color: var(--brand); margin: 12px 0; }
.done .chg { background: #FEF7E6; border-radius: 12px; padding: 10px 18px; font-size: 20px; font-weight: 700; }
.foot { flex: none; padding: 10px 16px calc(12px + var(--safe-bottom)); background: #fff; display: grid; gap: 10px; }

/* Receipt */
.receipt { background: #fff; max-width: 380px; margin: 0 auto; padding: 18px 16px 22px; font: 14px/1.45 ui-monospace, "SF Mono", Menlo, monospace; box-shadow: var(--shadow); }
.receipt hr { border: 0; border-top: 1px dashed #9CA3AF; margin: 8px 0; } .receipt hr.r-dd { border-top: 3px double #6B7280; }
.r-shop { text-align: center; font-weight: 800; font-size: 18px; } .r-c { text-align: center; }
.r-row { display: flex; justify-content: space-between; gap: 10px; } .r-row span:first-child { min-width: 0; }
.r-i { padding-left: 10px; color: #374151; } .r-b { font-weight: 800; } .r-total { font-weight: 800; font-size: 18px; } .r-pw { color: #9CA3AF; font-size: 12px; margin-top: 6px; }

/* Bottom sheet and dialogs */
.scrim { position: fixed; inset: 0; background: rgba(17,24,39,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + var(--safe-bottom)); animation: up .2s ease-out; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: #D1D5DB; margin: 0 auto 10px; }
.sheet h3 { margin: 4px 0 12px; font-size: 19px; }
.sheet .acts { display: flex; gap: 10px; margin-top: 16px; } .sheet .acts .btn { flex: 1; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } } @keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%); background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 60; max-width: 92vw; text-align: center; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); }

/* Splash */
#splash { position: fixed; inset: 0; background: linear-gradient(160deg, var(--brand), var(--dark)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: rgba(255,255,255,.85); font-weight: 600; z-index: 100; }
#splash img { width: 88px; height: 88px; border-radius: 22px; }

@media (min-width: 700px) { .pays { grid-template-columns: repeat(5, 1fr); } }
