/* ============================================================
   Vantara System — Intelligent Fleet Design System
   Enterprise Industrial Dark-Theme UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── CSS Variables ─────────────────────────────────────── */
:root {
  /* Core palette */
  --bg-base: #080b12;
  --bg-panel: #0d1017;
  --bg-panel-alt: #111520;
  --bg-surface: #161c28;
  --bg-hover: #1c2333;

  /* Borders */
  --border: #1e2840;
  --border-bright: #2a3855;

  /* Accent — Cyan (live / active / safe) */
  --cyan: #00e5ff;
  --cyan-dim: rgba(0, 229, 255, 0.12);
  --cyan-glow: rgba(0, 229, 255, 0.35);

  /* Danger — Red (alerts / immobilise) */
  --red: #ff1744;
  --red-dim: rgba(255, 23, 68, 0.12);
  --red-glow: rgba(255, 23, 68, 0.40);

  /* Warning — Amber */
  --amber: #ffd600;
  --amber-dim: rgba(255, 214, 0, 0.10);

  /* Success — Green */
  --green: #00e676;
  --green-dim: rgba(0, 230, 118, 0.12);

  /* Text */
  --text-primary: #e8edf5;
  --text-secondary: #7a8aaa;
  --text-muted: #3d4a63;
  --text-label: #4a5a78;

  /* Layout */
  --sidebar-w: 240px;
  --navbar-h: 56px;
  --radius: 6px;
  --radius-lg: 10px;

  /* Typography */
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

/* ── Reset & Base ──────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border-bright);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════ */

.app-shell {
  display: grid;
  grid-template-rows: var(--navbar-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Top Navbar ────────────────────────────────────────── */
.navbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  position: relative;
}

.navbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--cyan-glow), transparent 60%);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.nav-brand-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--cyan), #0097a7);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.nav-brand-icon::before {
  content: '⬡';
  color: var(--bg-base);
  font-size: 18px;
  line-height: 1;
}

.nav-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.nav-brand-text .name {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.3px;
}

.nav-brand-text .sub {
  font-size: 9px;
  font-weight: 500;
  color: var(--cyan);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.nav-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

.nav-status-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: var(--green-dim);
  border: 1px solid rgba(0, 230, 118, 0.25);
  color: var(--green);
}

.status-pill.warn {
  background: var(--amber-dim);
  border-color: rgba(255, 214, 0, 0.25);
  color: var(--amber);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(0.7);
  }
}

.nav-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.nav-clock {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--cyan);
  letter-spacing: 1px;
}

.nav-tenant {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.nav-tenant-avatar {
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, #6c3de0, #3d00c8);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}

.nav-tenant-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-label);
  text-transform: uppercase;
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
  border-radius: 0;
  outline: none;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--cyan-dim);
  color: var(--cyan);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--cyan);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--cyan-glow);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
  opacity: 0.8;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  animation: badge-pulse 3s ease-in-out infinite;
}

@keyframes badge-pulse {

  0%,
  80%,
  100% {
    box-shadow: 0 0 0 0 var(--red-glow);
  }

  40% {
    box-shadow: 0 0 0 5px transparent;
  }
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-version {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Main Content ──────────────────────────────────────── */
.main-content {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

.view {
  display: none;
  flex-shrink: 0;
  overflow: visible;
  padding: 16px;
  gap: 16px;
  flex-direction: column;
}

.view.active {
  display: flex;
}

/* Map & Alerts views manage their own internal scroll — lock them to viewport height */
#view-map,
#view-alerts {
  flex-shrink: 1;
  flex-grow: 1;
  min-height: 0;
  overflow: hidden;
  height: calc(100vh - var(--navbar-h) - 32px);
  max-height: calc(100vh - var(--navbar-h) - 32px);
}

/* ══════════════════════════════════════════════════════════
   LIVE MAP VIEW
   ══════════════════════════════════════════════════════════ */
.map-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.map-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-placeholder {
  width: 100%;
  height: 100%;
  position: relative;
  background:
    repeating-linear-gradient(0deg,
      transparent,
      transparent 39px,
      rgba(0, 229, 255, 0.04) 39px,
      rgba(0, 229, 255, 0.04) 40px),
    repeating-linear-gradient(90deg,
      transparent,
      transparent 39px,
      rgba(0, 229, 255, 0.04) 39px,
      rgba(0, 229, 255, 0.04) 40px),
    radial-gradient(ellipse at 40% 60%, rgba(0, 50, 80, 0.6) 0%, transparent 65%),
    var(--bg-panel);
}

.map-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.08) 2px,
      rgba(0, 0, 0, 0.08) 4px);
  pointer-events: none;
}

