/* ==========================================================================
   Delivery system: one stylesheet. Mobile first; admin gets a laptop layout >= 900px.
   ========================================================================== */
:root {
  --ink: #12222b;
  --muted: #5d6d76;
  --line: #d9e0e4;
  --bg: #eef1f3;
  --card: #ffffff;
  --brand: #0b5560;
  --brand-dark: #08414a;
  --accent: #f2a33a;
  --ok: #1d7a46;
  --warn: #9a6200;
  --err: #b3261e;
  --radius: 10px;
  --nav-h: 62px;
  --topbar-h: 49px;
  --side-w: 232px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  padding-top: env(safe-area-inset-top);
}
body.has-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); }
h1, h2 { margin: 0 0 .4rem; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .6rem; }
a { color: var(--brand); }
b { font-weight: 650; }
.muted, small { color: var(--muted); }
small { display: block; margin-top: .25rem; font-size: .85rem; }
.ic { width: 24px; height: 24px; display: block; flex: none; }
.btn .ic { width: 16px; height: 16px; margin-right: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar & page container ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--brand); color: #fff;
}
.topbar-title { font-weight: 650; font-size: 1.05rem; }
.topbar-user { font-size: .85rem; opacity: .85; }
.container { max-width: 640px; margin: 0 auto; padding: 14px 14px 0; }
.container.wide { max-width: 900px; }

