/* ══════════════════════════════════════════════════════════════
   LAYOUT — Shared components across all pages
   Apple HIG-inspired minimalist design for dispatchers
   ══════════════════════════════════════════════════════════════ */

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

[data-theme="light"] .topbar {
  background: rgba(255,255,255,0.8);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.topbar h1 {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.last-updated {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: -0.2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.freshness-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--duration), box-shadow var(--duration);
}
.freshness-dot.fresh { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.freshness-dot.aging { background: var(--orange); box-shadow: 0 0 0 3px var(--orange-bg); }
.freshness-dot.stale { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }

.countdown {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ── Live Pulse Dot ────────────────────────────────────────── */
.logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green); }
  50% { opacity: 0.4; box-shadow: 0 0 4px var(--green); }
}

/* ── Hamburger Button ──────────────────────────────────────── */
.menu-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--duration) var(--ease-default);
  color: var(--text);
}

.menu-btn:hover {
  background: var(--fill-tertiary);
}

.menu-icon {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
}

.menu-icon span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: background var(--duration);
}

.menu-btn:hover .menu-icon span { background: var(--text); }

/* ── Icon Buttons ──────────────────────────────────────────── */
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration), color var(--duration);
}

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

.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.75; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration), opacity var(--duration);
  white-space: nowrap;
  line-height: 1.3;
}

.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-secondary {
  background: var(--fill-quaternary);
  color: var(--text);
  border: none;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration);
  white-space: nowrap;
  line-height: 1.3;
}

.btn-secondary:hover { background: var(--fill-tertiary); }
.btn-secondary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--accent-text);
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration);
  white-space: nowrap;
}

.btn-ghost:hover { background: var(--accent-dim); }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--duration);
  white-space: nowrap;
}

.btn-danger:hover { filter: brightness(1.15); }

/* Legacy button classes (used in cancellations) */
.btn {
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--duration), background var(--duration), opacity var(--duration);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-cancel { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red); }
.btn-cancel:hover:not(:disabled) { filter: brightness(1.2); }
.btn-void { background: var(--purple-bg); border: 1px solid var(--purple-border); color: var(--purple); }
.btn-void:hover:not(:disabled) { filter: brightness(1.2); }
.btn.btn-primary { background: var(--accent); color: white; }
.btn.btn-primary:hover:not(:disabled) { opacity: 0.85; }
.btn.btn-secondary { background: var(--fill-quaternary); border: none; color: var(--text); }
.btn.btn-secondary:hover:not(:disabled) { background: var(--fill-tertiary); }

/* ── Refresh / Action Button (legacy) ──────────────────────── */
.refresh-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--duration);
  white-space: nowrap;
}

.refresh-btn:hover { opacity: 0.85; }
.refresh-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Navigation Drawer ─────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  z-index: 150;
  transition: opacity 0.25s var(--ease-default);
}

.overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 272px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.28s var(--ease-default);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.2px;
}

.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration), color var(--duration);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.drawer-close:hover {
  background: var(--fill-tertiary);
  color: var(--text);
}

.drawer-nav {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
  transition: background var(--duration);
  font-size: 14px;
  font-weight: 500;
}

.nav-link:hover {
  background: var(--fill-quaternary);
}

.nav-link.active {
  background: var(--accent-dim);
  color: var(--accent-text);
}

.nav-link .nav-kicker {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: -0.1px;
}

.nav-link.active .nav-kicker { color: var(--accent-text); opacity: 0.7; }

.nav-link .nav-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fill-quaternary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.nav-link.active .nav-icon {
  background: var(--accent);
  color: #fff;
}

/* ── Page Container ────────────────────────────────────────── */
.page {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

#dashboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 16px;
}

/* ── Stats Row ─────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.stat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  flex: 1;
  min-width: 120px;
  transition: border-color var(--duration), background var(--duration);
}
.stat-card:hover { border-color: var(--text-quaternary); }

.stat-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
}

.stat-card.danger .stat-value { color: var(--red); }
.stat-card.ok .stat-value { color: var(--green); }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.neutral .stat-value { color: var(--text); }

/* ── Section Header ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  background: var(--red);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  font-family: var(--font-mono);
}

.count-badge.ok { background: var(--green); color: #000; }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 1px;
  background: var(--fill-quaternary);
  border-radius: var(--radius-sm);
  padding: 3px;
  width: fit-content;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 6px 16px;
  border-radius: 5px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration) var(--ease-default);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .tab-btn.active {
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tab-btn:hover:not(.active) { color: var(--text); }

.tab-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--fill-tertiary);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.tab-btn.active .tab-badge {
  background: var(--accent);
  color: white;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  border-bottom: 1px solid var(--border);
}

thead th {
  background: var(--surface2);
}

th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 12px 18px;
  text-align: left;
  white-space: nowrap;
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-secondary); }

td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--fill-quaternary); }

.driver-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.route-name {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.stop-name {
  font-size: 13px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time-val {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: -0.3px;
}

.muted {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ── Badges (unified base) ─────────────────────────────────────
   Every badge family shares the same pill shape + type treatment.
   Size variants: default, .badge-sm (10px), .badge-xs (9px)
   Color variants applied via semantic modifier classes below. */