.map-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.map-label .map-icon {
  font-size: 48px;
  display: block;
  opacity: 0.15;
  margin-bottom: 8px;
}

.map-label .map-text {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.map-label .map-subtext {
  font-size: 10px;
  color: var(--text-label);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* Vehicle blips on map */
.map-blip {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid var(--bg-panel);
  box-shadow: 0 0 0 0 var(--cyan-glow);
  animation: blip-pulse 2.5s ease-out infinite;
  cursor: pointer;
  transition: transform 0.1s;
}

.map-blip:hover {
  transform: scale(1.4);
}

.map-blip.rented {
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(255, 214, 0, 0.4);
}

.map-blip.warning {
  background: var(--red);
  animation: blip-pulse-red 1.2s ease-out infinite;
}

@keyframes blip-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--cyan-glow);
  }

  70% {
    box-shadow: 0 0 0 10px transparent;
  }

  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@keyframes blip-pulse-red {
  0% {
    box-shadow: 0 0 0 0 var(--red-glow);
  }

  70% {
    box-shadow: 0 0 0 12px transparent;
  }

  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.map-blip-label {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid var(--border-bright);
  padding: 2px 8px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--cyan);
  white-space: nowrap;
  pointer-events: none;
}

.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-ctrl-btn {
  width: 28px;
  height: 28px;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-bright);
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}

.map-ctrl-btn:hover,
.map-ctrl-btn.active {
  background: var(--bg-hover);
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
}

.map-coords {
  position: absolute;
  bottom: 12px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(8, 11, 18, 0.8);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  z-index: 1000;
}

/* ── History Playback View ─────────────────────────────── */
.history-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.history-controls-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#history-map {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-lg);
}

.stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 4px;
}


/* Time Presets */
.time-presets {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.btn-preset {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  text-align: center;
}

.btn-preset:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.btn-preset.active {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* Route Summary Stats */
.route-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: rgba(0, 229, 255, 0.05);
  padding: 12px;
  border-radius: 8px;
  border: 1px dashed var(--border);
}

.summary-item {
  display: flex;
  flex-direction: column;
}

.summary-label {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.summary-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--cyan);
}


  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-box .label {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.stat-box .value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--cyan);
}

input[type="range"] {
  accent-color: var(--cyan);
  cursor: pointer;
}

input[type="datetime-local"].input-dark {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px;
  border-radius: var(--radius);
  width: 100%;
  font-size: 12px;
  outline: none;
}

input[datetime-local].input-dark:focus {
  border-color: var(--cyan);
}

/* ── Security Feed Panel ───────────────────────────────── */
.feed-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.panel-title .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse-dot 1.5s ease-in-out infinite;
  box-shadow: 0 0 6px var(--red-glow);
}

.panel-title .dot.green {
  background: var(--green);
  box-shadow: 0 0 6px rgba(0, 230, 118, 0.4);
  animation-duration: 2.5s;
}

.feed-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feed-item {
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 3px solid var(--border);
  animation: feed-slide-in 0.3s ease;
}

