/* ════════════════════════════════════════════════════════════
   RAPIDXPK PORTAL — THEME v2 OVERLAY
   The portal ships a light "LEDGER" default with a
   [data-theme="dark"] toggle. This overlay:
   1. swaps the type identity in BOTH modes,
   2. aligns dark mode's palette with the marketing site,
   3. patches light-theme rules that leak into dark mode.
   No layout or logic changes.
   ════════════════════════════════════════════════════════════ */

/* ── type identity — both modes ───────────────────── */
:root:root {
  --sans: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --disp: 'Space Grotesk', sans-serif;
}
html { -webkit-text-size-adjust: 100%; }
::selection { background: #c9ff3d; color: #0a0a0a; }

/* display numbers were hard-wired to Anton */
html .kpi .val, html .cod-cell .val, html .uv-fly {
  font-family: 'Space Grotesk', var(--sans) !important;
  font-weight: 700 !important;
  letter-spacing: -0.03em !important;
}

/* primary buttons: the site's volt pill, readable in both modes */
html .btn-volt {
  border-radius: 999px !important;
  background: linear-gradient(160deg, #d6ff5c 0%, #c9ff3d 45%, #a8e000 100%) !important;
  color: #0a0a0a !important;
  border: none !important;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(122, 160, 0, 0.9), 0 10px 26px -10px rgba(201, 255, 61, 0.45);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), box-shadow 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
html .btn-volt:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 2px 0 rgba(122, 160, 0, 0.9), 0 14px 32px -10px rgba(201, 255, 61, 0.55);
}
html .btn-volt:active { transform: scale(0.98); }

/* focus visibility everywhere */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid #c9ff3d;
  outline-offset: 2px;
}

