:root {
  color-scheme: only light;
  --bg: #fffff8;
  --panel: rgba(255, 255, 251, 0.96);
  --panel-2: rgba(248, 248, 239, 0.92);
  --panel-3: rgba(243, 239, 230, 0.92);
  --surface: rgba(255, 255, 251, 0.92);
  --surface-input: rgba(255, 255, 251, 0.96);
  --text: #1f1912;
  --muted: #6f6257;
  --line: rgba(31, 25, 18, 0.1);
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --danger: #b45c5c;
  --success: #2f855a;
  --shadow: 0 18px 42px rgba(31, 25, 18, 0.08);
}

html[data-theme="dark"] {
  color-scheme: only dark;
  --bg: #1a1714;
  --panel: rgba(30, 26, 22, 0.96);
  --panel-2: rgba(38, 34, 28, 0.92);
  --panel-3: rgba(44, 40, 34, 0.92);
  --surface: rgba(38, 34, 28, 0.92);
  --surface-input: rgba(42, 38, 32, 0.96);
  --text: #e8e0d8;
  --muted: #9a8b7f;
  --line: rgba(255, 255, 248, 0.1);
  --accent: #3b82f6;
  --accent-strong: #60a5fa;
  --danger: #e06b6b;
  --success: #48bb78;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.hidden { display: none !important; }
.container { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 16px 0 18px; }
.page-header { margin-bottom: 8px; }

.home-brand-link {
  display: inline-block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.home-brand-link:hover .home-app-title { opacity: 0.85; }

.team-session-bar {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}
.team-session-bar-left { text-align: left; }
.team-session-bar strong {
  color: var(--text);
  font-weight: 700;
}
.theme-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.theme-link:hover { color: var(--accent); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.home-brand-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.home-app-title {
  display: inline-block;
  font-family: 'Comfortaa', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: lowercase;
  color: #201912;
}

.title-letter {
  display: inline-block;
  position: relative;
  transition: color 0.18s ease;
}

.title-letter.active {
  color: #3b82f6;
}

html[data-theme="dark"] .home-app-title {
  color: var(--ink);
}

.page-footer { margin-top: 14px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); }
.footer-version { font-variant-numeric: tabular-nums; }
.footer-sep { margin: 0 4px; }
.footer-home { color: var(--muted); text-decoration: none; }
.footer-home:hover { color: var(--accent); text-decoration: underline; }

.auth-bar,
.panel,
.subpanel {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-bar { padding: 10px; margin-bottom: 10px; }
.auth-logged-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-shell { display: grid; gap: 10px; }

.tab-bar {
  display: inline-flex;
  gap: 0;
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  align-self: start;
}

.tab-button,
.button,
.text-input,
.text-area,
.color-input,
select {
  font: inherit;
}

.tab-button,
.button {
  border: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.tab-button {
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
}

.tab-button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button {
  padding: 7px 11px;
  background: var(--panel-2);
  color: var(--text);
}

.button:hover,
.tab-button:hover { transform: translateY(-1px); }
.button-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-primary:hover,
.tab-button.is-active:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.button-danger { background: rgba(180, 92, 92, 0.1); border-color: rgba(180, 92, 92, 0.24); color: var(--danger); }
.button-simulate {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #b45309;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.button-simulate:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.55);
}
.button-capture {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #047857;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.button-capture:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.55);
}

.panel { padding: 14px; }
.subpanel { padding: 12px; background: var(--panel-2); }
.subpanel-head,
.section-head-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subpanel-head { margin-bottom: 10px; }
.section-head-inline { margin-bottom: 12px; }
h2, h3, p { margin: 0; }
.muted { color: var(--muted); }

.accordion-table {
  display: grid;
  gap: 0;
}

.accordion-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.accordion-toolbar .text-input {
  flex: 1;
  min-width: 0;
}

.accordion-detail-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.accordion-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: background 100ms ease;
}

.accordion-table .accordion-row:first-child {
  border-radius: 0;
}

.accordion-table .accordion-row:last-child,
.accordion-table .accordion-detail:last-child {
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.accordion-table .accordion-row:first-child:last-child {
  border-radius: 0;
}

.accordion-row:hover {
  background: rgba(59, 130, 246, 0.04);
}

.accordion-row.is-selected {
  background: rgba(59, 130, 246, 0.06);
  border-bottom: 1px solid rgba(59, 130, 246, 0.18);
}

.accordion-row .route-chip {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.accordion-row-info {
  flex: 1;
  min-width: 0;
}

.accordion-row-info .item-title {
  font-size: 0.88rem;
}

.accordion-row-info .item-subtitle {
  font-size: 0.78rem;
}

.accordion-detail {
  padding: 10px;
  border: none;
  border-top: 1px solid rgba(59, 130, 246, 0.12);
  border-bottom: 1px solid rgba(59, 130, 246, 0.12);
  background: var(--panel-2);
}

.accordion-detail + .accordion-row {
  border-top: none;
}

.accordion-row .route-chip.home-chip {
  background: #1d4ed8;
}

.accordion-row .service-swatch {
  width: 12px;
  height: 12px;
}

.route-name-edit {
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  border: 1px solid transparent;
  background: transparent;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: 0;
  width: auto;
  max-width: 100%;
  color: var(--text);
  outline: none;
}

.route-name-edit:focus {
  background: var(--surface-input);
  border-color: var(--line);
}

.route-editor-body {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 12px;
  align-items: start;
}

.route-editor-aside {
  position: sticky;
  top: 12px;
  align-self: start;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.route-editor-aside-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 8px;
}

.route-scroll-top-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(31, 25, 18, 0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease, background 120ms ease;
}

.route-scroll-top-btn:hover {
  background: var(--surface-input);
}

.route-scroll-top-btn.hidden {
  display: none;
}

.route-scroll-top-btn.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.route-map-container {
  flex: 0 0 auto;
  height: min(380px, calc(100vh - 220px));
  min-height: 200px;
  border-radius: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f0ede4;
}

.route-map-container .waypoint-marker {
  background: transparent;
}

.route-map-container .waypoint-marker-dot {
  width: 22px;
  height: 22px;
  color: #000;
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.button-row,
.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.form-grid-home { grid-template-columns: 220px minmax(0, 1fr); }

.home-editor-body {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 12px;
  align-items: start;
}
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 0.85rem; color: var(--muted); }
.field-wide { grid-column: 1 / -1; }
.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
}

.text-input,
.text-area,
.color-input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-input);
  color: var(--text);
}

.text-input,
.color-input,
select { padding: 8px 10px; }
.text-area { padding: 8px 10px; resize: vertical; min-height: 60px; }
.color-input { min-height: 40px; padding: 4px; }

.editor-section {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel-2);
}

.editor-section-full { margin-top: 10px; }

.waypoint-editor-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 10px;
  align-items: start;
}