@keyframes feed-slide-in {
  from {
    opacity: 0;
    transform: translateX(10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.feed-item.critical {
  border-left-color: var(--red);
  background: rgba(255, 23, 68, 0.06);
}

.feed-item.high {
  border-left-color: var(--amber);
  background: rgba(255, 214, 0, 0.05);
}

.feed-item.medium {
  border-left-color: var(--cyan);
  background: rgba(0, 229, 255, 0.04);
}

.feed-item.low {
  border-left-color: var(--green);
  background: rgba(0, 230, 118, 0.04);
}

.feed-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.feed-severity {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}

.feed-item.critical .feed-severity {
  background: var(--red-dim);
  color: var(--red);
}

.feed-item.high .feed-severity {
  background: var(--amber-dim);
  color: var(--amber);
}

.feed-item.medium .feed-severity {
  background: var(--cyan-dim);
  color: var(--cyan);
}

.feed-item.low .feed-severity {
  background: var(--green-dim);
  color: var(--green);
}

.feed-plate {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-hover);
  padding: 1px 6px;
  border-radius: 3px;
}

.feed-time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
}

.feed-message {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ══════════════════════════════════════════════════════════
   ACTIVE FLEET VIEW
   ══════════════════════════════════════════════════════════ */
.fleet-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
}

/* ── Data Table ────────────────────────────────────────── */
.table-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar-stat {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.toolbar-stat span {
  color: var(--cyan);
  font-weight: 600;
  font-family: var(--font-mono);
}

.table-wrap {
  flex: 1;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--bg-panel-alt);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-label);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

tbody tr {
  border-bottom: 1px solid rgba(30, 40, 64, 0.6);
  transition: background 0.12s;
  cursor: default;
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody td {
  padding: 11px 14px;
  font-size: 12px;
  color: var(--text-primary);
  vertical-align: middle;
}

.td-plate {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.5px;
}

.td-vehicle {
  font-size: 12px;
  font-weight: 600;
}

.td-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-active {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(0, 230, 118, 0.2);
}

.badge-rented {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(255, 214, 0, 0.2);
}

.badge-maintenance {
  background: var(--cyan-dim);
  color: var(--cyan);
  border: 1px solid rgba(0, 229, 255, 0.2);
}

.badge-offline {
  background: rgba(60, 70, 90, 0.4);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-immobilised {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 23, 68, 0.2);
}

.telemetry-val {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

.telemetry-val.updating {
  animation: val-flash 0.4s ease;
}

@keyframes val-flash {
  0% {
    color: var(--cyan);
  }

  100% {
    color: var(--text-primary);
  }
}

/* ── Immobilise Button ─────────────────────────────────── */
.btn-immobilise {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--red-dim);
  border: 1px solid rgba(255, 23, 68, 0.4);
  border-radius: var(--radius);
  color: var(--red);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-immobilise:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  box-shadow: 0 0 16px var(--red-glow);
  transform: translateY(-1px);
}

.btn-immobilise:active {
  transform: translateY(0);
  box-shadow: 0 0 6px var(--red-glow);
}

.btn-immobilise.immobilised {
  background: rgba(60, 70, 90, 0.4);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-immobilise.immobilised:hover {
  transform: none;
  box-shadow: none;
}

/* ── Telemetry Summary Cards ───────────────────────────── */
.fleet-sidebar-panels {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.metric-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), transparent);
}

.metric-card.danger::before {
  background: linear-gradient(90deg, var(--red), transparent);
}

.metric-card.warn::before {
  background: linear-gradient(90deg, var(--amber), transparent);
}

.metric-card.ok::before {
  background: linear-gradient(90deg, var(--green), transparent);
}

.metric-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-label);
  margin-bottom: 8px;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.metric-value .unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 3px;
}

.metric-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════
   ALERTS VIEW
   ══════════════════════════════════════════════════════════ */
.alerts-layout {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alerts-header-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.alerts-count {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--red);
}

.alerts-count-label {
  font-size: 12px;
  color: var(--text-muted);
}

.alert-log {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  min-height: 0;
}

.alert-row {
  display: grid;
  grid-template-columns: 22px 80px 100px 110px 1fr 80px 100px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(30, 40, 64, 0.5);
  transition: background 0.1s;
}

.alert-row:hover {
  background: var(--bg-hover);
}

.alert-type-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.alert-type-dot.critical {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

.alert-type-dot.high {
  background: var(--amber);
}

.alert-type-dot.medium {
  background: var(--cyan);
}

.alert-type-dot.low {
  background: var(--green);
}

.alert-col {
  font-size: 11px;
}

.alert-col.mono {
  font-family: var(--font-mono);
  font-size: 10px;
}

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

.alert-col.msg {
  color: var(--text-secondary);
  font-size: 11px;
}

/* ══════════════════════════════════════════════════════════
   MAINTENANCE VIEW
   ══════════════════════════════════════════════════════════ */
.maint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  overflow-y: auto;
  padding-bottom: 8px;
}

.maint-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}

.maint-card:hover {
  border-color: var(--border-bright);
}

.maint-card-plate {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 3px;
}