.gap-badge, .status-badge, .type-badge, .fillable-badge, .mini-badge, .day-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  letter-spacing: -0.2px;
  border: 1px solid transparent;
  transition: background var(--duration), color var(--duration), border-color var(--duration);
}

/* ── Gap Badge (emphasized — gap amount in main table) ──────── */
.gap-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  letter-spacing: -0.3px;
}
.gap-badge.critical { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.gap-badge.warning { background: var(--orange-bg); border-color: var(--orange-border); color: var(--orange); }
.gap-badge.ok { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.gap-badge.ending { background: var(--purple-bg); border-color: var(--purple-border); color: var(--purple); }

/* ── Status Badge (state label in tables) ──────────────────── */
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  background: var(--fill-quaternary);
  color: var(--text-secondary);
}

.status-badge.gap { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.status-badge.progress { background: var(--orange-bg); border-color: var(--orange-border); color: var(--orange); }
.status-badge.ok { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.status-badge.closing { background: var(--orange-bg); border-color: var(--orange-border); color: var(--orange); }
.status-badge.ending { background: var(--purple-bg); border-color: var(--purple-border); color: var(--purple); }
.status-badge.en-route { background: var(--orange-bg); border-color: var(--orange-border); color: var(--orange); }
.status-badge.scheduled { background: var(--accent-dim); border-color: transparent; color: var(--accent-text); }

.gap-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 3px;
  font-family: var(--font-mono);
}

.type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.type-badge.cancel { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.type-badge.void { background: var(--purple-bg); border-color: var(--purple-border); color: var(--purple); }

.fillable-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  background: var(--orange-bg);
  border-color: var(--orange-border);
  color: var(--orange);
  margin-left: 6px;
  cursor: pointer;
  vertical-align: middle;
}

.fillable-badge:hover { filter: brightness(1.15); }

.mini-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  color: #fff;
  vertical-align: middle;
}

.mini-badge.now { background: var(--red); border-color: var(--red); }
.mini-badge.upcoming, .mini-badge.later { background: var(--purple); border-color: var(--purple); }

.billed-yes { color: var(--red); font-family: var(--font-mono); font-size: 11px; font-weight: 600; }
.billed-no { color: var(--green); font-family: var(--font-mono); font-size: 11px; font-weight: 600; }

/* ── City Chips ────────────────────────────────────────────── */
.city-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-wrap: wrap;
  padding-bottom: 2px;
}

.city-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: border-color var(--duration), background var(--duration);
  min-width: 80px;
}

.city-chip:hover { border-color: var(--accent); }
.city-chip.active { border-color: var(--accent); background: var(--accent-dim); }

.city-chip-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.city-chip-count {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.3px;
}

.city-chip-count.has-gaps { color: var(--red); }

.city-chip-fillable {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--orange, #f59e0b);
  margin-top: 2px;
}

.city-chip-total {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 3px;
}

/* ── Collapsible Panel ─────────────────────────────────────── */
.job-fit-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: visible;
}

.job-fit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  cursor: pointer;
  user-select: none;
  transition: background var(--duration);
  border-radius: var(--radius-md);
}

.job-fit-header:hover { background: var(--fill-quaternary); }

.job-fit-hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

.job-fit-body {
  border-top: 1px solid var(--border);
  padding: 18px;
  overflow: visible !important;
}

/* ── Job Fit Inputs ────────────────────────────────────────── */
.job-fit-inputs {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 18px;
  overflow: visible !important;
}

.job-input-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 180px;
}

.job-input-group.narrow { flex: 0 0 100px; min-width: 100px; }

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.job-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color var(--duration), box-shadow var(--duration);
  color-scheme: dark;
}

[data-theme="light"] .job-input { color-scheme: light; }

.job-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.job-input[type="number"] {
  -moz-appearance: textfield;
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}

.job-input[type="number"]::-webkit-inner-spin-button,
.job-input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.fit-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--duration);
  align-self: flex-end;
}

.fit-btn:hover { opacity: 0.85; }
.fit-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.fit-result-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.fit-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.fit-badge.yes { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.fit-badge.tight { background: var(--orange-bg); border: 1px solid var(--orange-border); color: var(--orange); }
.fit-badge.no { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red); }

