/* ==========================================================================
   Routes (modules/features/routes/)
   Route plan for managers: the routes by day on the left, the map on the
   right; a route opens in the same left pane to edit. My routes for reps:
   today's route first, and a route opens with its map and the stops in
   order. Phones put the map on top and the list under it.
   ========================================================================== */

:root {
  --rx-pin: #15171c;
  --rx-pin-text: #fff;
  --rx-pin-ring: #fff;
  --rx-dot: #9aa0aa;
  --rx-dot-ring: #fff;
  --rx-line: #2f5fd0;
  --rx-done: #16a34a;
}

[data-theme="dark"] {
  --rx-pin: #eef0f3;
  --rx-pin-text: #111318;
  --rx-pin-ring: #111318;
  --rx-dot: #5f6773;
  --rx-dot-ring: #111318;
  --rx-line: #7b9cff;
  --rx-done: #22c55e;
}

/* ── Page frame ────────────────────────────────────────────────────────── */

.rx-page,
.rx-run {
  display: grid;
  grid-template-columns: minmax(340px, 400px) 1fr;
  grid-template-areas: "side map";
  height: calc(100dvh - var(--header-height, 52px));
  min-height: 0;
  background: var(--bg-primary);
}

.rx-side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.rx-map-wrap {
  grid-area: map;
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--bg-tertiary);
}

.rx-map {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
}

.rx-map-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 500;
  transform: translateX(-50%);
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-secondary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  pointer-events: none;
}

.rx-muted {
  color: var(--text-muted);
}

.rx-loading {
  display: grid;
  place-items: center;
  min-height: 240px;
}

.rx-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: rx-spin .7s linear infinite;
}

@keyframes rx-spin {
  to { transform: rotate(360deg); }
}