.map-picker {
  height: 300px;
  border-radius: 0;
  border: 1px solid var(--line);
  overflow: hidden;
}

.map-picker .leaflet-container {
  height: 100%;
  border-radius: 0;
}

.stop-row-add {
  cursor: pointer;
  border-style: dashed;
  background: rgba(59, 130, 246, 0.03);
}

.stop-row-add:hover {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
}

.stop-row-adding,
.stop-row-creating {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.04);
}

.inline-select {
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 1px 4px;
  cursor: pointer;
  outline: none;
  max-width: 180px;
}

.inline-select:hover {
  border-color: var(--line);
}

.inline-select:focus {
  border-color: var(--accent);
  background: var(--surface-input);
}

.rnew-client-wrapper {
  position: relative;
  display: inline-block;
  width: 700px;
  max-width: 100%;
  min-width: 200px;
}

.rnew-client-wrapper .inline-input {
  font-size: 0.85rem;
  padding: 1px 4px;
  margin: 0;
  width: 100%;
}

.rnew-client-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 200;
  margin-top: 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  box-shadow: var(--shadow), 0 4px 12px rgba(31, 25, 18, 0.1);
  max-height: 240px;
  overflow-y: auto;
}

.rnew-client-dropdown:empty {
  display: none;
}


.route-add-dropdown {
  display: grid;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}

.route-add-result {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 0;
  cursor: pointer;
  transition: background 80ms ease;
}

.route-add-result:hover {
  background: rgba(59, 130, 246, 0.08);
}

.inline-input {
  font: inherit;
  font-size: 0.85rem;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  margin: -2px 0;
  border-radius: 0;
  width: 100%;
  color: var(--text);
  outline: none;
}

.inline-input:hover {
  border-color: var(--line);
}

.inline-input:focus {
  background: var(--surface-input);
  border-color: var(--accent);
}

.inline-input::placeholder {
  color: var(--muted);
  font-style: italic;
  font-size: 0.8rem;
}

.inline-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.inline-field {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.inline-field-wide {
  grid-column: 1 / -1;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  align-self: start;
  padding-top: 4px;
}

.inline-check input { margin: 0; }

.client-expanded {
  align-items: stretch;
  flex-direction: column;
  cursor: default;
}

.client-inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}

.client-waypoints-inline {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(31, 25, 18, 0.06);
  display: grid;
  gap: 4px;
}

.wp-stop-row {
  flex-wrap: wrap;
}

.wp-address-display {
  cursor: pointer;
  transition: color 100ms ease;
}

.wp-address-display:hover {
  color: var(--accent);
  text-decoration: underline;
}

.wp-address-editor {
  margin: -2px 0 4px;
  padding: 6px 10px;
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 0;
  background: rgba(248, 248, 239, 0.8);
  display: grid;
  gap: 8px;
}

.wp-address-editor-inner {
  display: grid;
  gap: 6px;
  position: relative;
  z-index: 60;
}

/* Sits under the routine Notes field; tinted so an operator can tell at a
   glance that this one reaches the driver as an urgent banner. */
.wp-alert-input {
  border-left: 3px solid #dc2626;
  background: rgba(220, 38, 38, 0.05);
}

.wp-alert-input:not(:placeholder-shown) {
  background: rgba(220, 38, 38, 0.11);
  font-weight: 600;
  color: #991b1b;
}

.wp-inline-map {
  height: 200px;
  border-radius: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  position: relative;
  z-index: 0;
}

.wp-photo-block {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.wp-photo-thumb {
  width: 132px;
  height: 88px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.04);
  flex: 0 0 auto;
}
.wp-photo-thumb--lightbox {
  cursor: zoom-in;
}
.wp-photo-thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 4px;
}
.stop-row--with-preview {
  position: relative;
}

.stop-row--with-preview > .stop-row-actions {
  position: relative;
  align-self: stretch;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: 30px;
  min-height: 0;
  margin: -5px -10px -5px 0;
  padding: 0 8px 0 0;
}

.stop-row-preview {
  position: absolute;
  right: calc(100% + 4px);
  top: 0;
  bottom: 0;
  width: auto;
  height: auto;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: opacity 100ms ease, box-shadow 100ms ease;
}

.stop-row-preview:hover {
  opacity: 0.92;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}

.stop-row-preview .wp-photo-thumb,
.stop-row-preview .wp-photo-thumb--empty {
  height: 100%;
  width: 100%;
  object-fit: cover;
  border: none;
  display: block;
}

.stop-row-preview .wp-photo-thumb--empty {
  font-size: 0.62rem;
  padding: 2px 4px;
}
.wp-photo-side {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.wp-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.wp-photo-meta {
  font-size: 0.72rem;
  color: var(--muted);
}
.wp-photo-status { font-size: 0.75rem; }
.wp-photo-status.is-error { color: #b45c5c; }
.wp-photo-status.is-success { color: #3f7d4f; }

/* Full-screen photo lightbox with scroll/pinch zoom. */
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.15s ease;
  cursor: zoom-out;
  overflow: hidden;
  touch-action: none;
}
.photo-lightbox.visible { opacity: 1; }
.photo-lightbox-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.photo-lightbox-img {
  max-width: 96vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 0;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  cursor: zoom-in;
}
.photo-lightbox-img.is-zoomed {
  cursor: grab;
}
.photo-lightbox-img.is-zoomed:active {
  cursor: grabbing;
}
.photo-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 1;
  width: 48px;
  height: 48px;
  font-size: 32px;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.service-checks-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 1px 0;
}

.service-check-sm {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  font-size: 0.78rem;
  cursor: pointer;
}

.service-check-sm input { margin: 0; }

.button-sm {
  padding: 4px 8px !important;
  font-size: 0.82rem !important;
}

.stop-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.stop-label-edit {
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid transparent;
  background: transparent;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: 0;
  width: calc(100% + 12px);
  color: var(--text);
  outline: none;
}

.stop-label-edit:hover {
  border-color: var(--line);
}

.stop-label-edit:focus {
  background: var(--surface-input);
  border-color: var(--accent);
}

.stop-list-unified {
  margin-top: 8px;
  display: grid;
  gap: 3px;
}

.stop-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  min-height: 36px;
}

.stop-row.is-home {
  background: rgba(29, 78, 216, 0.06);
  border-color: rgba(29, 78, 216, 0.1);
}

.stop-row.is-home-end {
  opacity: 0.55;
}