/* ── Stepper ───────────────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: stretch;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.stepper .job-input {
  border: none;
  border-radius: 0;
  flex: 1;
  min-width: 0;
}

.stepper .job-input:focus { box-shadow: inset 0 0 0 1px var(--accent); }

.stepper-btn {
  width: 30px;
  background: var(--fill-quaternary);
  border: none;
  color: var(--text-secondary);
  font-size: 15px;
  font-family: var(--font-mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration), color var(--duration);
  user-select: none;
}

.stepper-btn:hover { background: var(--fill-tertiary); color: var(--text); }
.stepper-btn:active { background: var(--accent); color: #fff; }

/* ── Time Picker ───────────────────────────────────────────── */
.tp-group { display: inline-flex; align-items: center; gap: 4px; }
.tp-group .tp-sep {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-tertiary);
  user-select: none;
}

.tp-wrap { position: relative; display: inline-block; }

.tp-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 4px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  width: 42px;
  text-align: center;
  outline: none;
  transition: border-color var(--duration), box-shadow var(--duration);
  -moz-appearance: textfield;
}

.tp-input::-webkit-inner-spin-button,
.tp-input::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
.tp-input:hover { border-color: var(--accent); }
.tp-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.tp-input::placeholder { color: var(--text-tertiary); font-weight: 400; }

.tp-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  min-width: 42px;
  text-align: center;
  transition: border-color var(--duration), box-shadow var(--duration);
  outline: none;
}

.tp-btn:hover { border-color: var(--accent); }
.tp-btn:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.tp-btn.ampm { font-size: 11px; letter-spacing: 0.05em; min-width: 40px; }

.tp-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 48px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
  padding: 4px;
}

.tp-list.open { display: block; }

.tp-item {
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
  text-align: center;
}

.tp-item:hover { background: var(--fill-quaternary); }
.tp-item.active { background: var(--accent-dim); color: var(--accent-text); }

/* ── Address Autocomplete ──────────────────────────────────── */
.autocomplete-wrap { position: relative; overflow: visible !important; }

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 300px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: none;
}

.autocomplete-dropdown.visible { display: block; }

.ac-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}

.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.highlighted { background: var(--fill-quaternary); }

.ac-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.ac-text { flex: 1; min-width: 0; }

.ac-main {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-status {
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ac-section-label {
  padding: 8px 14px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-light);
}

/* ── Expandable Detail Row ─────────────────────────────────── */
tr.expandable-row { cursor: pointer; }
tr.expandable-row:hover td { background: var(--fill-quaternary); }

tr.expandable-row td:first-child .driver-name::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--text-tertiary);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  margin-right: 8px;
  transition: transform 0.2s var(--ease-default);
  vertical-align: middle;
}

tr.expandable-row.expanded td:first-child .driver-name::before {
  transform: rotate(90deg);
}

tr.detail-row { display: none; }
tr.detail-row.open { display: table-row; }
tr.detail-row > td { padding: 0; border-bottom: 1px solid var(--border); }
tr.detail-row:hover > td { background: transparent; }

.detail-panel {
  background: var(--bg);
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  animation: detailSlide 0.2s ease-out;
}

@keyframes detailSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  font-size: 13px;
}

.detail-item-label { color: var(--text-tertiary); font-size: 12px; }

.detail-item-value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

.detail-divider {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

/* ── Map Container ─────────────────────────────────────────── */
/*
 * Hidden state is off-screen (not `display: none`) so Mapbox can be
 * eagerly instantiated at page load. Eliminates the 30-60s cold-boot
 * the user otherwise pays when clicking Map after data is already loaded.
 * When `.active` is added, the container rejoins the normal flow and a
 * resize() call picks up the new dimensions.
 */
#map-container {
  position: absolute;
  left: -99999px;
  top: 0;
  width: 800px;
  height: calc(100vh - 200px);
  min-height: 500px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

#map-container.active {
  position: relative;
  left: 0;
  width: auto;
  visibility: visible;
  pointer-events: auto;
}

/* ── Job Fit: "View on map" action ─────────────────────────── */
.jf-map-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text-muted);
  font: 600 10px/1 var(--mono, monospace);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.jf-map-btn:hover,
.jf-map-btn:focus-visible {
  background: var(--fill-tertiary, var(--surface));
  color: var(--ending);
  border-color: var(--ending);
  outline: none;
}
.jf-map-btn svg { display: block; }

/* ── Map Legend ────────────────────────────────────────────── */
.map-legend {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  width: 220px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.5;
  overflow: hidden;
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}

.map-legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  color: var(--text);
  border: 0;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  transition: background-color 150ms ease;
}