/* ── dark mode: align with the site's blacks ──────── */
html[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #121211;
  --surface-2: #0e0e0d;
  --raised: #171716;
  --sunk: #0c0c0b;
  --line: rgba(240, 240, 238, 0.08);
  --line-2: rgba(240, 240, 238, 0.15);
  --line2: rgba(240, 240, 238, 0.15);
  --text: #f0f0ee;
  --text-2: #a3a39b;
  --text2: #a3a39b;
  --text-3: #6b6b64;
  --text3: #6b6b64;
  --muted: #6b6b64;
  --volt: #c9ff3d;
  --volt-bright: #c9ff3d;
  --volt-ink: #c9ff3d;
  --volt-dim: rgba(201, 255, 61, 0.11);
  --volt-line: rgba(201, 255, 61, 0.38);
  --panel: #121211;
  --panel2: #0e0e0d;
  --shadow-sm: 0 10px 26px -18px rgba(0, 0, 0, 0.8);
  --shadow-md: 0 16px 40px -22px rgba(0, 0, 0, 0.85);
  --shadow-lg: 0 26px 60px -26px rgba(0, 0, 0, 0.9);
}
html[data-theme="dark"] body { background: #0a0a0a !important; }

/* ── dark-mode leak patches (light rules with no dark twin) ── */
/* the near-white line slicing through rider rows */
html[data-theme="dark"] .rider-stat {
  border-top-color: rgba(240, 240, 238, 0.09) !important;
}
/* light-gray scrollbar thumb on dark chrome */
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(240, 240, 238, 0.16);
  border-radius: 99px;
  border: 2px solid #0a0a0a;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(201, 255, 61, 0.4); }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }

/* ── mobile hardening ─────────────────────────────── */
@media (max-width: 640px) {
  /* stop iOS Safari zooming into sub-16px inputs
     (the :not(#\ ) bumps specificity past the portal's own rules) */
  :is(input, select, textarea):not(#\ ) { font-size: 16px !important; }
  /* momentum scrolling for wide ops tables */
  .tbl-scroll { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
}

/* ════════════════════════════════════════════════════
   LOGIN — full-viewport split (PostEx-style)
   ════════════════════════════════════════════════════ */
#view-login {
  grid-template-columns: 1.15fr 1fr !important;
  place-items: stretch !important;
  align-items: stretch !important;
  padding: 0 !important;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg) !important;
}
.lg-wrap {
  display: contents !important;
}

/* left: the brand panel */
.lg-side {
  display: flex !important;
  order: -1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: none !important;
  border-radius: 0 !important;
  background:
    repeating-linear-gradient(115deg, rgba(240, 240, 238, 0.016) 0 2px, transparent 2px 90px),
    repeating-linear-gradient(115deg, rgba(201, 255, 61, 0.02) 0 1px, transparent 1px 140px),
    linear-gradient(160deg, #0d0d0b, #070707) !important;
}
.lg-side::before {
  content: '';
  width: min(300px, 56%);
  aspect-ratio: 560 / 140;
  background: url('../logo-v2.png') center / contain no-repeat;
  filter: drop-shadow(0 0 40px rgba(201, 255, 61, 0.25));
  animation: lgBrandBreathe 6s ease-in-out infinite;
}
@keyframes lgBrandBreathe {
  0%, 100% { filter: drop-shadow(0 0 30px rgba(201, 255, 61, 0.18)); }
  50% { filter: drop-shadow(0 0 55px rgba(201, 255, 61, 0.4)); }
}
.lg-side::after {
  content: 'FULFILLMENT  ·  DELIVERY  ·  GROWTH';
  margin-top: 30px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.34em;
  color: rgba(240, 240, 238, 0.4);
}
.lg-side .lg-quote { display: none !important; }
.lg-side .lg-meta {
  position: absolute;
  left: 34px; right: 34px; bottom: 26px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(240, 240, 238, 0.35) !important;
}
.lg-side .lg-secure i { background: #c9ff3d; }

/* right: the form column */
.lg-card {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: var(--surface) !important;
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  padding: clamp(36px, 6vw, 96px) !important;
  max-width: none !important;
  width: auto !important;
}
.lg-card > * { width: 100%; max-width: 460px; margin-left: auto; margin-right: auto; }
.lg-brand { margin-bottom: clamp(30px, 6vh, 60px) !important; }
.lg-brand img { height: 30px !important; }
.lg-title {
  font-family: var(--disp) !important;
  font-size: clamp(30px, 3.4vw, 40px) !important;
  font-weight: 700 !important;
  letter-spacing: -0.03em !important;
  margin-bottom: 6px !important;
}
.lg-with {
  font-size: 15px;
  color: var(--text-2, var(--text2));
  margin: 0 0 26px;
}
.lg-card .field input {
  padding: 15px 16px !important;
  border-radius: 12px !important;
  font-size: 16px !important;
}
.lg-btn {
  padding: 16px !important;
  font-size: 16px !important;
  margin-top: 8px;
}
.lg-foot { margin-top: 30px !important; }

/* mobile: form only, brand strip on top */
@media (max-width: 880px) {
  #view-login { grid-template-columns: 1fr !important; }
  .lg-side {
    display: flex !important;
    order: -1;
    min-height: 150px;
    flex-direction: column;
  }
  .lg-side::before { width: 170px; }
  .lg-side::after { margin-top: 16px; font-size: 8.5px; }
  .lg-side .lg-meta { display: none !important; }
  .lg-card { min-height: calc(100dvh - 150px); justify-content: flex-start; padding-top: 44px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .lg-side::before { animation: none; }
}

/* ── login refinement: one left edge, one subtitle, calm button ── */
.lg-card { justify-content: flex-start !important; padding-top: clamp(48px, 13vh, 130px) !important; }
.lg-card, .lg-card .lg-title, .lg-card .lg-with, .lg-card .lg-brand,
.lg-card .field label, .lg-card .lg-foot { text-align: left !important; }
.lg-brand { display: block; margin: 0 auto clamp(44px, 9vh, 84px) !important; }
.lg-brand img { margin: 0 !important; display: block; }
/* one subtitle only — the JS-filled type line goes */
.lg-sub, #loginType { display: none !important; }
.lg-with { margin-bottom: 36px; }
/* PostEx-calm button: soft rectangle, restrained glow */
html .lg-btn {
  border-radius: 14px !important;
  padding: 15px !important;
  font-size: 15.5px !important;
  box-shadow: 0 1px 0 rgba(122, 160, 0, 0.9), 0 8px 20px -12px rgba(201, 255, 61, 0.4) !important;
}
html .lg-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 0 rgba(122, 160, 0, 0.9), 0 10px 24px -10px rgba(201, 255, 61, 0.5) !important;
}
/* footer sits on a hairline, aligned to the same edge */
.lg-foot {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  display: flex;
  gap: 8px;
  justify-content: flex-start !important;
}
/* field spacing rhythm */
.lg-card .field { margin-bottom: 18px !important; }

/* ── phone interactivity: real touch targets ──────── */
@media (max-width: 640px) {
  .btn-sm, .act, .ed-cancel {
    min-height: 42px !important;
    padding: 11px 15px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .btn-volt { min-height: 46px !important; }
  .tabs { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { min-height: 42px; display: inline-flex; align-items: center; }
  .pill { min-height: 26px; }
  /* modals fill the phone properly */
  .ed-modal { max-height: 92dvh !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch; }
  td, th { padding-top: 12px !important; padding-bottom: 12px !important; }
}

/* ════════════════════════════════════════════════════
   ZONE MAP — Karachi territories (Riders view)
   ════════════════════════════════════════════════════ */
.zone-wrap {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
  align-items: stretch;
}
.zone-map {
  height: 460px;
  border-radius: 14px;
  border: 1px solid var(--line2, var(--line-2));
  overflow: hidden;
  background: #eaeae2;
}
html[data-theme="dark"] .zone-map { background: #0b0d0a; }
html[data-theme="dark"] .zone-map .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.55);
}
.zone-lab {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-family: var(--mono) !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 0.08em;
  color: #1a1a14 !important;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.55);
  pointer-events: none;
}
html[data-theme="dark"] .zone-lab {
  color: #f0f0ee !important;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}
.zone-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 460px;
  padding-right: 2px;
}
.zl-row {
  display: grid;
  grid-template-columns: 14px 1fr;
  grid-template-areas: "dot name" "dot riders";
  column-gap: 10px;
  align-items: center;
  text-align: left;
  padding: 9px 12px;
  border: 1px solid var(--line, rgba(240,240,238,.08));
  border-radius: 11px;
  background: var(--raised);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
.zl-row:hover { border-color: rgba(201, 255, 61, 0.4); transform: translateX(3px); }
.zl-row i {
  grid-area: dot;
  width: 11px; height: 11px;
  border-radius: 4px;
  display: block;
}
.zl-name { grid-area: name; font-weight: 600; font-size: 13px; color: var(--text); }
.zl-riders {
  grid-area: riders;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-3, var(--text3));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* zone popup */
.zone-pop .leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line2, var(--line-2));
  border-radius: 14px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
}
.zone-pop .leaflet-popup-tip { background: var(--surface); }
.zone-pop .leaflet-popup-content { margin: 14px 16px; min-width: 220px; }
.zp-name {
  font-family: var(--disp);
  font-weight: 700;
  font-size: 16px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 2px solid;
}
.zp-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.zp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 99px;
  background: var(--volt-dim, rgba(201,255,61,.12));
  border: 1px solid var(--volt-line, rgba(201,255,61,.35));
}
.zp-chip button {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: 0.6; font-size: 11px; padding: 0 2px;
}
.zp-chip button:hover { opacity: 1; }
.zp-none { font-size: 12px; color: var(--text-3, var(--text3)); }
.zp-row { display: flex; gap: 8px; }
.zp-row select {
  flex: 1;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line2, var(--line-2));
  background: var(--raised);
  color: var(--text);
  font-size: 13px;
}
.zp-go {
  padding: 9px 16px;
  border-radius: 99px;
  border: none;
  background: linear-gradient(160deg, #d6ff5c, #a8e000);
  color: #0a0a0a;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
/* rider-card zone select */
.rz-sel {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line2, var(--line-2));
  background: var(--raised);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  max-width: 170px;
}
@media (max-width: 880px) {
  .zone-wrap { grid-template-columns: 1fr; }
  .zone-map { height: 340px; }
  .zone-side { max-height: none; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .zl-row { min-width: 190px; }
}

.zl-ord { font-style: normal; color: var(--volt); margin-left: 6px; }

/* one-tap rider unassign on order rows */
.rx-unassign {
  margin-left: 7px;
  width: 17px; height: 17px;
  border-radius: 50%;
  border: 1px solid var(--line2, var(--line-2));
  background: var(--raised);
  color: var(--text-3, var(--text3));
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: color 0.15s, border-color 0.15s, transform 0.2s;
}
.rx-unassign:hover {
  color: #ff6a45;
  border-color: rgba(255, 106, 69, 0.5);
  transform: scale(1.15);
}

/* ── subzone accordion in the zone legend ─────────── */
.zl-item { border-radius: 12px; overflow: hidden; }
.zl-head { display: flex; gap: 6px; align-items: stretch; }
.zl-head .zl-row { flex: 1; }
.zl-tg {
  width: 34px;
  border: 1px solid var(--line, rgba(240,240,238,.08));
  border-radius: 11px;
  background: var(--raised);
  color: var(--text-3, var(--text3));
  cursor: pointer;
  font-size: 11px;
  transition: color 0.15s, border-color 0.15s;
}
.zl-tg:hover { color: #c9ff3d; border-color: rgba(201, 255, 61, 0.4); }
.zl-item.open .zl-tg { color: #c9ff3d; border-color: rgba(201, 255, 61, 0.4); }
.zl-subs {
  margin: 6px 0 4px 24px;
  display: grid;
  gap: 5px;
  padding-left: 10px;
  border-left: 1px dashed var(--line2, var(--line-2));
}
.zl-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-2, var(--text2));
}
.zl-sub span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zl-sub select {
  max-width: 150px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line2, var(--line-2));
  background: var(--raised);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
}
@media (max-width: 880px) {
  .zl-item { min-width: 230px; }
  .zl-subs { margin-left: 10px; }
}

/* legend must overflow + scroll, never compress its rows */
.zone-side > * { flex: 0 0 auto; }
.zone-side {
  overflow-y: auto !important;
  scrollbar-width: thin;
  padding-right: 6px;
}
.zone-side::-webkit-scrollbar { width: 8px; }
.zone-side::-webkit-scrollbar-thumb {
  background: rgba(240, 240, 238, 0.18);
  border-radius: 99px;
}
.zone-side::-webkit-scrollbar-thumb:hover { background: rgba(201, 255, 61, 0.45); }

/* ── founder tier ─────────────────────────────────── */
body:not(.is-founder) .founder-only { display: none !important; }
body.is-founder .founder-only { display: revert; }
.tab.founder-only .ic { color: #c9ff3d; }
.fd-secret { cursor: pointer; user-select: none; }
.fd-secret em { font-style: normal; letter-spacing: 2px; color: var(--text-3, var(--text3)); }
.fd-secret b { display: none; font-weight: 600; color: #c9ff3d; }
.fd-secret.show em { display: none; }
.fd-secret.show b { display: inline; }

/* rider reconciliation requests */
.req-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 193, 77, 0.45);
  background: rgba(255, 193, 77, 0.07);
  border-radius: 14px;
  margin-bottom: 8px;
  animation: reqPulse 2.4s ease-in-out infinite;
}
@keyframes reqPulse {
  0%, 100% { border-color: rgba(255, 193, 77, 0.45); }
  50% { border-color: rgba(255, 193, 77, 0.9); }
}
.req-ico { font-size: 18px; }
.req-txt { flex: 1; font-size: 13.5px; color: var(--text); }
.req-go { padding: 10px 16px !important; font-size: 13px !important; white-space: nowrap; }
.req-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ffc14d;
  margin-left: 7px;
  animation: reqPulse2 1.4s ease-in-out infinite;
}
@keyframes reqPulse2 { 50% { opacity: 0.3; } }