.maint-card-model {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.maint-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.maint-progress-bar {
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.maint-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.maint-progress-fill.ok {
  background: var(--green);
}

.maint-progress-fill.warn {
  background: var(--amber);
}

.maint-progress-fill.danger {
  background: var(--red);
}

.maint-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.maint-item {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.maint-item-label {
  color: var(--text-muted);
}

.maint-item-val {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-size: 11px;
}

/* ══════════════════════════════════════════════════════════
   SHARED COMPONENTS
   ══════════════════════════════════════════════════════════ */

.view-title-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.view-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.view-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--cyan-dim);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: var(--radius);
  color: var(--cyan);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:hover {
  background: var(--cyan);
  color: var(--bg-base);
  box-shadow: 0 0 12px var(--cyan-glow);
}

.tag-update {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--green);
  background: var(--green-dim);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(0, 230, 118, 0.15);
  letter-spacing: 0.5px;
  animation: tag-flash 1s ease;
}

@keyframes tag-flash {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

/* ── Responsive / Utility ──────────────────────────────── */
.flex-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ml-auto {
  margin-left: auto;
}

.text-mono {
  font-family: var(--font-mono);
}

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

.text-cyan {
  color: var(--cyan);
}

.text-red {
  color: var(--red);
}

.text-green {
  color: var(--green);
}

.text-amber {
  color: var(--amber);
}

/* ══════════════════════════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════════════════════════ */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0;
}

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

.login-bg-grid {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(0, 229, 255, 0.03) 39px, rgba(0, 229, 255, 0.03) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(0, 229, 255, 0.03) 39px, rgba(0, 229, 255, 0.03) 40px),
    radial-gradient(ellipse at 50% 50%, rgba(0, 30, 60, 0.8) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  box-shadow: 0 0 60px rgba(0, 229, 255, 0.06), 0 0 120px rgba(0, 0, 0, 0.8);
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--cyan), #0097a7);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 12px;
  box-shadow: 0 0 24px var(--cyan-glow);
}

.login-brand-name {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.login-brand-sub {
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 3px;
}

.login-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-label);
  margin-bottom: 6px;
}

.login-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 14px;
}

.login-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.12);
}

.login-btn {
  width: 100%;
  padding: 11px;
  background: linear-gradient(135deg, var(--cyan), #0097a7);
  border: none;
  border-radius: var(--radius);
  color: var(--bg-base);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}

.login-btn:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 20px var(--cyan-glow);
}

.login-btn:active {
  transform: scale(0.98);
}

.login-error {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--red-dim);
  border: 1px solid rgba(255, 23, 68, 0.25);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 11px;
  display: none;
}

.login-error.visible {
  display: block;
}

.login-demo-hint {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.8;
}

.login-demo-hint code {
  font-family: var(--font-mono);
  color: var(--cyan);
  background: var(--cyan-dim);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ══════════════════════════════════════════════════════════
   ROLE BADGE & TENANT SWITCHER
   ══════════════════════════════════════════════════════════ */

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.role-badge.superadmin {
  background: rgba(108, 61, 224, 0.2);
  border: 1px solid rgba(108, 61, 224, 0.4);
  color: #a78bfa;
}

.role-badge.stakeholder {
  background: rgba(0, 151, 167, 0.15);
  border: 1px solid rgba(0, 151, 167, 0.35);
  color: var(--cyan);
}

.tenant-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tenant-switcher select {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  max-width: 200px;
  transition: border-color 0.15s;
}

.tenant-switcher select:focus {
  border-color: var(--cyan);
}

.tenant-switcher label {
  font-size: 9px;
  color: var(--text-label);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════════════
   DASHCAM VIDEO PANELS
   ══════════════════════════════════════════════════════════ */

/* ── Dashcam Drawer Overlay (Persistent across views) ── */
/* ── Floating dashcam panel (Overlay logic) ── */
.cam-panel-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 24px;
}

.cam-section {
  width: 95%;
  max-width: 900px;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  box-shadow: 0 10px 50px rgba(0,0,0,0.6);
  padding: 16px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  display: none;
}

.cam-section.open {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* ── Telemetry Modal Styles (Premium Analysis) ── */
#telemetry-modal .modal-card {
  border: 1px solid var(--cyan-dim);
  box-shadow: 0 0 40px rgba(0, 229, 255, 0.15);
}

.cam-tabs {
  display: flex;
  gap: 8px;
}

.cam-tab {
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
}

.cam-tab.active {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
}

.cam-pane {
  display: none;
}

.cam-pane.active {
  display: block;
}

.telemetry-log-wrap {
  background: #080b12;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-y: auto;
}

.telemetry-log-table {
  width: 100%;
  border-collapse: collapse;
}

.telemetry-log-table th {
  background: var(--bg-panel-alt);
  padding: 10px;
  font-size: 10px;
  color: var(--text-label);
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 2;
}

.telemetry-log-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.chart-container {
  background: #080b12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.chart-header {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
  letter-spacing: 1px;
}

.cam-section.locked {
  filter: grayscale(1) brightness(0.4);
  pointer-events: none;
}

.cam-section.locked {
  filter: grayscale(1) brightness(0.4);
  pointer-events: none;
}


.cam-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 12px;
}

