:root {
  --bg: #f7f3ea; --panel: #fffdf8; --ink: #161616; --muted: #6b665c; --line: #e4dccb;
  --gold: #b08d3c; --gold-soft: #f1e6c8; --black: #111; --ok: #2e7d4f; --warn: #b7791f; --bad: #b03a2e;
  --info: #2f5d8a; --radius: 8px; --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15140f; --panel: #1e1c17; --ink: #f1ece0; --muted: #a39b8a; --line: #353127;
    --gold: #d4b062; --gold-soft: #3a3220; --black: #0b0b0a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* layout */
.top { background: var(--black); color: #f1ece0; display: flex; align-items: center; gap: 4px; padding: 0 16px;
       position: sticky; top: 0; z-index: 50; overflow-x: auto; }
.top .brand { color: var(--gold); font-weight: 700; letter-spacing: .5px; margin-right: 14px; white-space: nowrap; padding: 12px 0; }
.top a.nav { color: #ddd5c2; padding: 13px 10px; white-space: nowrap; border-bottom: 2px solid transparent; }
.top a.nav:hover, .top a.nav.on { color: #fff; text-decoration: none; border-bottom-color: var(--gold); }
.top .spacer { flex: 1; }
.badge-count { background: var(--gold); color: #111; border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 700; margin-left: 3px; }
main { padding: 18px 16px 60px; max-width: 1400px; margin: 0 auto; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.side { grid-template-columns: 2fr 1fr; }
@media (max-width: 900px) { .grid.two, .grid.three, .grid.side { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stat { font-size: 26px; font-weight: 700; }

/* tables */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
tr.dim td { opacity: .55; }
.table-wrap { overflow-x: auto; }
td.money, th.money { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.num, th.num { white-space: nowrap; }    /* w8b Q04-9: the minus sign of the pay pages never breaks from its amount */

/* status pills */
.pill { display: inline-block; padding: 1px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap;
        background: var(--line); color: var(--ink); }
.pill.unassigned, .pill.failed, .pill.lost, .pill.void, .pill.cancelled, .pill.expired { background: #f6d9d5; color: var(--bad); }
.pill.offered, .pill.manual, .pill.draft, .pill.requested, .pill.partial, .pill.range, .pill.ask { background: #f8e7c4; color: var(--warn); }
.pill.assigned, .pill.farmed_out, .pill.sent, .pill.confirmed, .pill.viewed, .pill.queued { background: #dbe7f3; color: var(--info); }
.pill.en_route, .pill.on_location, .pill.pob { background: var(--gold-soft); color: #7a5d18; }
.pill.done, .pill.won, .pill.paid, .pill.completed, .pill.delivered, .pill.read, .pill.exact, .pill.received { background: #d8eedf; color: var(--ok); }
.pill.no_show { background: #e9e0f2; color: #5b3a87; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill { filter: brightness(.85) saturate(1.1); } }

/* forms */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 8px 0 3px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 9px; width: 100%; font-size: 16px; }
@media (min-width: 700px) { input, select, textarea { font-size: 14px; } }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 70px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 12px; }
.fields .wide { grid-column: 1 / -1; }
.errorlist { color: var(--bad); margin: 2px 0; padding-left: 16px; font-size: 12px; }
.help { font-size: 11px; color: var(--muted); }
button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--black); background: var(--black); color: #fff;
  border-radius: 6px; padding: 7px 14px; cursor: pointer; display: inline-block; white-space: nowrap; }
.btn:hover, button:hover { text-decoration: none; filter: brightness(1.15); }
.btn.gold, button.gold { background: var(--gold); border-color: var(--gold); color: #111; }
.btn.ghost, button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.small, button.small { padding: 3px 9px; font-size: 12px; }
.btn.danger, button.danger { background: var(--bad); border-color: var(--bad); }
form.inline { display: inline; }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline-form select, .inline-form input { width: auto; min-width: 120px; padding: 4px 7px; font-size: 13px; }

/* messages + alerts */
.flash { padding: 9px 12px; border-radius: 6px; margin-bottom: 12px; background: var(--gold-soft); }
.flash.error { background: #f6d9d5; color: var(--bad); }
.flash.success { background: #d8eedf; color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.ok { color: var(--ok); }
pre.trace { white-space: pre-wrap; font-size: 12px; background: var(--bg); padding: 8px; border-radius: 6px; max-height: 260px; overflow: auto; }

/* inbox */
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 0; min-height: 70vh; border: 1px solid var(--line);
         border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.inbox .list { border-right: 1px solid var(--line); overflow-y: auto; max-height: 80vh; }
.inbox .list a { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--ink); }
.inbox .list a.on { background: var(--gold-soft); }
.inbox .list a.unread { font-weight: 700; }
.thread { display: flex; flex-direction: column; max-height: 80vh; }
.thread .msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column-reverse; gap: 8px; }
.bubble { max-width: 75%; padding: 8px 11px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.in { background: var(--bg); align-self: flex-start; border: 1px solid var(--line); }
.bubble.out { background: #e6dcc0; align-self: flex-end; }
.bubble.note { background: #fff4c7; align-self: center; font-style: italic; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bubble.out { background: #4a3f22; }
  :root:not([data-theme="light"]) .bubble.note { background: #4a4422; } }
.bubble .meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.thread form { border-top: 1px solid var(--line); padding: 10px; }
@media (max-width: 800px) { .inbox { grid-template-columns: 1fr; } .inbox .list { max-height: 30vh; } }

/* dispatch */
.board td { font-size: 13px; }
.board .time { font-weight: 700; font-size: 15px; }
.board .moved { color: var(--warn); font-size: 12px; }
#map { height: 420px; border-radius: var(--radius); border: 1px solid var(--line); }

/* chauffeur app */
.driver main { max-width: 640px; }
.driver .trip { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.driver .big { font-size: 20px; font-weight: 700; }
.driver .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.driver .actions button, .driver .actions .btn { padding: 14px; font-size: 16px; text-align: center; }
.driver button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; }

/* public pages */
.public main { max-width: 760px; }
.public .head { text-align: center; padding: 18px 0 6px; }
.public .head .logo { font-weight: 800; letter-spacing: 1px; color: var(--gold); font-size: 20px; }
.option { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; background: var(--panel);
          display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.option .price { font-size: 20px; font-weight: 700; }
body.embed { background: transparent; }
body.embed main { padding: 8px; }