.stop-row.is-draggable {
  cursor: grab;
}

.stop-row.is-draggable:active {
  cursor: grabbing;
}

.stop-row.is-dragging {
  opacity: 0.35;
  border-style: dashed;
}

.stop-row.drag-over {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.3);
}

.drag-handle {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
  padding: 0 1px;
}

.stop-move-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.stop-move-btn:hover {
  color: var(--accent);
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.08);
}

.stop-row-info {
  flex: 1;
  min-width: 0;
}

.stop-remove-btn {
  width: 22px;
  height: 22px;
  border-radius: 0;
  border: 1px solid rgba(180, 92, 92, 0.2);
  background: rgba(180, 92, 92, 0.08);
  color: var(--danger);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 100ms ease;
}

.stop-remove-btn:hover {
  background: rgba(180, 92, 92, 0.18);
}

.add-waypoint-panel {
  margin-top: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel-2);
  display: grid;
  gap: 6px;
}

.add-waypoint-results {
  max-height: 260px;
  overflow-y: auto;
}

.add-create-btn {
  justify-self: start;
}

.create-waypoint-form {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(248, 248, 239, 0.6);
  display: grid;
  gap: 8px;
}

.scroll-panel {
  max-height: min(58dvh, 620px);
  overflow-y: auto;
  padding-right: 4px;
}

.client-list,
.service-list,
.route-stop-list,
.search-result-list,
.waypoint-list { display: grid; gap: 6px; }

.client-item,
.service-item,
.route-stop-item,
.search-result-item,
.waypoint-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  display: grid;
  gap: 6px;
}

.client-item.is-selected,
.service-item.is-selected {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.2);
}

.client-item-head,
.service-item-head,
.route-stop-item-head,
.waypoint-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.item-title { font-weight: 700; font-size: 0.88rem; }
.item-subtitle { color: var(--muted); font-size: 0.82rem; }

.pill,
.service-pill,
.route-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 0;
  border: 1px solid var(--line);
  background: rgba(59, 130, 246, 0.1);
  color: var(--text);
  font-size: 0.78rem;
}

.service-pill {
  background: var(--surface);
}

.service-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.service-check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.service-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
}

.service-check input { margin: 0; }

.route-stop-row-meta,
.search-result-meta,
.waypoint-meta-block {
  display: grid;
  gap: 4px;
}

.route-reuse-note { font-size: 0.82rem; color: var(--muted); }

.route-stop-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.stop-chip {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.stop-chip.home-chip { background: #1d4ed8; }

/* "old→new" move label: each number in its own circle */
.stop-chip-transform {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.stop-chip-transform .stop-chip {
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.7);
}

.stop-chip-arrow {
  font-size: 0.62rem;
  font-weight: 700;
  color: #f59e0b;
  line-height: 1;
}

.route-stop-item-head-left,
.search-result-head,
.waypoint-item-head-left {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.search-result-item { cursor: pointer; }
.search-result-item:hover { border-color: rgba(59, 130, 246, 0.3); }

.empty-state {
  min-height: 80px;
  display: grid;
  place-items: center;
  padding: 14px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 0;
  background: var(--panel-3);
}


.address-field-wrapper {
  position: relative;
}

.address-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  margin-top: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  box-shadow: var(--shadow), 0 4px 16px rgba(31, 25, 18, 0.12);
  max-height: 280px;
  overflow-y: auto;
}

.address-dropdown-item {
  padding: 6px 8px;
  border-radius: 0;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text);
  transition: background 80ms ease;
}

.address-dropdown-item:hover,
.address-dropdown-item.is-active {
  background: rgba(59, 130, 246, 0.08);
}

.address-dropdown-item .address-main {
  font-weight: 600;
}

.address-dropdown-item .address-context {
  color: var(--muted);
  font-size: 0.84rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(31, 25, 18, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.hidden { display: none; }

.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: 0 12px 40px rgba(31, 25, 18, 0.25);
  padding: 16px 20px;
  width: min(440px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.modal-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

.driver-route-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}

.driver-route-slot {
  padding: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
}

.driver-route-slot .item-subtitle {
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.driver-route-slot select {
  width: 100%;
  font-size: 0.82rem;
  padding: 4px 6px;
}

@media (max-width: 760px) {
  .home-brand-row { gap: 10px; }
  .home-app-title { font-size: 1.45rem; }
  .container { width: min(100% - 16px, 1440px); padding: 12px 0 14px; }
  .form-grid,
  .form-grid-home,
  .route-editor-body,
  .home-editor-body,
  .waypoint-editor-body,
  .client-inline-fields { grid-template-columns: 1fr; }
  .auth-logged-in,
  .subpanel-head,
  .section-head-inline { align-items: stretch; flex-direction: column; }
  .tab-bar { width: 100%; justify-content: stretch; }
  .tab-button { flex: 1; padding: 6px 8px; }
  .accordion-row { padding: 6px 10px; }
  .stop-row { padding: 4px 8px; }

  .stop-row--with-preview > .stop-row-actions {
    margin: -4px -8px -4px 0;
    padding: 0 6px 0 0;
    width: 28px;
  }
  .panel { padding: 10px; }
}

/* Offline status badges */
.offline-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 6px;
}
.offline-ready {
  background: #16a34a;
  color: #fff;
}
.offline-missing {
  background: #dc2626;
  color: #fff;
}

/* Theme toggle */
.theme-toggle-row {
  display: inline-flex;
  gap: 0;
}
.theme-toggle-row .theme-btn {
  border-radius: 0;
}
.theme-toggle-row .theme-btn:first-child { border-radius: 4px 0 0 4px; }
.theme-toggle-row .theme-btn:last-child  { border-radius: 0 4px 4px 0; }
.theme-toggle-row .theme-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Sync all row */
.sync-all-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.sync-all-status {
  font-size: 11px;
  color: var(--muted);
}

/* Route row: progress + SYNC / Synced (SYNC uses same .button.button-primary as EDIT) */
.route-row-sync {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.route-sync-action {
  flex-shrink: 0;
}
.route-sync-synced {
  cursor: default;
  pointer-events: none;
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.4);
  color: #15803d;
  font-weight: 600;
}

/* Sync progress bar in route row — inline to the left of SYNC button */
.route-sync-bar {
  position: relative;
  min-width: 0;
  flex: 1 1 120px;
  max-width: 200px;
  height: 20px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.08);
}
.route-sync-bar:empty {
  display: none;
  flex: 0;
}
.route-sync-bar .sync-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: rgba(37, 99, 235, 0.18);
  border-radius: 3px 0 0 3px;
  transition: width 0.2s ease;
}
.route-sync-bar .sync-label {
  position: relative;
  z-index: 1;
  display: block;
  text-align: center;
  font-size: 9.5px;
  font-weight: 600;
  color: #2563eb;
  line-height: 20px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 6px;
}
.route-sync-bar.sync-done {
  border-color: rgba(22,163,74,0.25);
}
.route-sync-bar.sync-done .sync-fill {
  background: rgba(22, 163, 74, 0.15);
}
.route-sync-bar.sync-done .sync-label {
  color: #16a34a;
}

html[data-theme="dark"] body {
  background: var(--bg);
}

html[data-theme="dark"] .route-map-container {
  background: #2a2620;
}

html[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.6);
}