.cam-feed {
  background: #000;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;
}

/* Scanline overlay — real dashcam aesthetic */
.cam-feed::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 3px,
      rgba(0, 0, 0, 0.12) 3px,
      rgba(0, 0, 0, 0.12) 4px);
  z-index: 2;
  pointer-events: none;
}

/* Static noise animation */
.cam-static {
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  z-index: 1;
  animation: static-shift 0.1s steps(1) infinite;
  opacity: 0.4;
}

@keyframes static-shift {
  0% {
    background-position: 0 0;
  }

  25% {
    background-position: -5px 3px;
  }

  50% {
    background-position: 3px -3px;
  }

  75% {
    background-position: -3px -5px;
  }

  100% {
    background-position: 5px 5px;
  }
}

/* Simulated road view gradient */
.cam-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.cam-scene.road {
  background:
    linear-gradient(180deg,
      #1a1a2e 0%,
      #16213e 30%,
      #0f3460 45%,
      #1a1a2e 46%,
      #111 47%,
      #0d0d0d 55%,
      #1a1a1a 100%);
}

.cam-scene.road::after {
  content: '';
  position: absolute;
  bottom: 20%;
  left: 50%;
  width: 6px;
  transform: translateX(-50%);
  top: 48%;
  background: repeating-linear-gradient(180deg,
      rgba(255, 214, 0, 0.8) 0px, rgba(255, 214, 0, 0.8) 20px,
      transparent 20px, transparent 40px);
  animation: road-lines 0.3s linear infinite;
}

@keyframes road-lines {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 0 40px;
  }
}

.cam-scene.cabin {
  background:
    radial-gradient(ellipse at 50% 50%, #1e1008 0%, #0d0d0d 70%),
    linear-gradient(180deg, #0d0d0d 0%, #1a1208 100%);
}

/* Burned-in overlay (like real dashcam footage) */
.cam-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
}

.cam-overlay-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cam-channel {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 1px;
  text-shadow: 0 0 4px rgba(0, 229, 255, 0.6);
}

.cam-rec {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 3px;
}

.cam-rec-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse-dot 1s infinite;
}

.cam-overlay-bottom {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cam-data-line {
  font-family: var(--font-mono);
  font-size: 8px;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 3px #000;
  letter-spacing: 0.5px;
}

.cam-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
}

.cam-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 3px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.cam-status-pill.streaming {
  color: var(--green);
  border-color: rgba(0, 230, 118, 0.2);
}

.cam-status-pill.buffering {
  color: var(--amber);
  border-color: rgba(255, 214, 0, 0.2);
}

.cam-status-pill.offline {
  color: var(--red);
  border-color: rgba(255, 23, 68, 0.2);
}

/* ══════════════════════════════════════════════════════════
   RELAY STATE BADGE
   ══════════════════════════════════════════════════════════ */

.relay-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 1px solid;
  white-space: nowrap;
  transition: all 0.3s ease;
}

.relay-badge.closed {
  background: var(--green-dim);
  border-color: rgba(0, 230, 118, 0.25);
  color: var(--green);
}

.relay-badge.open {
  background: var(--red-dim);
  border-color: rgba(255, 23, 68, 0.3);
  color: var(--red);
  animation: relay-open-pulse 2s ease-in-out infinite;
}

.relay-badge.pending {
  background: var(--amber-dim);
  border-color: rgba(255, 214, 0, 0.25);
  color: var(--amber);
  animation: relay-pending-flash 0.6s ease-in-out infinite alternate;
}

@keyframes relay-open-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 var(--red-glow);
  }

  50% {
    box-shadow: 0 0 8px 2px rgba(255, 23, 68, 0.2);
  }
}

@keyframes relay-pending-flash {
  from {
    opacity: 0.6;
  }

  to {
    opacity: 1;
  }
}

