:root {
  --ground: #F4F3EF;
  --card: #FFFFFF;
  --ink: #1C1B19;
  --muted: #5E5B54;
  --line: #DAD7CE;
  --accent: #1F6F4A;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3EFE8;
  --warn: #8A5300;
  --warn-soft: #FBEFD9;
  --bad: #A3241F;
  --bad-soft: #F8E1DF;
  --radius: 14px;
  --tap: 52px;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); }
body { font-size: 18px; line-height: 1.4; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--accent); color: var(--accent-ink);
}
.topbar-title { flex: 1; font-weight: 600; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: inherit;
  display: grid; place-items: center;
}
.icon-btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.conn {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  border: 1px solid rgba(255,255,255,.35); border-radius: 999px; background: rgba(0,0,0,.12);
  color: inherit; font-size: 15px; font-weight: 500;
}
.conn .dot { width: 11px; height: 11px; border-radius: 50%; background: #C9C6BD; }
.conn.online .dot { background: #7BE0A8; }
.conn.offline .dot { background: #FFB547; }

main { padding: 16px; max-width: 640px; margin: 0 auto; outline: none; }
h1 { font-size: 26px; margin: 4px 0 12px; line-height: 1.2; }
h2 { font-size: 20px; margin: 24px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }

/* Cards / lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
a.card, button.card { display: block; width: 100%; text-align: left; text-decoration: none; color: inherit; }
button.card:active, a.card:active { background: #FAFAF7; }

.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.green { background: var(--accent-soft); color: var(--accent); }
.chip.amber { background: var(--warn-soft); color: var(--warn); }
.chip.red { background: var(--bad-soft); color: var(--bad); }
.chip.grey { background: #ECEAE4; color: var(--muted); }

.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.big-amount { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--tap); padding: 0 18px;
  border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  font-size: 19px; font-weight: 600; text-decoration: none;
}
.btn.secondary { background: var(--card); color: var(--accent); border: 2px solid var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn:disabled { opacity: .45; cursor: default; }

/* Inputs */
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.code-input {
  width: 100%; height: 60px; padding: 0 16px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--card); font-size: 28px; font-weight: 600; letter-spacing: 2px; font-variant-numeric: tabular-nums;
}
.code-input:focus { border-color: var(--accent); outline: none; }
.search { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 17px; }

/* Login */
.driver-list .card { min-height: 64px; font-size: 21px; font-weight: 600; display: flex; align-items: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 20px 0; min-height: 22px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; background: var(--ink); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  height: 68px; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  font-size: 28px; font-weight: 600;
}
.keypad button:active { background: var(--accent-soft); }
.keypad .ok { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-size: 21px; }

/* Batch / stops */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary .card { padding: 12px 14px; }
.summary .label { font-size: 14px; color: var(--muted); }
.summary .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.progress { height: 10px; border-radius: 999px; background: #E2DFD6; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.stop-name { font-size: 19px; font-weight: 600; }
.stop-meta { font-size: 15px; color: var(--muted); }
.order { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; font-size: 16px; padding: 4px 0; }
.line .q { font-variant-numeric: tabular-nums; color: var(--muted); }
.notice { border-radius: 12px; padding: 12px 14px; font-size: 16px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.footer-actions { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--ground) 30%); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 600px; margin: 0 auto; padding: 14px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 17px; text-align: center;
}
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.btn.secondary .spinner, .btn.ghost .spinner { border-color: var(--line); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Stop number, actions, store photo */
.seq {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; margin-right: 10px; padding: 0 6px;
  border-radius: 8px; background: var(--ink); color: #fff; font-size: 16px; font-weight: 700; vertical-align: 2px;
}
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 12px; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.photo { display: block; width: 100%; padding: 0; border: 0; border-radius: var(--radius); overflow: hidden; background: #E2DFD6; margin-bottom: 14px; }
.photo img { display: block; width: 100%; height: 210px; object-fit: cover; }
.photo-missing { padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; margin-bottom: 12px; }
.photo-full {
  position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 16px;
}
.photo-full img { max-width: 100%; max-height: 80vh; border-radius: 8px; }
.photo-full .btn { max-width: 240px; }

/* Collect screen */
h3.sub { font-size: 16px; margin: 14px 0 6px; color: var(--muted); }
.order-card { margin-bottom: 10px; }
.item { border-top: 1px solid var(--line); padding: 10px 0; }
.item.short { background: var(--warn-soft); margin: 0 -16px; padding: 10px 16px; }
.item.need { outline: 3px solid var(--bad); outline-offset: -3px; }
.item-top { display: flex; align-items: center; gap: 10px; }
.item-name { flex: 1; font-size: 17px; font-weight: 500; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button, .denom > button {
  width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  font-size: 26px; font-weight: 600; line-height: 1;
}
.stepper button:active, .denom > button:active { background: var(--accent-soft); }
.stepper .q { min-width: 44px; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.reason { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.chips, .coin-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.pick {
  min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  font-size: 15px; font-weight: 600;
}
.pick.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.denom {
  display: grid; grid-template-columns: 58px 48px 1fr 48px; grid-template-areas: "l m i p" "a a a a";
  align-items: center; gap: 6px 6px; padding: 8px 0; border-top: 1px solid var(--line);
}
.denom .dl { grid-area: l; font-weight: 700; font-size: 18px; }
.denom > button[data-act="dec"] { grid-area: m; }
.denom > button[data-act="inc"] { grid-area: p; }
.denom input {
  grid-area: i; width: 100%; height: 48px; text-align: center; border: 2px solid var(--line); border-radius: 12px;
  font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--card);
}
.denom input:focus { border-color: var(--accent); outline: none; }
.denom .da { grid-area: a; text-align: right; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 0; }
.denom .da:empty { display: none; }
.denom .coin-tools { grid-column: 1 / -1; }
.total-line { border-top: 2px solid var(--ink); padding-top: 10px; margin-top: 6px; font-size: 19px; }
.due-card { margin-top: 14px; background: var(--ink); color: #fff; border-color: var(--ink); }
.due-card .muted { color: #CFCBC2; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 label { font-size: 14px; font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
textarea.note { height: auto; padding: 10px 14px; resize: vertical; }
.snap { width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; display: block; }
label.btn { cursor: pointer; }
.totals-bar {
  position: sticky; bottom: 0; margin: 20px -16px 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 16px rgba(0,0,0,.06);
  display: flex; flex-direction: column; gap: 6px;
}
.bal { text-align: center; font-size: 22px; font-weight: 700; border-radius: 10px; padding: 6px; }
.bal.ok { background: var(--accent-soft); color: var(--accent); }
.bal.warn { background: var(--warn-soft); color: var(--warn); }
.bal.bad { background: var(--bad-soft); color: var(--bad); }

/* Receipt preview + settings */
.paper { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 12px 0; display: flex; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.paper canvas { width: 100%; max-width: 320px; height: auto; image-rendering: pixelated; }
label.radio { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
label.radio input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); flex: none; }
input[type="range"] { width: 100%; height: 40px; accent-color: var(--accent); }

/* In-app confirmation sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; background: var(--card); border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet p { font-size: 18px; margin: 0 0 16px; }
.sheet-title { margin: 0 0 8px; font-size: 24px; }
.sheet-title.bad { color: var(--bad); }
.sheet-title.warn { color: var(--warn); }

.sig-pad { display: block; width: 100%; height: 180px; margin-top: 6px; border: 2px dashed var(--line); border-radius: 12px; background: #fff; touch-action: none; }
.need-card { outline: 3px solid var(--bad); outline-offset: -3px; }

/* Practice mode: orange bar so nobody mistakes it for real deliveries */
.practice .topbar { background: #B4530B; }
.practice body { background: #F6EEE4; }
.practice-note { margin-bottom: 12px; }
.pouch-row { border-top: 1px solid var(--line); padding-top: 8px; }
.pouch-row:first-child { border-top: 0; padding-top: 0; }
.collector-btn { border-style: dashed; color: var(--accent); }
.person-title { display: block; font-size: 15px; font-weight: 500; color: var(--muted); margin-top: 2px; }

/* "Customer not around" must stand out (Glen 2026-10-13: it was missed as a grey button) */
.btn.danger { background: var(--bad-soft); color: var(--bad); border: 2px solid var(--bad); }
.btn.danger:active { background: #F1C9C5; }
.spread.bad { color: var(--bad); }