html[data-theme="dark"] .wp-address-editor {
  background: var(--panel-3);
}

html[data-theme="dark"] .create-waypoint-form {
  background: var(--panel-3);
}

/* Upload route button */
.upload-route-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.upload-route-label input[type="file"] { display: none; }

/* Import review modal */
.import-review-overlay { padding: 16px; }

.import-review-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(31, 25, 18, 0.25);
  padding: 14px 18px;
  width: min(1280px, 100%);
  height: min(86vh, 100%);
  display: flex;
  flex-direction: column;
}

.import-review-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0 10px;
  font-size: 0.86rem;
}

.import-review-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  gap: 12px;
}

.import-review-list {
  overflow-y: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 6px;
}

.import-review-map-wrap {
  position: relative;
  min-height: 0;
}

.import-review-map {
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
}

.import-review-map-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 4px 12px;
  font-size: 0.84rem;
  box-shadow: 0 4px 14px rgba(31, 25, 18, 0.2);
}
.import-review-map-hint.hidden { display: none; }

.import-review-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
}
.import-review-footer [data-import-status] { flex: 1; }

.import-section-title {
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 6px 4px;
}

.import-stop {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 7px 9px;
  margin-bottom: 5px;
  cursor: pointer;
  border-left-width: 4px;
}
.import-stop.is-review { border-left-color: #d97706; }
.import-stop.is-accepted { border-left-color: #2f855a; }
.import-stop.is-skipped { border-left-color: #9ca3af; opacity: 0.65; }
.import-stop.is-selected { outline: 2px solid var(--accent, #3b82f6); }

.import-stop-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.import-stop-name { font-weight: 600; }
.import-stop-route { font-size: 0.78rem; white-space: nowrap; }

.import-stop-addr { font-size: 0.84rem; }
.import-stop-resolved {
  font-size: 0.82rem;
  color: var(--muted);
  word-break: break-word;
}

.import-stop-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
}
.import-stop-actions { display: inline-flex; gap: 4px; }

.import-chip {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 8px;
  border: 1px solid var(--line);
}
.import-chip.is-accepted { color: #2f855a; border-color: #2f855a; }
.import-chip.is-review { color: #d97706; border-color: #d97706; }
.import-chip.is-skipped { color: #6b7280; }
.import-chip.is-nores { color: #b45c5c; border-color: #b45c5c; }
.import-chip.is-src { color: var(--muted); }

.import-mini-btn {
  font-size: 0.74rem;
  padding: 2px 8px;
}
.import-mini-btn.is-active {
  background: var(--accent, #3b82f6);
  color: #fff;
}

.import-stop-editor {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.import-editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.import-coords { font-size: 0.78rem; }

@media (max-width: 900px) {
  .import-review-body { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

.route-alert-inline {
  color: #b45309;
  font-weight: 700;
}

.route-editor-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.route-geocode-panel {
  max-height: min(40vh, 320px);
  overflow-y: auto;
  border: 2px solid #f59e0b;
  background: #fff7ed;
  color: #7c2d12;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

.route-geocode-panel.hidden {
  display: none;
}

.route-geocode-panel-head strong {
  display: block;
  margin-bottom: 2px;
}

.route-geocode-panel-hint {
  display: block;
  font-size: 0.78rem;
  line-height: 1.35;
}

.route-geocode-nav {
  display: flex;
  gap: 6px;
}

.route-geocode-nav .button {
  flex: 1;
}

.route-geocode-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.route-geocode-links .button {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-geocode-links .button.is-active {
  box-shadow: inset 0 0 0 2px rgba(124, 45, 18, 0.35);
}

.route-geocode-panel-foot {
  font-size: 0.72rem;
  color: #9a3412;
  text-align: center;
}

/* Waypoint status badges */
.wp-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 4px;
}
.wp-badge-inactive {
  background: var(--danger);
  color: #fff;
}
/* Notes and alerts are hidden inside the collapsed address editor, so these
   badges are the only cue on the row that a stop carries either one. */
.wp-badge-alert {
  background: #dc2626;
  color: #fff;
}
.wp-badge-note {
  background: #d6d3d1;
  color: #44403c;
}
.wp-badge-needs-geocode {
  background: #f59e0b;
  color: #fff;
}
.wp-badge-seasonal {
  background: #7c3aed;
  color: #fff;
}
.wp-badge-seasonal.wp-badge-off {
  background: #78716c;
  color: #fff;
}

.stop-row.is-needs-geocode {
  border: 2px solid #f59e0b;
}

.stop-row.is-inactive {
  border: 2px solid var(--danger);
}

.stop-row.is-needs-geocode.is-inactive {
  border: 2px solid var(--danger);
  box-shadow: inset 0 0 0 2px #f59e0b;
}

/* Status toggle row (clicks must not bubble to accordion / stop-row parents) */
.wp-status-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  position: relative;
  z-index: 1;
  isolation: isolate;
}
.wp-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
}
.wp-toggle-label input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent);
}

/* Seasonal month selectors */
.seasonal-month-select {
  font-size: 11px;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-input);
  color: var(--text);
  cursor: pointer;
  margin-left: 4px;
}
.seasonal-to {
  font-size: 10px;
  color: var(--muted);
  margin: 0 2px;
}

/* Optimize route proposal */
.optimize-proposal {
  margin-top: 12px;
  padding: 12px 14px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.optimize-proposal.hidden { display: none; }
.optimize-summary {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 10px;
  color: var(--text);
}
.optimize-summary strong { color: var(--accent); }
.optimize-proposal .button-row { gap: 8px; }

/* "Add to route" placement suggestion under a customer's waypoints */
.wp-placement-suggest {
  margin: 8px 0;
  padding: 10px 12px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  font-size: 13px;
  color: var(--text);
}
.wp-placement-suggest strong { color: var(--accent); }
.wp-placement-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.wp-placement-actions { display: flex; gap: 6px; }

/* Ghost-waypoint preview map inside placement proposals */
.placement-preview-map {
  width: 100%;
  height: 260px;
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border, #d1d5db);
}
.placement-preview-map.hidden { display: none; }
#placementProposal .placement-preview-map { margin-bottom: 10px; }
.placement-preview-map .waypoint-marker-dot {
  width: 22px;
  height: 22px;
  color: #000;
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
/* The proposed (not yet real) waypoint: accent fill, dashed ring, slightly larger */
.placement-preview-map .placement-ghost-dot {
  width: 26px;
  height: 26px;
  background: #3b82f6;
  color: #fff;
  opacity: 0.9;
  border: 2px dashed #fff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3), 0 2px 6px rgba(0, 0, 0, 0.35);
}
/* Existing neighbouring stops: muted so the ghost stands out */
.placement-preview-map .placement-context-dot {
  background: #e5e7eb;
  color: #4b5563;
}

/* Route membership chips on waypoint rows in the customer view */
.wp-route-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.wp-route-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  cursor: pointer;
}
.wp-route-chip:hover {
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
}
.wp-route-unassigned-label {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}
.wp-route-chip.wp-route-suggest {
  color: var(--muted);
  background: transparent;
  border-style: dashed;
  border-color: var(--border, #d1d5db);
}
.wp-route-chip.wp-route-suggest:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

/* Inferred-order proposal (Capture Order review) */
.capture-order-list {
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.capture-order-row {
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.capture-order-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
}
.capture-flags { margin-top: 8px; }
.capture-flag-warn {
  color: var(--danger, #b45309);
  font-size: 13px;
  margin-top: 6px;
}

.capture-return-panel {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--border, #d4d4d8);
  border-radius: 8px;
  background: var(--panel-soft, #f8fafc);
}
.capture-return-panel.hidden { display: none; }
.capture-return-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.capture-drive-select-field { margin: 0 0 10px; }
.capture-return-summary { font-size: 14px; line-height: 1.45; }
.capture-return-phase { margin-top: 6px; font-weight: 500; }
.capture-return-phase--complete { color: var(--success, #15803d); }
.capture-return-phase--pending { color: var(--accent, #1d4ed8); }
.capture-return-actions { margin-top: 10px; flex-wrap: wrap; }
.capture-route-path { margin-top: 12px; }
.capture-route-path.hidden { display: none; }
.capture-return-phase--recording { color: var(--accent, #1d4ed8); }
.capture-return-phase--abandoned { color: var(--danger, #b45309); }
.path-scrubber {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}
.path-scrubber.hidden { display: none; }
.path-scrubber-range {
  width: 100%;
  accent-color: var(--accent, #1d4ed8);
}
.path-scrubber-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.path-scrubber-time { font-size: 12px; }

/* Admin sign-in gate (shown before the admin shell is accessible) */
.admin-gate {
  position: fixed;
  inset: 0;
  z-index: 1900;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
}
.admin-gate.hidden { display: none; }
.admin-gate-inner {
  width: min(720px, 100%);
  display: grid;
  gap: 18px;
  text-align: center;
  justify-items: center;
}
.admin-gate-title {
  margin: 0;
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}
.admin-gate-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  width: 100%;
  max-width: 600px;
}
.admin-gate-grid .route-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.admin-gate-grid .route-button {
  width: clamp(72px, 9vw, 106px);
  aspect-ratio: 1;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 18px 30px rgba(31, 25, 18, 0.18);
  transition: transform 120ms ease, background 120ms ease;
}
.admin-gate-grid .route-button:hover,
.admin-gate-grid .route-button:focus-visible {
  transform: translateY(-2px);
  background: var(--accent-strong);
  outline: none;
}
.admin-gate-grid .route-caption {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}
.admin-gate-grid .route-empty {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
}
.admin-gate-status { min-height: 1.2em; }
.admin-gate-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}
.admin-gate-back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.admin-gate-back:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 640px) {
  .admin-gate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Auth overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-overlay.hidden { display: none; }
.auth-card {
  display: grid;
  gap: 12px;
  width: min(360px, 100%);
  text-align: center;
}
.auth-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.auth-subtitle {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: -4px;
}
.auth-subtitle:empty { display: none; }
.auth-error {
  font-size: 0.85rem;
  color: var(--danger);
}
.auth-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* Page header with logout */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

@media (forced-colors: active) {
  body, .panel, .subpanel, .text-input, .text-area, select {
    forced-color-adjust: none;
  }
  .button-primary, .tab-button.is-active {
    forced-color-adjust: none;
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
  }
}

/* ============================================ */
/* LIVE MAP TAB                                 */
/* ============================================ */
.live-map-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.live-map-mode {
  display: inline-flex;
  gap: 6px;
}

.live-map-history-controls {
  display: inline-flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.live-map-status {
  margin-left: auto;
  font-size: 12px;
}

.live-map-container {
  width: 100%;
  height: 560px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-top: 10px;
  background: var(--panel-2);
  overflow: hidden;
}

.live-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 4px 0;
  font-size: 12px;
  color: var(--text);
}

.live-map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
}

.live-map-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.live-truck-marker { background: transparent; border: 0; }
.live-truck-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--truck-color, #3b82f6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 0 0 3px #fff;
  letter-spacing: 0.02em;
}

/* ============================================
   Per-waypoint Garbage controls.

   Layout: a compact summary CHIP that's always
   visible, plus a collapsible details panel
   underneath holding the toggle + frequency
   segmented + cart-count slider + size segmented.
   The panel is collapsed by default so a long
   route doesn't drown in identical widgets.
   ============================================ */
.garbage-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 2px 0;
}
.garbage-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.08);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.1;
  cursor: pointer;
  align-self: flex-start;
  max-width: 100%;
  text-align: left;
}
.garbage-chip:hover {
  background: rgba(59, 130, 246, 0.15);
}
.garbage-block.is-off > .garbage-chip {
  border-color: var(--border, rgba(0, 0, 0, 0.18));
  background: transparent;
  color: var(--muted, rgba(0, 0, 0, 0.55));
  font-weight: 500;
}
.garbage-block.is-off > .garbage-chip .service-swatch {
  background: transparent !important;
  border: 1px dashed var(--muted, rgba(0, 0, 0, 0.35));
}
.garbage-chip-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.garbage-chip-caret {
  font-size: 10px;
  opacity: 0.55;
  transition: transform 120ms ease;
}
.garbage-chip[aria-expanded='true'] .garbage-chip-caret {
  transform: rotate(180deg);
}
.garbage-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.04);
}
.garbage-details[hidden] {
  display: none;
}
/* Backwards-compat: the old class is still referenced from a few
   helper renderers (driver-routes-debug etc). Treat it like the
   new details panel so we don't have to dual-wire every callsite. */
.garbage-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.04);
}

/* ============================================
   Garbage service detail pane (Services tab):
   shows the per-stop attribute distribution as
   an aggregated table with bulk-edit affordance.
   ============================================ */
.garbage-service-panel {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.1));
}
.garbage-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.garbage-breakdown-table th,
.garbage-breakdown-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}
.garbage-breakdown-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted, rgba(0, 0, 0, 0.55));
  font-weight: 700;
  background: rgba(59, 130, 246, 0.04);
}
.garbage-breakdown-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.04);
}
.service-attr-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.service-browse-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.service-browse-fields,
.service-browse-facets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.service-browse-fields .button.is-active,
.service-browse-facets .button.is-active {
  background: var(--text);
  color: var(--bg, #fff);
}
.service-browse-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border, #ddd);
  border-radius: 4px;
}
.service-browse-stop-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  gap: 2px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--border, #eee);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.service-browse-stop-btn:hover {
  background: rgba(59, 130, 246, 0.04);
}
.service-browse-stop-title { font-weight: 600; }
.service-browse-stop-sub { font-size: 0.85rem; }
.wp-stop-row--highlight {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
}
.garbage-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.garbage-toggle input { margin: 0; }
.garbage-toggle-label { letter-spacing: 0.02em; }
.garbage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.garbage-row-label {
  display: inline-block;
  min-width: 36px;
  color: var(--muted, rgba(0, 0, 0, 0.55));
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10px;
}
.garbage-seg {
  display: inline-flex;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-soft, #fff);
}
.garbage-seg-btn {
  border: none;
  background: transparent;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  border-right: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  text-transform: capitalize;
}
.garbage-seg-btn:last-child { border-right: none; }
.garbage-seg-btn.is-active {
  background: #3b82f6;
  color: #fff;
  font-weight: 700;
}
.garbage-slider {
  flex: 1;
  max-width: 160px;
}
.garbage-slider-value {
  display: inline-block;
  min-width: 14px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 11px;
}

/* ============================================
   Recent pickups sub-panel inside customer
   detail (driver-reported "extra" gallons).
   ============================================ */
.recent-pickups-panel {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.04);
}
.recent-pickups-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, rgba(0, 0, 0, 0.6));
  margin-bottom: 8px;
}
.recent-pickups-sum { text-transform: none; letter-spacing: 0; font-weight: 500; }
.recent-pickups-sum strong { color: var(--fg, #111); font-weight: 700; }
.recent-pickups-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.recent-pickup-row {
  display: grid;
  grid-template-columns: 110px 60px 80px 1fr;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 4px;
}
.recent-pickup-row:nth-child(odd) { background: rgba(0, 0, 0, 0.02); }
.recent-pickup-date { font-weight: 600; }
.recent-pickup-route { color: var(--muted, rgba(0, 0, 0, 0.6)); font-variant-numeric: tabular-nums; }
.recent-pickup-extra { font-variant-numeric: tabular-nums; font-weight: 700; }
.recent-pickup-extra.is-zero { color: var(--muted, rgba(0, 0, 0, 0.5)); font-weight: 500; }
.recent-pickup-extra.is-extra { color: #b45c5c; }
/* Nothing-out visit: customer had no cans out at all (not a $0 pickup). */
.recent-pickup-extra.is-nothing { color: #b45309; }
.recent-pickup-note { color: var(--muted, rgba(0, 0, 0, 0.7)); font-size: 11px; }

/* ============================================================
   REPORTS TAB
   ============================================================ */
.reports-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.reports-filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.reports-sim-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  padding-bottom: 6px;
}
.reports-list-wrap { overflow-x: auto; }

.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.reports-table thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
}
.reports-table tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.report-row { cursor: pointer; transition: background 80ms ease; }
.report-row:hover { background: rgba(59, 130, 246, 0.08); }
.report-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.report-sim-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(124, 58, 237, 0.15);
  color: #7c3aed;
  vertical-align: middle;
}
.report-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.report-status-ok { background: rgba(22, 163, 74, 0.14); color: #16a34a; }
.report-status-live { background: rgba(59, 130, 246, 0.16); color: #2563eb; }
.report-status-warn { background: rgba(245, 158, 11, 0.18); color: #b45309; }
.report-status-muted { background: rgba(0, 0, 0, 0.06); color: var(--muted); }

.report-detail:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: calc(100dvh - 9.5rem);
}
#reportsSection.report-detail-open {
  padding: 10px 12px 14px;
}
#reportsSection.report-detail-open .report-detail {
  flex: 1;
}

.report-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 0;
  flex-shrink: 0;
}
.report-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.report-detail-title { margin: 0; font-size: 1.15rem; line-height: 1.25; }
.report-detail-sub { font-size: 13px; margin: 0; flex-shrink: 0; }
.report-detail-body {
  flex-shrink: 0;
  max-height: 42vh;
  overflow: auto;
  padding-right: 2px;
}
.report-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.report-metric {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.report-metric-label { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.report-metric-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.reports-detail-table thead th { position: static; }

.report-path-section {
  margin: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: min(72vh, calc(100dvh - 14rem));
}
.report-path-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 8px;
}
.report-path-stage.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  padding: 10px 12px 14px;
  gap: 10px;
}
.report-path-stage.is-expanded .report-path-head {
  flex-shrink: 0;
}
.report-path-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 0;
  flex-shrink: 0;
}
.report-path-head-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.report-path-title { margin: 0; font-size: 1rem; }
.report-path-status { font-size: 12px; }
.report-path-map {
  width: 100%;
  flex: 1;
  min-height: min(68vh, calc(100dvh - 17rem));
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #e8e4dc;
  overflow: hidden;
}
.report-path-stage.is-expanded .report-path-map {
  min-height: 0;
  border-radius: 8px;
}
.report-path-map.hidden { display: none; }
html[data-theme="dark"] .report-path-map { background: #2a2620; }
.report-path-stage .path-scrubber {
  flex-shrink: 0;
  margin-top: 0;
}

body.report-path-map-expanded {
  overflow: hidden;
}

.report-stop-marker { background: transparent; border: 0; }
.report-stop-marker-pin {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  border: 2px solid #64748b;
  background: #ffffff;
  color: #111827;
}
.report-stop-marker-pin.serviced {
  border-color: #1e3a8a;
  background: #1d4ed8;
  color: #ffffff;
}
.report-stop-marker-pin.highlighted {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.85), 0 1px 4px rgba(0, 0, 0, 0.25);
  transform: scale(1.08);
}
.report-stop-badge {
  display: inline-flex;
  min-width: 1.6rem;
  height: 1.6rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #1d4ed8;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.report-stop-row { cursor: pointer; }
/* Nothing-out visit in the per-stop table (customer had no cans out). */
.report-outcome-nothing { color: #b45309; font-weight: 700; }
.report-stop-row:hover { background: rgba(59, 130, 246, 0.08); }
.report-stop-row--active { background: rgba(245, 158, 11, 0.14); outline: 1px solid rgba(245, 158, 11, 0.45); }
html[data-theme="dark"] .report-stop-marker-pin.unserviced {
  background: #2a2620;
  color: #f3ebe1;
  border-color: #78695d;
}
html[data-theme="dark"] .report-stop-row:hover { background: rgba(59, 130, 246, 0.16); }
html[data-theme="dark"] .report-stop-row--active { background: rgba(245, 158, 11, 0.2); }

/* ============================================================
   SETTINGS PAGE (full tab section, formerly a modal)
   ============================================================ */
.settings-page { display: flex; flex-direction: column; gap: 0; max-width: 820px; }

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 20px;
  align-items: start;
}

.settings-layout .settings-page { max-width: none; }

.settings-version-panel {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 140px);
  overflow: auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
}

