/* Dash shopper app
   Layout: sticky utility bar (address, live ETA, bag) over a product grid; bag slides in from the right;
   tracking view pairs the live route map with an ETA + status column. Light by default, dark mirrors Ops. */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --ink: #101a2b;
  --muted: #5a6a83;
  --line: #dde3ec;
  --accent: #ffb547;        /* sodium amber, buttons and rider */
  --accent-ink: #8a5300;    /* amber for text on light ground */
  --hub: #138a7c;
  --ok: #1f8f55;
  --crit: #c93c3c;
  --tint-mix: 100%;
  --street: rgba(70, 92, 128, 0.22);
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --r: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a101c; --surface: #111a2b; --ink: #dfe6f1; --muted: #8193ad; --line: #22324a;
    --accent: #ffb547; --accent-ink: #ffcf85; --hub: #4fd6c4; --ok: #5fd68a; --crit: #ff6b6b;
    --tint-mix: 16%; --street: rgba(98, 132, 186, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a101c; --surface: #111a2b; --ink: #dfe6f1; --muted: #8193ad; --line: #22324a;
  --accent: #ffb547; --accent-ink: #ffcf85; --hub: #4fd6c4; --ok: #5fd68a; --crit: #ff6b6b;
  --tint-mix: 16%; --street: rgba(98, 132, 186, 0.3);
  color-scheme: dark;
}

/* Elements toggled with the hidden attribute must stay hidden even when a rule sets display. */
[hidden] { display: none !important; }