/* ---------- cards, forms, buttons ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; font-size: .95rem; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; padding: 12px; min-height: 48px;
  border: 1.5px solid var(--line); border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible,
.bottom-nav a:focus-visible, .bottom-nav button:focus-visible, .seg button:focus-visible {
  outline: 3px solid rgba(242,163,58,.55); outline-offset: 1px; border-color: var(--brand);
}
input[type=checkbox] { accent-color: var(--brand); width: 20px; height: 20px; min-height: 0; padding: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 20px; font: inherit; font-weight: 650; text-decoration: none;
  border: 0; border-radius: 8px; cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover, .btn-primary:active { background: var(--brand-dark); }
.btn-accent { background: var(--accent); color: #2b1d00; }
.btn-ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-ghost:hover { background: rgba(11,85,96,.07); }
.btn-danger { background: var(--err); color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: .9rem; }
.btn-block + .btn-block { margin-top: 0; }
.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; font-weight: 600; }
.check input { width: 22px; height: 22px; min-height: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
details.adv { border-top: 1px solid var(--line); margin: 6px 0 16px; padding-top: 10px; }
details.adv summary { cursor: pointer; font-weight: 650; padding: 8px 0; color: var(--brand); }
.page-actions { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.page-actions .btn { flex: 1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.actions form { margin: 0; }

/* ---------- alerts, badges, small text ---------- */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-size: .95rem; }
.alert-ok    { background: #e7f5ec; border-color: #a9d8bb; color: var(--ok); }
.alert-error { background: #fdecea; border-color: #f2b8b5; color: var(--err); }
.alert-warn  { background: #fff4de; border-color: #f0d298; color: var(--warn); }
.biz-err { margin: 10px 0 0; font-size: .88rem; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 650; background: #e3eaee; color: var(--ink); white-space: nowrap; }
.badge-on, .badge-ok, .badge-delivered { background: #e0f2e8; color: var(--ok); }
.badge-off { background: #e3eaee; color: var(--muted); }
.badge-err, .badge-returned { background: #fbe3e1; color: var(--err); }
.badge-warn, .badge-assigned { background: #fff0d2; color: var(--warn); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.kv { font-size: .9rem; color: var(--muted); word-break: break-word; }
.warn-text { color: var(--warn); }
.code { display: inline-block; background: var(--brand); color: #fff; border-radius: 6px; padding: 1px 8px; font-size: .8rem; font-weight: 700; vertical-align: middle; }
.qr { font: 600 .85rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); margin-left: 4px; }
.qrchip { display: inline-block; font: 700 .9rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #e8f3f4; color: var(--brand-dark); border: 1px solid #cfe5e7; border-radius: 6px; padding: 1px 8px; }
.oid { font: 600 .8rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }

/* ---------- dashboard tiles, card grids ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 1.7rem; line-height: 1.1; }
.stat span { font-size: .85rem; color: var(--muted); }
.cards-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); margin-bottom: 14px; }
.cards-grid .card { margin-bottom: 0; }
.biz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.log-row { padding: 12px 14px; }
.cred { border: 2px solid var(--accent); background: #fffaf0; }
.cred-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.cred-val { font: 650 1.2rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; word-break: break-all; }

/* ---------- login ---------- */
.login-wrap { max-width: 400px; margin: 0 auto; padding-top: 7vh; }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand img { border-radius: 14px; margin-bottom: 8px; }
.login-brand p { color: var(--muted); }

/* ---------- navigation: bottom bar on phones, sidebar on laptops ---------- */
.nav-brand { display: none; }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; min-height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font: inherit; font-size: .75rem;
  background: none; border: 0; cursor: pointer; width: 100%;
}
.bottom-nav form { flex: 1; display: flex; }
.bottom-nav a.on { color: var(--brand); font-weight: 650; box-shadow: inset 0 3px 0 var(--accent); }
@media (max-width: 899px) {
  body.role-admin .bottom-nav a, body.role-admin .bottom-nav button { font-size: .66rem; padding: 0 1px; }
  body.role-admin .bottom-nav .ic { width: 22px; height: 22px; }
}

/* ==========================================================================
   Lists: Orders, Deliveries (table on laptops, cards on phones)
   ========================================================================== */
/* summary strip */
.stat-strip { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; margin-bottom: 12px; }
.sstat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 16px; min-width: 104px; }
.sstat span { display: block; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.sstat b { font-size: 1.4rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sstat-cod b { color: var(--brand); }
.strip-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* tabs (Deliveries status) */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 650; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.n { display: inline-block; min-width: 20px; padding: 0 7px; border-radius: 99px; background: #e3eaee; color: var(--ink); font-size: .75rem; font-weight: 650; text-align: center; margin-left: 4px; }

/* toolbar: search + segmented filters */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 0 10px; }
.sbox {
  flex: 1 1 100%; display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 8px; padding: 0 10px; min-height: 48px;
}
.sbox:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(242,163,58,.45); }
.sbox .ic { width: 18px; height: 18px; color: var(--muted); }
.sbox input { border: 0; outline: 0; box-shadow: none; padding: 0; min-height: 44px; background: transparent; flex: 1; min-width: 0; }
.kbd { display: none; border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; font-size: .75rem; color: var(--muted); background: #f6f8f9; }
.toolbar select, .toolbar input[type=date] { width: auto; flex: 1 1 140px; }
.toolbar-end { margin-left: auto; }
.seg { display: flex; flex: 1 1 100%; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; overflow-x: auto; }
.seg button {
  flex: 1 0 auto; border: 0; border-right: 1px solid var(--line); background: transparent;
  font: inherit; font-size: .9rem; font-weight: 650; color: var(--muted);
  padding: 0 12px; min-height: 44px; cursor: pointer; white-space: nowrap;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: #f3f6f7; }
.seg button.on { background: var(--brand); color: #fff; }
.seg button .n { background: rgba(0,0,0,.08); }
.seg button.on .n { background: rgba(255,255,255,.25); color: #fff; }
.seg button[disabled] { color: var(--err); cursor: not-allowed; background: #fdecea; }
.lbl-name { display: none; }
.tb-extra { display: none; flex: 1 1 100%; flex-wrap: wrap; gap: 8px; }
.toolbar.open .tb-extra { display: flex; }
.toolbar.open .tb-toggle { background: rgba(11,85,96,.1); }

/* the table */
.table-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.dtable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.dtable thead th {
  text-align: left; padding: 10px 14px; background: #f6f8f9; border-bottom: 1px solid var(--line);
  font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 700; white-space: nowrap;
}
.dtable td { padding: 14px; vertical-align: top; }
.dtable tbody.pk tr:last-child td { border-bottom: 1px solid var(--line); }
.dtable tbody.pk:last-child tr:last-child td { border-bottom: 0; }
.dtable tbody.pk:hover { background: #f7fafb; }
.dtable tbody.pk.sel { background: #e8f3f4; }
.dtable tbody.pk.sel .c-sel { box-shadow: inset 3px 0 0 var(--brand); }
.c-sel { width: 46px; text-align: center; }
.c-pkg { width: 205px; }
.c-cust { width: 165px; }
.c-addr { width: 18%; }
.c-items { min-width: 170px; }
.c-rider { width: 185px; }
.c-amt { width: 190px; }
.pick-cb { width: 18px; height: 18px; min-height: 0; cursor: pointer; }
.cust-name { font-weight: 650; }
.cust-phone a { display: block; text-decoration: none; font-variant-numeric: tabular-nums; }
.cust-phone a:hover { text-decoration: underline; }
ul.items { margin: 0; padding: 0; list-style: none; }
ul.items li { margin-bottom: 6px; }
.it-name { font-weight: 550; }
.it-meta { font-size: .85rem; color: var(--muted); }
.amt div { display: flex; justify-content: space-between; gap: 12px; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.amt b { color: var(--ink); }
.amt .amt-cod { font-size: .85rem; color: var(--muted); padding-bottom: 3px; margin-bottom: 3px; border-bottom: 1px dashed var(--line); }
.amt .amt-cod b { color: var(--brand); font-size: 1.1rem; }

/* notes and warnings under a row */
tr.sub td { padding: 0 14px 14px 60px; }
.sub-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.note-box {
  display: flex; gap: 8px; align-items: flex-start; flex: 1 1 280px; max-width: 640px;
  background: #fff8e6; border: 1px solid #f0d9a0; border-radius: 8px; padding: 8px 10px; font-size: .88rem;
}
.note-box .ic { width: 18px; height: 18px; color: var(--warn); margin-top: 1px; }
.note-box b { margin-right: 6px; }
.note-warn { background: #fdecea; border-color: #f2b8b5; }
.note-warn .ic { color: var(--err); }
.note-text { white-space: pre-wrap; color: var(--ink); }

/* empty state */
.empty { text-align: center; padding: 44px 16px; background: #fff; border: 1px dashed var(--line); border-radius: 12px; margin-bottom: 14px; }
.empty h2 { margin-bottom: 4px; }

/* selection bar */
.selbar {
  position: fixed; z-index: 30; left: 10px; right: 10px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: #12222b; color: #fff; border-radius: 14px; padding: 10px 12px;
  box-shadow: 0 12px 32px rgba(10,25,35,.35);
}
.selbar-info { margin-right: auto; font-size: .95rem; }
.selbar-info b { color: var(--accent); font-variant-numeric: tabular-nums; }
.selbar select { width: auto; flex: 1 1 160px; min-height: 40px; background: #fff; color: var(--ink); }
.selbar .btn { min-height: 40px; }
.selbar .btn-primary { background: var(--accent); color: #2b1d00; }
.selbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.45); }
.selbar .btn-ghost:hover { background: rgba(255,255,255,.1); }
.container.wide { padding-bottom: 110px; }

/* ---------- phones: rows become cards ---------- */
@media (max-width: 899px) {
  .stat-strip { gap: 8px; }
  .sstat { flex: 1 1 0; min-width: 0; padding: 6px 10px; }
  .sstat b { font-size: 1.1rem; }
  .sstat span { font-size: .64rem; }
  .sstat b { white-space: nowrap; }
  .sstat-cod { flex: 1.7 1 0; }
  .strip-right { flex: 1 1 100%; justify-content: space-between; margin-left: 0; }
  .toolbar { gap: 6px; }
  .tb-toggle { flex: 1 1 auto; }
  .toolbar [data-clear] { flex: 0 0 auto; }
  .table-card { border: 0; background: transparent; overflow: visible; }
  .dtable, .dtable tbody, .dtable tr, .dtable td { display: block; }
  .dtable thead { display: none; }
  .dtable tbody.pk { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
  .dtable tbody.pk.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
  .dtable tr.main {
    display: grid; grid-template-columns: 44px 1fr; padding: 8px 0 10px;
    grid-template-areas: "sel pkg" ". cust" ". addr" ". items" ". rider" ". amt";
  }
  .dtable tbody.pk tr:last-child td { border-bottom: 0; }
  .dtable td { padding: 3px 14px 3px 0; width: auto; }
  .c-sel { grid-area: sel; padding: 8px 0 0 14px !important; text-align: left; box-shadow: none !important; }
  .c-pkg { grid-area: pkg; } .c-cust { grid-area: cust; } .c-addr { grid-area: addr; }
  .c-items { grid-area: items; } .c-rider { grid-area: rider; } .c-amt { grid-area: amt; padding-top: 8px; }
  .pick-cb { width: 24px; height: 24px; }
  tr.sub td { padding: 0 12px 12px; }
  .lbl-code { display: inline; }
}

/* ==========================================================================
   Laptop / desktop (>= 900px): admin gets a sidebar and compact controls
   ========================================================================== */
@media (min-width: 900px) {
  :root { --topbar-h: 63px; }
  body { font-size: 15px; }
  body.role-admin.has-nav { padding-left: var(--side-w); padding-bottom: 24px; }

  body.role-admin .bottom-nav {
    top: 0; right: auto; bottom: 0; width: var(--side-w);
    flex-direction: column; justify-content: flex-start; gap: 4px;
    background: var(--brand); border-top: 0; padding: 16px 10px;
  }
  body.role-admin .nav-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.1rem; padding: 4px 10px 20px; }
  body.role-admin .nav-brand img { border-radius: 8px; }
  body.role-admin .bottom-nav a, body.role-admin .bottom-nav button {
    flex: 0 0 auto; width: 100%; min-height: 42px; padding: 0 12px;
    flex-direction: row; justify-content: flex-start; gap: 12px;
    border-radius: 8px; color: #cfe3e6; font-size: .95rem;
  }
  body.role-admin .bottom-nav .ic { width: 20px; height: 20px; }
  body.role-admin .bottom-nav a:hover, body.role-admin .bottom-nav button:hover { background: rgba(255,255,255,.1); color: #fff; }
  body.role-admin .bottom-nav a.on { background: rgba(255,255,255,.16); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
  body.role-admin .bottom-nav form { flex: 0 0 auto; margin-top: auto; }

  body.role-admin .topbar { background: #fff; color: var(--ink); border-bottom: 1px solid var(--line); padding: 16px 28px; }
  body.role-admin .topbar-title { font-size: 1.25rem; }
  body.role-admin .topbar-user { color: var(--muted); opacity: 1; }
  body.role-admin .container { max-width: 1100px; padding: 22px 28px 0; }
  body.role-admin .container.wide { max-width: 1480px; padding-bottom: 120px; }
  body.role-admin form.card { max-width: 760px; }
  body.role-admin .stats { grid-template-columns: repeat(4, 1fr); }
  body.role-admin .page-actions .btn { flex: 0 0 auto; }
  body.role-admin .grid-2 { grid-template-columns: repeat(3, 1fr); }

  /* compact controls: laptops use a mouse, not a thumb */
  body.role-admin input, body.role-admin select, body.role-admin textarea { min-height: 40px; padding: 8px 12px; }
  body.role-admin .btn { min-height: 40px; }
  body.role-admin .btn-sm { min-height: 34px; padding: 0 12px; }
  body.role-admin .check input, body.role-admin .pick-cb { width: 18px; height: 18px; min-height: 0; padding: 0; }

  /* toolbar sticks under the page title while you scroll the table */
  body.role-admin .toolbar { position: sticky; top: var(--topbar-h); z-index: 9; background: var(--bg); padding: 10px 0; margin-bottom: 2px; }
  body.role-admin .sbox { flex: 1 1 200px; min-width: 200px; min-height: 40px; }
  body.role-admin .sbox input { min-height: 36px; padding: 0; }
  body.role-admin .kbd { display: inline-block; }
  body.role-admin .seg { flex: 0 1 auto; overflow: visible; }
  body.role-admin .seg button { min-height: 37px; font-size: .88rem; padding: 0 10px; }
  body.role-admin .tb-extra { display: contents; }
  body.role-admin .toolbar select, body.role-admin .toolbar input[type=date] { min-height: 40px; padding: 6px 8px; font-size: .9rem; }
  body.role-admin .tb-toggle { display: none; }
  body.role-admin .toolbar select { flex: 0 0 auto; width: auto; }
  body.role-admin .toolbar input[type=date] { flex: 0 0 auto; width: 138px; }
  .lbl-name { display: inline; }
  .lbl-code { display: none; }

  body.role-admin .selbar {
    left: calc(var(--side-w) + (100vw - var(--side-w)) / 2); right: auto; transform: translateX(-50%);
    bottom: 22px; width: min(780px, calc(100vw - var(--side-w) - 48px));
  }
  body.role-admin .selbar select { flex: 0 0 240px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ==========================================================================
   Rider screens (phone first)
   ========================================================================== */
.scan-cta { margin-bottom: 14px; min-height: 56px; font-size: 1.05rem; }
.scan-cta .ic { width: 22px; height: 22px; margin-right: 8px; }
.dlist { display: grid; gap: 12px; }
.dcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.dcard-main { display: block; padding: 14px 14px 10px; color: inherit; text-decoration: none; }
.dcard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.dcard-name { font-size: 1.1rem; font-weight: 700; }
.dcard-addr { color: var(--ink); margin: 2px 0 8px; }
.dcard-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; color: var(--muted); font-size: .92rem; }
.dcard-cod { color: var(--brand); font-size: 1.05rem; white-space: nowrap; }
.dcard-actions { display: flex; gap: 8px; padding: 0 14px 14px; }
.dcard-actions .btn { flex: 1; }
.dcard-actions .btn-primary { flex: 1.4; }

.backlink { display: inline-block; margin: 2px 0 12px; text-decoration: none; font-weight: 650; }
.dhead .qrchip { font-size: 1rem; }
.callrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.callrow .btn { flex: 1 1 140px; font-size: 1.05rem; min-height: 52px; }
.addr-block b { display: block; margin-bottom: 2px; }
.addr-block .btn { margin-top: 8px; }
.moneycard { padding: 8px 16px; }
.mrow { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.mrow:last-child { border-bottom: 0; }
.mrow span { color: var(--muted); }
.mcod span { color: var(--ink); font-weight: 650; }
.mcod b { color: var(--brand); font-size: 1.7rem; }
.center { text-align: center; }

/* scanner */
.scanner { position: relative; background: #000; border-radius: 14px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 62vh; width: 100%; margin-bottom: 12px; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18% 14%; pointer-events: none; }
.scan-frame i { position: absolute; width: 34px; height: 34px; border: 4px solid var(--accent); }
.scan-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.scan-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.scan-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.scan-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.scan-msg { position: absolute; left: 10px; right: 10px; bottom: 10px; background: rgba(0,0,0,.66); color: #fff; padding: 8px 12px; border-radius: 8px; text-align: center; font-size: .92rem; }
.scan-msg.bad { background: rgba(179,38,30,.9); }
.scan-torch { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.6); color: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 99px; padding: 6px 14px; font: inherit; cursor: pointer; }
.scan-torch.on { background: var(--accent); color: #2b1d00; }
.manual { margin-top: 14px; }
.manual-row { display: flex; gap: 8px; }
.manual-row input { flex: 1; text-transform: uppercase; }

/* rider bottom bar: raised Scan button */
body.role-rider .bottom-nav a.nav-scan { color: #2b1d00; font-weight: 700; }
body.role-rider .bottom-nav a.nav-scan .ic { background: var(--accent); color: #2b1d00; width: 46px; height: 46px; padding: 11px; border-radius: 50%; margin-top: -22px; box-shadow: 0 4px 12px rgba(0,0,0,.25); border: 3px solid #fff; }
body.role-rider .bottom-nav a.nav-scan.on { box-shadow: none; }

/* rider polish */
@media (max-width: 899px) {
  .tabs a { flex: 1 1 0; text-align: center; padding: 10px 4px; }
  .tabs .n { margin-left: 2px; padding: 0 6px; }
}
.card .note-box + .note-box { margin-top: 8px; }

/* ---- Take orders (continuous scanner) ---- */
.scanner.compact { aspect-ratio: 4 / 3; max-height: 44vh; }
.scan-toast {
  position: absolute; left: 12px; right: 12px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  padding: 14px 12px; border-radius: 14px; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.4); pointer-events: none;
}
.scan-toast b { font-size: 1.35rem; }
.scan-toast span { font-size: .95rem; opacity: .95; }
.scan-toast.ok { background: rgba(29,122,70,.96); }
.scan-toast.bad { background: rgba(179,38,30,.96); }
.scan-toast.info { background: rgba(18,34,43,.88); }
.scan-toast.info2 { background: rgba(11,85,96,.96); }
.takebar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 2px 12px; font-size: .95rem; }
.takebar b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.results { display: grid; gap: 8px; margin-bottom: 10px; }
.rcard { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 10px; padding: 10px 12px; }
.rcard-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rcard-main .muted { font-size: .88rem; }
.scan-open { margin: -4px 0 14px; }

/* ---- Component 7: delivered / returned ---- */
.btn.big { min-height: 56px; font-size: 1.08rem; }
.danger-outline { color: var(--err); border-color: var(--err); }
.danger-outline:hover { background: rgba(179,38,30,.07); }
.actions-bar { display: grid; gap: 10px; margin: 6px 0 18px; }
.payform h2 { margin-bottom: 8px; }
.quickpay { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 14px; }
.quickpay .btn { padding: 0 6px; }
.pay-grid { margin-top: 4px; }
.pay-grid input { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.diffline { padding: 10px 12px; border-radius: 8px; margin: 2px 0 14px; font-weight: 600; font-size: .95rem; }
.diffline.ok { background: #e7f5ec; color: var(--ok); }
.diffline.warn { background: #fff4de; color: var(--warn); }
.proof-preview { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.proof-preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.reasons { display: grid; gap: 8px; margin: 10px 0 14px; }
.reason { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; }
.reason input { width: 22px; height: 22px; min-height: 0; flex: none; }
.reason:has(input:checked) { border-color: var(--brand); background: #e8f3f4; }
.dcard-done { margin-top: 8px; padding: 6px 10px; border-radius: 8px; font-size: .88rem; font-weight: 600; }
.dcard-done.ok { background: #e7f5ec; color: var(--ok); }
.dcard-done.bad { background: #fdecea; color: var(--err); }

.paid { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: .85rem; }
.paid-title { font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.paid div:not(.paid-title):not(.kv):not(.diff-box):not(.pm) { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.paid b { color: var(--ink); }
.paid .badge { margin: 4px 0; }
.reason-tag { display: inline-block; margin: 4px 0; padding: 2px 10px; border-radius: 99px; background: #fdecea; color: var(--err); font-weight: 650; font-size: .82rem; }
.n.n-warn { background: #fbe3e1; color: var(--err); }
.selbar-note { flex: 1 1 200px; width: auto; min-height: 40px; background: #fff; color: var(--ink); }
.seg a { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; border-right: 1px solid var(--line); background: transparent; font-size: .9rem; font-weight: 650; color: var(--muted); padding: 0 12px; min-height: 37px; text-decoration: none; white-space: nowrap; }
.seg a:last-child { border-right: 0; }
.seg a:hover { background: #f3f6f7; }
.seg a.on { background: var(--brand); color: #fff; }
.seg a.on .n { background: rgba(255,255,255,.25); color: #fff; }

.bottom-nav a { position: relative; }
.nav-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--err); color: #fff; font: 700 .68rem/18px system-ui, sans-serif; text-align: center; font-style: normal; }
@media (min-width: 900px) { body.role-admin .nav-badge { position: static; margin-left: auto; } }

/* ---- delivery details, payment review ---- */
.qrlink { text-decoration: none; }
.qrlink:hover { background: #d6ebed; }
.qrchip.big { font-size: 1.15rem; padding: 3px 12px; }
.rowlinks { margin-top: 4px; font-size: .88rem; }
.inlineform { margin-top: 8px; }
.stack { display: grid; gap: 8px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.btnrow .btn { flex: 1 1 180px; }

.paid.paid-diff { border-top: 2px solid var(--err); }
.pm { display: inline-block; padding: 2px 10px; border-radius: 6px; font-weight: 700; font-size: .82rem; margin-bottom: 4px; }
.pm-cash { background: #e0f2e8; color: var(--ok); }
.pm-online { background: #e6eefc; color: #1f4fa3; }
.pm-split { background: #fff0d2; color: var(--warn); }
.pm-none { background: #e3eaee; color: var(--muted); }
.pm.big { font-size: 1rem; padding: 4px 14px; }
.paid-total { border-top: 1px solid var(--line); margin-top: 2px; padding-top: 2px; font-weight: 650; }
.diff-box { display: block; margin: 6px 0; padding: 5px 10px; border-radius: 6px; font-weight: 700; font-size: .88rem; }
.diff-box.ok { background: #e7f5ec; color: var(--ok); }
.diff-box.short { background: #fdecea; color: var(--err); }
.diff-box.over { background: #fff4de; color: var(--warn); }
.diff-box.big { font-size: 1.15rem; padding: 10px 14px; margin: 10px 0; }
.dtable tbody.pk.diff-row { background: #fff8f7; }
.dtable tbody.pk.diff-row:hover { background: #fff1ef; }
.dtable tbody.pk.diff-row .c-sel { box-shadow: inset 3px 0 0 var(--err); }
.sstat-bad b { color: var(--err); }

.detail-grid { display: grid; gap: 14px; grid-template-columns: 1fr; align-items: start; }
.detail-grid .card { margin-bottom: 14px; }
@media (min-width: 1000px) { .detail-grid { grid-template-columns: 1.15fr 1fr; gap: 18px; } }
.facts { display: grid; gap: 4px; margin-top: 10px; font-size: .95rem; }
.facts span { display: inline-block; min-width: 82px; color: var(--muted); }
.cust-name.big { font-size: 1.25rem; margin-bottom: 2px; }
.amt-wide { max-width: 320px; margin: 10px 0; }
.kvtable { width: 100%; border-collapse: collapse; margin: 6px 0; font-variant-numeric: tabular-nums; }
.kvtable td { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.kvtable td:last-child { text-align: right; font-weight: 650; }
.kvtable tr.total td { border-bottom: 0; border-top: 1px solid var(--line); font-size: 1.05rem; }
.proof-img { display: block; max-width: 100%; max-height: 460px; border-radius: 10px; border: 1px solid var(--line); margin-top: 6px; }
.verify-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.paycard.has-diff { border: 2px solid var(--err); }
.rider-quote { background: #f6f8f9; border-left: 3px solid var(--line); border-radius: 6px; padding: 8px 12px; margin: 8px 0; }
.reason-tag.big { font-size: 1.05rem; padding: 4px 14px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 12px 12px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline li.ok::before { background: var(--ok); }
.timeline li.bad::before { background: var(--err); }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.hist li:last-child { border-bottom: 0; }

/* ---- Component 8: settlements ---- */
.badge-st-pending   { background: #fff0d2; color: var(--warn); }
.badge-st-submitted { background: #e6eefc; color: #1f4fa3; }
.badge-st-verified  { background: #e0f2e8; color: var(--ok); }
.badge-st-disputed  { background: #fbe3e1; color: var(--err); }
.sect { margin: 20px 2px 8px; font-size: 1.05rem; }
.small { font-size: .85rem; }
.ta-r { text-align: right; white-space: nowrap; }
.ta-r .inlineform { display: inline-block; margin: 0 0 0 6px; }
.bal { font-size: 1.05rem; color: var(--brand); }
.dtable.balances td, .dtable.mini td { padding: 10px 14px; }
.dtable.mini th, .dtable.mini td { font-size: .88rem; }
.duecard { text-align: center; padding: 22px 16px; }
.duecard.has-due { border: 2px solid var(--accent); background: #fffaf0; }
.due-label { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.due-amount { font-size: 2.4rem; font-weight: 800; line-height: 1.15; color: var(--brand); font-variant-numeric: tabular-nums; margin: 2px 0 8px; }
.due-split { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.due-split b { color: var(--ink); }
.duecard .btn { margin-top: 12px; }
.owecard { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-decoration: none; color: inherit; border: 2px solid var(--accent); background: #fffaf0; }
.owecard b { font-size: 1.5rem; color: var(--brand); font-variant-numeric: tabular-nums; }
.scard { border-left: 4px solid var(--line); }
.scard.st-pending { border-left-color: var(--accent); } .scard.st-submitted { border-left-color: #1f4fa3; }
.scard.st-disputed { border-left-color: var(--err); } .scard.st-verified { border-left-color: var(--ok); }
details.card summary { cursor: pointer; padding: 2px 0; }
.slist { margin-top: 10px; }
.srow { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.srow-amt { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.srow-amt b { color: var(--ink); }

.nw { white-space: nowrap; }
.mrow b { white-space: nowrap; margin-left: 10px; }
.dtable.mini td:nth-child(n+3) { white-space: nowrap; }

/* ---- partial payments ---- */
.badge-st-partial { background: #e8e4f7; color: #4b3a9a; }
.scard.st-partial { border-left-color: #6b58c9; }
.progress { display: flex; height: 10px; border-radius: 99px; background: #e3eaee; overflow: hidden; margin: 10px 0 12px; }
.progress.big { height: 14px; }
.progress i { display: block; height: 100%; }
.progress .p-ver { background: var(--ok); }
.progress .p-sub { background: #1f4fa3; }
.due-lines { display: grid; gap: 4px; max-width: 360px; margin: 6px auto 4px; font-size: .92rem; }
.due-lines div { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.due-lines b { color: var(--ink); white-space: nowrap; }
.due-lines .soft { font-size: .85rem; }
.amtpick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.amtpick .btn { flex-direction: column; min-height: 64px; line-height: 1.25; }
.amtpick .btn span { font-weight: 600; font-size: .85rem; opacity: .85; }
.amtpick .btn b { font-size: 1.15rem; }
.amtpick .btn.on, .quickpay .btn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.diffline.info { background: #e6eefc; color: #1f4fa3; }
.diffline.bad { background: #fdecea; color: var(--err); }
.inst { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.inst-submitted { border-left-color: #1f4fa3; } .inst-verified { border-left-color: var(--ok); } .inst-disputed { border-left-color: var(--err); }
.proof-img.small { max-height: 220px; }

.dtable.mini .qrchip { white-space: nowrap; }