.settings-version-header {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.settings-version-hint {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 0.82rem;
  margin: 0 0 10px;
  line-height: 1.35;
}

.settings-version-hint kbd {
  font-family: inherit;
  font-size: 0.95em;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.04);
}

.settings-version-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-version-content .version-item {
  line-height: 1.5;
  color: var(--muted);
}

.settings-version-content .version-item strong {
  color: var(--accent);
  font-weight: 600;
}

html[data-theme="dark"] .settings-version-panel {
  background: rgba(20, 20, 20, 0.92);
  border-color: rgba(255, 255, 255, 0.12);
}

html[data-theme="dark"] .settings-version-content .version-item {
  color: #c9d1d9;
}

html[data-theme="dark"] .settings-version-content .version-item strong {
  color: #58a6ff;
}

@media (max-width: 960px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .settings-version-panel {
    position: static;
    max-height: min(420px, 55vh);
  }
}
.settings-block { padding: 16px 0; border-top: 1px solid var(--line); }
.settings-block:first-child { padding-top: 4px; border-top: 0; }
.settings-heading { margin-bottom: 8px; font-weight: 600; color: var(--text); }
.settings-help { font-size: 0.9rem; margin: 0 0 10px; line-height: 1.4; }
.settings-tests-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ============================================================
   UNIT TEST / REGRESSION REPORT
   ============================================================ */
