:root {
  --v2-navy: #10213a;
  --v2-muted: #607087;
  --v2-blue: #087bea;
  --v2-blue-soft: #eef7ff;
  --v2-green: #18a957;
  --v2-green-soft: #edf9f1;
  --v2-amber: #ad7200;
  --v2-amber-soft: #fff8df;
  --v2-danger: #c9362b;
  --v2-danger-soft: #fff1ef;
  --v2-line: #d8e0e9;
  --v2-rail: #cbd5df;
  --header-height: 64px;
  --tabbar-height: 74px;
}

.header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding-left: max(8px, env(safe-area-inset-left, 0px));
  padding-right: max(8px, env(safe-area-inset-right, 0px));
  color: var(--v2-navy);
}

.header-center {
  min-width: 0;
  align-self: center;
  text-align: center;
}

.header-title {
  color: var(--v2-navy);
  font-size: clamp(16px, 4.6vw, 20px);
  font-weight: 800;
  letter-spacing: -0.35px;
  line-height: 1.1;
  text-transform: none;
}

.header-sub {
  margin-top: 3px;
  overflow: hidden;
  color: var(--v2-muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-right {
  gap: 6px;
}

.header-action {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--v2-line);
  border-radius: 50%;
  background: #ffffff;
  color: var(--v2-navy);
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.header-action:focus-visible,
.tabbar-btn:focus-visible,
.route-map-action:focus-visible,
.route-stop button:focus-visible {
  outline: 3px solid rgba(8, 123, 234, 0.3);
  outline-offset: 2px;
}

.header-action .ph {
  font-size: 22px;
}

.header-store-chat {
  width: auto;
  min-width: 76px;
  gap: 6px;
  padding: 0 12px;
  border-radius: 999px;
}

.header-store-chat-label {
  font-size: 11px;
  font-weight: 800;
}

.permission-gate {
  z-index: 1050;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 8px 10px 0;
  padding: 11px 12px;
  border: 1px solid #f3c45d;
  border-radius: 16px;
  background: #fff9e8;
  box-shadow: 0 8px 24px rgba(120, 77, 0, 0.12);
  color: #684300;
}

.permission-gate[hidden] { display: none; }
.permission-gate-copy { display: grid; gap: 2px; min-width: 0; }
.permission-gate-copy strong { font-size: 13px; }
.permission-gate-copy span { font-size: 10px; font-weight: 650; line-height: 1.3; }
.permission-gate-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.permission-action {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 0;
  border-radius: 11px;
  background: #10213a;
  color: #fff;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
}
.permission-action[hidden] { display: none; }
.permission-action:disabled {
  border: 1px solid #d6a948;
  background: #fff3ce;
  color: #765000;
  cursor: default;
}

.header-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--v2-danger);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  line-height: 15px;
}

.app-shell,
.route-view,
.tab-pane .page-pad {
  background: #ffffff;
}

.route-view.route-timeline-view,
.route-view {
  display: grid;
  grid-template-rows: clamp(96px, 13dvh, 118px) auto minmax(0, 1fr);
  background: #ffffff;
}

.route-view.map-collapsed {
  grid-template-rows: 50px auto minmax(0, 1fr);
}

.route-map-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--v2-line);
  background: #eaf0f5;
}

.route-map {
  position: absolute;
  inset: 0;
}

.route-map-stage .leaflet-control-zoom {
  display: none;
}

.route-map-actions {
  position: absolute;
  z-index: 960;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 7px;
}

.route-map-action {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(16, 33, 58, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 5px 18px rgba(16, 33, 58, 0.16);
  color: var(--v2-navy);
  font-size: 19px;
}

.route-map-toggle {
  width: auto;
  min-width: 42px;
  gap: 6px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 800;
}

.route-map-toggle-label {
  font-size: 11px;
}

.route-view.map-collapsed .route-map,
.route-view.map-collapsed .nav-hud,
.route-view.map-collapsed .route-map-actions > :not(.route-map-toggle) {
  display: none !important;
}

.route-view.map-collapsed .route-map-stage {
  border-bottom-color: #cfe5fb;
  background: #f7fbff;
}

.route-view.map-collapsed .route-map-actions {
  inset: 4px 10px auto;
}

.route-view.map-collapsed .route-map-toggle {
  width: 100%;
  justify-content: center;
  border-color: #b9dafa;
  background: #eaf5ff;
  box-shadow: none;
  color: #0869c7;
}

.route-view.map-expanded .route-map-stage {
  position: absolute;
  z-index: 1080;
  inset: 0;
  min-height: 100%;
  border: 0;
}

.route-view.map-expanded .route-progress,
.route-view.map-expanded .route-sheet {
  visibility: hidden;
}

.route-map-action.active,
.route-map-action.primary {
  border-color: var(--v2-blue);
  background: var(--v2-blue);
  color: #ffffff;
}

.route-map-stage .push-cta {
  top: 10px;
  right: 10px;
  left: 10px;
  max-width: 360px;
  border-color: #f0d785;
  border-radius: 10px;
  background: rgba(255, 248, 223, 0.97);
}

.route-map-stage .nav-hud {
  top: 10px;
  right: 10px;
  left: 10px;
  max-width: none;
  border-radius: 10px;
}

.route-progress {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 18px;
  padding: 13px 18px 10px;
  border-bottom: 1px solid var(--v2-line);
  background: #ffffff;
}

.route-hud-left {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--v2-navy);
  text-align: left;
}