body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 10; background: var(--surface);
}
h1, h2 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
h1 { font-size: clamp(30px, 4.2vw, 44px); font-weight: 700; line-height: 1.02; letter-spacing: 0.005em; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap, .bar-inner, .view {
  max-width: 1180px; margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.bar-inner { display: flex; align-items: center; gap: 14px; padding-block: 10px; }
.wordmark {
  font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1;
  text-decoration: none; display: flex; align-items: center;
}
.wordmark .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-left: 3px;
  transform: translateY(5px); box-shadow: 0 0 10px 1px rgba(255, 181, 71, 0.55);
}
.deliver { position: relative; min-width: 0; }
.addr-btn {
  display: grid; text-align: left; background: none; border: 0; cursor: pointer; padding: 2px 8px;
  border-radius: 8px; min-width: 0;
}
.addr-btn:hover { background: var(--bg); }
.addr-k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.addr-v { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.addr-v::after { content: " ▾"; color: var(--muted); font-size: 12px; }
.addr-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 6; list-style: none; margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 12px 32px rgba(10, 16, 28, 0.18); width: min(320px, calc(100vw - 32px));
}
.addr-menu li button {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 0 10px; text-align: left;
  background: none; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.addr-menu li button:hover, .addr-menu li button[aria-selected="true"] { background: var(--bg); }
.addr-menu small { grid-column: 1; color: var(--muted); }
.addr-menu em { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-style: normal; font-family: var(--font-data); font-size: 12px; color: var(--muted); }

.eta-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; white-space: nowrap;
}
.eta-chip #eta-text { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.eta-chip .led { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.cart-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--ink); color: var(--surface); border: 0; border-radius: 999px; padding: 8px 14px 8px 12px;
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.cart-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cart-btn .cart-total { opacity: 0.75; font-weight: 500; }

/* ---------- shop ---------- */
.view { padding-block: 24px 48px; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 32px; flex-wrap: wrap; margin-bottom: 20px; }
.intro > div { max-width: 34rem; display: grid; gap: 8px; }
.intro p { margin: 0; color: var(--muted); }
.promo {
  border: 1px dashed var(--accent-ink); color: var(--accent-ink); border-radius: var(--r);
  padding: 10px 14px; font-size: 14px;
}
.promo b { font-family: var(--font-data); letter-spacing: 0.04em; }

.aisles {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none;
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 62px); z-index: 3; background: var(--bg);
}
.aisle {
  white-space: nowrap; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; font-size: 14px;
}
.aisle[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 14px; }
.product {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px; display: grid; gap: 6px; grid-template-rows: auto auto 1fr auto;
}
.product .art {
  aspect-ratio: 4 / 3; max-width: 100%; border-radius: 8px; display: grid; place-items: center;
  font-size: 54px; background: color-mix(in srgb, var(--tint) var(--tint-mix), var(--surface));
}
.product .name { font-weight: 600; line-height: 1.25; }
.product .unit { color: var(--muted); font-size: 13px; }
.product .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { font-family: var(--font-data); font-weight: 500; font-variant-numeric: tabular-nums; }
.add {
  border: 0; background: var(--accent); color: #2a1a00; border-radius: 999px; padding: 6px 14px;
  font-weight: 600; cursor: pointer;
}
.stepper { display: inline-flex; align-items: center; border-radius: 999px; background: var(--accent); color: #2a1a00; }
.stepper button { border: 0; background: none; width: 30px; height: 30px; cursor: pointer; font-weight: 700; color: inherit; }
.stepper span { min-width: 18px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.stock-low { font-size: 12px; color: var(--accent-ink); }

/* ---------- bag ---------- */
.cart {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 8; width: min(400px, 100%);
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: 18px; padding-right: max(18px, env(safe-area-inset-right, 0px));
  box-shadow: -16px 0 40px rgba(10, 16, 28, 0.18);
}
.cart-head { display: flex; justify-content: space-between; align-items: center; }
.icon-btn { border: 1px solid var(--line); background: none; border-radius: 8px; width: 34px; height: 34px; cursor: pointer; }
.scrim { position: fixed; inset: 0; z-index: 7; background: rgba(10, 16, 28, 0.4); }
.lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; overflow-y: auto; }
.cart .lines { flex: 1; align-content: start; }
.line { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; }
.line .mini {
  width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; font-size: 22px;
  background: color-mix(in srgb, var(--tint) var(--tint-mix), var(--surface));
}
.line .meta { min-width: 0; display: grid; }
.line .meta b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line .meta span { font-size: 12px; color: var(--muted); }
.lines.compact .line { grid-template-columns: 32px 1fr auto; }
.lines.compact .mini { width: 32px; height: 32px; font-size: 18px; }
.empty-bag { color: var(--muted); text-align: center; padding: 40px 0; }

.coupon { display: grid; gap: 6px; }
.coupon-row { display: flex; gap: 8px; }
.coupon-msg { font-size: 13px; min-height: 1.2em; }
.coupon-msg.ok { color: var(--ok); } .coupon-msg.bad { color: var(--crit); }
.field { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.input {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  background: var(--bg); color: var(--ink); font: inherit;
}
.totals { display: grid; gap: 4px; font-size: 14px; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; }
.totals .discount { color: var(--ok); }
.totals .grand { font-weight: 700; font-size: 17px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.primary {
  border: 0; border-radius: 999px; background: var(--accent); color: #2a1a00; font-weight: 700;
  padding: 13px 18px; cursor: pointer; font-size: 16px; width: 100%;
}
.primary[disabled] { opacity: 0.55; cursor: progress; }
.secondary {
  display: inline-block; text-align: center; text-decoration: none; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 10px 16px; cursor: pointer; font-weight: 600;
}
.secondary.small { padding: 8px 14px; font-size: 14px; }

/* ---------- checkout ---------- */
.back { display: inline-block; margin-bottom: 10px; color: var(--muted); text-decoration: none; font-size: 14px; }
.checkout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; margin-top: 18px; align-items: start; }
.co-main { display: grid; gap: 14px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; }
.co-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.eta-big { font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1; }
.eta-big small { font-size: 16px; color: var(--muted); margin-left: 3px; }
.pay { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.pay:has(input:checked) { border-color: var(--accent-ink); }
.brand-chip { font-family: var(--font-data); font-size: 11px; font-weight: 500; background: #1a2b6d; color: #fff; padding: 3px 6px; border-radius: 4px; }
.brand-chip.alt { background: var(--ink); color: var(--surface); }
.co-error {
  border: 1px solid var(--crit); color: var(--crit); background: color-mix(in srgb, var(--crit) 8%, var(--surface));
  border-radius: var(--r); padding: 12px 14px; font-size: 14px;
}
.fine { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- tracking ---------- */
.track { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.track-map { padding: 0; overflow: hidden; position: relative; aspect-ratio: 4 / 3; max-width: 100%; }
.track-map canvas { width: 100%; height: 100%; display: block; }
.map-credit { position: absolute; left: 10px; bottom: 6px; font-size: 11px; color: var(--muted); }
.track-side { display: grid; gap: 14px; min-width: 0; }
.eta-card { gap: 2px; }
.countdown { font-family: var(--font-display); font-size: 72px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.eta-card.done .countdown { color: var(--ok); }
.eta-card.late .countdown { color: var(--crit); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.steps li { position: relative; padding: 0 0 16px 28px; display: grid; }
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  content: ""; position: absolute; left: 4px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface);
}
.steps li::after { content: ""; position: absolute; left: 10px; top: 19px; bottom: 1px; width: 2px; background: var(--line); }
.steps li:last-child::after { display: none; }
.steps li span { font-size: 13px; color: var(--muted); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.done::after { background: var(--ok); }
.steps li.now::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
.steps li.failed::before { background: var(--crit); border-color: var(--crit); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 9;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--surface); border-radius: 999px; padding: 10px 18px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(10, 16, 28, 0.25); max-width: calc(100% - 32px);
}

@media (max-width: 860px) {
  .checkout, .track { grid-template-columns: minmax(0, 1fr); }
  .eta-chip #hub-text, .cart-btn .cart-total { display: none; }
  .bar-inner { gap: 8px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .product .art { font-size: 44px; }
  .countdown { font-size: 60px; }
}
@media (max-width: 420px) { .eta-chip { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