.map-legend-header:hover { background: var(--fill-tertiary); }
.map-legend-title { color: var(--text-muted); }
.legend-chevron { color: var(--text-muted); transition: transform 200ms ease; }
.map-legend.collapsed .legend-chevron { transform: rotate(-90deg); }
.map-legend.collapsed .map-legend-body { display: none; }
.map-legend.collapsed .map-legend-header { border-bottom: 0; }

.map-legend-body {
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-legend-section { display: flex; flex-direction: column; gap: 4px; }
.map-legend-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.75;
  margin-bottom: 2px;
}

.map-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
}

.legend-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.legend-circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--swatch-color);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1.5px var(--swatch-color), 0 1px 2px rgba(0,0,0,0.25);
}

.legend-triangle {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid var(--swatch-color);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
}

.legend-line {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
}
.legend-line-solid { background: var(--text-muted); opacity: 0.55; }
.legend-line-glow {
  background: var(--swatch-color);
  box-shadow: 0 0 6px var(--swatch-color);
}

.map-legend-hint {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  padding-top: 4px;
  border-top: 1px dashed var(--border-light);
  line-height: 1.4;
}

/* ── Map: Job-Fit proposed-match preview card (top-right) ───── */
.map-preview-card {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 300px;
  max-width: calc(100% - 28px);
  z-index: 12;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 14px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.45;
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  animation: mpcFadeIn 180ms ease;
}
.map-preview-card[hidden] { display: none; }

@keyframes mpcFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0);    }
}

.map-preview-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.map-preview-card-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ending);
}
.map-preview-card-close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms ease, color 150ms ease;
}
.map-preview-card-close:hover,
.map-preview-card-close:focus-visible {
  background: var(--fill-tertiary, var(--surface2));
  color: var(--text);
  outline: none;
}
.map-preview-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}
.map-preview-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.map-preview-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.map-preview-steps::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: linear-gradient(to bottom, transparent 0, var(--border) 6px, var(--border) calc(100% - 6px), transparent 100%);
  z-index: 0;
}
.map-preview-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  position: relative;
  z-index: 1;
}
.map-preview-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font: 700 12px/1 var(--mono, monospace);
  box-shadow: 0 0 0 2px var(--surface), 0 1px 3px rgba(0, 0, 0, 0.25);
}
.map-preview-step-body { min-width: 0; flex: 1; padding-top: 2px; }
.map-preview-step-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.map-preview-step-text {
  font-size: 12px;
  color: var(--text);
  word-break: break-word;
  line-height: 1.35;
  margin-top: 1px;
}

.map-preview-card-legend {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-light);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}
.map-preview-card-legend span { display: inline-flex; align-items: center; gap: 6px; }
.mpc-dash-sample, .mpc-solid-sample {
  display: inline-block;
  width: 20px;
  height: 2px;
  background: #8b5cf6;
  border-radius: 2px;
}
.mpc-dash-sample {
  background-image: linear-gradient(to right, #8b5cf6 0 50%, transparent 50% 100%);
  background-size: 6px 2px;
  background-color: transparent;
}

/* ── Map: numbered waypoint markers for Job-Fit preview ────── */
.jf-waypoint-marker {
  position: relative;
  width: 28px;
  height: 28px;
  pointer-events: none; /* let map panning pass through the chip */
}
.jf-waypoint-pin {
  position: relative;
  width: 28px;
  height: 28px;
  color: #fff;
  font: 700 13px/1 var(--mono, monospace);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  isolation: isolate; /* keeps z-index containment local */
}
.jf-waypoint-pin::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--pin-color, #8b5cf6);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95), 0 3px 8px rgba(0, 0, 0, 0.35);
  z-index: -1;
}

.jf-waypoint-chip {
  position: absolute;
  left: calc(100% + 6px);
  bottom: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 3px 8px;
  font: 500 11px/1.15 var(--font-body, -apple-system, sans-serif);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  backdrop-filter: saturate(180%) blur(6px);
  -webkit-backdrop-filter: saturate(180%) blur(6px);
}
.jf-waypoint-chip strong { font-weight: 700; color: var(--ending); }

/* Mobile: tuck the card to the bottom edge so the map shows through */
@media (max-width: 640px) {
  .map-preview-card {
    top: auto;
    bottom: 14px;
    left: 14px;
    right: 14px;
    width: auto;
    max-height: 45vh;
    overflow-y: auto;
  }
  .jf-waypoint-chip { display: none; } /* rely on the card on small screens */
}

/* ── Map Inspector (driver detail panel, right edge) ──────── */
.map-inspector {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: 320px;
  max-width: calc(100% - 28px);
  z-index: 10;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  transform: translateX(calc(100% + 28px));
  opacity: 0;
  transition: transform 260ms var(--ease-default), opacity 200ms ease;
  pointer-events: none;
  overflow: hidden;
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}

.map-inspector.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.map-inspector-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px 16px;
  border-bottom: 1px solid var(--border-light);
}

