*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #0d0f14;
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}

body {
  display: flex;
  height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0d0f14;
  color: #e0e0e0;
}

/* SW update toast */
.sw-toast {
  position: fixed; bottom: 24px; left: 0; right: 0;
  z-index: 9999;
  width: fit-content; margin: 0 auto;
  background: #1e293b; color: #38bdf8;
  font-family: 'DM Sans', -apple-system, sans-serif;
  font-size: 13px; font-weight: 600;
  padding: 10px 20px; border-radius: 10px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  cursor: pointer; white-space: nowrap;
  animation: toast-in 0.4s ease-out;
}
.sw-toast.hidden { display: none; }
@keyframes toast-in { from { opacity: 0; translate: 0 20px; } to { opacity: 1; translate: 0 0; } }

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: 280px;
  min-width: 280px;
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 2px solid #0f3460;
  z-index: 10;
}

/* Mobile drag handle (hidden on desktop) */
#mobile-handle {
  display: none;
  justify-content: center;
  align-items: center;
  padding: 10px 0 6px;
  cursor: pointer;
  flex-shrink: 0;
}
#mobile-handle::before {
  content: '';
  width: 36px; height: 4px;
  background: #333;
  border-radius: 2px;
}

#refreshBtn.spinning { animation: spin 0.6s linear infinite; }

/* Search */
#sidebar-search {
  padding: 8px 10px;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

#truckSearchText {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  background: #1a1a2e;
  border: 1px solid #0f3460;
  color: #e0e0e0;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}
#truckSearchText:focus { border-color: #e94560; }
#truckSearchText::placeholder { color: #444; }

.sidebar-settings-btn {
  background: none;
  border: 1px solid #0f3460;
  color: #475569;
  width: 28px; height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
.sidebar-settings-btn:hover { color: #94a3b8; border-color: #334155; }

/* Stat chips (used inside settings modal) */
.stat {
  font-size: 11px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.stat span { color: #aaa; font-weight: 600; }
.stat-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Tool buttons (used inside settings modal) */
.tool-btn {
  background: #1a1a2e;
  color: #94a3b8;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 4px 9px;
  font-size: 11px;
  height: 26px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.tool-btn:hover  { background: #0f3460; color: #e0e0e0; }
.tool-btn.active { background: #e94560; border-color: #e94560; color: #fff; }
.tool-icon { min-width: 26px; padding: 4px; font-size: 13px; }

.tool-btn-sm {
  background: #1a1a2e;
  color: #94a3b8;
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}
.tool-btn-sm.active { background: #e94560; border-color: #e94560; color: #fff; }

/* Section label inside settings modal */
.settings-section-label {
  font-size: 10px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* ─── Truck list ──────────────────────────────────────────────────────────── */
#truck-list {
  flex: 1;
  overflow-y: auto;
}

#truck-list::-webkit-scrollbar { width: 4px; }
#truck-list::-webkit-scrollbar-track { background: #1a1a2e; }
#truck-list::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 2px; }

.truck-item {
  padding: 8px 12px;
  border-bottom: 1px solid #0d0d1f;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: background 0.1s;
}
.truck-item:hover { background: #16213e; }
.truck-item.active {
  background: #0f3460;
  border-left: 3px solid #e94560;
  padding-left: 9px;
}

.truck-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.15);
}

.truck-info { flex: 1; min-width: 0; }

.truck-name {
  font-size: 12px;
  font-weight: 600;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.truck-driver {
  font-weight: 400;
  color: #888;
  font-size: 11px;
}

.truck-meta {
  font-size: 10px;
  color: #555;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.truck-spd {
  font-size: 10px;
  font-weight: 700;
  color: #22c55e;
  flex-shrink: 0;
  min-width: 24px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}
.truck-parked {
  color: #92814a;
  font-weight: 500;
}

.no-results {
  padding: 24px;
  text-align: center;
  color: #444;
  font-size: 13px;
}

/* ─── Map ─────────────────────────────────────────────────────────────────── */
#map {
  flex: 1;
  height: 100%;
  position: relative;
  background: #0d0f14;
}

/* ─── Loading / Error ─────────────────────────────────────────────────────── */
#loadingIndicator {
  position: fixed;
  top: 50%; left: calc(280px + (100vw - 280px) / 2);
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 10px;
  padding: 16px 24px;
  color: #94a3b8;
  font-size: 13px;
  z-index: 100;
}

.spinner {
  width: 18px; height: 18px;
  border: 3px solid #0f3460;
  border-top-color: #e94560;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

#errorMessage {
  position: fixed;
  top: 50%; left: calc(280px + (100vw - 280px) / 2);
  transform: translate(-50%, -50%);
  background: #16213e;
  border: 1px solid #e94560;
  border-radius: 10px;
  padding: 20px 28px;
  color: #fca5a5;
  font-size: 13px;
  z-index: 100;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Info window (dark Mission Control) ──────────────────────────────────── */
.iw-root {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  min-width: 240px;
  max-width: 300px;
  background: #0c1018;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.iw-root::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #38bdf8 40%, #e94560 60%, transparent);
  opacity: 0.5;
}

.iw-head {
  background: #131a28;
  padding: 12px 14px 10px;
  border-bottom: 1px solid #1c2640;
}

.iw-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.3px;
  display: block;
  margin-bottom: 2px;
}

.iw-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.iw-body {
  padding: 10px 14px 4px;
  background: #0c1018;
}

.iw-table {
  border-collapse: collapse;
  width: 100%;
}

.iw-key {
  padding: 3px 10px 3px 0;
  font-family: 'JetBrains Mono', monospace;
  color: #3b4563;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: top;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.iw-val {
  padding: 3px 0;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 500;
}

.iw-foot {
  padding: 6px 14px 12px;
  background: #0c1018;
}
.iw-foot-row {
  display: flex; gap: 6px;
}
.iw-foot-row > * { flex: 1; }

.iw-maps-btn {
  display: block;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  background: transparent;
  color: #38bdf8;
  font-size: 10px;
  font-weight: 600;
  padding: 7px;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  text-decoration: none;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.2s;
}
.iw-maps-btn:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

.iw-track-toggle {
  display: block;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(56, 189, 248, 0.08);
  color: #38bdf8;
  font-size: 10px;
  font-weight: 600;
  padding: 7px;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}
.iw-track-toggle:hover,
.iw-track-toggle.active {
  background: #38bdf8;
  color: #0c1018;
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.3);
}

/* Track period pills */
.iw-track-periods {
  display: flex; gap: 4px; margin-top: 6px;
}
.iw-period-pill {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 600;
  padding: 5px 0; text-align: center;
  background: transparent;
  color: #64748b;
  border: 1px solid #1c2640;
  border-radius: 5px;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: all 0.2s;
}
.iw-period-pill:hover { color: #94a3b8; border-color: #334155; }
.iw-period-pill.active {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}
.iw-track-custom {
  display: flex; flex-direction: column; gap: 4px; margin-top: 5px;
}
.iw-dt-label {
  font-size: 8px; font-weight: 600; color: #475569;
  letter-spacing: 0.5px; text-transform: uppercase;
}
.iw-dt-input {
  width: 100%; box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  background: #0c1018;
  color: #e2e8f0;
  border: 1px solid #1c2640;
  border-radius: 5px;
  padding: 6px 8px;
}
.iw-dt-input:focus { border-color: #38bdf8; outline: none; }
.iw-go-btn { margin-top: 2px; padding: 7px 0; font-size: 10px; }

/* Track line / dot popups */
.iw-track {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: #0c1018;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 170px;
  border: 1px solid #1c2640;
  position: relative;
}
.iw-track::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #38bdf8, transparent);
  opacity: 0.4;
}
.iw-track-title {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 14px;
  color: #38bdf8;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}
.iw-track-btn {
  font-family: 'JetBrains Mono', monospace;
  background: transparent;
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  width: 100%;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.2s;
}
.iw-track-btn:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

.iw-dot {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: #0c1018;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  min-width: 200px;
  border: 1px solid #1c2640;
  position: relative;
}
.iw-dot::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #38bdf8, transparent);
  opacity: 0.3;
}
.iw-dot-ts {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 8px;
  color: #94a3b8;
  letter-spacing: 0.2px;
}
.iw-dot-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 3px;
}
.iw-dot-key {
  font-family: 'JetBrains Mono', monospace;
  color: #3b4563;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.iw-dot-val {
  font-weight: 600;
  color: #cbd5e1;
}

/* ─── Fuel-ups modal ─────────────────────────────────────────────────────── */
#fuelupsOverlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.88);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px) saturate(1.2);
}

#fuelupsModal {
  background: #0c1018;
  border: 1px solid #1c2640;
  border-radius: 14px;
  width: min(740px, 95vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.04),
    0 4px 24px rgba(0,0,0,0.4),
    0 24px 64px rgba(0,0,0,0.5);
  position: relative;
}
#fuelupsModal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, #38bdf8 30%, #e94560 70%, transparent 95%);
  opacity: 0.35;
  z-index: 5;
}

.fuelups-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #1c2640;
  background: #131a28;
}
.fuelups-title {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 13px;
  color: #38bdf8;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fuelups-title-truck {
  color: #64748b;
  font-weight: 500;
}

#fuelupsBody {
  overflow-y: auto;
  padding: 16px 20px;
  color: #e2e8f0;
  font-size: 12px;
  font-family: 'DM Sans', -apple-system, sans-serif;
}
#fuelupsBody::-webkit-scrollbar { width: 5px; }
#fuelupsBody::-webkit-scrollbar-track { background: transparent; }
#fuelupsBody::-webkit-scrollbar-thumb { background: #1c2640; border-radius: 3px; }

