:root {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --bg-hover: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #0284c7;
  
  --accent-primary: #0284c7;
  --accent-cyan: #0284c7;
  --accent-amber: #d97706;
  --accent-green: #16a34a;
  --accent-red: #dc2626;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* HEADER */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
}

.logo-title h1 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.sub-title {
  font-size: 11px;
  color: var(--text-secondary);
}

.header-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-chip {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card-subtle);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  min-width: 64px;
}

.metric-chip.chip-total {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

.metric-chip.chip-online {
  background-color: #ecfdf5;
  border-color: #a7f3d0;
}

.metric-chip.chip-online .chip-val {
  color: #059669;
}

.metric-chip.chip-stale {
  background-color: #fffbeb;
  border-color: #fde68a;
}

.metric-chip.chip-stale .chip-val {
  color: #d97706;
}

.metric-chip.chip-offline {
  background-color: #fef2f2;
  border-color: #fecaca;
}

.metric-chip.chip-offline .chip-val {
  color: #dc2626;
}

.status-dot-mini {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 2px;
}

.status-dot-mini.online {
  background: #10b981;
  box-shadow: 0 0 4px #10b981;
}

.status-dot-mini.stale {
  background: #f59e0b;
}

.status-dot-mini.offline {
  background: #ef4444;
}

.header-divider {
  width: 1px;
  height: 24px;
  background: #e2e8f0;
  margin: 0 2px;
}

.header-admin-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip-label {
  font-size: 8.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
}

.chip-val {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.btn-export-header {
  padding: 6px 10px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border: 1px solid #0284c7;
  border-radius: 6px;
  color: #ffffff;
  font-weight: 700;
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.2);
}

.btn-export-header:hover {
  background: #0369a1;
  transform: translateY(-1px);
}

.btn-delete-header {
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  color: #dc2626;
  font-weight: 700;
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-delete-header:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 20px;
  background-color: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 8px rgba(22, 163, 74, 0.6);
  animation: pulse 2s infinite;
}

.status-indicator.offline {
  background-color: #fef2f2;
  border-color: #fecaca;
}

.status-indicator.offline .status-dot {
  background-color: var(--accent-red);
  box-shadow: none;
  animation: none;
}

.status-text {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent-green);
}

.status-indicator.offline .status-text {
  color: var(--accent-red);
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* MAIN LAYOUT */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* SIDEBAR MOBILE TOGGLE BUTTONS & DRAWER */
.btn-toggle-sidebar {
  display: none;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0284c7;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-toggle-sidebar:hover {
  background: #e0f2fe;
}

.toggle-badge,
.drawer-badge {
  background: #0284c7;
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
}

.btn-close-sidebar {
  display: none;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 18px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-close-sidebar:hover {
  background: #fee2e2;
  color: #ef4444;
}

.btn-map-fleet-drawer {
  display: none;
  background: #f0f9ff;
  border: 1px solid #0284c7;
  color: #0284c7;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  align-items: center;
  gap: 4px;
}

.btn-map-fleet-drawer:hover {
  background: #0284c7;
  color: #ffffff;
}

.sidebar-backdrop {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 1050;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  display: block;
}

/* SIDEBAR FLEET LIST */
.sidebar {
  width: 330px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
}

.badge {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
}

.search-box {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
}

.search-box input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 11px;
  outline: none;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.search-box input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.sidebar-filter-section {
  padding: 6px 10px 6px 10px;
  background-color: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-color);
}

.fleet-filter-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  background: #f1f5f9;
  padding: 2px;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
}

.filter-tab {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 5px 2px;
  font-size: 9.5px;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-tab:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.7);
}

.filter-tab.active {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(2, 132, 199, 0.25);
}

.fleet-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  background-color: var(--bg-card-subtle);
}