.map-inspector-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
  color: var(--text);
}

.map-inspector-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.map-inspector-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--fill-tertiary);
  color: var(--text);
  border: 0;
  cursor: pointer;
  line-height: 1;
  transition: background-color 150ms ease;
}
.map-inspector-close:hover { background: var(--fill-secondary); }
.map-inspector-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.map-inspector-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-inspector-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #fff;
}

.map-inspector-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.map-inspector-activity {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
}
.map-inspector-activity svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}
.map-inspector-activity-detail {
  font-weight: 500;
  opacity: 0.75;
  margin-left: 2px;
}
.map-inspector-activity[data-activity="en-route"] {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}
.map-inspector-activity[data-activity="waiting"] {
  background: var(--orange-bg);
  color: var(--orange);
  border-color: var(--orange-border);
}
.map-inspector-activity[data-activity="idle"] {
  background: var(--fill-tertiary);
  color: var(--text-secondary);
  border-color: var(--border-light);
}
.map-inspector-activity[data-activity="ending"] {
  background: var(--purple-bg);
  color: var(--purple);
  border-color: var(--purple-border);
}

.map-inspector-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
}
.map-inspector-row-key {
  color: var(--text-secondary);
  font-weight: 500;
}
.map-inspector-row-val {
  color: var(--text);
  text-align: right;
}

.map-inspector-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 4px;
}

.map-inspector-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: 12.5px;
}
.map-inspector-tl-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.map-inspector-tl-marker {
  flex-shrink: 0;
  width: 12px;
  display: flex;
  justify-content: center;
  margin-top: 4px;
}
.map-inspector-tl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--status-color, var(--accent));
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--status-color, var(--accent));
}
.map-inspector-tl-ring {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--status-color, var(--accent));
  background: var(--surface);
}
.map-inspector-tl-connector {
  flex-shrink: 0;
  width: 12px;
  display: flex;
  justify-content: center;
  height: 14px;
}
.map-inspector-tl-connector::before {
  content: "";
  width: 2px;
  background-image: linear-gradient(to bottom, var(--status-color, var(--accent)) 50%, transparent 50%);
  background-size: 2px 5px;
  opacity: 0.6;
}
.map-inspector-tl-content {
  flex: 1;
  line-height: 1.45;
}
.map-inspector-tl-label { font-weight: 600; color: var(--text); }
.map-inspector-tl-meta  { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

.map-inspector-gap-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text);
}
.map-inspector-gap-tri {
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid var(--orange);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .map-inspector {
    top: auto;
    right: 14px;
    left: 14px;
    bottom: 14px;
    width: auto;
    max-height: 45%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-inspector { transition: opacity 120ms ease; transform: none; }
  .legend-chevron { transition: none; }
}

/* Mapbox GL popup styling to match our theme */
.mapboxgl-popup-content {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 14px 16px !important;
  border: 1px solid var(--border) !important;
}

.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip { border-top-color: var(--surface) !important; }
.mapboxgl-popup-anchor-top .mapboxgl-popup-tip { border-bottom-color: var(--surface) !important; }
.mapboxgl-popup-anchor-left .mapboxgl-popup-tip { border-right-color: var(--surface) !important; }
.mapboxgl-popup-anchor-right .mapboxgl-popup-tip { border-left-color: var(--surface) !important; }

.mapboxgl-popup-close-button {
  color: var(--text-secondary) !important;
  font-size: 18px !important;
  padding: 4px 8px !important;
}

.mapboxgl-popup-close-button:hover { color: var(--text) !important; }

.mapboxgl-ctrl-group {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-sm) !important;
}

.mapboxgl-ctrl-group button {
  border-bottom-color: var(--border) !important;
}

.mapboxgl-ctrl-group button:hover {
  background-color: var(--fill-quaternary) !important;
}

.mapboxgl-ctrl-attrib {
  background: transparent !important;
  font-size: 10px !important;
}

.mapboxgl-ctrl-attrib a { color: var(--text-tertiary) !important; }

/* ── Trends / Charts ───────────────────────────────────────── */
.trends-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.trends-chart-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  position: relative;
}

.trends-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

/* ── Handle Button ─────────────────────────────────────────── */
.handle-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--duration);
}

.handle-btn:hover { border-color: var(--green); color: var(--green); }
.handle-btn.handled { border-color: var(--green); color: var(--green); background: var(--green-bg); }

tr.handled-row td { opacity: 0.3; }

/* ── Alert Button ──────────────────────────────────────────── */
.alert-btn { background: var(--fill-quaternary) !important; border: none !important; color: var(--text-secondary) !important; }
.alert-btn.active { background: var(--accent) !important; color: white !important; }