.rx-icon-btn {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.rx-icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.rx-icon-btn.rx-danger:hover {
  background: color-mix(in srgb, var(--color-danger, #dc2626) 10%, transparent);
  color: var(--color-danger, #dc2626);
}

.rx-text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  min-height: 0;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.rx-text-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.rx-avatar {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── The list of routes ────────────────────────────────────────────────── */

.rx-side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}

.rx-side-head .rx-new {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  white-space: nowrap;
}

.rx-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 24px;
}

.rx-group + .rx-group {
  margin-top: 4px;
}

.rx-group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 14px 10px 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.rx-group-count {
  font-weight: 500;
  color: var(--text-muted);
}

.rx-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color .12s ease;
}

.rx-row:hover,
.rx-row:focus-visible {
  background: var(--bg-tertiary);
  outline: none;
}

.rx-row-swatch {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rc, var(--text-muted));
}

.rx-row-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.rx-row-name {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rx-row-meta {
  margin-top: 2px;
  overflow: hidden;
  font-size: 12.5px;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rx-row-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.rx-row-rep {
  display: inline-flex;
  font-size: 13px;
}

.rx-row-chevron {
  display: inline-flex;
  color: var(--text-muted);
  transform: rotate(180deg);
}

.rx-progress-text {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.rx-progress-text.is-done {
  color: var(--rx-done);
}

.rx-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px 28px;
  text-align: center;
}

.rx-empty h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.rx-empty p {
  max-width: 320px;
  margin: 6px 0 18px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.rx-empty .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rx-empty-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ── The editor ────────────────────────────────────────────────────────── */

.rx-ed-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 50px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.rx-ed-crumb {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.rx-ed-head .rx-danger {
  margin-left: auto;
}

.rx-ed-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 24px;
}

.rx-ed-name {
  width: 100%;
  min-height: 0;
  padding: 2px 0;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.rx-ed-name::placeholder {
  color: var(--text-muted);
  opacity: .7;
}

.rx-ed-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 22px;
}

.rx-stops-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 26px;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.rx-stops {
  display: grid;
  gap: 2px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.rx-stop {
  display: grid;
  grid-template-columns: 14px 24px 1fr 28px;
  align-items: start;
  gap: 8px;
  padding: 8px 4px 8px 2px;
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  transition: background-color .12s ease;
}

.rx-stop:hover {
  background: var(--bg-tertiary);
}

.rx-stop.is-chosen {
  cursor: grabbing;
}

.rx-stop.is-ghost {
  opacity: .35;
}

.rx-stop-grip {
  display: grid;
  place-items: center;
  height: 22px;
  color: var(--text-muted);
  opacity: 0;
}

.rx-stop:hover .rx-stop-grip {
  opacity: .8;
}

.rx-stop-num {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--rx-pin);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--rx-pin-text);
}

.rx-stop-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-top: 1px;
}

.rx-stop-name {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rx-stop-meta {
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rx-stop-leg {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.rx-stop-leg:empty {
  display: none;
}

.rx-visited {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-right: 6px;
  font-weight: 600;
  color: var(--rx-done);
}

.rx-stop-remove {
  width: 26px;
  height: 26px;
  opacity: 0;
}

.rx-stop:hover .rx-stop-remove,
.rx-stop-remove:focus-visible {
  opacity: 1;
}

.rx-stops-empty {
  padding: 14px;
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.rx-add {
  position: relative;
}

.rx-add-icon {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 11px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  pointer-events: none;
}

.rx-add input {
  width: 100%;
  height: 36px;
  min-height: 0;
  padding: 0 12px 0 33px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  font: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
}

.rx-add input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 16%, transparent);
}

.rx-add-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 300px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .18);
}

.rx-add-opt {
  display: flex;
  flex-direction: column;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.rx-add-opt:hover,
.rx-add-opt.is-active {
  background: var(--bg-tertiary);
}

.rx-add-opt.is-off {
  opacity: .55;
  cursor: default;
}

.rx-add-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
}

.rx-add-meta {
  overflow: hidden;
  font-size: 12px;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rx-add-none {
  padding: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.rx-ed-tip {
  margin: 8px 2px 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.rx-ed-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.rx-total {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.rx-total strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.rx-ed-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Pickers: who it's for, and Optimize ───────────────────────────────── */

.rx-faces {
  display: inline-flex;
  align-items: center;
}

.rx-faces .rx-avatar {
  box-shadow: 0 0 0 2px var(--bg-primary);
}

.rx-faces .rx-avatar + .rx-avatar {
  margin-left: -3px;
}

.rx-faces-more {
  margin-left: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.rx-pick {
  position: relative;
  display: inline-flex;
}

.rx-pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  min-height: 0;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}

.rx-pick-btn:hover,
.rx-pick-btn[aria-expanded="true"] {
  border-color: var(--text-muted);
}

.rx-pick-btn .rx-avatar {
  width: 20px;
  height: 20px;
  font-size: 8.5px;
}

.rx-pick-btn .rx-faces .rx-avatar {
  box-shadow: 0 0 0 2px var(--bg-secondary);
}

.rx-pick-label {
  color: var(--text-muted);
}

.rx-pick-value {
  max-width: 200px;
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rx-pick-chev {
  color: var(--text-muted);
}

.rx-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  width: 280px;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
  box-shadow: 0 16px 40px -10px rgba(0, 0, 0, .22);
}

.rx-pop[hidden] {
  display: none;
}

.rx-pop-search {
  width: 100%;
  height: 32px !important;
  min-height: 0;
  margin-bottom: 4px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
}

.rx-pop-list {
  max-height: 280px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.rx-pop-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--text-primary);
  cursor: pointer;
}

.rx-pop-opt:hover {
  background: var(--bg-tertiary);
}

.rx-pop-opt[hidden] {
  display: none;
}

.rx-check {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 4px;
  color: transparent;
}

.rx-check svg {
  width: 11px;
  height: 11px;
}

.rx-pop-opt.is-on .rx-check {
  border-color: var(--text-primary);
  background: var(--text-primary);
  color: var(--bg-secondary);
}

.rx-pop-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rx-pop-role {
  font-size: 12px;
  color: var(--text-muted);
}

.rx-stops-tools {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.rx-opt-pop {
  right: 0;
  left: auto;
  width: 300px;
  padding: 14px;
}

.rx-pop-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.rx-pop-sub {
  margin: 3px 0 12px;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--text-muted);
}

.rx-opt-seg {
  display: flex;
  margin-bottom: 12px;
}

.rx-opt-seg button {
  flex: 1;
  justify-content: center;
}

.rx-opt-seg button[aria-checked="true"] {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 500;
}

.rx-opt-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-secondary);
  cursor: pointer;
}

.rx-opt-check input {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 2px 0 0;
  accent-color: var(--text-primary);
}

.rx-opt-check strong {
  font-weight: 600;
  color: var(--text-primary);
}

.rx-pop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.rx-opt-note {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── The map: pins, dots, the drive ────────────────────────────────────── */

/* OpenStreetMap's tiles, quietened to greys so the route stands out */
.rx-map-tiles .leaflet-tile-pane {
  filter: grayscale(1) contrast(.78) brightness(1.12);
}

[data-theme="dark"] .rx-map-tiles .leaflet-tile-pane {
  filter: grayscale(1) invert(1) contrast(.72) brightness(.82);
}

.rx-map .leaflet-control-attribution {
  padding: 1px 6px;
  border-radius: 6px 0 0 0;
  background: color-mix(in srgb, var(--bg-secondary) 80%, transparent);
  font-size: 10px;
  color: var(--text-muted);
}

.rx-map .leaflet-control-attribution a {
  color: inherit;
}

.rx-map .leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid var(--border-color) !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

.rx-map .leaflet-control-zoom a {
  width: 30px;
  height: 30px;
  border-bottom-color: var(--border-color) !important;
  background: var(--bg-secondary);
  line-height: 28px;
  color: var(--text-primary);
}

.rx-map .leaflet-control-zoom a:hover {
  background: var(--bg-tertiary);
}

.rx-pin-wrap {
  border: 0 !important;
  background: none !important;
}

.rx-pin {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--rx-pin-ring);
  border-radius: 50%;
  background: var(--rx-pin);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--rx-pin-text);
  transition: transform .15s ease;
}

.rx-pin--done {
  background: var(--rx-done);
  color: #fff;
}

.rx-pin--next {
  background: var(--rx-line);
  color: #fff;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--rx-line) 25%, transparent), 0 2px 6px rgba(0, 0, 0, .25);
  transform: scale(1.12);
}

.is-hot .rx-pin,
.rx-pin-wrap:hover .rx-pin {
  transform: scale(1.18);
}

.leaflet-interactive.rx-dot {
  stroke: var(--rx-dot-ring);
  fill: var(--rx-dot);
  cursor: pointer;
  transition: fill .12s ease;
}

.leaflet-interactive.rx-dot:hover {
  fill: var(--text-primary);
}

.rx-dot.is-stop {
  display: none;
}

.rx-line {
  stroke: var(--rx-line);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rx-line-halo {
  stroke: var(--rx-line);
  stroke-opacity: .16;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.leaflet-tooltip.rx-tip {
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: #15171c;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
}

.leaflet-tooltip.rx-tip::before {
  display: none;
}

/* You are here */
.rx-me {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #1a73e8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}

.rx-me::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  background: rgba(26, 115, 232, .22);
  animation: rx-ping 2s ease-out infinite;
}

@keyframes rx-ping {
  from { transform: scale(.5); opacity: 1; }
  to { transform: scale(1.4); opacity: 0; }
}

/* ── My routes: the list ───────────────────────────────────────────────── */

.rx-mine {
  min-height: 100%;
  background: var(--bg-primary);
}

.rx-mine-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

.rx-today {
  margin-bottom: 18px;
  padding: 20px 20px 18px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-secondary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.rx-today-kicker {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.rx-today-name {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.rx-today-meta {
  margin: 4px 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.rx-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-tertiary);
}

.rx-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--rx-done);
  transition: width .4s ease;
}

.rx-today-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

.rx-today-foot > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rx-today.is-finished .rx-today-foot > span {
  font-weight: 600;
  color: var(--rx-done);
}

.rx-quiet {
  margin-bottom: 8px;
  padding: 14px 16px;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.rx-quiet p {
  margin: 0;
}

.rx-quiet strong {
  color: var(--text-primary);
}

.rx-mine .rx-group-head {
  padding-top: 18px;
}

.rx-row-day {
  margin: 6px 10px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.rx-mine .rx-row {
  padding: 10px 10px 12px;
}

/* ── My routes: one route ──────────────────────────────────────────────── */

.rx-mine:has(.rx-run) .rx-mine-wrap {
  display: none;
}

.rx-run-side {
  overflow: hidden;
}

.rx-run-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 16px 12px 10px;
}

.rx-run-title {
  min-width: 0;
  padding-top: 3px;
}

.rx-run-day {
  margin: 0;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.rx-run-title h2 {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.rx-run-progress {
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--border-color);
}

.rx-run-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.rx-run-progress-row > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rx-run-progress-row strong {
  color: var(--text-primary);
}

.rx-run-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  margin-top: 12px;
  text-decoration: none;
}

.rx-run-stops {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 10px 10px 24px;
  overflow-y: auto;
  list-style: none;
}

.rx-run-stop {
  position: relative;
  border: 1px solid transparent;
  border-radius: 12px;
}

/* The line joining the stops */
.rx-run-stop:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 38px;
  bottom: -8px;
  left: 22px;
  width: 2px;
  border-radius: 1px;
  background: var(--border-color);
}

.rx-run-stop.is-done:not(:last-child)::after {
  background: color-mix(in srgb, var(--rx-done) 45%, transparent);
}

.rx-run-stop + .rx-run-stop {
  margin-top: 2px;
}

.rx-run-stop.is-open {
  border-color: var(--border-color);
  background: var(--bg-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

.rx-run-stop.is-open::after {
  display: none;
}

.rx-run-stop-head {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: start;
  gap: 10px;
  width: 100%;
  min-height: 0;
  padding: 10px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.rx-run-stop:not(.is-open) .rx-run-stop-head:hover {
  background: var(--bg-tertiary);
}

.rx-run-stop .rx-stop-num {
  position: relative;
  z-index: 1;
  width: 24px;
  height: 24px;
  background: var(--bg-secondary);
  box-shadow: inset 0 0 0 1.5px var(--border-color);
  color: var(--text-secondary);
}

.rx-run-stop.is-open .rx-stop-num {
  background: var(--rx-line);
  box-shadow: none;
  color: #fff;
}

.rx-run-stop.is-done .rx-stop-num {
  background: var(--rx-done);
  box-shadow: none;
  color: #fff;
}

.rx-run-stop.is-done .rx-stop-meta {
  font-weight: 500;
  color: var(--rx-done);
}

.rx-run-stop .rx-stop-name,
.rx-run-stop .rx-stop-meta {
  white-space: normal;
}

.rx-run-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 14px 44px;
}

.rx-run-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  text-decoration: none;
}

.rx-run-address {
  flex-basis: 100%;
  margin: -4px 0 2px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ── Phones ────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .rx-page,
  .rx-run {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100dvh - var(--header-height, 52px));
  }

  .rx-map-wrap {
    order: -1;
    flex-shrink: 0;
    height: 36vh;
    min-height: 220px;
    border-bottom: 1px solid var(--border-color);
  }

  .rx-run .rx-map-wrap {
    height: 40vh;
  }

  .rx-side {
    flex: 1;
    border-right: 0;
  }

  .rx-list,
  .rx-ed-body,
  .rx-run-stops {
    overflow: visible;
  }

  .rx-side-head {
    flex-wrap: wrap;
  }

  /* Above the bottom tab bar */
  .rx-ed-foot {
    position: sticky;
    bottom: calc(var(--bottom-nav-height, 64px) + env(safe-area-inset-bottom, 0px));
    z-index: 5;
  }

  .rx-map-hint {
    display: none;
  }

  .rx-mine-wrap {
    padding: 16px 14px 40px;
  }

  .rx-today-foot {
    flex-direction: column;
    align-items: stretch;
  }

  .rx-today-foot .btn {
    height: 44px;
  }

  .rx-run-actions .btn {
    flex: 1;
    height: 44px;
  }

  .rx-stop-grip {
    opacity: .6;
  }

  .rx-stop-remove {
    opacity: 1;
  }

  .rx-opt-pop {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: calc(var(--bottom-nav-height, 64px) + 16px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    width: auto;
  }
}

/* The name reads as a title, so no field box around it while typing */
.rx-ed-name,
.rx-ed-name:focus,
.rx-ed-name:focus-visible {
  height: auto !important;
  border: 0 !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Buttons with their own display still hide when told to */
.rx-side [hidden],
.rx-mine [hidden] {
  display: none !important;
}
