/* RapidXpk Dispatch. Charcoal #0C0C0A, lime #c9ff3d. Space Grotesk (headings), Inter (text and numbers), JetBrains Mono (codes). */
:root {
  --bg: #0C0C0A; --bg2: #141412; --card: #1A1A17; --card2: #22221E; --line: #2C2C27; --line2: #3A3A33;
  --text: #F2F1EA; --muted: #A3A296; --dim: #6E6D64;
  --lime: #c9ff3d; --lime-ink: #0C0C0A; --lime-soft: rgba(201, 255, 61, .12); --lime-text: #c9ff3d;
  --hover: rgba(255, 255, 255, .03); --glass: rgba(26, 26, 23, .92); --map: #1b1b18; --shadow: rgba(0, 0, 0, .5);
  --blue: #7cc4ff; --amber: #ffc857; --red: #ff6b5e; --violet: #c4a7ff; --green: #5fe39a;
  --head: "Space Grotesk", Inter, system-ui, sans-serif; --body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r: 12px; --r-sm: 8px; --rail: 220px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--body); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
a { color: var(--lime-text); }
h1, h2, h3, h4 { font-family: var(--head); margin: 0; letter-spacing: -.01em; }
.muted, .sub { color: var(--muted); }
.mono, .code { font-family: var(--mono); }
.err { color: var(--red); min-height: 1.2em; margin: 6px 0 0; }
.bad { color: var(--red); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; outline: none; min-height: 36px;
}
input:focus, select:focus, textarea:focus { border-color: var(--lime-text); box-shadow: 0 0 0 3px var(--lime-soft); }
textarea { width: 100%; resize: vertical; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line2); background: var(--card2); color: var(--text); cursor: pointer; text-decoration: none; font-weight: 600; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.primary { background: var(--lime); color: var(--lime-ink); border-color: var(--lime-text); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: transparent; color: var(--red); border-color: rgba(255, 107, 94, .45); }
.btn.danger:hover { background: rgba(255, 107, 94, .1); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }

/* sign in */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 20% -10%, rgba(201, 255, 61, .10), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px; display: grid; gap: 12px; }
.login-card h1 { font-size: 28px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.brandmark { font-family: var(--head); font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brandmark b { color: var(--lime-text); }
.bm-dot { width: 12px; height: 12px; border-radius: 4px; background: var(--lime); box-shadow: 0 0 18px rgba(201, 255, 61, .6); display: inline-block; }
.env-note { font-size: 12px; color: var(--amber); margin: 0; }

/* app frame */
.app { display: grid; grid-template-columns: var(--rail) 1fr; height: 100vh; height: 100dvh; }
.rail { background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; gap: 18px; }
.rail-top { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-size: 18px; font-weight: 700; padding: 4px 8px; }
.rail nav { display: grid; gap: 2px; }
.rail nav a { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; }
.rail nav a:hover { background: var(--card); color: var(--text); }
.rail nav a.on { background: var(--lime-soft); color: var(--lime-text); }
.rail-foot { margin-top: auto; display: grid; gap: 8px; padding: 8px; border-top: 1px solid var(--line); }
.me { font-weight: 600; font-size: 13px; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.search { flex: 1; max-width: 640px; position: relative; display: flex; align-items: center; }
.search .ic { position: absolute; left: 12px; color: var(--dim); }
.search input { width: 100%; padding-left: 36px; border-radius: 999px; min-height: 40px; }
.conn { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.conn.live i { background: var(--lime); box-shadow: 0 0 0 4px var(--lime-soft); animation: pulse 2s infinite; }
.conn.poll i { background: var(--amber); }
.conn.off { color: var(--red); border-color: rgba(255, 107, 94, .4); } .conn.off i { background: var(--red); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
.env-tag { font: 600 11px var(--mono); color: var(--lime-ink); background: var(--amber); padding: 4px 8px; border-radius: 6px; letter-spacing: .06em; }
.view { flex: 1; min-height: 0; overflow: auto; position: relative; }
.soon { padding: 48px 32px; max-width: 520px; } .soon h2 { font-size: 26px; margin-bottom: 8px; } .soon p { color: var(--muted); }

/* icons (drawn with CSS masks, no files) */
.ic { width: 18px; height: 18px; display: inline-block; background: currentColor; flex: none;
  -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.ic-orders { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E"); }
.ic-pos { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 5v14M7 5v14M11 5v14M14 5v14M18 5v14M21 5v14'/%3E%3C/svg%3E"); }
.ic-box { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M21 8l-9-5-9 5 9 5 9-5zM3 8v8l9 5 9-5V8M12 13v8'/%3E%3C/svg%3E"); }
.ic-bike { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='5.5' cy='17' r='3.5'/%3E%3Ccircle cx='18.5' cy='17' r='3.5'/%3E%3Cpath d='M15 6h2l1.5 11M5.5 17l4-8h6l-4 8'/%3E%3C/svg%3E"); }
.ic-bell { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M18 8a6 6 0 10-12 0c0 7-3 9-3 9h18s-3-2-3-9M13.7 21a2 2 0 01-3.4 0'/%3E%3C/svg%3E"); }
.ic-scan { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 7V5a2 2 0 012-2h2M17 3h2a2 2 0 012 2v2M21 17v2a2 2 0 01-2 2h-2M7 21H5a2 2 0 01-2-2v-2M7 12h10'/%3E%3C/svg%3E"); }
.ic-phone { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M5 3h4l2 5-2.5 1.5a11 11 0 006 6L16 13l5 2v4a2 2 0 01-2 2A16 16 0 013 5a2 2 0 012-2z'/%3E%3C/svg%3E"); }
.ic-search { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E"); }

/* orders */
.ord { padding: 18px 20px 24px; display: flex; flex-direction: column; gap: 12px; min-height: 100%; }
.ord-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ord-head h1 { font-size: 26px; }
.views { display: flex; gap: 8px; align-items: center; }
.views select { min-width: 170px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; white-space: nowrap; font-weight: 500; }
.chip b { font-weight: 600; color: var(--text); font-size: 12px; }
.chip:hover { border-color: var(--line2); color: var(--text); }
.chip.on { background: var(--lime); color: var(--lime-ink); border-color: var(--lime-text); }
.chip.on b { color: var(--lime-ink); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select { max-width: 200px; }
.filters .date { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.filters .date input { min-height: 36px; padding: 6px 8px; }
.only-phone { display: none !important; }
.bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; background: var(--card); border: 1px solid var(--lime); border-radius: var(--r); position: sticky; top: 0; z-index: 3; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.bulk b { color: var(--lime-text); margin-right: 4px; }
.grid-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; transition: opacity .15s; flex: 1; min-height: 240px; }
.grid-wrap.dim { opacity: .55; }
.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
.grid th { position: sticky; top: 0; z-index: 2; background: var(--card2); text-align: left; font: 600 12px var(--body); color: var(--muted); padding: 0 10px; height: 40px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid th.r, .grid td.r { text-align: right; }
.grid .sort { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; display: inline-flex; gap: 4px; align-items: center; }
.grid .sort:hover, .grid .sort.on { color: var(--text); }
.grid .sort i { font-style: normal; font-size: 9px; color: var(--lime-text); }
.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tbody tr { cursor: pointer; transition: background .08s; }
.grid tbody tr:hover { background: var(--hover); }
.grid tbody tr.sel { background: var(--lime-soft); }
.grid tbody tr.open { box-shadow: inset 3px 0 0 var(--lime); }
.grid .cb { width: 36px; text-align: center; }
.grid .cb input { min-height: 0; width: 16px; height: 16px; accent-color: var(--lime-text); }
.grid td > span { display: block; }
.grid td > span.tier { display: table; }   /* the Flash tag stays its own width */
.code { font-size: 13px; font-weight: 600; white-space: nowrap; }
.tier { display: inline-block; font: 700 10px var(--body); letter-spacing: .04em; text-transform: uppercase; color: var(--lime-ink); background: var(--lime); border-radius: 4px; padding: 1px 6px; margin-top: 3px; }
/* order tags: fulfillment / courier, scheduled day, promised today, call status */
.tag { display: inline-block; font: 600 11px var(--body); border-radius: 4px; padding: 1px 6px; margin: 3px 4px 0 0; border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; }
.grid td > span.tag { display: inline-block; }
.t-courier { color: var(--violet); border-color: rgba(196, 167, 255, .4); }
.t-fulfillment { color: var(--blue); border-color: rgba(124, 196, 255, .4); }
.t-sched { color: var(--amber); border-color: rgba(255, 200, 87, .45); }
.t-today { color: var(--lime-ink); background: var(--amber); border-color: var(--amber); }
.t-nr { color: var(--red); border-color: rgba(255, 107, 94, .45); }
.t-ok { color: var(--green); border-color: rgba(95, 227, 154, .45); }
.b-name, .c-name { font-weight: 500; }
.sub { font-size: 12px; }
.area, .items { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-weight: 600; white-space: nowrap; }
.paid { color: var(--blue); font-weight: 500; }
.state { text-align: center; padding: 48px 16px !important; color: var(--muted); cursor: default; }
.state.err { color: var(--red); }
.sk td span { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--card2), var(--line), var(--card2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 13px; }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-received { color: var(--violet); background: rgba(196, 167, 255, .1); }
.p-packed { color: var(--blue); background: rgba(124, 196, 255, .1); }
.p-out { color: var(--amber); background: rgba(255, 200, 87, .1); }
.p-out::before { animation: blink 1.4s infinite; }
.p-delivered { color: var(--lime-ink); background: var(--lime); }
.p-failed { color: var(--red); background: rgba(255, 107, 94, .1); }
.p-rto { color: var(--bg); background: var(--red); }
.p-void { color: var(--dim); background: transparent; border-color: var(--line2); text-decoration: line-through; }
.p-cancel { color: var(--red); background: transparent; border-color: var(--red); }
@keyframes blink { 50% { opacity: .25; } }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--bg2); border-left: 1px solid var(--line); z-index: 20;
  display: flex; flex-direction: column; box-shadow: -20px 0 50px rgba(0, 0, 0, .45); animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.dr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.code.big { font-size: 18px; margin-right: 6px; }
.dr-body { flex: 1; overflow: auto; padding: 16px 18px 32px; display: grid; gap: 14px; align-content: start; }
.dr-act { display: flex; flex-wrap: wrap; gap: 6px; }
.dr-assign { display: flex; gap: 8px; } .dr-assign select { flex: 1; }
.dr-sec { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 8px; }
.dr-sec h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); font-family: var(--body); }
.kv { display: grid; gap: 3px; }
.note { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: rgba(196, 167, 255, .08); color: var(--violet); font-size: 13px; }
.note.bad { background: rgba(255, 107, 94, .08); color: var(--red); }
.mini { width: 100%; border-collapse: collapse; } .mini td { padding: 5px 0; border-bottom: 1px solid var(--line); } .mini td.r { text-align: right; padding-left: 8px; } .mini tr:last-child td { border: 0; }
.tl { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 10px; }
.tl li { position: relative; display: grid; gap: 1px; font-size: 13px; }
.tl li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--line2); border: 2px solid var(--bg2); }
.tl li.ok::before { background: var(--lime); } .tl li.bad::before { background: var(--red); } .tl li.audit::before { background: var(--blue); }
.tl time { font-size: 11px; color: var(--dim); }
.sk-block { height: 90px; border-radius: var(--r); background: linear-gradient(90deg, var(--card), var(--card2), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; }

/* toasts + modal */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(560px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--card2); border: 1px solid var(--line2); border-radius: 12px; padding: 11px 14px; box-shadow: 0 12px 30px var(--shadow); animation: up .2s ease-out; transition: opacity .3s, transform .3s; }
.toast.ok { border-color: rgba(201, 255, 61, .5); } .toast.bad { border-color: var(--red); color: var(--toast-bad, #ffd2cd); } .toast.warn { border-color: var(--amber); }
.toast.new { background: var(--lime); color: var(--lime-ink); border-color: var(--lime-text); font-weight: 600; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; overscroll-behavior: contain; background: var(--card); border: 1px solid var(--line2); border-radius: 16px; padding: 22px; display: grid; gap: 12px; }
.modal h3 { font-size: 19px; } .modal p { margin: 0; }
.modal-act { display: flex; justify-content: flex-end; gap: 8px; }

/* phone dock */
.dock { display: none; }

/* ---------- tablet ---------- */
@media (max-width: 1100px) { :root { --rail: 72px; } .rail-name, .rail nav a span, .rail-foot .me { display: none; } .rail nav a { justify-content: center; } .rail-foot .btn { padding: 0 6px; font-size: 11px; } }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .top { padding: 10px 16px; gap: 8px; }
  .conn span { display: none; } .conn { padding: 8px; }
  .ord { padding: 14px 16px 96px; }
  .ord-head h1 { font-size: 22px; }
  .views select { min-width: 0; max-width: 150px; }
  .only-phone { display: inline-flex !important; }
  .rd-nopin { left: 10px; max-width: calc(100% - 96px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* keeps clear of the Map toggle at the right */
  .filters > select, .filters > .date, #fClear { display: none; }
  .filters.open > select, .filters.open > .date, .filters.open #fClear { display: flex; width: 100%; max-width: none; }
  .filters.open > .date input { flex: 1; }
  .bulk { position: fixed; left: 16px; right: 16px; bottom: 80px; top: auto; z-index: 30; }
  .grid-wrap { background: transparent; border: 0; overflow: visible; }
  .grid thead { display: none; }
  .grid, .grid tbody { display: block; }
  .grid tbody tr { display: grid; grid-template-columns: 28px 1fr auto; grid-template-areas: "cb code st" "cb cust cod" "cb area area" "cb brand rider";
    gap: 2px 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 8px; }
  .grid td { border: 0; padding: 0; }
  .grid td.cb { grid-area: cb; } .grid td[data-l="Order"] { grid-area: code; } .grid td[data-l="Status"] { grid-area: st; text-align: right; }
  .grid td[data-l="Customer"] { grid-area: cust; } .grid td[data-l="COD"] { grid-area: cod; }
  .grid td[data-l="Area"] { grid-area: area; } .grid td[data-l="Brand"] { grid-area: brand; } .grid td[data-l="Rider"] { grid-area: rider; text-align: right; font-size: 12px; }
  .grid td[data-l="Items"], .grid td[data-l="Created"] { display: none; }
  .area { max-width: none; }
  .grid tr.sk { display: block; height: 96px; } .grid tr.sk td { display: none; }
  .grid tr.sk { background: linear-gradient(90deg, var(--card), var(--card2), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; }
  .grid td.state { display: block; }
  .pager { justify-content: space-between; }
  .drawer { width: 100vw; border: 0; }
  .dock { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 25;
    background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line2); border-radius: 20px; padding: 6px; }
  .dock a { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border-radius: 14px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
  .dock a .ic { width: 22px; height: 22px; }
  .dock a.on { background: var(--lime); color: var(--lime-ink); }
  body.drawer-open .dock { display: none; }
  .toasts { bottom: 92px; }
}

/* drawer: edit form, hints */
.dr-sec.edit label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.dr-sec.edit .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.note.warn { background: rgba(255, 200, 87, .08); color: var(--amber); }
.md-hint { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.modal select { width: 100%; }
.grid tbody tr:focus-visible { outline: 2px solid var(--lime); outline-offset: -2px; }

/* ---------- POS ---------- */
.pos { padding: 18px 20px 28px; display: grid; gap: 14px; }
.pos-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pos-head h1 { font-size: 26px; margin-right: 4px; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 8px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.seg button.on { background: var(--lime); color: var(--lime-ink); }
.seg.sm button { padding: 6px 12px; font-size: 13px; }
/* the mode switch in the top bar (mode.js): full words on wide screens, one letter on phones */
.mode-seg { flex: 0 0 auto; }
.mode-seg .short { display: none; }
@media (max-width: 760px) { .mode-seg .full { display: none; } .mode-seg .short { display: inline; } .mode-seg.seg.sm button { padding: 6px 9px; } }
.mode-split { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; margin: 2px 0 8px; font-size: 13px; color: var(--muted); }
.mode-split b { color: var(--ink); font-variant-numeric: tabular-nums; }
.mode-split .bad { color: var(--red, #e5484d); font-weight: 700; }
.chk { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-left: auto; }
.chk input { min-height: 0; width: 16px; height: 16px; accent-color: var(--lime-text); }
.pos-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 14px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; }
.card h3 { font-size: 16px; }
.field { display: grid; gap: 6px; }
.field label, .field .lab { font-size: 12px; color: var(--muted); font-weight: 500; }
.field input, .field textarea { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.ta { position: relative; flex: 1; }
.ta input { width: 100%; }
.ta-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 15; margin: 0; padding: 4px; list-style: none; background: var(--card2); border: 1px solid var(--line2); border-radius: 10px; box-shadow: 0 14px 30px rgba(0,0,0,.5); max-height: 320px; overflow: auto; }
.ta-list li { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ta-list li.hi, .ta-list li:hover { background: var(--lime-soft); }
.pos-scan { background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--r); padding: 12px; display: grid; gap: 8px; }
.pos-scan > label { font-size: 12px; color: var(--muted); font-weight: 600; }
.pos-scan input { font: 600 18px var(--mono); min-height: 48px; }
.pos-scan.flash { animation: flash .6s; }
@keyframes flash { 0%, 60% { background: rgba(255,107,94,.25); border-color: var(--red); } }
.scanrow { display: flex; gap: 8px; align-items: stretch; }
.scanrow .btn { min-height: 48px; }
.pos-msg { margin: 0; min-height: 1.3em; font-weight: 600; }
.pos-msg.err { color: var(--red); font-size: 16px; }
.pos-msg.ok { color: var(--lime-text); }
.empty { color: var(--muted); margin: 6px 0; }
.lines { width: 100%; border-collapse: collapse; }
.lines th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.lines td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lines td span { display: block; }
.lines .r { text-align: right; }
.lines .warn { color: var(--amber); font-weight: 600; }
.lines tr.over td { background: rgba(255,107,94,.08); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line2); border-radius: 999px; overflow: hidden; }
.qty button { width: 32px; height: 32px; border: 0; background: var(--card2); color: var(--text); cursor: pointer; font-size: 16px; }
.qty input { width: 46px; min-height: 32px; border: 0; border-radius: 0; text-align: center; padding: 0; background: transparent; -moz-appearance: textfield; }
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.x { border: 0; background: transparent; color: var(--dim); font-size: 20px; cursor: pointer; width: 30px; height: 30px; border-radius: 50%; }
.x:hover { color: var(--red); background: rgba(255,107,94,.1); }
.repeat { margin: 0; font-size: 12px; color: var(--lime-text); min-height: 0; }
.pos-sum { display: grid; gap: 6px; padding: 12px; background: var(--bg2); border-radius: 10px; }
.pos-sum div { display: flex; justify-content: space-between; } .pos-sum span { color: var(--muted); } .pos-sum small { color: var(--dim); }
.btn.big { min-height: 50px; font-size: 16px; }
kbd { font: 600 10px var(--mono); padding: 2px 5px; border-radius: 4px; border: 1px solid currentColor; opacity: .55; margin-left: 4px; }
.ocard { display: grid; gap: 4px; padding: 12px; background: var(--bg2); border-radius: 10px; border: 1px solid var(--line); justify-items: start; }
.ocard-p { margin: 4px 0; }
.progress { position: relative; padding-bottom: 10px; } .progress i, .expect i { position: absolute; left: 0; bottom: 0; height: 4px; width: var(--p); background: var(--lime); border-radius: 4px; transition: width .2s; }
.progress::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--line); border-radius: 4px; z-index: -1; }
.expect { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.expect li { position: relative; display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px 14px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; }
.expect li span { display: block; } .expect li.full { border-color: rgba(201,255,61,.5); } .expect li.hint { color: var(--muted); }
.expect .cnt { font: 700 18px var(--mono); white-space: nowrap; } .expect li.full .cnt { color: var(--lime-text); }
.waitlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 60vh; overflow: auto; }
.waitlist button { width: 100%; text-align: left; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.waitlist button:hover { border-color: var(--lime-text); }
.done { max-width: 560px; margin: 24px auto; text-align: center; justify-items: center; padding: 32px; }
.done-tick { width: 64px; height: 64px; border-radius: 50%; background: var(--lime); position: relative; animation: pop .3s ease-out; }
.done-tick::after { content: ""; position: absolute; left: 22px; top: 16px; width: 14px; height: 26px; border: solid var(--lime-ink); border-width: 0 5px 5px 0; transform: rotate(45deg); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.done h2 { font-size: 24px; } .done-code { font-size: 34px; font-weight: 700; color: var(--lime-text); margin: 0; }
.done-act { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* camera */
.cam { position: fixed; inset: 0; z-index: 70; background: #000; display: grid; place-items: center; }
.cam-in { position: relative; width: 100%; height: 100%; }
.cam video { width: 100%; height: 100%; object-fit: cover; }
.cam-frame { position: absolute; left: 10%; right: 10%; top: 35%; height: 22%; border: 3px solid var(--lime); border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.cam-frame.hit { animation: camhit .4s; }
@keyframes camhit { 0% { background: rgba(201,255,61,.35); } }
.cam-bar { position: absolute; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: center; color: #fff; font-weight: 600; }
.cam-err { position: absolute; left: 16px; right: 16px; top: 24px; color: #ffd2cd; background: rgba(0,0,0,.6); padding: 10px; border-radius: 10px; margin: 0; }
.cam-err:empty { display: none; }

@media (max-width: 900px) { .pos-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .pos { padding: 14px 16px 100px; }
  .pos-head .seg { width: 100%; } .pos-head .seg button { flex: 1; padding: 8px 6px; }
  .chk { margin-left: 0; }
  .lines th:nth-child(2), .lines td:nth-child(2) { display: none; }
  .row2 { grid-template-columns: 1fr; }
}

/* ---------- inventory ---------- */
.inv .filters input[type=search] { min-width: 260px; }
.oh { display: inline-block; min-width: 44px; text-align: center; font: 700 15px var(--body); padding: 2px 8px; border-radius: 8px; background: var(--card2); }
.oh.low { color: var(--lime-ink); background: var(--amber); }
.oh.zero { color: #fff; background: var(--red); }
.chip.c-low { background: rgba(255,200,87,.12); color: var(--amber); border-color: rgba(255,200,87,.4); }
.chip.c-low:empty { display: none; }
.expect.ret li { align-items: center; padding-bottom: 10px; }
.cnt-in { width: 80px; text-align: right; font-weight: 700; }
.inv-grid td > span { display: block; }
@media (max-width: 760px) {
  .inv .filters input[type=search] { min-width: 0; width: 100%; }
  .inv-grid tbody tr { grid-template-columns: 1fr auto; grid-template-areas: "item oh" "brand bin"; padding: 12px; }
  .inv-grid td[data-l="Item"] { grid-area: item; } .inv-grid td[data-l="On hand"] { grid-area: oh; } .inv-grid td[data-l="Brand"] { grid-area: brand; font-size: 12px; color: var(--muted); }
  .inv-grid td[data-l="Shelf"] { grid-area: bin; text-align: right; } .inv-grid td[data-l="Barcode"], .inv-grid td[data-l="Low at"] { display: none; }
  #invTabs { overflow-x: auto; max-width: 100%; } #invTabs button { flex: 0 0 auto; }
}

/* phone scan hub */
.hub { padding: 18px 16px 110px; display: grid; gap: 10px; max-width: 560px; }
.hub h1 { font-size: 26px; } .hub p { margin: 0 0 6px; }
.hub button { display: grid; gap: 2px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; color: var(--text); cursor: pointer; }
.hub button b { font: 600 17px var(--head); } .hub button span { color: var(--muted); font-size: 13px; }
.hub button:active, .hub button:hover { border-color: var(--lime-text); }

/* ---------- riders ---------- */
.rd { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 14px; padding: 18px 20px 28px; align-items: start; }
.rd-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.rd-h h3 { font-size: 16px; }
.rd-ready { position: sticky; top: 0; max-height: calc(100dvh - 110px); overflow: auto; align-content: start; }
.rd-bulk { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border: 1px solid var(--lime); border-radius: 10px; }
.rd-bulk b { color: var(--lime-text); } .rd-bulk select { flex: 1; min-width: 120px; }
.zgroup { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.zhead { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--card2); cursor: grab; }
.zhead b { flex: 1; } .zn { font: 700 12px var(--mono); background: var(--bg); padding: 2px 8px; border-radius: 999px; }
.zhead .give { min-height: 28px; padding: 0 10px; font-size: 12px; background: var(--lime-soft); border-color: rgba(201,255,61,.4); color: var(--lime-text); }
.zcb input, .zlist input { min-height: 0; width: 16px; height: 16px; accent-color: var(--lime-text); }
.zlist { list-style: none; margin: 0; padding: 0; }
.zlist li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--line); cursor: grab; }
.zlist li span.sub { display: block; } .zlist li:hover { background: var(--hover); }
.rd-main { display: grid; gap: 12px; min-width: 0; }
.rd-mapcard { padding: 0; overflow: hidden; position: relative; isolation: isolate; z-index: 0; }   /* the map's own layers stay under drawers and dialogs */
#rdMap { height: 380px; background: var(--map); }
.rd-maptoggle { position: absolute; right: 10px; top: 10px; z-index: 500; }
.leaflet-container { font: inherit; background: var(--map); }
.leaflet-tile-pane { filter: grayscale(.6) brightness(.72) contrast(1.1); }
.mk-hq { width: 34px; height: 34px; border-radius: 10px; background: var(--lime); color: var(--lime-ink); font: 700 12px var(--head); display: grid; place-items: center; box-shadow: 0 0 0 3px rgba(12,12,10,.7); }
.mk-rider { width: 34px; height: 34px; border-radius: 50%; background: var(--rc); color: #0C0C0A; font: 700 15px var(--head); display: grid; place-items: center; border: 3px solid #0C0C0A; box-shadow: 0 0 0 2px var(--rc), 0 4px 12px rgba(0,0,0,.5); }
.mk-rider.s-nosignal, .mk-rider.s-offline { filter: grayscale(.8); opacity: .7; }
.mk-stop { width: 22px; height: 22px; border-radius: 50%; background: #0C0C0A; color: var(--rc); border: 2px solid var(--rc); font: 700 11px var(--body); display: grid; place-items: center; }
.rd-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.rcard { position: relative; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--rc); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 8px; cursor: pointer; transition: border-color .12s, transform .12s; }
.rcard:hover, .rcard.open { border-color: var(--rc); }
.rcard.over { transform: scale(1.02); box-shadow: 0 0 0 2px var(--lime); }
.rcard.s-offline { opacity: .6; }
.rc-top { display: flex; align-items: center; gap: 8px; } .rc-top b { flex: 1; font: 600 16px var(--head); }
.rc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rc); display: inline-block; }
.rpill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.rpill.free { background: var(--lime); color: var(--lime-ink); } .rpill.out { background: rgba(255,200,87,.15); color: var(--amber); }
.rpill.nosignal { background: rgba(255,107,94,.15); color: var(--red); } .rpill.offline { background: var(--card2); color: var(--dim); }
.rc-nums { display: grid; grid-template-columns: auto auto 1fr; gap: 14px; } .rc-nums div { display: grid; } .rc-nums b { font: 700 18px var(--body); } .rc-nums span { font-size: 11px; color: var(--muted); }
.rc-nums .warn b, .rc-nums .warn span { color: var(--amber); }
.rc-ask { font-size: 12px; color: var(--lime-text); }
.rc-act { display: flex; flex-wrap: wrap; gap: 6px; } .rc-act .btn { min-height: 30px; padding: 0 10px; font-size: 12px; }
.rc-drop { display: none; margin: 0; text-align: center; color: var(--lime-text); font-weight: 600; font-size: 12px; }
body.dragging .rc-drop { display: block; } body.dragging .rcard { border-style: dashed; }
.stops { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.stops li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; cursor: grab; }
.stops li span { display: block; }
.sn { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--rc); color: var(--rc); font: 700 11px var(--body); display: grid !important; place-items: center; }
.st-act { grid-column: 2; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; } .st-act select { min-height: 30px; padding: 4px 8px; font-size: 12px; }
.warn { color: var(--amber); }
.b.big, b.big { font: 600 18px var(--head); }
.modal.wide { width: min(560px, 100%); } .ho-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; }
@media (max-width: 1100px) { .rd { grid-template-columns: 300px minmax(0, 1fr); } }
@media (max-width: 760px) {
  .rd { grid-template-columns: 1fr; padding: 14px 16px 100px; }
  .rd-ready { position: static; max-height: none; order: 2; }
  .rd-main { order: 1; }
  #rdMap { height: 0; } .rd-mapcard { min-height: 44px; } .rd-mapcard.open #rdMap { height: 320px; }
  .rd-board { grid-template-columns: 1fr; }
}

/* ---------- pairing, alerts, devices ---------- */
.rail-foot #btnPair { width: 100%; }
.modal.pair { width: min(400px, 100%); justify-items: center; text-align: center; }
.qr { background: #fff; padding: 14px; border-radius: 14px; width: 260px; min-height: 260px; display: grid; place-items: center; }
.qr.dead { opacity: .25; filter: blur(2px); }
.qr .done-tick { background: var(--lime); }
.pair-st { margin: 0; font-weight: 600; } .pair-st.ok { color: var(--lime-text); } .pair-st.bad { color: var(--red); }
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font: 700 11px var(--body); display: inline-grid; place-items: center; }
.badge[hidden] { display: none !important; }
.dock a { position: relative; } .dock .badge { position: absolute; top: 2px; right: 18%; margin: 0; }
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.al button { width: 100%; display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center; text-align: left; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); cursor: pointer; }
.al button:hover { border-color: var(--line2); }
.al span { display: block; } .al time { font-size: 11px; color: var(--dim); white-space: nowrap; }
.al i { width: 10px; height: 10px; border-radius: 50%; background: var(--dim); }
.al.k-new_order i { background: var(--lime); } .al.k-failed i { background: var(--red); } .al.k-low_stock i { background: var(--amber); } .al.k-rider_idle i { background: var(--blue); } .al.k-no_signal i { background: var(--violet); }
.al.unread button { border-color: rgba(201,255,61,.45); } .al.unread b::after { content: " · new"; color: var(--lime-text); font-weight: 600; font-size: 12px; }
.devs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.devs li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; }
.devs li span.sub { display: block; } .devs li.gone { opacity: .5; }
@media (max-width: 1100px) { .rail-foot #btnPair { font-size: 10px; padding: 0 4px; } }

/* ---------- offline ---------- */
.conn { cursor: pointer; }
.outbox { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.outbox li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; }
.outbox li span { display: block; } .outbox li.failed { border-color: rgba(255,107,94,.5); }
.outbox li.other { opacity: .7; border-style: dashed; }   /* another account's change: never sent under this one */
.done.offline .done-tick { background: var(--amber); }
#oOffline { margin: 0; }

/* calls (7 Oct 2026) */
.calls #cSearch { max-width: 420px; }
.clist { display: grid; gap: 10px; transition: opacity .15s; }
.clist.dim, .grid-wrap.dim { opacity: .55; }
.ccard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 6px; }
.cc-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.cc-top .tag, .cc-top .tier { margin: 0; }
.cc-cod { margin-left: auto; }
.cc-who { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.cc-who a { color: var(--blue); }
.cc-who .area { max-width: 420px; }
.cc-state { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cc-state .tag { margin: 0; }
.cc-act { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-top: 4px; }
.cc-gap { flex: 1; }
.btn.ok { color: var(--green); border-color: rgba(95, 227, 154, .45); }
.btn.ok:hover { background: rgba(95, 227, 154, .1); }
.daypick { display: flex; flex-wrap: wrap; gap: 6px; }
.daypick button { border: 1px solid var(--line2); background: var(--bg2); color: var(--text); border-radius: 999px; padding: 7px 12px; cursor: pointer; font-weight: 500; }
.daypick button.on, .daypick button:hover { border-color: var(--lime-text); }
.daypick button.on { background: var(--lime); color: var(--lime-ink); }
.dr-call { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dr-call .tag { margin: 0; }
@media (max-width: 760px) {
  .ccard { padding: 12px; }
  .cc-act .btn { flex: 1 1 auto; }
  .cc-gap { display: none; }
  .cc-who .area { max-width: 100%; white-space: normal; }
  .calls .views { width: 100%; flex-wrap: wrap; } .calls .views select { max-width: none; flex: 1; }
}

/* rider day sheet */
.modal.xwide { width: min(980px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.ds-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ds-list { max-height: 50vh; }
.mini.ds th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line2); position: sticky; top: 0; background: var(--card); }
.mini.ds td { padding: 6px 8px 6px 0; vertical-align: top; } .mini.ds td .sub { display: block; }
.mini.ds th.r { text-align: right; }
.ds-ad { max-width: 240px; }
.ds-r { font-weight: 600; } .r-fulfilled { color: var(--green); } .r-returned { color: var(--red); } .r-pending { color: var(--amber); }
.ds-sum { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 760px) { .ds-sum { grid-template-columns: repeat(2, 1fr); } .mini.ds .ds-ad { display: none; } }
.ds-sum div { flex-direction: column; gap: 2px; justify-content: flex-start; }

/* ---------- light mode (8 Oct 2026). Follows the device unless the sun/moon button in the top bar was used. ---------- */
:root[data-theme="light"] {
  --bg: #F4F3EE; --bg2: #FFFFFF; --card: #FFFFFF; --card2: #F7F6F1; --line: #E3E1D8; --line2: #D2CFC3;
  --text: #16160F; --muted: #5C5B52; --dim: #8C8A80;
  --lime-soft: rgba(110, 160, 0, .14); --lime-text: #4A7300;
  --blue: #1F6FB8; --amber: #9A6200; --red: #C9372C; --violet: #6B4BC4; --green: #1E8A4C;
  --hover: rgba(0, 0, 0, .035); --glass: rgba(255, 255, 255, .92); --map: #E8E6DF; --shadow: rgba(0, 0, 0, .14); --toast-bad: #C9372C;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F4F3EE; --bg2: #FFFFFF; --card: #FFFFFF; --card2: #F7F6F1; --line: #E3E1D8; --line2: #D2CFC3;
    --text: #16160F; --muted: #5C5B52; --dim: #8C8A80;
    --lime-soft: rgba(110, 160, 0, .14); --lime-text: #4A7300;
    --blue: #1F6FB8; --amber: #9A6200; --red: #C9372C; --violet: #6B4BC4; --green: #1E8A4C;
    --hover: rgba(0, 0, 0, .035); --glass: rgba(255, 255, 255, .92); --map: #E8E6DF; --shadow: rgba(0, 0, 0, .14); --toast-bad: #C9372C;
    color-scheme: light;
  }
}
/* amber, red and green are darker in light mode: text on them is white there */
:root[data-theme="light"] .t-today, :root[data-theme="light"] .p-rto { color: #fff; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .t-today, :root:not([data-theme="dark"]) .p-rto { color: #fff; } }
.theme-btn { width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; background: var(--card); border: 1px solid var(--line); color: var(--text); cursor: pointer; flex: none; }
.theme-btn:hover { border-color: var(--line2); }
.theme-btn svg { width: 18px; height: 18px; }

/* deliveries by date */
.rd-h #rdDeliv { margin-left: auto; }
.dv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; } .dv-chips .tag { margin: 0; }
#dvRider { max-width: 200px; }

/* 12 Oct 2026: no pin, customer answers, performance */
.t-nopin { color: var(--red); border-color: rgba(255, 107, 94, .45); }
.t-cust { color: var(--blue); border-color: rgba(124, 196, 255, .45); }
.pf-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pf-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.pf-kpi div { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.pf-kpi b { display: block; font: 700 22px var(--head); } .pf-kpi span { color: var(--muted); font-size: 12px; }
.pf-tabs { margin: 6px 0 8px; }
.pct-good { color: var(--green); font-weight: 600; } .pct-mid { color: var(--amber); font-weight: 600; } .pct-bad { color: var(--red); font-weight: 600; }
@media (max-width: 760px) { .pf-kpi { grid-template-columns: repeat(2, 1fr); } }
/* POS deals (13 Oct 2026, sql/39 + 40) */
.pos-deal { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.pos-deal label { font-weight: 600; }
.pos-deal select { flex: 1; min-width: 180px; }
.lines tr.deal-ok td { background: rgba(201, 255, 61, .06); }
.t-warn { color: var(--amber, #FFC857); border-color: rgba(255, 200, 87, .45); }
.rd-mapcard { position: relative; }
.rd-nopin { position: absolute; top: 10px; left: 54px; z-index: 500; border: 1px solid rgba(255, 200, 87, .6); background: rgba(12, 12, 10, .88); color: var(--amber); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12.5px; cursor: pointer; }
.rd-nopin[hidden] { display: none; }

/* sign-in: show password (14 Oct 2026) */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 64px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted, #a3a39b); font: inherit; font-size: 12.5px; padding: 6px 8px; cursor: pointer; }

/* handover: parcels coming back with the rider (sql/46) */
.btn.warn { color: var(--amber, #FFC14D); border-color: rgba(255, 193, 77, .5); }
.btn.warn:hover { background: rgba(255, 193, 77, .1); }
.modal h4 { margin: 14px 0 6px; font-size: 13px; letter-spacing: .02em; }
.ho-rets { list-style: none; margin: 6px 0 0; padding: 0; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.ho-rets li { padding: 8px 10px; border-top: 1px solid var(--line); }
.ho-rets li:first-child { border-top: 0; }
.ho-rets label { display: block; cursor: pointer; }
.ho-rets input { margin-right: 6px; vertical-align: -2px; }
.ho-rets .sub { display: block; margin-left: 22px; }

/* rider settlement sheet (sql/54) */
.rs-sheet{ border:1px solid var(--line); border-radius:10px; overflow:hidden; margin:8px 0 10px; }
.rs-line{ display:grid; grid-template-columns:1fr auto; gap:4px 12px; align-items:center; padding:9px 12px; border-top:1px solid var(--line); font-size:13.5px; }
.rs-line:first-child{ border-top:0; }
.rs-line b{ font-variant-numeric:tabular-nums; text-align:right; }
.rs-line small{ grid-column:1 / -1; color:var(--muted, #9a9f94); font-size:11.5px; }
.rs-line.rs-big b{ font-size:18px; }
.rs-line.rs-total{ background:var(--panel-2, rgba(255,255,255,.04)); font-weight:700; }
.rs-line.rs-edit b{ display:flex; gap:6px; align-items:center; justify-content:flex-end; flex-wrap:wrap; }
.rs-line.rs-edit input[type=number]{ width:110px; text-align:right; }
.rs-line.rs-edit input[type=file]{ font-size:11px; max-width:180px; }
/* a row the database just changed (section 11): one short lime wash, none for people who asked for less motion */
@keyframes rxFlash { 0% { background: rgba(201, 255, 61, .55); } 100% { background: transparent; } }
.rx-flash, tr.rx-flash > td { animation: rxFlash 1.4s ease-out; }
@media (prefers-reduced-motion: reduce) { .rx-flash, tr.rx-flash > td { animation: none; background: rgba(201, 255, 61, .22); } }

/* ── phone touch pass (fix round 2, 17 Oct 2026): 44px targets, notch padding, no clipped headers ── */
@media (max-width: 760px) {
  .top { padding-top: calc(10px + env(safe-area-inset-top)); position: sticky; top: 0; z-index: 40; }
  .dock, .tabbar { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  button, .btn, .chip, select, input:not([type=checkbox]):not([type=radio]), textarea, .seg button, .views select { min-height: 44px; box-sizing: border-box; }
  .seg button { padding: 10px 14px; }
  .conn { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; }
  .pw-eye { min-width: 44px; min-height: 44px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  .grid td.cb { display: grid; place-items: start; min-height: 44px; }
  .ord-head, .rd-head, .pos-head, .cl-head { flex-wrap: wrap; row-gap: 8px; }
  .ord-head h1, .rd-head h1 { flex: 0 0 100%; }
  .rd-sub, .rd-head .sub, .ord-head .sub { flex: 0 0 100%; white-space: normal; }
  html, body { max-width: 100%; overflow-x: hidden; }
  .ord, .rd, .view, .card { min-width: 0; max-width: 100%; }
}
@media (max-width: 760px) {
  .rd-h { flex-wrap: wrap; row-gap: 8px; }
  .rd-h .sub { flex: 0 0 100%; white-space: normal; line-height: 1.5; }
  .rd-mapcard { max-width: 100%; overflow: hidden; }
  .rd-maptoggle { right: 8px; }
}
@media (max-width: 1024px) {
  button, .btn, .chip, select, input:not([type=checkbox]):not([type=radio]), textarea, .seg button, .rail nav a, .views select { min-height: 44px; box-sizing: border-box; }
  .rail nav a { min-width: 44px; }
  .theme-btn, .conn, .pw-eye, .mode-seg button, .seg.sm button, .rd-maptoggle { min-width: 44px; min-height: 44px; }
  .mode-seg button { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 760px) {
  .top { flex-wrap: wrap; }
  .top > * { min-width: 0; }
  .top .search, .top input[type=search], .top #gSearch { flex: 1 1 120px; min-width: 0; }
  .mode-seg button { padding-left: 8px; padding-right: 8px; min-width: 40px; }
  .env-tag { display: none; }
}
@media (max-width: 1024px) {
  #themeBtn, .theme-btn, #btnPair, #btnOut, #alNotes, .btn.sm, .btn.ghost.sm, .rd-maptoggle, #rdMapT, #rdDeliv, #rdPerf { min-height: 44px !important; min-width: 44px !important; }
}
@media (max-width: 1024px) { .sort, button.sort, .grid th button { min-width: 44px; min-height: 44px; } }

/* hunt fixes 20 Oct: on the phone the order drawer and rider panel sit ABOVE the sticky top bar (40), under dialogs (50)
   and toasts (60); the top bar stays on one row at 380 px */
@media (max-width: 760px) {
  .drawer { z-index: 45; }
  .top { flex-wrap: nowrap; gap: 6px; padding-left: 12px; padding-right: 12px; }
  .top .search { flex: 1 1 0; min-width: 60px; }
  .top .search input { padding-left: 32px; padding-right: 8px; }
  .top .search .ic { left: 10px; }
  .top .mode-seg { flex: 0 0 auto; }
  .top .mode-seg button { min-width: 36px; padding-left: 6px; padding-right: 6px; }
  .top .conn, .top .theme-btn { flex: 0 0 auto; }
}