/* ── Threshold Input ───────────────────────────────────────── */
.threshold-input {
  width: 48px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}

.threshold-input:focus { border-color: var(--accent); }

.threshold-input::-webkit-inner-spin-button,
.threshold-input::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }

/* ── Filter / Search Input ─────────────────────────────────── */
.search-bar,
.search,
.filter-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color var(--duration), box-shadow var(--duration);
}

.search-bar:focus,
.search:focus,
.filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-wrap { flex: 1 1 320px; min-width: 200px; }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.action-btns { display: flex; gap: 6px; }

.paging-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

/* ── Spinner ───────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--fill-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

.loading-row td {
  text-align: center;
  padding: 48px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
}

.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 13px; }

/* ── Error Banner ──────────────────────────────────────────── */
.error-banner {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--red);
  font-size: 13px;
  display: none;
}

/* ── Data Health Banner ───────────────────────────────────────
   Yellow warning shown when an upstream data source (Samsara,
   RideCare, OSRM, local DB) is degraded. Distinct from
   error-banner which is reserved for fatal/unrecoverable errors. */
.health-banner {
  background: var(--warning-bg, #fff8e1);
  border: 1px solid var(--warning-border, #f1c40f);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--warning, #b7791f);
  font-size: 12px;
  display: none;
  margin-bottom: 12px;
  font-family: var(--mono);
}
.health-banner.visible { display: block; }
.health-banner strong { color: var(--warning, #b7791f); }
.health-banner .health-detail {
  display: block;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 11px;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 95vw;
  padding: 24px;
  box-shadow: var(--shadow-xl);
}

.modal h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

.modal h3.cancel-title { color: var(--red); }
.modal h3.void-title { color: var(--purple); }

.modal-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--orange-bg);
  border: 1px solid var(--orange-border);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--orange);
  font-weight: 500;
}
.modal-warning svg { flex-shrink: 0; margin-top: 1px; color: var(--orange); }
.modal-warning span { color: var(--text); }

.modal-info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
  font-size: 13px;
}

.modal-info-row { display: flex; gap: 8px; margin-bottom: 4px; }
.modal-info-label { font-size: 11px; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-tertiary); min-width: 70px; }
.modal-info-value { color: var(--text); font-size: 13px; }

.modal-field { margin-bottom: 12px; }
.modal-field label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 6px; }

.modal-field input,
.modal-field select,
.modal-field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  outline: none;
  resize: vertical;
}

.modal-field input:focus,
.modal-field select:focus,
.modal-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.modal-note {
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.modal-note.cancel-note { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red); }
.modal-note.void-note { background: var(--purple-bg); border: 1px solid var(--purple-border); color: var(--purple); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Schedule Page Specifics ───────────────────────────────── */
.vehicle-id { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); }

.day-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  margin: 1px 2px;
}

.day-badge.active { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.day-badge.off { background: var(--fill-quaternary); border-color: var(--border); color: var(--text-tertiary); }
.day-badge.today { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-text); }

.day-toggle {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 3px;
  margin: 1px 2px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, border-color 0.1s;
}

.day-toggle.on { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.day-toggle.off { background: var(--fill-quaternary); border: 1px solid var(--border); color: var(--text-tertiary); }
.day-toggle:hover { border-color: var(--accent); }

.time-range { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.shift-hours { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); }

.status-on { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-sm); background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.status-off { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-sm); background: var(--fill-quaternary); border: 1px solid var(--border); color: var(--text-tertiary); }
.status-unmatched { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-sm); background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red); }

.date-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.date-row label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

.date-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  color-scheme: dark;
  outline: none;
}

[data-theme="light"] .date-input { color-scheme: light; }
.date-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.avail-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 3px; display: inline-block; }
.avail-badge.default { background: var(--fill-quaternary); border: 1px solid var(--border); color: var(--text-tertiary); }
.avail-badge.partial { background: var(--orange-bg); border: 1px solid var(--orange-border); color: var(--orange); }
.avail-badge.off { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red); }
.avail-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.avail-note { font-size: 10px; color: var(--text-tertiary); font-style: italic; margin-top: 1px; }
.avail-set { font-size: 10px; color: var(--accent-text); cursor: pointer; border: none; background: none; padding: 0; text-decoration: underline; }
.avail-set:hover { opacity: 0.7; }
.avail-clear { font-size: 9px; color: var(--text-tertiary); cursor: pointer; border: none; background: none; padding: 0; margin-left: 6px; }
.avail-clear:hover { color: var(--red); }