/* ══════════════════════════════════════════════════════════
   PHASE 2 — LEAFLET MAP OVERRIDES
   ══════════════════════════════════════════════════════════ */

/* Map panel — fill the panel instead of stretch-align */
.map-panel {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}

/* Leaflet container fills its parent */
#leaflet-map {
  width: 100%;
  height: 100%;
  min-height: 420px;
  z-index: 0;
}

/* Dark tile treatment */
.leaflet-tile {
  filter: brightness(0.75) saturate(0.6) hue-rotate(185deg);
}

/* Controls sit above tiles but below our overlay panels */
.leaflet-control-container {
  z-index: 1;
}

/* Map control buttons (top-right) need to sit above Leaflet layers */
.map-controls {
  z-index: 500;
}

.map-coords {
  z-index: 500;
}

/* Dark popup */
.leaflet-popup-content-wrapper {
  background: #0d1017;
  border: 1px solid #1e2840;
  border-radius: 8px;
  color: #e8edf5;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

.leaflet-popup-tip {
  background: #0d1017;
}

.leaflet-popup-close-button {
  color: #7a8aaa !important;
}

/* Attribution bar */
.leaflet-control-attribution {
  background: rgba(8, 11, 18, 0.75) !important;
  color: #3d4a63 !important;
  font-size: 9px !important;
}

.leaflet-control-attribution a {
  color: #4a5a78 !important;
}

/* ══════════════════════════════════════════════════════════
   PHASE 3 — MAINTENANCE & BOOKING MODULE
   ══════════════════════════════════════════════════════════ */

/* Utility */
.ml-auto {
  margin-left: auto;
}

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

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary {
  padding: 6px 14px;
  background: var(--cyan);
  color: #000;
  font-weight: 700;
  font-size: 11px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: var(--font-ui);
}

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

.btn-secondary {
  padding: 6px 14px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-ui);
}

.btn-secondary:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ── Tab bar ────────────────────────────────────────────── */
.maint-tabs {
  display: flex;
  gap: 2px;
  padding-bottom: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.maint-tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s;
  outline: none;
  margin-bottom: -1px;
}

.maint-tab:hover {
  color: var(--text-primary);
}

.maint-tab.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
  font-weight: 600;
}

/* ── Tab panels ─────────────────────────────────────────── */
.maint-tab-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.maint-tab-panel.active {
  display: flex;
}

/* ── Service type badge ─────────────────────────────────── */
.svc-type-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #a5b4fc;
}

/* ── Booking Calendar grid ─────────────────────────────── */
.cal-header-cell {
  text-align: center;
  padding: 4px 2px;
  background: var(--bg-surface);
  border-radius: 3px;
  line-height: 1.2;
}

.cal-header-cell.today {
  background: var(--cyan-dim);
  border: 1px solid rgba(0, 229, 255, 0.25);
}

.cal-vehicle-cell {
  padding: 6px 8px;
  background: var(--bg-surface);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 36px;
}

.cal-day-cell {
  min-height: 36px;
  border-radius: 2px;
  background: var(--bg-surface);
  position: relative;
  display: flex;
  align-items: stretch;
}

.cal-day-cell.weekend {
  background: rgba(255, 255, 255, 0.02);
}

.cal-day-cell.cal-today-col {
  outline: 1px solid rgba(0, 229, 255, 0.25);
}

.cal-booking-block {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 2px;
  min-height: 34px;
}

/* ── Insurance / Docs cards ────────────────────────────── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.docs-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.docs-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.docs-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.docs-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  margin-top: 2px;
}

.docs-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  margin-bottom: 2px;
}

.docs-value {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  margin-bottom: 4px;
}

/* ── Countdown pills ────────────────────────────────────── */
.countdown-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.countdown-ok {
  background: var(--green-dim);
  border: 1px solid rgba(0, 230, 118, 0.25);
  color: var(--green);
}

.countdown-warn {
  background: var(--amber-dim);
  border: 1px solid rgba(255, 214, 0, 0.25);
  color: var(--amber);
}

.countdown-danger {
  background: var(--red-dim);
  border: 1px solid rgba(255, 23, 68, 0.3);
  color: var(--red);
  animation: badge-pulse 2s ease-in-out infinite;
}