.test-report { margin-top: 8px; }
.test-report-loading, .test-report-empty { padding: 12px 0; font-size: 0.9rem; }

.test-report-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 6px 16px; padding: 12px 14px; border-radius: 10px; margin-bottom: 14px;
  border: 1px solid var(--line);
}
.test-report-banner.is-pass { background: rgba(34, 197, 94, 0.10); border-color: rgba(34, 197, 94, 0.35); }
.test-report-banner.is-fail { background: rgba(239, 68, 68, 0.10); border-color: rgba(239, 68, 68, 0.40); }
.test-report-banner-main { display: flex; align-items: center; gap: 9px; }
.test-report-banner-title { font-weight: 700; font-size: 0.98rem; }
.test-report-banner-meta { font-size: 0.82rem; }
.test-report-status-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.is-pass .test-report-status-dot { background: #22c55e; }
.is-fail .test-report-status-dot { background: #ef4444; }

.test-group-list { display: flex; flex-direction: column; gap: 8px; }
.test-group {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); overflow: hidden;
}
.test-group.is-fail { border-color: rgba(239, 68, 68, 0.45); }
.test-group-summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 11px 13px; list-style: none; user-select: none;
}
.test-group-summary::-webkit-details-marker { display: none; }
.test-group-summary:hover { background: var(--panel-3); }
.test-group-badge {
  width: 20px; height: 20px; flex: 0 0 auto; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; color: #fff;
}
.test-group.is-pass .test-group-badge { background: #22c55e; }
.test-group.is-fail .test-group-badge { background: #ef4444; }
.test-group-title { font-weight: 600; flex: 1 1 auto; }
.test-group-count { font-size: 0.82rem; flex: 0 0 auto; }
.test-group-body { padding: 4px 14px 14px; }
.test-group-module { font-size: 0.8rem; margin-bottom: 6px; }
.test-group-module code {
  background: var(--panel-3); padding: 1px 6px; border-radius: 4px; font-size: 0.78rem;
}
.test-group-purpose { font-size: 0.88rem; line-height: 1.45; margin: 6px 0; color: var(--text); }
.test-group-application { font-size: 0.84rem; line-height: 1.45; margin: 6px 0 10px; }

.test-group-terms-wrap {
  margin: 10px 0 4px; padding: 10px 12px;
  background: var(--panel-3); border-radius: 8px;
}
.test-terms-label {
  font-size: 0.74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); margin-bottom: 6px;
}
.test-group-terms { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; }
.test-group-terms dt { font-weight: 700; font-size: 0.82rem; color: var(--text); }
.test-group-terms dd { margin: 0; font-size: 0.82rem; line-height: 1.4; }
@media (max-width: 560px) {
  .test-group-terms { grid-template-columns: 1fr; gap: 1px; }
  .test-group-terms dd { margin-bottom: 6px; }
}

.test-suite-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.test-suite-name {
  font-size: 0.82rem; font-weight: 700; color: var(--text); margin-bottom: 2px;
}
.test-suite-name code { background: var(--panel-3); padding: 1px 6px; border-radius: 4px; font-size: 0.8rem; }
.test-suite-desc { font-size: 0.82rem; line-height: 1.4; margin-bottom: 5px; }
.test-case-list { list-style: none; margin: 0; padding: 0; }
.test-case {
  display: grid; grid-template-columns: 18px 1fr auto; align-items: baseline;
  gap: 8px; padding: 3px 0; font-size: 0.88rem;
}
.test-case-sym { font-weight: 700; text-align: center; }
.test-case-passed .test-case-sym { color: #22c55e; }
.test-case-failed .test-case-sym { color: #ef4444; }
.test-case-skipped .test-case-sym { color: var(--muted); }
.test-case-skipped .test-case-name { color: var(--muted); }
.test-case-name { line-height: 1.35; }
.test-case-dur { font-size: 0.76rem; white-space: nowrap; }
.test-case-failure {
  grid-column: 2 / -1; margin: 4px 0 2px; padding: 8px 10px;
  background: rgba(239, 68, 68, 0.10); border: 1px solid rgba(239, 68, 68, 0.30);
  border-radius: 6px; font-size: 0.78rem; line-height: 1.4;
  white-space: pre-wrap; overflow-x: auto;
}

/* ---- Calendar / scheduling ---- */
.calendar-setup-banner {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(217, 119, 6, 0.45);
  background: rgba(251, 191, 36, 0.14);
  border-radius: 6px;
  font-size: 0.92rem;
  line-height: 1.4;
}
.calendar-toolbar { margin-bottom: 12px; }
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.calendar-month-label {
  margin: 0;
  font-size: 1.25rem;
  min-width: 10rem;
}
.calendar-blurb { margin: 0; font-size: 0.9rem; line-height: 1.4; max-width: 52rem; }
.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .calendar-layout { grid-template-columns: 1fr; }
}
.calendar-dow-row,
.calendar-cells {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.calendar-dow {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 0;
}
.calendar-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 72px;
  padding: 6px;
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 6px;
  background: var(--panel, #fff);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.calendar-cell.is-outside { opacity: 0.4; }
.calendar-cell.is-today { box-shadow: inset 0 0 0 1px #3b82f6; }
.calendar-cell.is-selected { background: rgba(59, 130, 246, 0.12); border-color: #3b82f6; }
.calendar-cell.has-routes { background: rgba(34, 197, 94, 0.06); }
.calendar-cell-day { font-weight: 700; font-size: 0.9rem; }
.calendar-cell-routes { display: flex; flex-wrap: wrap; gap: 2px; }
.calendar-route-chip {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(59, 130, 246, 0.18);
}
.calendar-route-chip.is-route-chip-active {
  background: rgba(34, 197, 94, 0.35);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.6);
}
.calendar-route-more { font-size: 0.68rem; color: var(--muted); }
.calendar-day-panel {
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 8px;
  padding: 12px;
  max-height: 70vh;
  overflow: auto;
}
.calendar-day-heading { font-weight: 700; font-size: 1.05rem; margin-bottom: 10px; }
.calendar-route-card { margin-bottom: 14px; }
.calendar-route-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.calendar-stop-list { list-style: none; margin: 0; padding: 0; }
.calendar-stop-open {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 6px 8px;
  border: 0;
  border-bottom: 1px solid var(--border, #eee);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.calendar-stop-row.is-skip .calendar-stop-title { color: var(--muted); text-decoration: line-through; }
.calendar-stop-row.is-due .calendar-stop-open:hover { background: rgba(59, 130, 246, 0.06); }
.calendar-stop-row.is-pending-customer .calendar-stop-open {
  background: rgba(59, 130, 246, 0.08);
}
.calendar-stop-open-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border, #eee);
  background: rgba(59, 130, 246, 0.04);
  font-size: 0.85rem;
}
.calendar-stop-open-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.calendar-routes-block { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border, rgba(0,0,0,0.1)); }
.calendar-routes-title { margin: 0 0 4px; font-size: 1.05rem; }
.calendar-route-weekday-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.06));
}
.calendar-route-weekday-label { min-width: 12rem; }
.calendar-weekday-warn {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #b45309;
}
.route-weekdays-editor,
.weekday-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.weekday-toggle {
  border: 1px solid var(--border, #ccc);
  background: var(--panel, #fff);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  color: inherit;
}
.weekday-toggle.is-active {
  background: #1e3a5f;
  border-color: #1e3a5f;
  color: #fff;
}
.cadence-anchor-row { align-items: center; }
.cadence-anchor-input { max-width: 11rem; padding: 4px 6px; font-size: 0.85rem; }
.cadence-anchor-hint { font-size: 0.75rem; }
.route-weekdays-field { margin-bottom: 10px; }

/* ---- Calendar filters + compact day panel + customer embed ---- */
.calendar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin: 10px 0 8px;
}
.calendar-filter-field { margin: 0; min-width: 10rem; }
.calendar-filter-customer { position: relative; flex: 1; min-width: 14rem; }
.calendar-customer-results {
  position: absolute;
  left: 0; right: 0; top: 100%;
  z-index: 20;
  background: var(--panel, #fff);
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  max-height: 220px;
  overflow: auto;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
.calendar-customer-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--border, #eee);
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.calendar-customer-option:hover { background: rgba(59, 130, 246, 0.08); }
.calendar-active-filter {
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.calendar-route-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.calendar-route-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 6px 10px;
  border: 1px solid var(--border, #ccc);
  border-radius: 6px;
  background: var(--panel, #fff);
  cursor: pointer;
  font: inherit;
  color: inherit;
  max-width: 11rem;
}
.calendar-route-pill span {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.calendar-route-pill-count { font-weight: 700; color: var(--text) !important; }
.calendar-route-pill.is-active {
  border-color: #1e3a5f;
  background: rgba(30, 58, 95, 0.08);
  box-shadow: inset 0 0 0 1px #1e3a5f;
}
.calendar-stop-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 4px 0;
}
.calendar-skip-details { margin-top: 8px; }
.calendar-skip-details summary { cursor: pointer; padding: 4px 0; }
.calendar-customer-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.2rem;
  padding: 0 4px;
  border-radius: 999px;
  background: #1e3a5f;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}
.calendar-cell.has-customer-due { background: rgba(30, 58, 95, 0.08); }
.calendar-cell.is-route-highlight {
  background: rgba(34, 197, 94, 0.22);
  box-shadow: inset 0 0 0 2px rgba(34, 197, 94, 0.55);
}
.calendar-cell.is-route-muted { opacity: 0.38; }
.calendar-nav-embed {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.calendar-month-label-embed {
  font-weight: 700;
  min-width: 8rem;
}
.calendar-layout.is-compact .calendar-cell { min-height: 56px; }
.client-calendar-block {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 8px;
  background: var(--panel-2, rgba(0,0,0,0.02));
}
.client-calendar-title { margin: 0 0 4px; font-size: 1.05rem; }
.client-calendar-head { margin-bottom: 8px; }
.wp-schedule-summary {
  font-size: 0.85rem;
  margin: 4px 0 2px;
  line-height: 1.35;
}
.wp-schedule-summary.is-unassigned .wp-schedule-cadence { color: var(--muted); }
.wp-schedule-cadence {
  font-weight: 700;
  color: #1e3a5f;
}
.wp-route-context-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 4px;
  align-self: center;
}
.calendar-mini-route-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.calendar-mini-route {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border, #ccc);
  background: var(--panel, #fff);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.calendar-mini-route.is-due {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.5);
}
.calendar-mini-route.is-active {
  box-shadow: 0 0 0 2px var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
}