.fuelups-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.fuelups-table thead { position: sticky; top: 0; z-index: 1; }
.fuelups-table th {
  font-family: 'JetBrains Mono', monospace;
  padding: 8px 12px;
  color: #3b4563;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  text-align: left;
  background: #131a28;
  border-bottom: 1px solid #1c2640;
}
.fuelups-table th:first-child { border-radius: 6px 0 0 0; }
.fuelups-table th:last-child  { border-radius: 0 6px 0 0; }

.fuelups-table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(28, 38, 64, 0.4);
  vertical-align: middle;
}
.fuelups-table tbody tr { transition: background 0.15s; }
.fuelups-table tbody tr:hover { background: rgba(56, 189, 248, 0.03); }
.fuelups-table tbody tr:nth-child(even) { background: rgba(19, 26, 40, 0.4); }

.fuel-before { color: #fbbf24; font-weight: 600; }
.fuel-after  { color: #22c55e; font-weight: 600; }
.fuel-delta  { color: #22c55e; font-size: 11px; font-weight: 500; }
.fuel-arrow  { color: #3b4563; margin: 0 2px; }
.fuel-dist   { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: #e2e8f0; }
.fuel-loc    { color: #64748b; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Setup Modal — Mission Control ───────────────────────────────────────── */

/* Design tokens */
#setupModal {
  --mc-bg: #0c1018;
  --mc-surface: #131a28;
  --mc-surface-raised: #19223a;
  --mc-border: #1c2640;
  --mc-border-subtle: rgba(56, 189, 248, 0.08);
  --mc-text: #e2e8f0;
  --mc-text-dim: #64748b;
  --mc-text-muted: #3b4563;
  --mc-accent: #e94560;
  --mc-cyan: #38bdf8;
  --mc-green: #22c55e;
  --mc-yellow: #eab308;
  --mc-blue: #3b82f6;
  --mc-font-display: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
  --mc-font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

#setupOverlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.88);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 2000;
  padding: 24px 16px;
  overflow-y: auto;
  backdrop-filter: blur(8px) saturate(1.2);
}

#setupModal {
  background: var(--mc-bg);
  border: 1px solid var(--mc-border);
  border-radius: 16px;
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.04),
    0 4px 24px rgba(0,0,0,0.4),
    0 24px 64px rgba(0,0,0,0.5);
  position: relative;
  overflow: hidden;
}

/* Subtle top accent line */
#setupModal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, var(--mc-cyan) 30%, var(--mc-accent) 70%, transparent 95%);
  opacity: 0.35;
  z-index: 5;
}

/* Background grid texture */
#setupModal::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.015) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

/* Custom scrollbar */
#setupBody::-webkit-scrollbar { width: 5px; }
#setupBody::-webkit-scrollbar-track { background: transparent; }
#setupBody::-webkit-scrollbar-thumb {
  background: var(--mc-border);
  border-radius: 3px;
}
#setupBody::-webkit-scrollbar-thumb:hover { background: #334155; }

#setupHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

#setupTitle {
  font-family: var(--mc-font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--mc-cyan);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* ─── Setup modal body ─────────────────────────────────────────────────────── */
#setupBody {
  padding: 0;
  overflow-y: auto;
  flex: 1;
  position: relative;
  z-index: 1;
}

/* ─── Settings cards ───────────────────────────────────────────────────────── */
.s-card {
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 14px;
  position: relative;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.s-card:last-child { margin-bottom: 0; }
.s-card:hover {
  border-color: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.03);
}