.override-row { background: var(--orange-bg); }
.override-form { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.override-form .of-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.of-label { font-size: 10px; color: var(--text-tertiary); min-width: 40px; }
.of-note { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; font-family: var(--font-mono); font-size: 11px; color: var(--text); outline: none; width: 140px; }
.of-note:focus { border-color: var(--accent); }
.of-status-btn { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 4px; border: 1px solid var(--border); background: var(--fill-quaternary); color: var(--text-tertiary); cursor: pointer; transition: all 0.1s; }
.of-status-btn:hover { border-color: var(--accent); }
.of-status-btn.sel { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-text); }

.edit-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration), border-color var(--duration), color var(--duration);
}

.edit-btn:hover { background: var(--fill-quaternary); border-color: var(--accent); color: var(--accent-text); }

.save-btn {
  background: var(--green);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.save-btn:hover { opacity: 0.85; }

.cancel-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.cancel-btn:hover { border-color: var(--red); color: var(--red); }

/* ── Cancellations Page Specifics ──────────────────────────── */
.btn-outline {
  background: var(--fill-quaternary);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration), border-color var(--duration);
  white-space: nowrap;
}

.btn-outline:hover { background: var(--fill-tertiary); border-color: var(--text-tertiary); }

.btn-sm {
  padding: 3px 10px;
  font-size: 11px;
  border-radius: 4px;
}

.btn-undo {
  background: var(--fill-quaternary);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration);
  white-space: nowrap;
}

.btn-undo:hover { background: var(--accent-dim); }

.btn-delete {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--duration);
  white-space: nowrap;
}

.btn-delete:hover { opacity: 0.85; }

/* ── Row Action Hierarchy (primary/secondary) ─────────────────── */
.btn-cancel.primary {
  background: var(--red);
  color: #fff;
  border: 1px solid var(--red);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--duration);
  white-space: nowrap;
}
.btn-cancel.primary:hover:not(:disabled) { filter: brightness(1.1); }

.btn-void.secondary {
  background: transparent;
  color: var(--purple);
  border: 1px solid var(--purple-border);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration), border-color var(--duration);
  white-space: nowrap;
}
.btn-void.secondary:hover:not(:disabled) { background: var(--purple-bg); border-color: var(--purple); }

.btn-expand {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration), color var(--duration), transform var(--duration);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-expand:hover { background: var(--fill-quaternary); color: var(--text); }
.btn-expand.expanded { color: var(--accent); border-color: var(--accent); transform: rotate(180deg); }

/* ── Composite Cell Styling ───────────────────────────────────── */
.cell-stacked { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-stacked .primary {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-stacked .secondary {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  max-width: 260px;
}
.trip-cell .trip-line {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
.trip-cell .trip-arrow {
  color: var(--text-tertiary);
  font-size: 10px;
  flex-shrink: 0;
}
.trip-cell .trip-addr {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}
.trip-cell .trip-addr.from { color: var(--text-secondary); }
.trip-cell .trip-addr.to { color: var(--text); font-weight: 500; }

/* Combined type+billed badge */
.type-badge.combined {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 10px;
  line-height: 1.1;
}
.type-badge.combined .type-line { font-weight: 700; font-size: 10px; letter-spacing: 0.05em; }
.type-badge.combined .billed-line { font-size: 9px; font-weight: 500; opacity: 0.85; text-transform: none; letter-spacing: 0; }

/* Stop detail — indexed list (Apple HIG: aligned columns, sequential scan) */
.stop-detail-panel {
  padding: 14px 20px 18px;
  background: var(--bg);
  border-top: 1px solid var(--border-light);
  animation: detailSlide 0.2s ease-out;
}

.stop-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.stop-list-head .detail-section-title { margin-bottom: 0; }

.stop-list-summary { display: flex; gap: 6px; flex-wrap: wrap; }
.stop-summary-chip {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.stop-summary-chip.ok { color: var(--green); background: var(--green-bg); border-color: var(--green); }
.stop-summary-chip.voided { color: var(--red); background: var(--red-bg); border-color: var(--red); }

/* Stop table — real <table> for rock-solid columns */
.stop-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.stop-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.stop-table col.stop-tcol-idx     { width: 44px; }
.stop-table col.stop-tcol-type    { width: 68px; }
.stop-table col.stop-tcol-stop    { width: auto; }
.stop-table col.stop-tcol-time    { width: 96px; }
.stop-table col.stop-tcol-state   { width: 120px; }
.stop-table col.stop-tcol-actions { width: 200px; }

.stop-table thead th {
  background: var(--surface2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.stop-table thead th.stop-tcol-idx { text-align: right; }

.stop-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-light);
  border-left: 1px solid var(--border-light);
}
.stop-table tbody td:first-child { border-left: 0; }
.stop-table tbody tr:last-child td { border-bottom: 0; }

.stop-table tbody tr.is-voided { opacity: 0.6; }
.stop-table tbody tr.is-voided .stop-row-name { text-decoration: line-through; }
.stop-table tbody tr.is-edge td { background: color-mix(in srgb, var(--surface2) 40%, transparent); }

.stop-table td.stop-tcol-idx {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stop-table td.stop-tcol-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stop-table td.stop-tcol-state .status-badge { font-size: 10px; }

.stop-table td.stop-tcol-actions { text-align: right; }
.stop-table td.stop-tcol-actions .action-btns {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: flex-end;
}

.stop-no-action {
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
}
.muted-dash { color: var(--text-tertiary); }

.stop-type-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  font-family: var(--font-mono);
  min-width: 44px;
}
.stop-type-chip.pu { background: rgba(10,132,255,0.14); color: var(--accent); }
.stop-type-chip.del { background: var(--green-bg); color: var(--green); }
.stop-type-chip.voided { background: var(--red-bg); color: var(--red); }
.stop-type-chip.edge { background: var(--surface2); color: var(--text-tertiary); }

.stop-row-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stop-row-addr {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.35;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}
.stop-row-addr span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stop-list-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  font-style: italic;
}

@media (max-width: 860px) {
  .stop-table-wrap { overflow-x: auto; }
  .stop-table { min-width: 720px; }
}

/* ── Schedule Edit Panel ────────────────────────────────────── */
.edit-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin: 8px 0;
}

.edit-panel-grid {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.edit-panel-section {
  flex: 1;
  min-width: 280px;
}

.edit-panel-section.override {
  border-left: 1px solid var(--border);
  padding-left: 24px;
}

.edit-panel-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--text);
}

.edit-panel-title .muted-hint {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 400;
}

.edit-panel-field {
  margin-bottom: 10px;
}

.edit-panel-field-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.edit-panel-time-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.edit-panel-time-sep {
  color: var(--text-tertiary);
  font-weight: 700;
  font-size: 13px;
}

.edit-panel-footer {
  text-align: right;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.override-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--orange-bg);
  color: var(--orange);
  border: 1px solid var(--orange-border);
  margin-top: 2px;
}