/* HIGH DENSITY FLEET CARD */
.fleet-card {
  padding: 8px 10px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-left: 3.5px solid #cbd5e1;
  border-radius: 7px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.fleet-card.online {
  border-left-color: #10b981;
}

.fleet-card.stale {
  border-left-color: #f59e0b;
}

.fleet-card.offline {
  border-left-color: #ef4444;
}

.fleet-card:hover {
  background-color: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.fleet-card.selected {
  border-color: var(--accent-primary);
  border-left-color: var(--accent-primary);
  border-left-width: 4px;
  background-color: #f0f9ff;
  box-shadow: 0 0 0 1px var(--accent-primary);
}

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

.fleet-title {
  font-weight: 800;
  font-size: 12.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.fleet-badge {
  font-size: 8.5px;
  padding: 1.5px 5px;
  border-radius: 4px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.fleet-badge.online {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.fleet-badge.stale {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}

.fleet-badge.offline {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.status-dot-sm {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot-sm.online {
  background-color: var(--accent-green);
  box-shadow: 0 0 4px rgba(22, 163, 74, 0.7);
}

.status-dot-sm.stale {
  background-color: #f59e0b;
}

.status-dot-sm.offline {
  background-color: var(--accent-red);
}

.fleet-oper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: #475569;
  background: #f8fafc;
  padding: 2.5px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.fleet-oper-row strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.fleet-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9.5px;
  color: #64748b;
}

.fleet-meta-row strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* MAP SECTION */
.map-section {
  flex: 1;
  position: relative;
}

.map-view {
  width: 100%;
  height: 100%;
}

/* FLOATING TELEMETRY INSPECTOR (STRUCTURED SECTIONS A-F) */
.telemetry-inspector {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: auto;
  width: 380px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 40px);
  background-color: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15), 0 2px 6px rgba(15, 23, 42, 0.05);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  animation: modal-fade 0.2s ease;
}

.inspector-content-scroll {
  overflow-y: auto;
  max-height: calc(100vh - 160px);
  padding-right: 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inspector-content-scroll::-webkit-scrollbar {
  width: 4px;
}

.inspector-content-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
}

.unit-id-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.unit-id-badge h3 {
  font-size: 16px;
  font-weight: 900;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.1;
}

.unit-rx-age {
  font-size: 10px;
  color: #94a3b8;
  font-weight: 500;
  font-family: var(--font-main);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  font-family: var(--font-main);
  padding: 4px 10px;
  border-radius: 5px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  line-height: 1;
}

.status-badge.online {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.status-badge.stale {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}

.status-badge.offline {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

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

.btn-trail-toggle {
  height: 24px;
  padding: 0 9px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-main);
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  line-height: 1;
  white-space: nowrap;
}

.btn-trail-toggle:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-trail-toggle.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(2, 132, 199, 0.25);
}

.trail-toggle-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
  transition: all 0.15s ease;
}

.btn-trail-toggle.active .trail-toggle-dot {
  background: #ffffff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
}

.btn-close-insp {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  transition: all 0.15s ease;
}

.btn-close-insp:hover {
  background-color: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}

/* ================= FLOATING MAP CONTROLS ================= */
.map-controls-bar {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 4px 6px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
  pointer-events: auto;
}

.map-layer-selector {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.layer-btn {
  background: transparent;
  border: none;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.layer-btn:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.8);
}

.layer-btn.active {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);
}

.btn-fit-fleet {
  padding: 5px 12px;
  background: #ffffff;
  border: 1px solid #0284c7;
  color: #0284c7;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-fit-fleet:hover {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

@media (max-width: 768px) {
  .map-controls-bar {
    top: 8px;
    left: 8px;
    right: 8px;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .layer-btn {
    padding: 4px 6px;
    font-size: 10px;
  }
}

/* ================= SECTION B, C, D, E, F STYLES ================= */
.insp-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.insp-section-title {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #64748b;
  margin-bottom: 2px;
}

.insp-oper-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
}

.insp-data-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.data-label {
  font-size: 9px;
  color: #94a3b8;
  font-weight: 600;
  font-family: var(--font-main);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.data-val-primary {
  font-size: 16px;
  font-weight: 900;
  color: #0f172a;
  font-family: var(--font-mono);
  line-height: 1.2;
}

.data-val {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
  font-family: var(--font-mono);
  line-height: 1.2;
}

.data-val-mono {
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  font-family: var(--font-main);
  padding: 3px 8px;
  border-radius: 4px;
  width: fit-content;
  line-height: 1;
}

.badge-status-pill.on {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.badge-status-pill.off {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

/* ================= TILT / INCLINOMETER WIDGET ================= */
.tilt-gauge-container {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
}

.tilt-gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.tilt-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--font-main);
  color: var(--text-primary);
}

.tilt-status-badge {
  font-size: 9px;
  font-weight: 800;
  font-family: var(--font-main);
  padding: 3px 8px;
  border-radius: 4px;
  line-height: 1;
}

.tilt-status-badge.normal {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.tilt-status-badge.warning {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}

.tilt-status-badge.danger {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.tilt-gauge-body {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  align-items: start;
}

.tilt-meter-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}

.tilt-meter-label {
  font-size: 8px;
  font-weight: 600;
  font-family: var(--font-main);
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tilt-meter-val {
  font-size: 18px;
  font-weight: 900;
  color: #10b981;
  font-family: var(--font-mono);
  line-height: 1.1;
  margin: 3px 0 5px 0;
}

.tilt-meter-val small {
  font-size: 10px;
}

.tilt-bar-bg {
  width: 100%;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}

.tilt-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease, background 0.3s ease;
}

.tilt-sub-details {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 2px;
}

.tilt-sub-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.tilt-sub-item .sub-label {
  font-size: 9px;
  font-family: var(--font-main);
  color: #94a3b8;
  font-weight: 600;
}

.tilt-sub-item strong {
  font-size: 10.5px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 700;
}

.gs-raw-text {
  font-family: var(--font-mono);
  font-size: 9px;
  color: #94a3b8;
  font-weight: 500;
}

.fleet-tilt-badge {
  font-size: 8.5px;
  font-weight: 800;
  padding: 1.5px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.fleet-tilt-badge.normal {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.fleet-tilt-badge.warning {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.fleet-tilt-badge.danger {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* ================= SECTION D & E: LOCATION & COMMUNICATION DELAY ================= */
.insp-loc-comm-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.loc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.trail-info-badge,
#insp-trail-count {
  font-size: 9.5px !important;
  font-weight: 700 !important;
  font-family: var(--font-main) !important;
  color: #0284c7 !important;
  background: #e0f2fe !important;
  padding: 2.5px 7px !important;
  border-radius: 4px !important;
  border: 1px solid #bae6fd !important;
  display: inline-flex !important;
  align-items: center !important;
  width: fit-content !important;
  max-width: 100% !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.comm-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.comm-item.full-width {
  grid-column: span 2;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 2px;
}

.comm-label {
  font-size: 8.5px;
  text-transform: uppercase;
  font-family: var(--font-main);
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.comm-val {
  font-size: 10.5px;
  color: #0f172a;
  font-family: var(--font-mono);
  font-weight: 700;
}

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

.delay-tag {
  font-size: 9px;
  font-weight: 800;
  font-family: var(--font-main);
  padding: 3px 8px;
  border-radius: 4px;
  line-height: 1;
  white-space: nowrap;
}

.delay-tag.realtime {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.delay-tag.delayed {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* ================= SECTION F: FOOTNOTE & ACTIONS ================= */
.insp-tech-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid #e2e8f0;
}

.tech-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9.5px;
  font-family: var(--font-main);
  color: #94a3b8;
}

.tech-meta-row strong {
  color: #475569;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 9.5px;
}

.inspector-actions {
  display: flex;
  gap: 6px;
}

.btn-action-download {
  flex: 2;
  padding: 8px 12px;
  font-size: 11px;
  font-family: var(--font-main);
  border-radius: 6px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border: 1px solid #0284c7;
  color: #ffffff;
  transition: all 0.2s ease;
}

.btn-action-download:hover {
  background: #0369a1;
}

.btn-action-delete-subtle {
  flex: 1;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #94a3b8;
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-main);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.btn-action-delete-subtle:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

/* MODAL STYLES */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  animation: modal-fade 0.2s ease;
}

@keyframes modal-fade {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title h3 {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-select {
  padding: 8px 10px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  font-family: var(--font-main);
  transition: all 0.15s ease;
}

.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  font-family: inherit;
  transition: all 0.15s ease;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.date-inputs-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

.date-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.date-sublabel {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.format-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.format-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.format-card:hover {
  border-color: #cbd5e1;
  background-color: #ffffff;
}

.format-card.selected {
  border-color: var(--accent-primary);
  background-color: #f0f9ff;
}

.format-card input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--accent-primary);
}

.format-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.format-info strong {
  font-size: 12px;
  color: var(--text-primary);
}

.format-info small {
  font-size: 10px;
  color: var(--text-muted);
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background-color: var(--bg-card-subtle);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.btn-secondary {
  padding: 7px 14px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-primary {
  padding: 7px 16px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border: 1px solid #0284c7;
  border-radius: 6px;
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
}

.btn-primary:hover {
  background: #0369a1;
  box-shadow: 0 4px 8px rgba(2, 132, 199, 0.35);
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 12px;
}

.btn-action-delete {
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #dc2626;
  font-weight: 700;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-action-delete:hover {
  background: #dc2626;
  color: #ffffff;
}

.btn-danger {
  padding: 7px 16px;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  border: 1px solid #dc2626;
  border-radius: 6px;
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
  background: #b91c1c;
  box-shadow: 0 4px 8px rgba(220, 38, 38, 0.35);
}

.header-danger {
  border-bottom-color: #fecaca !important;
  background-color: #fff1f2 !important;
}

.header-danger h3 {
  color: #991b1b !important;
}

.alert-box-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #dc2626;
  padding: 10px 12px;
  border-radius: 6px;
  color: #991b1b;
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 12px;
}

.error-banner {
  background: #fee2e2;
  border: 1px solid #f87171;
  color: #b91c1c;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 10px;
}

.success-banner {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #15803d;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 10px;
}

/* ================= DEDICATED MOBILE BOTTOM NAVIGATION & STATS ================= */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
  z-index: 1300;
  padding: 4px 16px env(safe-area-inset-bottom, 4px) 16px;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-items: center;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: all 0.15s ease;
  position: relative;
  touch-action: manipulation;
}

.nav-tab-btn .nav-icon {
  font-size: 18px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.nav-tab-btn .nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.nav-tab-btn .nav-badge {
  position: absolute;
  top: 1px;
  right: calc(50% - 18px);
  background: #0284c7;
  color: #ffffff;
  font-size: 8.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
  border: 1.5px solid #ffffff;
}

.nav-tab-btn:hover {
  color: #0f172a;
}

.nav-tab-btn.active {
  color: #0284c7;
}

.nav-tab-btn.active .nav-icon {
  transform: translateY(-2px) scale(1.1);
}

.bottom-sheet-handle {
  display: none;
  width: 36px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  margin: 0 auto 8px auto;
}

/* MOBILE STATS SCREEN VIEW */
.mobile-stats-screen {
  background: var(--bg-surface);
  flex-direction: column;
  overflow-y: auto;
  padding: 14px;
}

.mobile-stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.mobile-stats-header h2 {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}

.mobile-stats-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-actions-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  margin-top: 4px;
}

.mobile-actions-card h3 {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.m-stat-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m-stat-label {
  font-size: 9.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
}

.m-stat-val {
  font-size: 18px;
  font-weight: 900;
  color: #0f172a;
  font-family: var(--font-mono);
}

.m-stat-box small {
  font-size: 9.5px;
  color: #94a3b8;
}

.m-stat-box.highlight-online {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
}

.m-stat-box.highlight-online .m-stat-val {
  color: #10b981;
}

.m-stat-box.highlight-packets {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.3);
}

.m-stat-box.highlight-packets .m-stat-val {
  color: #0284c7;
}

/* ================= RESPONSIVE MOBILE & TABLET STYLES ================= */
@media (max-width: 992px) {
  .header-metrics {
    overflow-x: auto;
  }
}

@media (max-width: 768px) {
  /* CLEAN COMPACT MOBILE HEADER */
  .header {
    height: 48px;
    padding: 6px 12px;
    justify-content: space-between;
    align-items: center;
  }
  .header-metrics {
    display: none !important;
  }
  .logo-title h1 {
    font-size: 13px;
  }
  .sub-title {
    display: none;
  }
  .logo-badge {
    font-size: 9.5px;
    padding: 2px 5px;
  }

  .btn-toggle-sidebar,
  .btn-map-fleet-drawer,
  .btn-close-sidebar,
  .sidebar-backdrop {
    display: none !important;
  }

  /* MOBILE 3-TAB VIEW SWITCHING */
  .mobile-bottom-nav {
    display: grid !important;
  }

  .main-layout {
    height: calc(100vh - 48px - 56px);
    height: calc(100dvh - 48px - 56px);
    overflow: hidden;
    position: relative;
  }

  /* DEFAULT MOBILE STATE (MAP FULLSCREEN) */
  #sidebar-fleet {
    display: none;
  }
  .map-section {
    display: flex;
    width: 100%;
    height: 100%;
    flex: 1;
  }
  #view-stats {
    display: none;
  }

  /* 1. Map View (Default) */
  .main-layout.view-map .map-section {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    flex: 1 !important;
  }
  .main-layout.view-map #sidebar-fleet,
  .main-layout.view-map #view-stats {
    display: none !important;
  }

  /* 2. Fleet View */
  .main-layout.view-fleet #sidebar-fleet {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    position: static !important;
    transform: none !important;
    box-shadow: none !important;
    border-right: none !important;
  }
  .main-layout.view-fleet .map-section,
  .main-layout.view-fleet #view-stats {
    display: none !important;
  }

  /* 3. Stats View */
  .main-layout.view-stats #view-stats {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
  }
  .main-layout.view-stats .map-section,
  .main-layout.view-stats #sidebar-fleet {
    display: none !important;
  }

  /* FLOATING MAP CONTROLS ON MOBILE */
  .map-controls-bar {
    top: 8px;
    left: 8px;
    right: 8px;
    justify-content: space-between;
    padding: 4px 6px;
    gap: 4px;
  }

  .layer-btn {
    padding: 4px 6px;
    font-size: 10px;
  }

  .btn-fit-fleet {
    padding: 4px 8px;
    font-size: 10px;
  }

  /* BOTTOM SHEET TELEMETRY INSPECTOR ON MOBILE */
  .bottom-sheet-handle {
    display: block;
  }

  .telemetry-inspector {
    position: fixed;
    top: auto;
    bottom: 56px;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: 72vh;
    border-radius: 16px 16px 0 0;
    padding: 10px 14px 14px 14px;
    box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.2);
    z-index: 1200;
  }
}

@media (max-width: 480px) {
  .layer-btn {
    padding: 4px 5px;
    font-size: 9.5px;
  }
  .btn-fit-fleet {
    padding: 4px 6px;
    font-size: 9.5px;
  }
}