/* ── Modal overlay ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 95vw;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  transform: translateY(12px);
  transition: transform 0.2s ease;
  overflow: hidden;
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

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

.modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.modal-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.modal-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-ui);
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.modal-input:focus {
  border-color: var(--cyan);
}

.modal-input option {
  background: var(--bg-panel-alt);
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

/* ══════════════════════════════════════════════════════════
   PHASE 4 — ALERTS & RELAY COMMAND CENTRE
   ══════════════════════════════════════════════════════════ */

/* ── Alert filter pills ─────────────────────────────────── */
.alert-filter-bar {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}

.alert-filter-pill {
  padding: 4px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  outline: none;
  flex-shrink: 0;
}

.alert-filter-pill:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.alert-filter-pill.active {
  background: var(--cyan-dim);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ── Alert row ACK state ────────────────────────────────── */
tr.alert-row.acked td {
  opacity: 0.45;
}

tr.alert-row.acked td:last-child {
  opacity: 1;
}

/* ── ACK button ─────────────────────────────────────────── */
.ack-btn {
  padding: 3px 10px;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: 4px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s;
  outline: none;
}

.ack-btn:hover {
  background: rgba(6, 182, 212, 0.25);
  border-color: var(--cyan);
}

/* ── ACKed badge ────────────────────────────────────────── */
.ack-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: var(--green-dim);
  border: 1px solid rgba(0, 230, 118, 0.25);
  color: var(--green);
}

/* ── Relay Command Panel ────────────────────────────────── */
.relay-cmd-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.relay-cmd-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel-alt);
}

.relay-cmd-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.relay-cmd-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

/* ── Status key-value rows ──────────────────────────────── */
.relay-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

/* ── Action buttons ─────────────────────────────────────── */
.relay-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.relay-action-btn {
  padding: 10px 8px;
  border: none;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.3px;
  outline: none;
}

.relay-action-btn.danger {
  background: rgba(255, 23, 68, 0.14);
  border: 1px solid rgba(255, 23, 68, 0.4);
  color: var(--red);
}

.relay-action-btn.danger:hover {
  background: rgba(255, 23, 68, 0.28);
  border-color: var(--red);
  box-shadow: 0 0 12px rgba(255, 23, 68, 0.25);
}

.relay-action-btn.safe {
  background: rgba(0, 230, 118, 0.1);
  border: 1px solid rgba(0, 230, 118, 0.3);
  color: var(--green);
}

.relay-action-btn.safe:hover {
  background: rgba(0, 230, 118, 0.22);
  border-color: var(--green);
  box-shadow: 0 0 12px rgba(0, 230, 118, 0.2);
}

/* ── Cooldown overlay ───────────────────────────────────── */
.relay-cooldown {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 18, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.relay-cooldown-ring {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.relay-cooldown-label {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1;
}

/* ══════════════════════════════════════════════════════════
   PHASE 5 — REPORTS & ANALYTICS
   ══════════════════════════════════════════════════════════ */

/* ── KPI Stat Cards ─────────────────────────────────────── */
.report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.rpt-stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s;
}

.rpt-stat-card:hover {
  border-color: var(--cyan);
}

.rpt-stat-icon {
  font-size: 26px;
  flex-shrink: 0;
  line-height: 1;
  opacity: 0.85;
}

.rpt-stat-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rpt-stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.rpt-stat-value {
  font-size: 26px;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1;
}

.rpt-stat-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Charts row ─────────────────────────────────────────── */
.report-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.report-chart-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.report-chart-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-label);
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Fleet summary table ────────────────────────────────── */
.report-table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ── Print / PDF ────────────────────────────────────────── */
@media print {
  body {
    background: #fff !important;
    color: #111 !important;
  }

  .nav-top,
  .sidebar,
  .btn-primary,
  .btn-secondary {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }

  .view {
    padding: 0 !important;
  }

  .view:not(.active) {
    display: none !important;
  }

  .report-chart-card,
  .report-table-wrap,
  .rpt-stat-card {
    border: 1px solid #e5e7eb !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .rpt-stat-label,
  .rpt-stat-sub,
  .report-chart-title {
    color: #374151 !important;
  }

  .rpt-stat-value {
    color: #111 !important;
  }

  .alert-row td {
    color: #374151 !important;
  }

  .view-title {
    color: #111 !important;
  }

  .view-subtitle {
    color: #374151 !important;
  }

  /* Hide nav/sidebar in print */
  .navbar,
  .sidebar,
  .btn-secondary,
  .btn-primary,
  .view-title-bar .ml-auto {
    display: none !important;
  }

  /* Reset layout for print */
  .app-shell {
    grid-template-columns: 0 1fr !important;
    grid-template-rows: 1fr !important;
  }

  .main-content {
    overflow: visible !important;
  }

  /* Make report charts print-friendly */
  .report-charts {
    grid-template-columns: 1fr 1fr !important;
    break-inside: avoid;
  }

  .report-chart-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* ══════════════════════════════════════════════════════════
   DEVICE SDK INTEGRATION GUIDE
   ══════════════════════════════════════════════════════════ */

.relay-guide-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.relay-guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  cursor: pointer;
  gap: 10px;
  border-bottom: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.relay-guide-header:hover {
  background: var(--bg-panel-alt);
}

.relay-guide-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.relay-guide-wrap.open .relay-guide-header {
  border-bottom-color: var(--border);
}

.relay-guide-wrap.open .relay-guide-chevron {
  transform: rotate(180deg);
}

.relay-guide-body {
  display: none;
  padding: 16px;
  gap: 16px;
  flex-direction: column;
}

.relay-guide-wrap.open .relay-guide-body {
  display: flex;
}

.relay-guide-section {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.relay-guide-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 10px;
}

.relay-guide-text {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.relay-guide-table-wrap {
  overflow-x: auto;
}

.relay-guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.relay-guide-table th {
  padding: 6px 10px;
  text-align: left;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-label);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.relay-guide-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  font-size: 11px;
}

.relay-guide-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.relay-guide-wiring {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.relay-wire-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: var(--font-mono);
}

.relay-wire-label {
  color: var(--cyan);
  min-width: 190px;
  font-size: 10px;
}

.relay-wire-line {
  color: var(--text-muted);
  letter-spacing: -2px;
}

.relay-wire-dest {
  color: var(--text-secondary);
  font-size: 10px;
}

.relay-guide-steps {
  padding-left: 18px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.relay-guide-steps li {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.relay-guide-steps li code {
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(6, 182, 212, 0.12);
  color: var(--cyan);
  padding: 1px 5px;
  border-radius: 3px;
}

.relay-guide-steps strong {
  color: var(--text-primary);
}

/*  
   PHASE 6  TEAM MANAGEMENT
    */

.role-chip {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
}

.role-chip.superadmin {
  background: rgba(167, 139, 250, 0.15);
  border-color: rgba(167, 139, 250, 0.3);
  color: #a78bfa;
}

.role-chip.stakeholder {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.3);
  color: var(--cyan);
}

.role-chip.fleetmanager {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
}

.role-chip.viewer {
  background: rgba(107, 114, 128, 0.15);
  border-color: rgba(107, 114, 128, 0.3);
  color: var(--text-muted);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}

.status-chip.active {
  color: var(--green);
}

.status-chip.inactive {
  color: var(--text-muted);
  opacity: 0.6;
}

.status-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-chip.active .dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.status-chip.inactive .dot {
  background: var(--text-muted);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.btn-icon:hover {
  opacity: 1;
}
/* ══════════════════════════════════════════════════════════
   PHASE 4 — SUPPORT & TICKETING
   ══════════════════════════════════════════════════════════ */

.support-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--cyan), #0097a7);
  border: none;
  border-radius: 30px;
  color: var(--bg-base);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 229, 255, 0.4);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.support-fab:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 229, 255, 0.6);
  filter: brightness(1.1);
}

.support-fab-icon {
  font-size: 18px;
  line-height: 1;
}

.support-fab-label {
  letter-spacing: 1px;
  text-transform: uppercase;
}

#support-modal .modal-card {
  width: 500px;
}

#support-description {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 12px;
  resize: none;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
  min-height: 120px;
}

#support-description:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.1);
}

.modal-field.full {
  grid-column: span 2;
}


/* -- ONBOARDING VIEW -- */
.onboarding-grid {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 20px;
    align-items: start;
    margin-top: 10px;
}

.onboarding-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.onboarding-form {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.onboarding-help {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.help-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.help-card h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--cyan);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.help-card p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.help-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.help-card ul li {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 12px;
}

.help-card ul li::before {
    content: '?';
    color: var(--green);
    font-weight: 800;
}

.alert-box {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 12px;
    line-height: 1.5;
}

.alert-box.info {
    background: var(--cyan-dim);
    border: 1px solid rgba(0, 229, 255, 0.2);
    color: var(--text-primary);
}