.s-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.s-card-title {
  font-family: var(--mc-font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--mc-text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.s-card-title-icon {
  font-size: 14px;
  opacity: 0.5;
}

/* ─── Fleet stat cards ─────────────────────────────────────────────────────── */
.fleet-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.fleet-stat-card {
  background: var(--mc-bg);
  border: 1px solid var(--mc-border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.fleet-stat-card:hover {
  transform: translateY(-1px);
}

/* Colored top edge */
.fleet-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: #475569;
}
.fleet-stat-card.stat-total::before    { background: var(--mc-blue); box-shadow: 0 0 10px rgba(59, 130, 246, 0.3); }
.fleet-stat-card.stat-moving::before   { background: var(--mc-green); box-shadow: 0 0 10px rgba(34, 197, 94, 0.3); }
.fleet-stat-card.stat-parked::before   { background: var(--mc-yellow); box-shadow: 0 0 10px rgba(234, 179, 8, 0.3); }
.fleet-stat-card.stat-offline::before  { background: #6b7280; }

/* Subtle background glow */
.fleet-stat-card.stat-total    { border-color: rgba(59, 130, 246, 0.15); }
.fleet-stat-card.stat-moving   { border-color: rgba(34, 197, 94, 0.12); }
.fleet-stat-card.stat-parked   { border-color: rgba(234, 179, 8, 0.1); }
.fleet-stat-card.stat-offline  { border-color: var(--mc-border); }

.fleet-stat-value {
  font-family: var(--mc-font-display);
  font-size: 28px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -1px;
  line-height: 1;
}
.fleet-stat-card.stat-total  .fleet-stat-value { color: #93c5fd; }
.fleet-stat-card.stat-moving .fleet-stat-value { color: #86efac; }
.fleet-stat-card.stat-parked .fleet-stat-value { color: #fde68a; }

.fleet-stat-label {
  font-family: var(--mc-font-display);
  font-size: 9px;
  font-weight: 500;
  color: var(--mc-text-dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

/* ─── Server health panel ──────────────────────────────────────────────────── */
.health-panel { padding: 2px 0; }
.health-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.health-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--mc-border);
  border-radius: 6px;
}
.health-label {
  font-size: 9px;
  font-weight: 500;
  color: var(--mc-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 2px;
}
.health-value {
  font-family: var(--mc-font-mono, monospace);
  font-size: 12px;
  font-weight: 600;
  color: var(--mc-text);
}
.health-warn { color: #f59e0b; }
.health-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--mc-text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 4px 0 4px 2px;
}

/* ─── Map layers row ───────────────────────────────────────────────────────── */
.layers-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.rain-controls {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.rain-controls.visible { display: flex; }

.rain-timestamp {
  font-family: var(--mc-font-display);
  font-size: 11px;
  color: var(--mc-text-dim);
}

/* ─── Filters row ──────────────────────────────────────────────────────────── */
.filters-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.s-select {
  flex: 1;
  min-width: 140px;
  font-family: var(--mc-font-body);
  background: var(--mc-bg);
  color: var(--mc-text);
  border: 1px solid var(--mc-border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.s-select:focus {
  border-color: var(--mc-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.1);
}

.custom-range-wrap {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.custom-range-wrap.visible { display: flex; }

.s-input-dt {
  font-family: var(--mc-font-display);
  background: var(--mc-bg);
  border: 1px solid var(--mc-border);
  color: var(--mc-text);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 11px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
.s-input-dt:focus { border-color: var(--mc-cyan); }

.s-btn-apply {
  background: var(--mc-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-family: var(--mc-font-display);
  font-size: 11px;
  cursor: pointer;
  font-weight: 700;
  align-self: flex-end;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: background 0.15s, box-shadow 0.15s;
}
.s-btn-apply:hover {
  background: #d6364e;
  box-shadow: 0 0 16px rgba(233, 69, 96, 0.25);
}

/* ─── Truck assignments table ──────────────────────────────────────────────── */
#setupTable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--mc-font-body);
  font-size: 12px;
}

#setupTable thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

#setupTable th {
  text-align: left;
  padding: 11px 12px;
  font-family: var(--mc-font-display);
  color: var(--mc-text-dim);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  background: var(--mc-surface);
  border-bottom: 1px solid var(--mc-border);
}
#setupTable th:first-child { border-radius: 8px 0 0 0; }
#setupTable th:last-child  { border-radius: 0 8px 0 0; }

#setupTable td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(28, 38, 64, 0.5);
  color: #cbd5e1;
  vertical-align: middle;
}

#setupTable tbody tr { transition: background 0.15s; }
#setupTable tbody tr:hover { background: rgba(56, 189, 248, 0.04); }
#setupTable tbody tr:nth-child(even) { background: rgba(19, 26, 40, 0.5); }
#setupTable tbody tr:nth-child(even):hover { background: rgba(56, 189, 248, 0.06); }

.setup-unitid {
  font-family: var(--mc-font-display);
  font-weight: 700;
  color: var(--mc-cyan);
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.setup-vin {
  font-size: 11px;
  color: var(--mc-text-dim);
  font-family: var(--mc-font-display);
  letter-spacing: 0.2px;
}

.setup-driver-input,
.setup-company-input {
  font-family: var(--mc-font-body);
  background: var(--mc-bg);
  color: var(--mc-text);
  border: 1px solid var(--mc-border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  width: 100%;
  outline: none;
  min-width: 130px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.setup-driver-input:focus,
.setup-company-input:focus {
  border-color: var(--mc-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.1);
}
.setup-driver-input::placeholder,
.setup-company-input::placeholder { color: var(--mc-text-muted); }

.setup-view-btn {
  font-family: var(--mc-font-display);
  background: transparent;
  color: var(--mc-cyan);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.2s;
}
.setup-view-btn:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--mc-cyan);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

/* ctrl-btn / icon-btn used in setup modal */
.ctrl-btn {
  font-family: var(--mc-font-display);
  background: var(--mc-surface);
  color: var(--mc-text);
  border: 1px solid var(--mc-border);
  border-radius: 6px;
  padding: 4px 14px;
  font-size: 11px;
  height: 30px;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.3px;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
  gap: 5px;
}
.ctrl-btn:hover { background: var(--mc-surface-raised); border-color: #334155; }
.icon-btn { min-width: 30px; padding: 4px 6px; }

.ctrl-btn-save {
  background: var(--mc-blue);
  color: #fff;
  border-color: var(--mc-blue);
}
.ctrl-btn-save:hover {
  background: #2563eb;
  border-color: #2563eb;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}

.ctrl-btn-csv {
  background: #065f46;
  color: #6ee7b7;
  border-color: #065f46;
}
.ctrl-btn-csv:hover {
  background: #047857;
  border-color: #047857;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.save-status {
  font-family: var(--mc-font-display);
  font-size: 11px;
  color: var(--mc-green);
  display: none;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  animation: fadeInOut 2s ease;
}
@keyframes fadeInOut {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { opacity: 0; }
}

.src-badge {
  font-family: var(--mc-font-display);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  margin-right: 3px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.src-badge.src-raven    { background: rgba(124,58,237,0.12); color: #a78bfa; border: 1px solid rgba(124,58,237,0.2); }
.src-badge.src-eld-ds   { background: rgba(29,78,216,0.12);  color: #60a5fa; border: 1px solid rgba(29,78,216,0.2); }
.src-badge.src-eld-cx   { background: rgba(146,64,14,0.12);  color: #fbbf24; border: 1px solid rgba(146,64,14,0.2); }
.src-badge.src-merged   { background: rgba(5,150,105,0.12);  color: #34d399; border: 1px solid rgba(5,150,105,0.2); }
.src-badge.src-eld      { background: rgba(29,78,216,0.12);  color: #60a5fa; border: 1px solid rgba(29,78,216,0.2); }
.src-badge.src-motive-1 { background: rgba(14,125,84,0.12);  color: #10b981; border: 1px solid rgba(14,125,84,0.2); }
.src-badge.src-motive-2 { background: rgba(12,74,110,0.12);  color: #38bdf8; border: 1px solid rgba(12,74,110,0.2); }

/* ─── Sessions panel ───────────────────────────────────────────────────────── */
.session-card {
  background: var(--mc-bg);
  border: 1px solid var(--mc-border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
.session-card:last-child { margin-bottom: 0; }
.session-card:hover { border-color: rgba(56, 189, 248, 0.12); }

.session-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.session-ip {
  font-family: var(--mc-font-display);
  font-weight: 600;
  color: var(--mc-text);
  font-size: 12px;
  letter-spacing: 0.2px;
}
.session-meta {
  font-family: var(--mc-font-display);
  color: var(--mc-text-muted);
  font-size: 10px;
  letter-spacing: 0.3px;
}
.session-event {
  font-family: var(--mc-font-body);
  color: var(--mc-text-dim);
  font-size: 11px;
  padding: 1px 0;
}
.session-event b { color: var(--mc-text); }

.session-history-table {
  width: 100%;
  border-collapse: collapse;
}
.session-history-table thead {
  position: sticky;
  top: 0;
  background: var(--mc-surface);
}
.session-history-table th {
  font-family: var(--mc-font-display);
  color: var(--mc-text-muted);
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 6px 8px;
  text-align: left;
  letter-spacing: 0.8px;
}
.session-history-table td {
  font-family: var(--mc-font-body);
  padding: 6px 8px;
  border-bottom: 1px solid rgba(28, 38, 64, 0.3);
  font-size: 12px;
  color: var(--mc-text-dim);
}
.session-history-table td:nth-child(2) {
  font-family: var(--mc-font-display);
  color: var(--mc-text);
  font-weight: 600;
  font-size: 11px;
}
.session-history-table tbody tr:hover { background: rgba(56, 189, 248, 0.03); }

.s-input-filter {
  font-family: var(--mc-font-display);
  width: 130px;
  background: var(--mc-bg);
  border: 1px solid var(--mc-border);
  color: var(--mc-text);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  outline: none;
  transition: border-color 0.2s;
}
.s-input-filter:focus { border-color: var(--mc-cyan); }

/* ─── Telegram panel ───────────────────────────────────────────────────────── */
.tg-config-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.tg-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tg-field-label {
  font-family: var(--mc-font-display);
  font-size: 10px;
  font-weight: 500;
  color: var(--mc-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.s-input {
  font-family: var(--mc-font-display);
  background: var(--mc-bg);
  border: 1px solid var(--mc-border);
  color: var(--mc-text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.s-input:focus {
  border-color: var(--mc-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.1);
}

.tg-user-card {
  background: var(--mc-bg);
  border: 1px solid var(--mc-border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}
.tg-user-card:last-child { margin-bottom: 0; }
.tg-user-card:hover { border-color: rgba(56, 189, 248, 0.12); }

.tg-user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.tg-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tg-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--mc-cyan), var(--mc-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mc-font-display);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.15);
}
.tg-user-name {
  font-family: var(--mc-font-body);
  font-weight: 700;
  color: var(--mc-text);
  font-size: 13px;
}
.tg-user-meta {
  color: var(--mc-text-muted);
  font-size: 11px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.tg-user-meta code {
  font-family: var(--mc-font-display);
  color: var(--mc-text-dim);
  font-size: 10px;
  letter-spacing: 0.3px;
}

.tg-revoke-btn {
  font-family: var(--mc-font-display);
  background: rgba(127, 29, 29, 0.4);
  color: #fca5a5;
  border: 1px solid rgba(153, 27, 27, 0.5);
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  transition: all 0.2s;
}
.tg-revoke-btn:hover {
  background: rgba(153, 27, 27, 0.6);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.15);
}

.tg-prefs-label {
  font-family: var(--mc-font-display);
  color: var(--mc-text-muted);
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.tg-prefs-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tg-pref-chip {
  font-family: var(--mc-font-body);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  color: var(--mc-text-dim);
  white-space: nowrap;
  padding: 4px 10px;
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: 5px;
  transition: all 0.2s;
}
.tg-pref-chip:hover {
  border-color: rgba(56, 189, 248, 0.15);
  color: var(--mc-text);
  background: var(--mc-surface-raised);
}
.tg-pref-chip input[type="checkbox"] {
  accent-color: var(--mc-cyan);
  cursor: pointer;
  width: 12px;
  height: 12px;
}
.tg-pref-chip.report-chip input[type="checkbox"] {
  accent-color: var(--mc-green);
}

/* ─── Staggered card entry ─────────────────────────────────────────────────── */
.settings-panel.active .s-card:nth-child(1) { animation-delay: 0s; }
.settings-panel.active .s-card:nth-child(2) { animation-delay: 0.06s; }
.settings-panel.active .s-card:nth-child(3) { animation-delay: 0.12s; }
.settings-panel.active .s-card {
  animation: mcCardIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}
@keyframes mcCardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Setup modal mobile ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #setupModal { max-width: 100%; border-radius: 10px; }
  .fleet-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .fleet-stat-value { font-size: 22px; }
  .tg-config-row { flex-direction: column; }
}

/* ─── Markers ─────────────────────────────────────────────────────────────── */
.marker-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 2.5px solid #666;
  border-radius: 7px;
  padding: 3px 8px;
  min-width: 38px;
  font-size: 11px;
  font-weight: 700;
  color: #1e293b;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  cursor: pointer;
  white-space: nowrap;
  gap: 4px;
}

/* ─── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body { display: block; position: fixed; inset: 0; overflow: hidden; }

  #map {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
  }

  #sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    min-width: unset;
    max-height: 80vh;
    border-right: none;
    border-top: 2px solid #e94560;
    border-radius: 16px 16px 0 0;
    z-index: 1000;
    transform: translateY(calc(100% - 70px));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
  }
  #sidebar.open { transform: translateY(0); }


  #mobile-handle { display: flex; }

  #truck-list { max-height: calc(80vh - 70px); overflow-y: auto; }

  .truck-item { padding: 10px 14px; }
  .truck-name { font-size: 13px; }
  .truck-meta { font-size: 11px; }
}

/* Google Maps InfoWindow overrides — Mission Control dark */
.gm-style .gm-style-iw-c {
  padding: 0 !important;
  border-radius: 10px !important;
  background: #0c1018 !important;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(56,189,248,0.06) !important;
  max-width: 320px !important;
}
.gm-style .gm-style-iw-d {
  overflow: visible !important;
  background: #0c1018 !important;
}
.gm-style .gm-style-iw-chr {
  background: transparent !important;
}
.gm-style .gm-style-iw-tc::after { background: #0c1018 !important; }
.gm-style .gm-style-iw-t::after {
  background: #0c1018 !important;
}
.gm-style .gm-ui-hover-effect {
  top: 6px !important;
  right: 6px !important;
  opacity: 0.6 !important;
}
.gm-style .gm-ui-hover-effect > span { background-color: #94a3b8 !important; }

/* ─── Stale data banner — Mission Control ────────────────────────────────── */
.stale-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9;
  background: linear-gradient(90deg, rgba(12,16,24,0.97) 0%, rgba(19,26,40,0.97) 50%, rgba(12,16,24,0.97) 100%);
  color: #cbd5e1;
  text-align: center;
  padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  backdrop-filter: blur(12px) saturate(1.3);
  border-bottom: 1px solid rgba(56, 189, 248, 0.12);
  transform: translateY(0);
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.stale-banner.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}
.stale-banner.success {
  background: linear-gradient(90deg, rgba(5,46,22,0.95), rgba(22,101,52,0.95), rgba(5,46,22,0.95));
  border-bottom-color: rgba(34,197,94,0.2);
}
.stale-banner .spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(56,189,248,0.2);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

/* ─── Driver bot config ───────────────────────────────────────────────────── */
.dbot-config-panel { padding: 4px 0; }
.dbot-config-divider { border-top: 1px solid var(--mc-border); margin: 6px 0; opacity: 0.4; }
.dbot-config-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.dbot-config-row label {
  flex: 1;
  font-size: 12px;
  color: var(--mc-text-dim);
}
.dbot-input {
  width: 60px;
  padding: 4px 6px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--mc-border);
  border-radius: 4px;
  color: var(--mc-text);
  font-size: 12px;
  text-align: right;
}
.dbot-unit {
  font-size: 11px;
  color: var(--mc-text-dim);
  min-width: 24px;
}

/* ─── Driver bot group assignment ─────────────────────────────────────────── */
.dbot-assign-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}
.dbot-group-select {
  max-width: 120px;
  padding: 2px 4px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--mc-border);
  border-radius: 4px;
  color: var(--mc-text);
  font-size: 11px;
}
.dbot-prefs-btn {
  background: none;
  border: 1px solid var(--mc-border);
  border-radius: 4px;
  color: var(--mc-text-dim);
  cursor: pointer;
  padding: 1px 4px;
  font-size: 11px;
}
.dbot-prefs-btn:hover { color: var(--mc-text); border-color: var(--mc-text-dim); }
.dbot-prefs-popover {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  background: var(--mc-bg-card, #1e293b);
  border: 1px solid var(--mc-border);
  border-radius: 6px;
  padding: 8px;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.dbot-pref-row {
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--mc-text);
}
.dbot-pref-row label { display: flex; align-items: center; gap: 4px; }
.dbot-pref-divider { border-top: 1px solid var(--mc-border); margin: 6px 0; }
.dbot-th-input {
  width: 50px;
  padding: 2px 4px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--mc-border);
  border-radius: 3px;
  color: var(--mc-text);
  font-size: 11px;
  text-align: right;
  margin-left: auto;
}

/* ──────────────────────────────────────────────────────────────────────────
   Settings UI redesign (2026-04) — sidebar nav, sub-panels, cards, tooltips
   ────────────────────────────────────────────────────────────────────────── */

#settingsShell {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar (desktop ≥1024px) ── */
#settingsSidebar {
  flex: 0 0 170px;
  background: #0f1520;
  border-right: 1px solid var(--mc-border, #1c2640);
  padding: 14px 0;
  overflow-y: auto;
}
.sn-group { margin-bottom: 18px; }
.sn-group-label {
  padding: 4px 18px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: #64748b;
  text-transform: uppercase;
}
.sn-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 18px;
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.sn-item:hover { background: rgba(56, 189, 248, 0.05); }
.sn-item.active {
  background: rgba(56, 189, 248, 0.08);
  border-left-color: var(--mc-cyan, #38bdf8);
  color: var(--mc-cyan, #38bdf8);
}
.sn-icon { font-size: 13px; opacity: 0.85; width: 16px; text-align: center; }
.sn-label { flex: 1; }
.sn-sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height 180ms ease;
}
.sn-sub.open { max-height: 200px; }
.sn-sub-item {
  display: block;
  width: 100%;
  padding: 6px 18px 6px 46px;
  background: transparent;
  border: 0;
  color: #94a3b8;
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.sn-sub-item:hover { color: #e2e8f0; }
.sn-sub-item.active { color: var(--mc-cyan, #38bdf8); font-weight: 600; }

/* ── Panel container ── */
#settingsBody {
  flex: 1;
  min-width: 0;
  padding: 18px 22px;
  overflow-y: auto;
}
.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* ── Bottom nav + sub-strip (mobile) ── */
#settingsBottomNav { display: none; }
#settingsSubStrip { display: none; }

/* New mobile-only elements — hidden by default, shown via mobile media query */
#settingsHamburger { display: none; }
#settingsDrawer    { display: none; }
#settingsScrim     { display: none; }
#settingsSaveBar   { display: none; }

@media (max-width: 767px) {
  /* ── Modal chrome: full-screen, no padding, single scroller ── */
  #setupOverlay {
    padding: 0;
    overflow: hidden;
    backdrop-filter: none;
    background: rgba(4, 6, 12, 0.95);
  }
  #setupModal {
    width: 100%;
    height: 100dvh;
    max-width: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
    box-shadow: none;
  }
  #setupModal::before { display: none; }
  #setupModal::after  { display: none; }

  /* Header: sticky at top, hamburger visible, action buttons hidden */
  #setupHeader {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 10px 12px;
    background: var(--mc-bg);
    border-bottom: 1px solid var(--mc-border);
    gap: 8px;
  }
  #setupHeader > div:last-child {
    /* Container holding save status / CSV / Save All / × */
    margin-left: auto;
    gap: 6px !important;
  }
  /* Hide desktop save status, CSV, Save All on mobile (relocated to save bar) */
  #setupHeader #setupSaveStatus,
  #setupHeader #fuelupsDownloadAllBtn,
  #setupHeader #setupSaveBtn { display: none !important; }

  #settingsHamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--mc-surface);
    border: 1px solid var(--mc-border);
    border-radius: 6px;
    color: var(--mc-cyan);
    font-size: 18px;
    flex-shrink: 0;
  }

  #setupTitle {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  /* Body: single scroller. Inner shells become non-scrolling. */
  #setupBody {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
  }
  #settingsShell {
    display: block;
    overflow: visible;
    flex: 1;
  }
  #settingsSidebar { display: none; }
  #settingsMain {
    display: block;
    overflow: visible;
  }
  #settingsBody {
    overflow: visible;
    padding: 12px;
  }

  /* Retire the old bottom nav — replaced by drawer */
  #settingsBottomNav { display: none !important; }

  /* Sub-strip: sticky just under header, scrollbar hidden */
  #settingsSubStrip {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 4;
    background: #0f1520;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    border-bottom: 1px solid var(--mc-border);
    scrollbar-width: none;
    flex-shrink: 0;
  }
  #settingsSubStrip.hidden { display: none; }
  #settingsSubStrip::-webkit-scrollbar { display: none; }

  /* Sub-strip chips */
  .sn-substrip-item {
    padding: 6px 14px;
    background: var(--mc-surface);
    border: 1px solid var(--mc-border);
    border-radius: 14px;
    color: #94a3b8;
    font-family: inherit;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
  }
  .sn-substrip-item.active {
    background: rgba(56, 189, 248, 0.1);
    border-color: var(--mc-cyan);
    color: var(--mc-cyan);
  }

  /* Release inner per-panel scrollers */
  #sessionHistoryList {
    max-height: none !important;
    overflow: visible !important;
  }
}

/* ─── Settings drawer + scrim (mobile only) ─── */
.settings-drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: 232px;
  max-width: 85vw;
  background: #0f1520;
  border-right: 1px solid var(--mc-border, #1c2640);
  z-index: 2100;
  display: none;
  flex-direction: column;
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.6);
  transform: translateX(-100%);
  transition: transform 220ms ease;
}
.settings-drawer.open { transform: translateX(0); }

.settings-drawer-header {
  height: 44px;
  flex-shrink: 0;
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--mc-border, #1c2640);
  color: var(--mc-cyan, #38bdf8);
  font-family: var(--mc-font-display, 'JetBrains Mono', monospace);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.settings-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.settings-scrim {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.6);
  z-index: 2050;
  display: none;
  opacity: 0;
  transition: opacity 220ms ease;
}
.settings-scrim.open { opacity: 1; }

/* Lock background scroll while drawer is open (mobile) */
body.settings-drawer-open { overflow: hidden; }

@media (max-width: 767px) {
  #settingsDrawer { display: flex; }
  #settingsScrim.open { display: block; }
}

/* ─── Settings mobile save bar ─── */
#settingsSaveBar {
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #0f1520;
  border-top: 1px solid var(--mc-border, #1c2640);
  position: sticky;
  bottom: 0;
  z-index: 5;
}
#settingsSaveBar #setupSaveStatusMobile {
  flex: 1;
  font-size: 11px;
  color: var(--mc-text-dim, #94a3b8);
}
#settingsSaveBar #fuelupsDownloadAllBtnMobile,
#settingsSaveBar #setupSaveBtnMobile {
  height: 36px;
  padding: 0 14px;
  font-size: 12px;
}

/* Save All / CSV are only relevant on the Trucks panel.
   Hide everywhere else (desktop header + mobile save bar). */
#setupHeader #setupSaveBtn,
#setupHeader #fuelupsDownloadAllBtn { display: none; }
#setupModal:has(.settings-panel.active[data-panel="trucks"]) #setupHeader #setupSaveBtn,
#setupModal:has(.settings-panel.active[data-panel="trucks"]) #setupHeader #fuelupsDownloadAllBtn { display: inline-flex; }

@media (max-width: 767px) {
  #setupModal:has(.settings-panel.active[data-panel="trucks"]) #settingsSaveBar { display: flex; }
}

/* ── Alert-type cards ── */
.alert-card {
  background: #131a28;
  border: 1px solid var(--mc-border, #1c2640);
  border-left: 3px solid #64748b;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.alert-card.type-speeding { border-left-color: #eab308; }
.alert-card.type-fuel     { border-left-color: #e94560; }
.alert-card.type-idle     { border-left-color: #3b82f6; }
.alert-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #e2e8f0;
  margin-bottom: 10px;
}
.alert-card-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.alert-card-field label {
  flex: 1;
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 4px;
}
.alert-card-field input {
  width: 80px;
  padding: 5px 8px;
  background: #0c1018;
  border: 1px solid var(--mc-border, #1c2640);
  border-radius: 4px;
  color: #e2e8f0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  text-align: right;
}
.alert-card-field .unit { color: #64748b; font-size: 11px; width: 30px; }

.alert-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 767px) {
  .alert-card-grid { grid-template-columns: 1fr; }
}

/* ── Driver-Bot per-truck expandable cards ── */
.dbot-truck-card {
  background: #131a28;
  border: 1px solid var(--mc-border, #1c2640);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}
.dbot-truck-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
}
.dbot-truck-head-summary {
  flex-basis: 100%;
  font-size: 11px;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
  padding-top: 2px;
}
.dbot-truck-head .unit {
  color: var(--mc-cyan, #38bdf8);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}
.dbot-truck-head .driver {
  color: #cbd5e1;
  font-family: var(--mc-font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: 0.005em;
}
.dbot-truck-head .driver::before {
  content: '·';
  margin: 0 10px 0 6px;
  color: #475569;
  font-weight: 400;
}
.dbot-truck-head .vehicle {
  flex: 1;
  min-width: 0;
  color: #64748b;
  font-family: var(--mc-font-display, 'JetBrains Mono', monospace);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dbot-truck-head .vehicle::before {
  content: '·';
  margin: 0 10px 0 6px;
  color: #475569;
  text-transform: none;
}
.dbot-truck-head .badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.dbot-truck-head .badge-global { background: #1f2937; color: #94a3b8; }
.dbot-truck-head .badge-custom { background: rgba(56, 189, 248, 0.15); color: var(--mc-cyan, #38bdf8); }
.dbot-truck-body {
  display: none;
  padding: 12px 14px 16px;
  border-top: 1px solid var(--mc-border, #1c2640);
}
.dbot-truck-card.open .dbot-truck-body { display: block; }
.dbot-assign-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
@media (max-width: 767px) {
  .dbot-assign-row { grid-template-columns: 1fr; }
}
.dbot-assign-row label { font-size: 11px; color: #64748b; display: block; margin-bottom: 4px; }
.dbot-assign-row select {
  width: 100%;
  padding: 6px 8px;
  background: #0c1018;
  border: 1px solid var(--mc-border, #1c2640);
  border-radius: 4px;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 12px;
}
.dbot-prefs-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}
.dbot-prefs-chips label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #0c1018;
  border: 1px solid var(--mc-border, #1c2640);
  border-radius: 14px;
  font-size: 11px;
  color: #cbd5e1;
  cursor: pointer;
}
.dbot-prefs-chips input[type="checkbox"] { margin: 0; }
.dbot-hint {
  margin-top: 10px;
  font-size: 11px;
  color: #64748b;
  font-style: italic;
}

/* ── Trucks tab — card layout on mobile ── */
.trucks-card {
  background: #131a28;
  border: 1px solid var(--mc-border, #1c2640);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
.trucks-card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.trucks-card-head .unit {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--mc-cyan, #38bdf8);
  font-size: 15px;
}
.trucks-card-head .vehicle { color: #cbd5e1; font-size: 13px; }
.trucks-card .vin {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #64748b;
  word-break: break-all;
  margin-bottom: 8px;
}
.trucks-card .sources { margin-bottom: 10px; }
.trucks-card .inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.trucks-card .inputs input {
  padding: 6px 8px;
  background: #0c1018;
  border: 1px solid var(--mc-border, #1c2640);
  border-radius: 4px;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 12px;
}
.trucks-card .fuel-btn {
  width: 100%;
  padding: 8px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid var(--mc-cyan, #38bdf8);
  border-radius: 6px;
  color: var(--mc-cyan, #38bdf8);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

#trucksDesktop { display: block; }
#trucksMobile  { display: none; }
@media (max-width: 767px) {
  #trucksDesktop { display: none; }
  #trucksMobile  { display: block; }
}

/* ── Alert Log ── */
.alertlog-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.alertlog-filters select,
.alertlog-filters input {
  padding: 6px 10px;
  background: #0c1018;
  border: 1px solid var(--mc-border, #1c2640);
  border-radius: 4px;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 12px;
}
.alertlog-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #131a28;
  border: 1px solid var(--mc-border, #1c2640);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}
.alertlog-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  min-width: 58px;
  text-align: center;
}
.alertlog-badge.speeding { background: rgba(234, 179, 8, 0.18); color: #eab308; }
.alertlog-badge.lowFuel  { background: rgba(233, 69, 96, 0.18); color: #e94560; }
.alertlog-badge.idle     { background: rgba(59, 130, 246, 0.18); color: #3b82f6; }
.alertlog-row .unit {
  font-family: 'JetBrains Mono', monospace;
  color: var(--mc-cyan, #38bdf8);
  font-weight: 600;
  min-width: 60px;
}
.alertlog-row .driver {
  color: #cbd5e1;
  font-family: var(--mc-font-body, 'DM Sans', system-ui, sans-serif);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.alertlog-row .driver::before {
  content: '·';
  margin: 0 8px 0 4px;
  color: #475569;
  font-weight: 400;
}
.alertlog-row .detail { flex: 1; color: #94a3b8; }
.alertlog-row .status-active   { color: #e94560; font-weight: 600; }
.alertlog-row .status-resolved { color: #22c55e; font-weight: 600; }
.alertlog-row .ts { color: #64748b; font-size: 11px; }
.alertlog-mute {
  background: transparent; border: 1px solid #f59e0b; color: #f59e0b;
  border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer;
  transition: background .15s, color .15s;
}
.alertlog-mute:hover { background: #f59e0b; color: #fff; }
.alertlog-dismiss {
  background: transparent; border: 1px solid #e94560; color: #e94560;
  border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer;
  transition: background .15s, color .15s;
}
.alertlog-dismiss:hover { background: #e94560; color: #fff; }
.alertlog-mute:disabled, .alertlog-dismiss:disabled { opacity: .5; cursor: default; }
.alertlog-row .status-muted { color: #f59e0b; font-weight: 600; }

/* Alert Log: filters stack 2 cols, rows become cards (mobile) */
@media (max-width: 767px) {
  .alertlog-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }
  .alertlog-filters > * {
    width: 100%;
    min-width: 0;
  }
  .alertlog-filters input,
  .alertlog-filters select {
    width: 100%;
    height: 36px;
    font-size: 14px;
  }
  .alertlog-filters > span {
    grid-column: 1 / -1;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
  }
  .alertlog-filters > span input[type="date"] {
    height: 36px;
    font-size: 13px !important;
    padding: 4px 8px !important;
  }
  .alertlog-filters button { height: 36px; }

  .alertlog-row {
    display: grid;
    grid-template-columns: auto auto 1fr auto auto;
    column-gap: 8px;
    row-gap: 6px;
    padding: 10px 12px;
    align-items: center;
  }
  .alertlog-row .alertlog-badge   { grid-row: 1; grid-column: 1; }
  .alertlog-row .unit              { grid-row: 1; grid-column: 2; }
  .alertlog-row .driver            { grid-row: 1; grid-column: 3; min-width: 0; }
  .alertlog-row .status-active,
  .alertlog-row .status-resolved,
  .alertlog-row .status-muted      { grid-row: 1; grid-column: 4 / -1; justify-self: end; }
  .alertlog-row .detail            { grid-row: 2; grid-column: 1 / -1; line-height: 1.4; }
  .alertlog-row .ts                { grid-row: 3; grid-column: 1 / 4; }
  .alertlog-row .alertlog-mute     { grid-row: 3; grid-column: 4; height: 28px; padding: 0 10px; justify-self: end; }
  .alertlog-row .alertlog-dismiss  { grid-row: 3; grid-column: 5; height: 28px; padding: 0 10px; justify-self: end; }
}

/* ── Info tooltips ── */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 50%;
  color: #94a3b8;
  font-family: serif;
  font-style: italic;
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  position: relative;
}
.tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: #0c1018;
  border: 1px solid var(--mc-cyan, #38bdf8);
  border-radius: 6px;
  padding: 6px 10px;
  color: #e2e8f0;
  font-family: inherit;
  font-style: normal;
  font-size: 11px;
  font-weight: 400;
  white-space: normal;
  width: 220px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.tip[data-tip-pos="left"]:hover::after {
  left: auto;
  right: 20px;
}
@media (max-width: 767px) {
  .tip:hover::after,
  .tip[data-tip-pos="left"]:hover::after {
    left: 50%;
    right: auto;
    top: 20px;
    transform: translateX(-50%);
  }
}

/* ─── Destinations feature ───────────────────────────────────────── */
.dest-iw-section {
  border-top: 1px solid #1e293b;
  margin-top: 12px;
  padding-top: 12px;
}
.dest-iw-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  font-size: 10px;
  line-height: 1.6;
  margin-bottom: 8px;
}
.dest-iw-lbl {
  color: #475569;
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.05em;
}
.dest-iw-val { color: #e0e0e0; }
.dest-iw-blue { color: #60a5fa; font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.dest-iw-dim  { color: #64748b; font-weight: 400; }
.dest-iw-pill {
  display: inline-block;
  font-size: 8px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.03em;
}
.dest-iw-btns { display: flex; gap: 6px; }
.dest-iw-btn {
  flex: 1;
  background: #1a2e42;
  color: #60a5fa;
  border: 1px solid #1e3a5f;
  border-radius: 3px;
  padding: 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  font-family: 'DM Sans', system-ui, sans-serif;
}
.dest-iw-btn:hover { background: #223a52; }
.dest-iw-btn.dest-iw-danger {
  background: #2a1a1f;
  color: #f87171;
  border-color: #5f1e2a;
}
.dest-iw-btn.dest-iw-danger:hover { background: #3a1f27; }
.dest-iw-set-btn {
  width: 100%;
  background: rgba(233, 69, 96, 0.12);
  color: #e94560;
  border: 1px solid #e94560;
  border-radius: 3px;
  padding: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  font-family: 'DM Sans', system-ui, sans-serif;
}
.dest-iw-set-btn:hover { background: rgba(233, 69, 96, 0.2); }

.dest-sidebar-line {
  margin-top: 5px;
  padding: 3px 0 3px 7px;
  border-left: 3px solid #94a3b8;
}
.dest-sidebar-addr {
  color: #cbd5e1;
  font-size: 10px;
  line-height: 1.35;
  word-break: break-word;
}
.dest-sidebar-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Destinations settings panel */
.dest-settings-panel .dest-table {
  background: #0d0f14;
  border: 1px solid #16213e;
  border-radius: 6px;
  overflow: hidden;
  font-size: 11px;
}
.dest-settings-panel .dest-table .th,
.dest-settings-panel .dest-table .tr {
  display: grid;
  grid-template-columns: 90px 1fr 150px 150px 90px 32px;
  gap: 10px;
  padding: 10px 14px;
  align-items: center;
}
.dest-settings-panel .dest-table .th {
  background: #1a1a2e;
  border-bottom: 1px solid #16213e;
  font-size: 9px;
  color: #475569;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dest-settings-panel .dest-table .tr {
  border-bottom: 1px solid #16213e;
}
.dest-settings-panel .dest-table .tr.ontime  { background: rgba(16,185,129,0.05); }
.dest-settings-panel .dest-table .tr.tight   { background: rgba(245,158,11,0.08); }
.dest-settings-panel .dest-table .tr.late    { background: rgba(233,69,96,0.08);  }
.dest-settings-panel .dest-table .tr.arrived { background: rgba(96,165,250,0.08); }
.dest-settings-panel .dest-set-btn {
  background: #e94560;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 5px 12px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

/* Destinations: stacked cards on mobile */
@media (max-width: 767px) {
  .dest-settings-panel .dest-table .th { display: none !important; }

  .dest-settings-panel .dest-table {
    background: transparent;
    border: 0;
    overflow: visible;
  }
  .dest-settings-panel .dest-table .tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "truck   status"
      "address address"
      "eta     deadline"
      "action  action";
    gap: 6px 12px;
    background: var(--mc-surface, #131a28);
    border: 1px solid var(--mc-border, #1c2640);
    border-left: 3px solid var(--mc-cyan, #38bdf8);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  .dest-settings-panel .dest-table .tr.completed { border-left-color: #22c55e; }
  .dest-settings-panel .dest-table .tr.late      { border-left-color: var(--mc-accent, #e94560); }
  .dest-settings-panel .dest-table .tr.arrived   { border-left-color: #60a5fa; }

  /* Render order from destinations.js: truck, address, eta, deadline, status, action */
  .dest-settings-panel .dest-table .tr > div:nth-child(1) { grid-area: truck;   text-align: left; }
  .dest-settings-panel .dest-table .tr > div:nth-child(2) { grid-area: address; text-align: left; font-size: 12px; line-height: 1.4; color: var(--mc-text, #e2e8f0); }
  .dest-settings-panel .dest-table .tr > div:nth-child(3) { grid-area: eta;      text-align: left !important; font-size: 11px; }
  .dest-settings-panel .dest-table .tr > div:nth-child(4) { grid-area: deadline; text-align: left !important; font-size: 11px; }
  .dest-settings-panel .dest-table .tr > div:nth-child(5) { grid-area: status;   justify-self: end; }
  .dest-settings-panel .dest-table .tr > div:nth-child(6) { grid-area: action;   text-align: left; padding-top: 4px; }

  .dest-settings-panel .dest-table .tr > div:nth-child(3)::before {
    content: 'ETA';
    display: block;
    font-size: 9px;
    color: var(--mc-text-muted, #475569);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: var(--mc-font-display, 'JetBrains Mono', monospace);
  }
  .dest-settings-panel .dest-table .tr > div:nth-child(4)::before {
    content: 'Deadline';
    display: block;
    font-size: 9px;
    color: var(--mc-text-muted, #475569);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: var(--mc-font-display, 'JetBrains Mono', monospace);
  }
}

/* Destinations modal */
.dest-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.dest-modal-overlay.open { display: flex; }
.dest-modal {
  background: #0d0f14;
  border: 2px solid #3b82f6;
  border-radius: 10px;
  padding: 18px;
  width: 420px;
  max-width: 92vw;
  color: #e0e0e0;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}
.dest-modal h3 { font-size: 14px; margin-bottom: 12px; display: flex; justify-content: space-between; }
.dest-modal .field { margin-bottom: 12px; }
.dest-modal .field label {
  display: block;
  font-size: 10px;
  color: #475569;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.dest-modal input[type="text"],
.dest-modal input[type="datetime-local"] {
  width: 100%;
  background: #1a1a2e;
  border: 1px solid #16213e;
  color: #e0e0e0;
  border-radius: 4px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12px;
}
.dest-modal .suggestions {
  background: #1a1a2e;
  border: 1px solid #16213e;
  border-radius: 4px;
  margin-top: 2px;
  max-height: 160px;
  overflow-y: auto;
  display: none;
}
.dest-modal .suggestions.open { display: block; }
.dest-modal .suggestions .item {
  padding: 8px 10px;
  font-size: 11px;
  border-bottom: 1px solid #16213e;
  cursor: pointer;
  color: #94a3b8;
}
.dest-modal .suggestions .item:hover { background: #16213e; color: #e0e0e0; }
.dest-modal .preview {
  background: rgba(96,165,250,0.1);
  border-left: 3px solid #60a5fa;
  padding: 10px;
  border-radius: 4px;
  font-size: 11px;
  margin-top: 6px;
  display: none;
}
.dest-modal .preview.open { display: block; }
.dest-modal .preview .big {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: #60a5fa;
  font-size: 16px;
}
.dest-modal .btns { display: flex; gap: 8px; margin-top: 14px; }
.dest-modal .btns button {
  flex: 1;
  background: #1a1a2e;
  color: #94a3b8;
  border: 1px solid #16213e;
  border-radius: 4px;
  padding: 10px;
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}
.dest-modal .btns .confirm {
  background: #e94560;
  color: white;
  border-color: #e94560;
  flex: 2;
}

/* ─── Truck details popup prefs ────────────────────────────────────────────── */
.popup-prefs-group {
  margin-bottom: 18px;
}
.popup-prefs-legend {
  font-family: var(--mc-font-display);
  font-size: 10px;
  font-weight: 600;
  color: var(--mc-text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--mc-border);
}
.popup-prefs-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  font-size: 13px;
  color: var(--mc-text);
  cursor: pointer;
  border-radius: 4px;
}
.popup-prefs-row:hover {
  background: rgba(255,255,255,0.03);
}
.popup-prefs-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #3b82f6;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Broadcast console (driver-bot Broadcast + Broadcast Log panels) ─── */
.bcast-recipient-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid #1c2640;
  border-radius: 6px;
  background: #0c1424;
}
.bcast-recipient-list .bcast-row { cursor: pointer; }
.bcast-recipient-list .bcast-row:hover { background: #131c30; }
.bcast-chip {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  color: #cbd5e1;
  background: #1e293b;
  border: 1px solid #1c2640;
  border-radius: 999px;
  white-space: nowrap;
}

/* Broadcast panel: touch-friendly layout (mobile) */
@media (max-width: 767px) {
  .settings-panel[data-panel="driverbot-broadcast"] .bcast-row {
    padding: 10px 8px !important;
    gap: 10px !important;
  }
  .settings-panel[data-panel="driverbot-broadcast"] .bcast-recipient-list {
    max-height: none !important;
  }
  .settings-panel[data-panel="driverbot-broadcast"] .bcast-recipient-list label {
    min-height: 36px;
    padding: 8px;
    font-size: 13px;
  }
  .settings-panel[data-panel="driverbot-broadcast"] textarea#bcastText {
    font-size: 16px;
    min-height: 140px;
  }
  .settings-panel[data-panel="driverbot-broadcast"] input[type="file"] {
    width: 100%;
    margin-bottom: 6px;
  }
  .settings-panel[data-panel="driverbot-broadcast"] #bcastSendBtn {
    width: 100%;
    height: 44px;
    font-size: 14px;
  }
  .settings-panel[data-panel="driverbot-broadcast"] #bcastSearch {
    flex: 1 1 100% !important;
    width: 100%;
    font-size: 14px !important;
    height: 36px;
  }
}

/* Settings: touch targets, iOS zoom prevention, generic mobile polish */
@media (max-width: 767px) {
  /* Prevent iOS zoom-on-focus by making text inputs >=16px */
  #setupBody input[type="text"],
  #setupBody input[type="number"],
  #setupBody input[type="search"],
  #setupBody input[type="email"],
  #setupBody input[type="password"],
  #setupBody input[type="tel"],
  #setupBody input[type="url"],
  #setupBody input[type="datetime-local"],
  #setupBody input[type="time"],
  #setupBody select,
  #setupBody textarea {
    font-size: 16px;
  }
  #setupBody button { min-height: 36px; }

  /* Custom range datetime: stack vertically, full-width Apply */
  .custom-range-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .custom-range-wrap .s-btn-apply { width: 100%; }

  /* Office Bot config row: full-width inputs */
  .tg-config-row .tg-field input,
  .tg-config-row .tg-field { width: 100% !important; }
  .tg-config-row > div:last-child { width: 100%; justify-content: flex-end; }
}
