:root {
  --ink: #0F172A; --muted: #475569; --line: #E2E8F0; --soft: #F1F5F9; --bg: #F8FAFC; --card: #FFFFFF;
  --teal: #0F766E; --teal-dark: #115E59; --teal-soft: #CCFBF1;
  --amber: #B45309; --amber-soft: #FEF3C7; --amber-line: #FDE68A; --amber-bg: #FFFBEB;
  --red: #B91C1C; --red-soft: #FEE2E2; --red-line: #FECACA; --red-bg: #FEF2F2;
  --green: #15803D; --green-soft: #DCFCE7;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal); }
.app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; background: var(--bg); }

.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); padding: calc(14px + env(safe-area-inset-top)) 16px 12px; display: flex; align-items: center; justify-content: space-between; }
.titles { display: flex; flex-direction: column; gap: 2px; }
.brand { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--teal); }
.top h1 { margin: 0; font-size: 20px; font-weight: 700; }
.chip { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--soft); border-radius: 999px; padding: 6px 10px; }

main { flex: 1; padding: 16px 16px 96px; display: flex; flex-direction: column; gap: 14px; outline: none; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 14px; font-weight: 700; }
.hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, monospace; font-size: 11px; word-break: break-all; color: var(--muted); }
.divider { height: 1px; background: var(--line); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); font-size: 14px; }

.btn { border: 0; border-radius: 12px; min-height: 48px; padding: 0 16px; font-size: 15px; font-weight: 600; background: var(--teal); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:hover { background: var(--teal-dark); }
.btn.dark { background: var(--ink); }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid #CBD5E1; }
.btn.danger { background: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { min-height: 40px; font-size: 14px; padding: 0 12px; }

.hero { border: 0; border-radius: 16px; background: var(--teal); color: #fff; padding: 18px; display: flex; align-items: center; gap: 14px; text-align: left; min-height: 64px; text-decoration: none; }
.hero svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.hero b { display: block; font-size: 17px; } .hero span { font-size: 13px; opacity: .9; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); }
.tile .n { font-size: 28px; font-weight: 700; }
.tile .l { font-size: 13px; font-weight: 600; } .tile .s { font-size: 12px; color: var(--muted); }
.tile.amber { border-color: var(--amber-line); background: var(--amber-bg); } .tile.amber .n { color: var(--amber); }
.tile.red { border-color: var(--red-line); background: var(--red-bg); } .tile.red .n { color: var(--red); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; background: var(--line); border-radius: 12px; padding: 4px; }
.seg button { border: 0; border-radius: 9px; min-height: 40px; font-size: 14px; font-weight: 600; background: transparent; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(15,23,42,.12); }

.locbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.locbar.unset { border-color: var(--amber-line); background: var(--amber-bg); }
.locbar select { border: 0; background: transparent; font-weight: 600; font-size: 14px; text-align: right; max-width: 60%; }

.camera { position: relative; border-radius: 16px; background: #1E293B; min-height: 180px; overflow: hidden; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; color: #CBD5E1; font-size: 13px; }
.camera #reader { width: 100%; }
.camera #reader video { border-radius: 16px; }
.manual { display: flex; gap: 8px; }
.manual input { flex: 1; min-width: 0; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=date], input[type=number], select.input { border: 1px solid #CBD5E1; border-radius: 10px; min-height: 44px; padding: 0 12px; font-size: 16px; background: #fff; width: 100%; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #5EEAD4; outline-offset: 2px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.kv { display: flex; flex-direction: column; gap: 2px; font-size: 13px; } .kv span:first-child { font-size: 12px; color: var(--muted); } .kv span:last-child { font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; font-size: 12px; color: var(--muted); }
.stats b { display: block; color: var(--ink); font-size: 14px; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid #CBD5E1; background: #fff; font-size: 20px; }
.stepper input { width: 64px; text-align: center; font-weight: 700; font-size: 18px; }

.pill { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.pill.green { color: var(--green); background: var(--green-soft); }
.pill.amber { color: var(--amber); background: var(--amber-soft); }
.pill.red { color: var(--red); background: var(--red-soft); }
.pill.gray { color: var(--muted); background: var(--soft); }
.pill.teal { color: var(--teal); background: var(--teal-soft); }

.banner { border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.5; }
.banner.red { background: var(--red-soft); color: #7F1D1D; }
.banner.green { background: var(--green-soft); color: #14532D; }
.banner.amber { background: var(--amber-soft); color: #78350F; }

.list { display: flex; flex-direction: column; }
.list > * { padding: 8px 0; border-top: 1px solid var(--soft); font-size: 13px; }
.list > *:first-child { border-top: 0; }

.pick { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pick.on { border: 2px solid var(--teal); padding: 13px; }
.check { width: 24px; height: 24px; border-radius: 6px; border: 1.5px solid #94A3B8; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; }
.pick.on .check { background: var(--teal); border-color: var(--teal); }
.qtyin { width: 80px; min-height: 40px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 4px calc(10px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; min-height: 52px; color: var(--muted); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--teal); }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.signed-out .tabs { display: none; }

#toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); max-width: calc(100% - 32px); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.4; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }
