/* Truck Nav — high-contrast automotive dark theme (OLED black). */
:root {
  --bg: #000;
  --panel: #0b0f14;
  --panel-2: #121821;
  --line: #1f2a37;
  --text: #f1f5f9;
  --muted: #8a97a8;
  --cyan: #22d3ee;
  --amber: #f59e0b;
  --green: #22c55e;
  --blue: #3b82f6;
  --red: #ef4444;
  --yellow: #facc15;
  --slate: #334155;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; touch-action: manipulation; }
button:disabled { opacity: .35; cursor: default; }
input, select { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; width: 100%; min-height: 48px; font-size: 17px; }
input:focus, select:focus { outline: 2px solid var(--cyan); outline-offset: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row.three > * { flex: 1 1 0; }

/* ------------------------------------------------------------ buttons, pills, badges */
.btn { background: var(--cyan); color: #001018; font-weight: 700; border-radius: 12px; padding: 12px 16px; min-height: 48px; }
.btn-ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.small, .btn-ghost.small { min-height: 38px; padding: 8px 12px; font-size: 14px; }
.btn.active, .btn-ghost.active { background: var(--cyan); color: #001018; }
.btn-wide { width: 100%; }
.btn-xl { display: block; width: 100%; min-height: 64px; font-size: 20px; font-weight: 800; letter-spacing: .02em;
  border-radius: 16px; background: var(--cyan); color: #001018; padding: 14px; }
.btn-green { background: var(--green); color: #02140a; }
.armed { background: var(--red) !important; color: #fff !important; }

.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800;
  letter-spacing: .06em; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.ws-live, .gps-ok { color: #bbf7d0; border-color: #166534; background: #052e16; }
.ws-reconnecting, .ws-connecting, .gps-warn, .gps-sim { color: #fde68a; border-color: #92400e; background: #2a1704; }
.ws-offline, .ws-auth, .gps-bad { color: #fecaca; border-color: #991b1b; background: #2a0606; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 800;
  letter-spacing: .08em; background: var(--slate); color: #e2e8f0; }
.badge.small { font-size: 10px; padding: 2px 6px; }
.stage-pickup { background: #7c2d12; color: #fed7aa; }
.stage-dropoff { background: #14532d; color: #bbf7d0; }
.stage-auto { background: #1e3a5f; color: #bfdbfe; }

.st-amber { background: var(--amber); color: #1a0f00; }
.st-green { background: var(--green); color: #02140a; }
.st-blue { background: var(--blue); color: #fff; }
.st-slate { background: var(--slate); color: #e2e8f0; }

#toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: #111827; border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 12px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 1000; max-width: 92vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { border-color: #166534; } #toast.error { border-color: var(--red); background: #2a0606; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 900; display: grid; place-items: center; padding: 24px; }
.start-card, .key-card { width: min(460px, 100%); text-align: center; display: grid; gap: 18px; }
.key-card { text-align: left; background: var(--panel); padding: 24px; border-radius: var(--radius); border: 1px solid var(--line); }
.key-card h2 { margin: 0; }
.brand { font-size: 32px; font-weight: 900; letter-spacing: .12em; display: flex; align-items: center; justify-content: center; gap: 12px; }
.brand-icon { width: 34px; height: 34px; fill: var(--cyan); }

/* ============================================================ COCKPIT (landscape iPad) */
body.cockpit { height: 100dvh; overflow: hidden; display: grid;
  grid-template-rows: auto auto 1fr auto; padding: var(--safe-t) var(--safe-r) 0 var(--safe-l); user-select: none; -webkit-user-select: none; }

.status-banner { display: flex; align-items: center; justify-content: center; min-height: 64px; padding: 8px 16px;
  font-size: clamp(22px, 3vw, 34px); font-weight: 900; letter-spacing: .04em; text-align: center; transition: background .3s; }
.status-banner.flash { animation: flash .6s ease-in-out 4; }
@keyframes flash { 50% { filter: brightness(1.6) saturate(1.3); } }

.telemetry { display: flex; align-items: center; gap: 14px; padding: 6px 12px; white-space: nowrap; overflow: hidden; background: var(--panel); border-bottom: 1px solid var(--line); }
.tel { display: flex; align-items: baseline; gap: 4px; flex: none; }
.tel-k { font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--muted); margin-right: 4px; }
.tel-v { font-size: 19px; white-space: nowrap; font-weight: 800; font-variant-numeric: tabular-nums; }
.tel-spacer { flex: 1; }
.clock { font-size: 18px; }
.telemetry .pill { margin-left: -8px; flex: none; font-size: 11px; padding: 3px 8px; }
.clock { flex: none; }

.cockpit-main { display: grid; grid-template-columns: 30% 70%; min-height: 0; }
.side { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow: hidden;
  background: var(--bg); border-right: 1px solid var(--line); }

.turn-card { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; background: #0a1a24;
  border: 2px solid #0e7490; border-radius: var(--radius); padding: 14px; }
.turn-card.imminent { background: #0e7490; border-color: var(--cyan); }
.turn-card.idle { background: var(--panel); border-color: var(--line); }
.turn-arrow { width: 96px; height: 96px; color: #fff; }
.arrow-svg { width: 100%; height: 100%; }
.arrow-svg.dim { color: #334155; }
.turn-dist { font-size: clamp(32px, 4.2vw, 50px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.turn-street { font-size: clamp(17px, 1.9vw, 23px); font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.turn-then { grid-column: 1 / -1; font-size: 15px; font-weight: 700; color: #a5f3fc; border-top: 1px solid #155e75; padding-top: 8px; }

.stop-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stop-head { display: flex; justify-content: space-between; align-items: center; }
.stop-label { font-size: 24px; font-weight: 800; margin-top: 8px; }
.stop-address { color: var(--muted); font-size: 16px; margin-top: 2px; }
.eta-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
.eta-row > div { display: flex; flex-direction: column; }
.eta-v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

.next-list { display: grid; gap: 6px; overflow: auto; }
.next-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel); border-radius: 10px; font-weight: 600; }
.next-n { width: 24px; height: 24px; border-radius: 50%; background: var(--slate); display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.next-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.canvas { position: relative; min-height: 0; background: #05070a; }
#map { position: absolute; inset: 0; }
.map-buttons { position: absolute; right: 14px; bottom: 40px; display: grid; gap: 12px; z-index: 5; }
.round-btn { width: 64px; height: 64px; border-radius: 50%; background: rgba(11,15,20,.92); border: 2px solid var(--line);
  display: grid; place-items: center; color: var(--text); }
.round-btn svg { width: 30px; height: 30px; fill: currentColor; }
.round-btn.off { color: var(--red); }
#btn-recenter { background: var(--cyan); color: #001018; border-color: var(--cyan); }
.arrived-banner { position: absolute; left: 40%; bottom: 40px; transform: translateX(-50%); z-index: 5; background: var(--green);
  color: #02140a; font-weight: 900; font-size: 28px; letter-spacing: .1em; padding: 10px 28px; border-radius: 999px; }

.truck-marker svg { width: 46px; height: 46px; }
.truck-marker path { fill: var(--cyan); stroke: #001018; stroke-width: 2; }
.truck-marker .halo { fill: rgba(34,211,238,.18); stroke: rgba(34,211,238,.5); stroke-width: 1.5; }
.dest-marker svg { width: 38px; height: 50px; }
.dest-marker path { fill: var(--red); stroke: #fff; stroke-width: 2; }
.dest-marker .dot { fill: #fff; }
.queue-marker { width: 28px; height: 28px; border-radius: 50%; background: var(--slate); border: 2px solid #94a3b8;
  color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 13px; }

/* Video box docked over the map's top-right corner. */
.video-dock { position: absolute; top: 10px; right: 10px; z-index: 6; background: #000; border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; box-shadow: 0 6px 24px rgba(0,0,0,.6); display: grid; }
.video-dock.size-s { width: max(38%, 330px); }
.video-dock.size-m { width: 54%; }
.video-dock.size-l { width: calc(100% - 20px); }
.video-stage { position: relative; aspect-ratio: 16 / 9; max-height: calc(100dvh - 300px); }
.video-stage video, .video-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.dock-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; background: var(--panel); }
.size-s .dock-sizes button { width: 34px; }
.size-s .dock-btn { font-size: 14px; padding: 0 6px; }
.dock-sizes { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.dock-sizes button { width: 42px; height: 40px; font-weight: 800; background: var(--panel-2); }
.dock-sizes button.active { background: var(--cyan); color: #001018; }
.dock-btn { flex: 1 1 auto; min-width: 0; height: 40px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 700; }

/* Video browser sheet over the map */
.media-sheet { position: absolute; inset: 10px; z-index: 8; background: rgba(11,15,20,.98); border: 1px solid var(--line);
  border-radius: var(--radius); display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px;
  border-bottom: 1px solid var(--line); }
.sheet-tabs { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.sheet-tabs button { padding: 0 18px; height: 44px; font-weight: 800; background: transparent; }
.sheet-tabs button.active { background: var(--cyan); color: #001018; }
.sheet-body { overflow: auto; padding: 14px; min-height: 0; }
.sheet-body section { display: grid; gap: 12px; align-content: start; }
.sheet-body p { margin: 0; }
.media-form { display: grid; gap: 10px; max-width: 720px; }
.media-saved { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.media-saved li { display: flex; align-items: center; gap: 10px; }
.media-saved .lib-play { flex: 1; text-align: left; }

/* YouTube results (iPad grid, iPhone list) */
.yt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.yt-item { display: grid; gap: 6px; align-content: start; min-width: 0; }
.yt-play { display: grid; gap: 6px; text-align: left; background: transparent; padding: 0; min-width: 0; }
.yt-thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--panel-2); }
.yt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-len { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.85); color: #fff; font-size: 12px;
  font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.yt-len:empty { display: none; }
.yt-meta { display: grid; gap: 2px; min-width: 0; }
.yt-meta b { font-size: 15px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.yt-meta span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yt-save { justify-self: start; }
.yt-list { grid-template-columns: minmax(0, 1fr); gap: 10px; }
.yt-list .yt-play { grid-template-columns: 140px minmax(0, 1fr); align-items: center; gap: 10px; }
.media-link summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 6px 0; }
.media-link .push-form { margin-top: 8px; }

.minibar { display: flex; align-items: center; gap: 12px; padding: 8px 14px calc(8px + var(--safe-b));
  background: var(--panel); border-top: 1px solid var(--line); }
.mb-btn { min-width: 52px; height: 46px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-weight: 700; padding: 0 12px; }
.mb-btn svg { width: 24px; height: 24px; fill: currentColor; }
.mb-title { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-primary { background: var(--cyan); color: #001018; border-color: var(--cyan); padding: 0 22px; }

/* Debug drawer */
.drawer { position: fixed; left: 0; bottom: 0; width: min(460px, 46vw); max-height: 86dvh; overflow: auto; z-index: 50;
  background: rgba(11,15,20,.97); border: 1px solid var(--line); border-radius: 0 16px 0 0; padding: 16px;
  padding-bottom: calc(16px + var(--safe-b)); transform: translateY(105%); transition: transform .25s; display: grid; gap: 12px; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer h3 { margin: 0; }
.switch-row, .slider-row { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.switch-row input { width: 24px; height: 24px; min-height: 0; }
.slider-row input { flex: 1; min-height: 0; padding: 0; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-grid .btn { font-size: 14px; }
.readout { margin: 0; font: 12px/1.5 ui-monospace, Menlo, monospace; background: #000; padding: 10px; border-radius: 10px;
  white-space: pre-wrap; color: #a5f3fc; }

/* ------------------------------------------------------------ offer card (shared) */
.offer-card { border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; background: #0b0f14;
  border: 3px solid var(--slate); box-shadow: 0 0 0 9999px rgba(0,0,0,0); }
.cockpit .offer-card { position: absolute; inset: 10px; z-index: 20; align-content: start; overflow: auto; }
.offer-card.grade-good { border-color: var(--green); }
.offer-card.grade-ok { border-color: var(--yellow); }
.offer-card.grade-bad { border-color: var(--red); }
.offer-top { display: flex; justify-content: space-between; align-items: center; }
.offer-tag { font-weight: 900; letter-spacing: .14em; font-size: 14px; }
.offer-timer { font-weight: 900; font-size: 24px; font-variant-numeric: tabular-nums; }
.offer-bar { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.offer-bar-fill { height: 100%; width: 100%; background: var(--cyan); transition: width .25s linear; }
.offer-bar-fill.urgent { background: var(--red); }
.offer-payout { font-size: clamp(48px, 6vw, 72px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.offer-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.offer-metrics > div { display: flex; flex-direction: column; }
.offer-metrics b { font-size: 24px; font-variant-numeric: tabular-nums; }
.grade-good .o-ppm { color: var(--green); } .grade-ok .o-ppm { color: var(--yellow); } .grade-bad .o-ppm { color: var(--red); }
.grade-good .o-ppm, .grade-ok .o-ppm, .grade-bad .o-ppm { font-size: 30px; }
.offer-rest { font-size: 20px; font-weight: 800; }
.offer-drop { color: var(--muted); }
.offer-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 4px; }
.offer-btn { min-height: 92px; border-radius: 16px; font-size: 26px; font-weight: 900; letter-spacing: .06em; }
.offer-btn.accept { background: var(--green); color: #02140a; }
.offer-btn.decline { background: #3f0d0d; color: #fecaca; border: 2px solid var(--red); }
.offer-result { text-align: center; font-size: 22px; padding: 10px; border-radius: 12px; background: var(--panel-2); }
.offer-result .bad { color: #fca5a5; font-size: 16px; font-weight: 800; margin-top: 4px; }
.offer-result div { font-size: 15px; color: var(--muted); }
.status-accepted .offer-result { border: 2px solid var(--green); }
.status-declined .offer-result, .status-expired .offer-result { border: 2px solid var(--slate); }

/* ============================================================ DISPATCH (portrait iPhone) */
body.dispatch { padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 12px) calc(var(--safe-b) + 24px) calc(var(--safe-l) + 12px);
  display: grid; gap: 14px; max-width: 640px; margin: 0 auto; }
.d-header { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 10; background: var(--bg);
  padding: 8px 0; }
.d-title { flex: 1; font-weight: 900; letter-spacing: .14em; font-size: 18px; }
.d-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 12px; }
.d-section-title { font-size: 13px; font-weight: 900; letter-spacing: .12em; color: var(--muted); text-transform: uppercase;
  display: flex; justify-content: space-between; gap: 8px; }
.d-section-title .muted { text-transform: none; letter-spacing: 0; font-weight: 600; text-align: right; }
.dispatch .offer-card { position: sticky; top: 56px; z-index: 9; }
.dispatch .offer-btn { min-height: 76px; }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.status-btn { min-height: 84px; border-radius: 14px; font-size: 18px; font-weight: 900; padding: 10px; line-height: 1.15;
  opacity: .55; border: 3px solid transparent; }
.status-btn.current { opacity: 1; border-color: #fff; }

.push-form { display: grid; gap: 10px; }
.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; min-height: 46px; font-weight: 700; background: transparent; }
.seg button.active { background: var(--cyan); color: #001018; }

.active-stop { background: var(--panel-2); border-radius: 12px; padding: 12px; border-left: 5px solid var(--cyan); }
.as-top { display: flex; justify-content: space-between; align-items: center; }
.as-label { font-size: 22px; font-weight: 800; margin-top: 6px; }
.as-addr { color: var(--muted); }
.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.q-item { background: var(--panel-2); border-radius: 12px; padding: 10px; display: grid; gap: 8px; }
.q-main b { margin-left: 6px; }
.q-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--slate);
  font-size: 12px; font-weight: 800; margin-right: 6px; }
.q-actions { display: grid; grid-template-columns: 52px 52px 1fr 1fr; gap: 6px; }
.q-btn { min-height: 46px; border-radius: 10px; background: #1b2430; border: 1px solid var(--line); font-weight: 700; }
.q-btn.danger { color: #fca5a5; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats-grid > div { display: flex; flex-direction: column; background: var(--panel-2); border-radius: 10px; padding: 8px 10px; }
.stats-grid b { font-size: 20px; font-variant-numeric: tabular-nums; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.preset { min-height: 60px; border-radius: 12px; background: #052e16; border: 2px solid #166534; color: #bbf7d0; font-size: 18px; font-weight: 900; }
.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.recent li { background: var(--panel-2); border-radius: 8px; padding: 4px 10px; }
.d-foot { text-align: center; }

@media (max-width: 380px) {
  .status-btn { font-size: 16px; min-height: 72px; }
  .preset { font-size: 16px; }
}
/* Narrow landscape fallback (e.g. testing on a laptop window) */
@media (max-width: 900px) and (orientation: landscape) {
  .cockpit-main { grid-template-columns: 36% 64%; }
}

/* ------------------------------------------------------------ optimizer additions */
.offer-verdict { font-weight: 900; letter-spacing: .12em; font-size: 15px; padding: 4px 10px; border-radius: 8px; background: var(--slate); }
.grade-good .offer-verdict { background: var(--green); color: #02140a; }
.grade-ok .offer-verdict { background: var(--yellow); color: #1a1400; }
.grade-bad .offer-verdict { background: var(--red); color: #fff; }
.offer-reasons { font-size: 14px; font-weight: 700; color: #fca5a5; min-height: 0; }
.offer-reasons:empty { display: none; }

.hotspot-card { background: var(--panel); border: 1px solid #5b21b6; border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; }
#hotspot-list { display: grid; gap: 6px; }
.hotspot { width: 100%; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; background: var(--panel-2); border-radius: 10px; padding: 8px 10px; min-height: 52px; }
.hs-arrow { width: 34px; height: 34px; flex: none; display: grid; place-items: center; color: #c4b5fd; transition: transform .4s; }
.hs-arrow svg { width: 26px; height: 26px; fill: currentColor; }
.hs-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.hs-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ref-input { flex: 0 0 120px !important; }
.rules-form { display: grid; gap: 10px; }
.rules-form > label:not(.switch-row) { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 10px; font-weight: 700; }
.rules-form .switch-row input { width: 26px; height: 26px; min-height: 0; flex: none; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { display: flex; align-items: center; gap: 8px; background: #2a0606; border: 1px solid #991b1b; border-radius: 999px; padding: 4px 6px 4px 12px; font-weight: 700; }
.chips li.muted { background: none; border: 0; padding: 0; font-weight: 500; }
.chips button { background: #450a0a; color: #fecaca; border-radius: 999px; padding: 6px 10px; font-size: 13px; font-weight: 700; }

/* iPhone width: never let a wide child stretch the page sideways */
body.dispatch { grid-template-columns: minmax(0, 1fr); overflow-x: hidden; }
.d-header { flex-wrap: wrap; row-gap: 6px; }
.d-header .pill { font-size: 11px; padding: 3px 8px; }
.d-card, .dispatch .offer-card { min-width: 0; }
.d-section-title .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dispatch .offer-metrics b { font-size: 20px; }
.dispatch .offer-payout { font-size: 52px; }

/* ============================================================ PAIRING: errors */
.login-error { margin: 0; color: #fca5a5; font-weight: 700; }

/* ============================================================ PAIRING */
body.pair { min-height: 100vh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 20px 24px; }
.pair-wrap { width: min(860px, 100%); }
.pair-card { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 32px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
#approve.pair-card { grid-template-columns: minmax(0, 1fr); max-width: 460px; margin: 0 auto; }
.pair-qr { background: #fff; border-radius: 16px; padding: 12px; aspect-ratio: 1; }
.pair-qr svg { display: block; width: 100%; height: 100%; }
.pair-text { display: grid; gap: 12px; }
.pair-text h1 { margin: 0; font-size: clamp(28px, 4vw, 38px); }
.pair-text p { margin: 0; }
.pair-code { font: 900 clamp(44px, 8vw, 64px)/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .12em;
  color: var(--cyan); white-space: nowrap; }
.pair-first { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 15px; }
.pair-first code { display: block; margin-top: 6px; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.pair-note { margin: 0; color: var(--yellow); font-weight: 700; }
@media (max-width: 640px) {
  .pair-card { grid-template-columns: minmax(0, 1fr); padding: 20px; gap: 20px; }
  .pair-qr { width: min(260px, 100%); margin: 0 auto; }
}
.devices-overlay { align-items: start; overflow-y: auto; }
.devices-card { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: grid; gap: 18px; }
.devices-head { display: flex; justify-content: space-between; align-items: center; }
.devices-head h2, .devices-card h3 { margin: 0; }
.devices-card h3 { font-size: 16px; color: var(--muted); margin-bottom: 8px; }
.devices-card section > p { margin: 0 0 10px; }
.devices-row { display: flex; flex-wrap: wrap; gap: 10px; }
.devices-row > .btn { flex: 1 1 160px; }
.code-form { display: flex; gap: 8px; flex: 1 1 200px; }
.code-input { flex: 1; min-width: 0; font: 800 20px ui-monospace, Menlo, monospace; letter-spacing: .12em; text-transform: uppercase; }
.devices-msg { margin: 10px 0 0; font-weight: 700; color: var(--green); min-height: 1em; }
.devices-msg.bad { color: #fca5a5; }
.scan-box { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; margin-bottom: 10px; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid var(--cyan); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.devices-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.devices-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--panel-2);
  border-radius: 12px; padding: 10px 12px; }
.devices-list small { display: block; color: var(--muted); }
.this-dev { font-size: 12px; color: var(--cyan); font-weight: 700; }
.devices-list .danger { color: #fca5a5; flex: none; }
