:root {
    --blue: #0b6fe8;
    --blue-soft: #eaf2ff;
    --ink: #101828;
    --text: #344054;
    --muted: #667085;
    --line: #e4e7ec;
    --canvas: #f2f6fb;
    --good: #079455;
    --warn: #b54708;
    --bad: #b42318;
    --radius: 14px;
    color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--canvas); color: var(--ink); font: 16px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 12px; padding: 12px 16px; cursor: pointer; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; width: 100%; padding: 15px; }
button.danger { color: var(--bad); width: 100%; margin-bottom: 8px; }
button:disabled { opacity: .5; }
input { font: inherit; width: 100%; padding: 13px 14px; border: 1px solid #d0d5dd; border-radius: 12px; background: #fff; color: var(--ink); }
select, textarea { font: inherit; width: 100%; padding: 12px 14px; border: 1px solid #d0d5dd; border-radius: 12px; background: #fff; color: var(--ink); margin-top: 6px; font-weight: 400; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
label { display: block; font-size: 14px; font-weight: 600; color: var(--text); margin: 14px 0 6px; }
label input { margin-top: 6px; font-weight: 400; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 22px; margin: 4px 0; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-size: 14px; }
.card { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 2px rgba(16,24,40,.06); }

.screen { min-height: 100%; }
.login { display: flex; flex-direction: column; justify-content: center; padding: 24px 18px max(24px, env(safe-area-inset-bottom)); max-width: 440px; margin: 0 auto; }
.login .card button { margin-top: 18px; }
.brand { display: flex; gap: 12px; align-items: center; margin: 0 4px 22px; }
.brand img { width: 46px; height: 46px; }
.brand b { display: block; font-size: 20px; }
.brand span { color: var(--muted); font-size: 14px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: max(12px, env(safe-area-inset-top)) max(16px, calc((100% - 692px) / 2)) 12px; background: rgba(242,246,251,.92); backdrop-filter: blur(10px); }
.top h1 { flex: 1; }
.icon { border: 0; background: none; font-size: 22px; padding: 4px 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; padding: 0; background: var(--blue-soft); color: var(--blue); font-weight: 700; border: 0; }

.page { padding: 4px 14px calc(96px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input { flex: 1; }
button.scan { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 600; min-width: 84px; }
.photo-note { font-size: 13px; margin: -4px 4px 12px; }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: var(--radius); padding: 12px 14px; text-align: left; width: 100%; border: 0; box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.row .thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--blue-soft); flex: none; display: grid; place-items: center; color: var(--blue); font-weight: 700; }
.row .main { flex: 1; min-width: 0; }
.row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; flex: none; }
.row .end b { display: block; }
.row .end span { font-size: 13px; color: var(--muted); }
.compact .row { padding: 10px 14px; }
.stock-low { color: var(--warn) !important; }
.stock-none { color: var(--bad) !important; }

.item img { width: 100%; max-height: 260px; object-fit: contain; border-radius: 10px; margin-bottom: 10px; background: #f9fafb; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; color: var(--blue); margin: 0; }
.price { font-size: 40px; font-weight: 800; margin: 8px 0 14px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fact { background: #f9fafb; border-radius: 10px; padding: 10px 12px; }
.fact span { display: block; font-size: 12px; color: var(--muted); }
.fact b { font-size: 17px; }

.progress-card { margin-bottom: 12px; }
.progress-row { display: flex; justify-content: space-between; margin-bottom: 10px; }
.bar { height: 8px; border-radius: 4px; background: var(--blue-soft); overflow: hidden; }
.bar div { height: 100%; background: var(--blue); width: 0; transition: width .3s; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 4px 4px 12px; }
.switch input { width: 22px; height: 22px; }
.last { border-left: 5px solid var(--good); margin-bottom: 4px; }
.last b { font-size: 18px; }
.last.waiting { border-left-color: var(--warn); }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 40px; height: 40px; padding: 0; font-size: 20px; border-radius: 10px; }
.stepper input { width: 58px; text-align: center; padding: 8px 4px; }
button.sticky { position: fixed; left: 14px; right: 14px; bottom: calc(76px + env(safe-area-inset-bottom)); width: auto; max-width: 692px; margin: 0 auto; box-shadow: 0 6px 20px rgba(11,111,232,.35); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: #fff; border-top: 1px solid var(--line); padding: 6px 6px max(6px, env(safe-area-inset-bottom)); z-index: 6; }
.tabs button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); padding: 6px; }
.tabs button span { font-size: 20px; }
.tabs button.active { color: var(--blue); font-weight: 600; }

.toast { position: fixed; left: 14px; right: 14px; top: calc(70px + env(safe-area-inset-top)); z-index: 40; background: var(--ink); color: #fff; padding: 13px 16px; border-radius: 12px; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 600px; margin: 0 auto; }
.toast.bad { background: var(--bad); }
.toast.good { background: var(--good); }
.toast.warn { background: var(--warn); }

.scanner { position: fixed; inset: 0; background: #000; z-index: 30; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; left: 8%; right: 8%; top: 36%; height: 22%; max-width: 640px; margin: 0 auto; border: 3px solid rgba(255,255,255,.9); border-radius: 16px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); transition: border-color .15s, background-color .15s; }
.scanner .frame.hit { border-color: #22c55e; background: rgba(34,197,94,.3); }
.scanner .hint { position: absolute; left: 16px; right: 16px; top: calc(20px + env(safe-area-inset-top)); color: #fff; text-align: center; margin: 0 auto; max-width: 600px; }
.scanner .hint.problem { top: 18%; background: rgba(180,35,24,.92); padding: 14px 16px; border-radius: 12px; }
.scanner .actions { position: absolute; left: 16px; right: 16px; bottom: calc(30px + env(safe-area-inset-bottom)); display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.scanner .actions button { background: rgba(255,255,255,.95); min-width: 120px; }
.scanner .actions button.on { background: #fde68a; border-color: #fde68a; }

.sheet { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex; align-items: flex-end; z-index: 25; }
.sheet .card { width: 100%; max-width: 640px; margin: 0 auto; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 22px 18px max(22px, env(safe-area-inset-bottom)); }
.sheet button { width: 100%; }
.sheet form button { margin-top: 10px; }
.sheet form button.primary { margin-top: 18px; }

.queue { position: sticky; top: calc(62px + env(safe-area-inset-top)); z-index: 4; display: flex; align-items: center; gap: 10px; margin: 0 14px 8px; padding: 8px 8px 8px 14px; border-radius: 12px; background: #fef0c7; color: #7a2e0e; font-size: 14px; font-weight: 600; max-width: 692px; }
.queue span { flex: 1; }
.queue button { padding: 8px 12px; font-size: 14px; background: #fff; border-color: #fedf89; }

.description { white-space: pre-line; color: var(--text); font-size: 15px; margin: 14px 0 0; max-height: 9.5em; overflow: hidden; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.actions-grid button { background: #fff; font-weight: 600; color: var(--blue); }
button.small { padding: 8px 12px; font-size: 14px; font-weight: 600; color: var(--blue); flex: none; }
.row .main[data-open] { cursor: pointer; }
.sub.wrap { white-space: normal; }
.chevron { font-size: 24px; color: var(--muted); }
.list.single { display: flex; }
.list h3 { margin: 14px 4px 0; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--blue-soft); color: var(--blue); }
.badge.new { background: #fef0c7; color: #93370d; }
.badge.ready { background: #dcfae6; color: var(--good); }
.note { background: #f9fafb; border-radius: 10px; padding: 10px 12px; margin: 10px 0 0; white-space: pre-line; }
.card + .searchbar.spaced, .searchbar.spaced { margin-top: 12px; }
.row.pick .tick { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #d0d5dd; flex: none; display: grid; place-items: center; color: #fff; font-weight: 800; }
.row.pick.done .tick { background: var(--good); border-color: var(--good); }
.row.pick.done .name { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tile { background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.tile span { display: block; font-size: 13px; color: var(--muted); }
.tile b { display: block; font-size: 22px; margin: 2px 0; }
.tile small { color: var(--muted); font-size: 12px; }
#todaySummary > button { width: 100%; font-weight: 600; color: var(--blue); }
.summary h2 { font-size: 19px; }
.summary ul { padding-left: 20px; color: var(--text); }
.fact.good b { color: var(--good); }
.fact.watch b { color: var(--warn); }

.chips { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; }
.chips button { flex: none; padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.chips button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.hero { margin-bottom: 12px; }
.hero span { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.hero b { display: block; font-size: 38px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0; }
.delta { font-weight: 600; font-size: 15px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.warning { background: #fef3f2; color: var(--bad); border-radius: 12px; padding: 12px 14px; font-weight: 600; margin-bottom: 12px; }
.small-note { font-size: 12px; text-align: center; margin-top: 16px; }
.intro { margin: 0 4px 12px; font-size: 14px; }
.pricecheck { text-align: center; margin-bottom: 4px; }
.pricecheck .price { font-size: 56px; margin: 6px 0; }
.pricecheck .name { font-size: 20px; font-weight: 700; }
.pricecheck .stockline { color: var(--muted); margin-bottom: 14px; }
.pricecheck button { width: 100%; font-weight: 600; color: var(--blue); }
.contact { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.contact a { display: block; text-align: center; padding: 12px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); font-weight: 600; text-decoration: none; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; margin-left: 6px; vertical-align: middle; }
.pill.good { background: #dcfae6; color: var(--good); }
.pill.bad { background: #fee4e2; color: var(--bad); }
.pill.club { background: #eaf2ff; color: var(--blue); }
.row .end .bad { color: var(--bad); }
.row .end .good { color: var(--good); }

@media (min-width: 760px) {
    .actions-grid { grid-template-columns: repeat(4, 1fr); }
    .tiles { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 760px) {
    .list:not(.compact):not(.single) { display: grid; grid-template-columns: 1fr 1fr; }
}