.route-hud-title,
.route-eta strong {
  color: var(--v2-navy);
  font-size: clamp(21px, 6.2vw, 26px);
  font-weight: 800;
  letter-spacing: -0.7px;
  line-height: 1;
  text-transform: none;
}

.route-hud-sub,
.route-eta span {
  margin-top: 4px;
  color: var(--v2-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.route-eta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.route-progress-track {
  position: relative;
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf3;
}

.route-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--v2-blue);
  transition: width 180ms ease;
}

.route-progress-status {
  position: absolute;
  top: 10px;
  left: 50%;
  display: flex;
  max-width: 34%;
  transform: translateX(-50%);
  gap: 6px;
}

.route-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--v2-muted);
  font-size: 9px;
  font-weight: 700;
  opacity: 0.72;
}

.route-status.ok {
  color: #0b7f3d;
  opacity: 1;
}

.route-sheet {
  position: relative;
  inset: auto;
  min-width: 0;
  max-width: none;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

.route-sheet-body {
  height: 100%;
  max-height: none;
  padding: 0 14px 28px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: none;
}

.route-sheet-body::-webkit-scrollbar {
  display: none;
}

.route-sheet.collapsed .route-sheet-body {
  display: block;
}

.route-next-actions,
.route-sheet > .route-sheet-handle {
  display: none !important;
}

.route-stops {
  display: block;
  margin: 0;
}

.route-timeline {
  position: relative;
  padding: 8px 0 12px;
}

.route-timeline::before {
  position: absolute;
  top: 34px;
  bottom: 42px;
  left: 21px;
  width: 2px;
  background: var(--v2-rail);
  content: "";
}

.route-timeline-row {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  min-width: 0;
  padding: 7px 0;
  color: var(--v2-navy);
}

.route-timeline-node {
  z-index: 1;
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  align-self: start;
  justify-self: center;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--v2-navy);
  box-shadow: 0 0 0 1px var(--v2-line);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.route-timeline-node.complete {
  background: var(--v2-green);
  box-shadow: 0 0 0 4px rgba(24, 169, 87, 0.14);
}

.route-timeline-node.active {
  background: var(--v2-blue);
  box-shadow: 0 0 0 4px rgba(8, 123, 234, 0.14);
}

.route-timeline-node .ph {
  font-size: 16px;
}

.route-timeline-copy,
.route-stop-compact-main,
.route-stop-card {
  min-width: 0;
}

.route-stop {
  width: auto;
  padding: 7px 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  outline: none;
}

.route-stop.active,
.route-stop.selected {
  background: transparent;
  outline: none;
}

.route-stop.compact {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 0;
  align-items: start;
}

.route-stop.compact.delivered {
  opacity: 0.72;
}

.route-stop.compact .route-stop-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-stop-compact-side {
  display: flex;
  min-width: 58px;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 1px;
  padding-left: 8px;
}

.route-stop-time {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid #cfe3f5;
  border-radius: 8px;
  background: #f5faff;
  color: var(--v2-navy);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.route-stop-disclosure {
  color: var(--v2-muted);
  font-size: 17px;
}

.route-stop-undo {
  min-height: 32px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--v2-muted);
  font: 600 10px/1.2 var(--font-stack);
  text-decoration: underline;
}

.route-stop-card {
  padding: 12px 10px 10px;
  border: 1px solid #b8d9f7;
  border-top: 3px solid var(--v2-blue);
  border-radius: 10px;
  background: var(--v2-blue-soft);
  box-shadow: 0 7px 20px rgba(16, 33, 58, 0.08);
}

.route-stop-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.route-stop-title {
  overflow: visible;
  color: var(--v2-navy);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: clip;
  white-space: normal;
}

.route-stop.active .route-stop-title {
  font-size: 15px;
}

.route-stop-order {
  margin-top: 3px;
  color: var(--v2-muted);
  font-size: 10px;
  font-weight: 600;
}

.route-stop-sub {
  margin-top: 4px;
  overflow: visible;
  color: var(--v2-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  text-overflow: clip;
  white-space: normal;
}

.route-stop-meta {
  margin-top: 5px;
  overflow: visible;
  color: var(--v2-muted);
  font-size: 11px;
  font-weight: 600;
  white-space: normal;
}

.route-stop-due,
.route-stop-sync {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  color: #0b66bd;
  font-size: 12px;
  font-weight: 700;
}

.route-stop-sync {
  color: var(--v2-amber);
}

.route-stop-badge {
  flex: 0 0 auto;
  min-height: 27px;
  padding: 5px 9px;
  border-radius: 9px;
  font-size: 10px;
}

.route-stop-badge.pay-cash {
  border-color: #efce6c;
  background: var(--v2-amber-soft);
  color: var(--v2-amber);
}

.route-stop-fold-btn {
  min-height: 38px;
  border-style: solid;
  border-color: var(--v2-line);
  border-radius: 8px;
  background: #ffffff;
  font-size: 11px;
}

.route-stop-fold-left .ph {
  font-size: 18px;
}

.route-stop-fold-chev {
  font-size: 14px;
}

.route-stop-bag-content {
  background: #ffffff;
}

.route-stop-actions {
  display: grid;
  width: 100%;
  margin-top: 7px;
  gap: 7px;
}

.route-stop-actions-primary {
  grid-template-columns: 1fr;
}

.route-stop-actions-secondary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.route-stop-actions .btn {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  height: auto;
  padding: 7px 9px;
  border-radius: 9px;
  font-size: 11px;
  line-height: 1.15;
  white-space: normal;
}

.route-stop-actions-primary .btn {
  min-height: 46px;
  background: var(--v2-blue);
  font-size: 14px;
}

.route-stop-actions .ph {
  flex: 0 0 auto;
  font-size: 19px;
}

.route-stop-actions-secondary .btn-success {
  background: var(--v2-green);
  border-color: var(--v2-green);
}

.route-stop-actions-secondary .route-stop-delivered-btn {
  grid-column: 1 / -1;
  min-height: 56px;
  border-radius: 14px;
  background: var(--v2-green);
  border-color: var(--v2-green);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.route-stop-delivered-btn .ph { font-size: 23px; }

.route-stop-eater-chat, .route-stop-eater-chat-compact {
  width: 100%; border: 1px solid #bae6fd; border-radius: 14px; background: #f0f9ff; color: #0c4a6e; cursor: pointer;
}
.route-stop-eater-chat { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; margin: 10px 0; padding: 10px 12px; text-align: left; }
.route-stop-eater-chat > span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.route-stop-eater-chat strong { font-size: 12px; }
.route-stop-eater-chat em { overflow: hidden; color: #475569; font-size: 11px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.route-stop-eater-chat-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #0ea5e9; color: white; font-size: 18px; }
.route-stop-eater-chat-compact { display: inline-flex; width: auto; align-items: center; gap: 5px; margin-top: 6px; padding: 5px 8px; font-size: 10px; font-weight: 800; }

.eater-chat-overlay { position: fixed; z-index: 1200; inset: 0; display: grid; align-items: end; background: rgba(15,23,42,.52); padding: 16px; }
.eater-chat-overlay[hidden] { display: none; }
.eater-chat-modal { width: min(640px, 100%); max-height: min(78vh, 760px); margin: 0 auto; display: flex; flex-direction: column; overflow: hidden; border-radius: 22px 22px 12px 12px; background: white; box-shadow: 0 24px 70px rgba(15,23,42,.32); }
.eater-chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid #e2e8f0; }
.eater-chat-head span { color: #64748b; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; }
.eater-chat-head h2 { margin: 2px 0 0; font-size: 18px; }
.eater-chat-close { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #e2e8f0; border-radius: 12px; background: white; color: #334155; font-size: 24px; }
.eater-chat-status { min-height: 18px; padding: 10px 18px 0; color: #64748b; font-size: 11px; font-weight: 700; }
.eater-chat-history { flex: 1; min-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 14px 18px; }
.eater-chat-message { max-width: 86%; padding: 9px 11px; border-radius: 14px 14px 14px 4px; background: #e0f2fe; color: #0f172a; }
.eater-chat-message.restaurant { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: #f1f5f9; }
.eater-chat-message span { display: block; margin-bottom: 3px; color: #64748b; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.eater-chat-message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.4; }
.eater-chat-readonly { margin: 0; padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid #e2e8f0; color: #64748b; font-size: 11px; text-align: center; }

#btnFinishRoute {
  width: calc(100% - 44px);
  min-height: 48px;
  margin-left: 44px;
  border-radius: 10px;
}

.today-page {
  padding: 14px;
}

.today-hero {
  padding: 18px;
  border: 1px solid #cfe3f5;
  border-radius: 14px;
  background: var(--v2-blue-soft);
}

.today-greeting {
  color: var(--v2-navy);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.today-route-state {
  margin-top: 7px;
  color: var(--v2-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.today-hero-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.today-hero-actions .btn {
  min-height: 44px;
  height: auto;
  padding: 8px 10px;
  white-space: normal;
}

.today-section {
  margin-top: 18px;
}

.today-section-title {
  margin-bottom: 9px;
  color: var(--v2-navy);
  font-size: 13px;
  font-weight: 800;
}

.today-readiness {
  overflow: hidden;
  border: 1px solid var(--v2-line);
  border-radius: 12px;
  background: #ffffff;
}

.today-readiness-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  min-height: 50px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #edf1f5;
}

.today-readiness-row:last-child {
  border-bottom: 0;
}

.today-readiness-row .ph {
  color: var(--v2-muted);
  font-size: 19px;
}

.today-readiness-row strong {
  color: var(--v2-navy);
  font-size: 11px;
  font-weight: 700;
}

.today-readiness-state {
  color: var(--v2-muted);
  font-size: 10px;
  font-weight: 700;
  text-align: right;
}

.today-readiness-state.ok {
  color: #0b7f3d;
}

.today-readiness-state.warn {
  color: var(--v2-amber);
}

.tabbar {
  border-top-color: var(--v2-line);
  background: #ffffff;
}

.tabbar-btn {
  min-width: 0;
  border: 0;
  border-radius: 0;
  color: var(--v2-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.tabbar-btn.active {
  border-color: transparent;
  background: transparent;
  color: var(--v2-blue);
}

.tabbar-ic,
.tabbar-ic .ph,
.tabbar-ic svg {
  width: 24px;
  height: 24px;
  font-size: 24px;
  line-height: 24px;
}

[dir="rtl"] .route-timeline::before {
  right: 21px;
  left: auto;
}

[dir="rtl"] .route-timeline-row {
  grid-template-columns: 44px minmax(0, 1fr);
}

[dir="rtl"] .route-stop-compact-side {
  padding-right: 8px;
  padding-left: 0;
}

@media (max-width: 359px) {
  .header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .header-action {
    width: 40px;
    height: 40px;
  }

  .route-progress {
    padding-right: 14px;
    padding-left: 14px;
  }

  .route-progress-status {
    display: none;
  }

  .route-sheet-body {
    padding-right: 9px;
    padding-left: 9px;
  }

  .route-stop-actions-secondary,
  .today-hero-actions {
    grid-template-columns: 1fr;
  }

  .route-stop.compact {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .route-stop-compact-side {
    grid-column: 2;
    justify-content: flex-start;
    padding: 6px 0 0;
  }
}

@media (max-width: 560px) {
  .permission-gate { grid-template-columns: 1fr; }
  .permission-gate-actions { justify-content: stretch; }
  .permission-action { flex: 1 1 140px; justify-content: center; }
}

@media (min-width: 720px) {
  .route-view {
    grid-template-columns: minmax(280px, 36%) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .route-view.map-collapsed {
    grid-template-columns: 58px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .route-view.map-collapsed .route-map-actions {
    inset: 6px;
  }

  .route-view.map-collapsed .route-map-toggle {
    width: 46px;
    padding: 0;
  }

  .route-view.map-collapsed .route-map-toggle-label {
    display: none;
  }

  .route-map-stage {
    grid-row: 1 / -1;
    min-height: 100%;
    border-right: 1px solid var(--v2-line);
    border-bottom: 0;
  }

  .route-progress {
    grid-column: 2;
  }

  .route-sheet {
    grid-column: 2;
  }

  .today-page,
  #tabCash .page-pad,
  #tabMessages .page-pad,
  #tabSettings .page-pad {
    width: min(100%, 760px);
    margin: 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .route-progress-track span {
    transition: none;
  }
}