/* ══════════════════════════════════════════════════════════════
   SIDEBAR LAYOUT — Apple HIG persistent sidebar for dashboard
   Desktop: sidebar always visible, no hamburger
   Mobile (<900px): collapses to drawer
   ══════════════════════════════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 252px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 110;
  overflow-y: auto;
}

[data-theme="light"] .sidebar {
  background: var(--bg);
}

.sidebar-brand {
  padding: 16px 18px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.sidebar-nav {
  padding: 10px 10px 6px;
}

.sidebar-section {
  padding: 6px 10px;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: 12px 8px 6px;
}

/* ── Sidebar Stats ─────────────────────────────────────────── */
.sidebar-stats {
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--duration);
}

.sidebar-stat { cursor: default; }
.sidebar-stat:hover { background: var(--fill-quaternary); }

.sidebar-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-stat-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* ── Sidebar Config ────────────────────────────────────────── */
.sidebar-config {
  padding: 8px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-config-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Sidebar Footer ────────────────────────────────────────── */
.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--duration), color var(--duration);
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.sidebar-footer-btn:hover { background: var(--fill-quaternary); color: var(--text); }
.sidebar-footer-btn svg { flex-shrink: 0; }

/* ── Main Content (with sidebar offset) ────────────────────── */
.main-content {
  flex: 1;
  margin-left: 252px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content .topbar {
  position: sticky;
  top: 0;
  z-index: 100;
}

.main-content #dashboard {
  flex: 1;
  padding: 20px;
  gap: 16px;
}

/* ── Inline Stats (compact row in main area) ───────────────── */
.stats-inline {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  white-space: nowrap;
}

.stat-pill-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.3px;
}

.stat-pill-label {
  color: var(--text-tertiary);
  font-size: 11px;
}

/* ── Responsive ────────────────────────────────────────────── */

/* Desktop: sidebar visible, hamburger hidden */
@media (min-width: 901px) {
  .app-layout .menu-btn { display: none; }
  .app-layout .sidebar { transform: translateX(0); }
}

/* Tablet/Mobile: sidebar becomes drawer */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease-default);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
  }

  .hide-mobile { display: none; }

  .stats-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 14px; }
  #dashboard, .page { padding: 14px; }
  .job-fit-inputs { flex-direction: column; }
  .job-input-group { min-width: 100%; }
  .job-input-group.narrow { flex: 1; min-width: 100%; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 12px; height: 48px; }
  .topbar h1 { font-size: 14px; }
  .last-updated { display: none; }
  #dashboard, .page { padding: 10px; gap: 10px; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 8px; }
}

@media (max-width: 1200px) {
  .trends-charts { grid-template-columns: 1fr; }
  .trends-summary { grid-template-columns: repeat(2, 1fr); }
}
