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

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

:root {
    --bg: #08080a;
    --bg-subtle: #0e0e11;
    --card: #131316;
    --card-hover: #1a1a1e;
    --card-active: #1e1e24;
    --accent: #ff2d3b;
    --accent-dim: rgba(255, 45, 59, 0.12);
    --accent-glow: rgba(255, 45, 59, 0.25);
    --text: #eaeaec;
    --text-secondary: #a0a0a8;
    --muted: #5a5a65;
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --green: #00e676;
    --green-dim: rgba(0, 230, 118, 0.12);
    --green-glow: rgba(0, 230, 118, 0.3);
    --yellow: #ffd600;
    --yellow-dim: rgba(255, 214, 0, 0.12);
    --red: #ff3d3d;
    --red-dim: rgba(255, 61, 61, 0.12);
    --red-glow: rgba(255, 61, 61, 0.3);
    --blue: #448aff;
    --blue-dim: rgba(68, 138, 255, 0.12);
    --sidebar-w: 380px;
    --header-h: 56px;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ═══ Background texture ═══ */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(255, 45, 59, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 230, 118, 0.02) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* ═══ Header ═══ */
.header {
    height: var(--header-h);
    background: rgba(13, 13, 16, 0.85);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: relative;
    z-index: 1000;
}

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

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.logo-mark {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.logo-mark::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.02em;
}

.logo-text span { color: var(--accent); }

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 8px;
}

.header-nav {
    display: flex;
    gap: 2px;
}

.header-nav a {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.header-nav a:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.header-nav a.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
}

.header-nav a.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--accent-dim);
    background: rgba(255, 45, 59, 0.06);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.header-badge .pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s ease-in-out infinite;
}

.header-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    font-weight: 500;
}

.header-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #b0b0bc;
}

.stat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.stat-dot.green { background: var(--green); box-shadow: 0 0 8px var(--green-glow); }
.stat-dot.gray { background: var(--muted); }
.stat-dot.red { background: var(--red); box-shadow: 0 0 8px var(--red-glow); }

.stat-count {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text);
}

/* ═══ Layout ═══ */
.layout {
    display: flex;
    height: calc(100vh - var(--header-h));
    position: relative;
    z-index: 1;
}

/* ═══ Sidebar ═══ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-subtle);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-search {
    padding: 14px 16px 10px;
}

.search-wrap {
    position: relative;
}

.search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 16px;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    background: var(--card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: #f0f0f2;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

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

.sidebar-filters {
    padding: 6px 16px 10px;
    display: flex;
    gap: 6px;
}

.filter-btn {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    background: transparent;
    color: #a0a0ac;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.filter-btn:hover { border-color: rgba(255,255,255,0.15); color: var(--text); }

.filter-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.filter-btn[data-filter="moving"].active { border-color: var(--green); color: var(--green); background: var(--green-dim); }
.filter-btn[data-filter="parked"].active { border-color: var(--text-secondary); color: var(--text-secondary); background: rgba(255,255,255,0.04); }
.filter-btn[data-filter="offline"].active { border-color: var(--red); color: var(--red); background: var(--red-dim); }

.vehicle-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 8px;
}

.vehicle-list::-webkit-scrollbar { width: 3px; }
.vehicle-list::-webkit-scrollbar-track { background: transparent; }
.vehicle-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ═══ Vehicle Card (compact for 179 vehicles) ═══ */
.vehicle-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    position: relative;
    animation: cardEnter 0.3s ease both;
    min-height: 36px;
}

@keyframes cardEnter {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

.vehicle-card:hover { background: var(--card); border-color: var(--border); }

.vehicle-card.active {
    background: var(--card-active);
    border-color: var(--accent);
}

.vehicle-card.active .vehicle-name { color: #fff; }

/* Status bar on the left edge */
.v-status-bar {
    width: 3px;
    align-self: stretch;
    border-radius: 2px;
    margin-right: 10px;
    flex-shrink: 0;
}

.v-status-bar.moving { background: var(--green); box-shadow: 0 0 6px var(--green-glow); }
.v-status-bar.parked { background: var(--muted); }
.v-status-bar.offline { background: var(--red); }

.v-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
    position: relative;
}

.v-icon.moving { background: var(--green-dim); color: var(--green); }
.v-icon.parked { background: rgba(255,255,255,0.04); color: var(--muted); }
.v-icon.offline { background: var(--red-dim); color: var(--red); }

.v-icon .status-ring {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid var(--bg-subtle);
}

.v-icon .status-ring.moving { background: var(--green); box-shadow: 0 0 5px var(--green-glow); }
.v-icon .status-ring.parked { background: var(--muted); }
.v-icon .status-ring.offline { background: var(--red); animation: pulse 2s ease-in-out infinite; }

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

.vehicle-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f0f0f2;
    line-height: 1.3;
}

.vehicle-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 12px;
    color: #9a9aa6;
}

.v-plate {
    padding: 2px 7px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.3px;
    color: #b0b0bc;
}

.v-right {
    text-align: right;
    flex-shrink: 0;
}

.v-speed {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 700;
    min-width: 28px;
    text-align: right;
}

.v-speed.moving { color: var(--green); }
.v-speed.parked { color: #7a7a86; font-size: 12px; font-family: 'Plus Jakarta Sans', sans-serif; }
.v-speed.offline { color: var(--red); font-size: 12px; font-family: 'Plus Jakarta Sans', sans-serif; }

.v-time {
    font-size: 11px;
    color: #6a6a75;
    margin-top: 3px;
    font-family: 'JetBrains Mono', monospace;
}

/* ═══ Map ═══ */
.map-container { flex: 1; position: relative; }
#map, #detail-map { width: 100%; height: 100%; }
.leaflet-container { background: #080810 !important; font-family: 'Plus Jakarta Sans', sans-serif !important; }

/* Animated markers */
.leaflet-marker-icon.smooth-move { transition: transform 2s linear !important; }

/* Custom map markers */
.map-marker {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 14px;
    border: 2px solid;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.map-marker.moving {
    background: rgba(0, 230, 118, 0.9);
    border-color: #00c853;
    box-shadow: 0 0 16px var(--green-glow), 0 2px 8px rgba(0,0,0,0.4);
}

.map-marker.parked {
    background: rgba(60, 60, 70, 0.9);
    border-color: #555;
}

.map-marker.offline {
    background: rgba(255, 61, 61, 0.8);
    border-color: #e53935;
    box-shadow: 0 0 12px var(--red-glow), 0 2px 8px rgba(0,0,0,0.4);
    opacity: 0.7;
}

.marker-arrow {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* Map popup */
.leaflet-popup-content-wrapper {
    background: rgba(19, 19, 22, 0.95) !important;
    backdrop-filter: blur(16px) !important;
    color: var(--text) !important;
    border-radius: var(--radius) !important;
    border: 1px solid var(--border-light) !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6) !important;
    padding: 0 !important;
}

.leaflet-popup-tip { background: rgba(19, 19, 22, 0.95) !important; border: none !important; }
.leaflet-popup-content { margin: 0 !important; font-family: 'Plus Jakarta Sans', sans-serif !important; min-width: 220px; }
.leaflet-popup-close-button { color: var(--muted) !important; font-size: 18px !important; top: 8px !important; right: 10px !important; }
.leaflet-popup-close-button:hover { color: var(--text) !important; }

.popup-inner { padding: 16px; }

.popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.popup-header-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.popup-header-icon.moving { background: var(--green-dim); color: var(--green); }
.popup-header-icon.parked { background: rgba(255,255,255,0.04); color: var(--muted); }
.popup-header-icon.offline { background: var(--red-dim); color: var(--red); }

.popup-name { font-weight: 700; font-size: 14px; }
.popup-plate { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-secondary); }

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

.popup-stat {
    padding: 8px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
}

.popup-stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.popup-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 600; margin-top: 2px; }

.popup-link {
    display: block;
    margin-top: 12px;
    padding: 8px 0;
    text-align: center;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: var(--transition);
}

.popup-link:hover { opacity: 0.85; transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-dim); }

/* Leaflet controls */
.leaflet-control-zoom a {
    background: var(--card) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-size: 16px !important;
}

.leaflet-control-zoom a:hover { background: var(--card-hover) !important; }
.leaflet-control-zoom { border: none !important; border-radius: var(--radius-sm) !important; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important; }

.leaflet-control-attribution {
    background: rgba(8, 8, 10, 0.7) !important;
    color: var(--muted) !important;
    font-size: 9px !important;
    backdrop-filter: blur(8px) !important;
}

.leaflet-control-attribution a { color: var(--text-secondary) !important; }

/* Route polyline */
.route-line { stroke-linecap: round; stroke-linejoin: round; }

/* ═══ Vehicle Detail Page ═══ */
.detail-layout {
    display: flex;
    height: calc(100vh - var(--header-h));
    position: relative;
    z-index: 1;
}

.detail-sidebar {
    width: 400px;
    background: var(--bg-subtle);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
    padding: 20px 20px 40px;
}

.detail-sidebar::-webkit-scrollbar { width: 3px; }
.detail-sidebar::-webkit-scrollbar-track { background: transparent; }
.detail-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.detail-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 20px;
    transition: var(--transition);
}

.back-link:hover { color: var(--text); }

.detail-vehicle-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.detail-vehicle-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.detail-vehicle-icon.moving { background: var(--green-dim); color: var(--green); }
.detail-vehicle-icon.parked { background: rgba(255,255,255,0.04); color: var(--muted); }
.detail-vehicle-icon.offline { background: var(--red-dim); color: var(--red); }

.detail-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.detail-num {
    color: var(--text-secondary);
    font-weight: 400;
}

.detail-plate {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.detail-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.detail-status-badge.moving { background: var(--green-dim); color: var(--green); }
.detail-status-badge.parked { background: rgba(255,255,255,0.04); color: var(--muted); }
.detail-status-badge.offline { background: var(--red-dim); color: var(--red); }

/* Stats cards */
.info-section { margin-top: 24px; }

.info-section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
    margin-bottom: 10px;
}

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

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    transition: var(--transition);
}

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

.stat-card-label {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 6px;
}

.stat-card-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.stat-card-value.green { color: var(--green); }
.stat-card-value.red { color: var(--red); }
.stat-card-value.blue { color: var(--blue); }
.stat-card-value.yellow { color: var(--yellow); }
.stat-card-value.white { color: var(--text); }

.stat-card-unit {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.info-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.info-row-label { color: var(--text-secondary); }

.info-row-value {
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

/* ═══ Telemetry Table ═══ */
.telemetry-panel {
    background: var(--bg-subtle);
    border-top: 1px solid var(--border);
    max-height: 300px;
    overflow-y: auto;
}

.telemetry-panel::-webkit-scrollbar { width: 3px; }
.telemetry-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

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

.telem-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-subtle);
}

.telem-table th {
    padding: 10px 14px;
    text-align: left;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.telem-table td {
    padding: 7px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
}

.telem-table tbody tr { transition: background 0.1s; }
.telem-table tbody tr:hover td { background: rgba(255,255,255,0.02); color: var(--text); }

.telem-ign {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.telem-ign.on { background: var(--green); box-shadow: 0 0 4px var(--green-glow); }
.telem-ign.off { background: var(--muted); }

/* ═══ Codec8 Packet Viewer ═══ */
.packet-section { margin-top: 24px; }

.packet-box {
    background: #050507;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    line-height: 2;
    word-break: break-all;
    overflow-x: auto;
    position: relative;
}

.packet-box::before {
    content: 'CODEC8 PACKET';
    position: absolute;
    top: 6px;
    right: 10px;
    font-size: 9px;
    color: var(--muted);
    letter-spacing: 1px;
}

.hex-preamble { color: var(--muted); }
.hex-length { color: var(--yellow); }
.hex-codec { color: var(--accent); }
.hex-timestamp { color: var(--blue); }
.hex-gps { color: var(--green); }
.hex-io { color: #ce93d8; }
.hex-crc { color: var(--muted); opacity: 0.5; }

.packet-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    font-size: 10px;
}

.packet-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.packet-legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* ═══ Mileage & Alerts pages ═══ */
.content-page {
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
    padding: 32px;
    position: relative;
    z-index: 1;
}

.page-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 26px;
    letter-spacing: -0.02em;
    margin-bottom: 24px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.data-table th {
    padding: 14px 20px;
    text-align: left;
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 20px;
    font-size: 13px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.data-table tr:hover td { background: rgba(255, 255, 255, 0.015); }

.data-table .mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.data-table .km-value { font-weight: 700; color: var(--text); }

/* Alert cards */
.alert-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    transition: var(--transition);
}

.alert-card:hover { border-color: var(--border-light); }

.alert-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.alert-icon.speed { background: var(--red-dim); color: var(--red); }
.alert-icon.signal { background: var(--yellow-dim); color: var(--yellow); }

.alert-info { flex: 1; }
.alert-title { font-size: 13px; font-weight: 600; }
.alert-desc { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.alert-time { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* ═══ Animations ═══ */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.4s ease; }
.slide-up { animation: slideUp 0.5s ease; }

/* ═══ Cluster & Marker Overrides ═══ */
.fleet-cluster { background: none !important; border: none !important; }
.fm { background: none !important; border: none !important; }
.fm.fm-moving svg { filter: drop-shadow(0 1px 3px rgba(0,230,118,0.4)); }

/* Override default markercluster styles */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large { background: none !important; }
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div { background: none !important; }

/* Smooth marker transitions */
.leaflet-marker-icon.fm-moving { transition: transform 2.5s linear !important; }

/* Geofence labels */
.geofence-label {
    background: rgba(38, 50, 56, 0.85) !important;
    border: 1px solid rgba(120, 144, 156, 0.4) !important;
    color: #b0bec5 !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    letter-spacing: 0.8px !important;
    text-transform: uppercase !important;
    padding: 3px 8px !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}
.geofence-label::before { border: none !important; }

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

/* ── Bottom Navigation (mobile only) ── */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(13, 13, 16, 0.95);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-top: 1px solid var(--border);
    z-index: 2000;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-inner {
    display: flex;
    height: 100%;
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item i { font-size: 22px; }

.mobile-nav-item.active {
    color: var(--accent);
}

/* ── Bottom Sheet Handle ── */
.sheet-handle {
    display: none;
    width: 100%;
    padding: 10px 0 6px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sheet-handle-bar {
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 0 auto;
}

/* ── Mobile Stats Bar (inside bottom sheet) ── */
.mobile-stats {
    display: none;
    padding: 0 16px 8px;
    gap: 10px;
}

.mobile-stats .m-stat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.mobile-stats .m-stat .stat-dot { flex-shrink: 0; }
.mobile-stats .m-stat .stat-count { color: var(--text); font-family: 'JetBrains Mono', monospace; }

/* ── Map FAB (Recenter) ── */
.map-fab {
    display: none;
    position: absolute;
    z-index: 500;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(19, 19, 22, 0.9);
    backdrop-filter: blur(12px);
    color: var(--text);
    font-size: 20px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    :root {
        --header-h: 48px;
        --sidebar-w: 100%;
    }

    html, body { overflow: auto; }

    /* ── Header: compact ── */
    .header {
        height: var(--header-h);
        padding: 0 12px;
    }

    .header-nav { display: none; }
    .header-divider { display: none; }
    .header-stats { display: none; }
    .header-right { gap: 8px; }

    .logo-mark { width: 28px; height: 28px; font-size: 14px; border-radius: 6px; }
    .logo-text { font-size: 14px; }
    .header-badge { padding: 3px 8px; font-size: 10px; }
    .header-badge .pulse-dot { width: 5px; height: 5px; }

    /* ── Show bottom nav ── */
    .mobile-nav { display: block; }

    /* ── Fleet Map Layout ── */
    .layout {
        flex-direction: column;
        height: calc(100vh - var(--header-h));
        height: calc(100dvh - var(--header-h));
    }

    .map-container {
        flex: 1;
        min-height: 0;
        position: relative;
    }

    .map-fab { display: flex; }
    .map-fab.fab-list {
        bottom: 16px;
        left: 12px;
    }

    /* ── Sidebar -> Bottom Sheet ── */
    .sidebar {
        width: 100%;
        position: fixed;
        bottom: 60px; /* above mobile nav */
        left: 0;
        right: 0;
        max-height: 55dvh;
        height: auto;
        border-right: none;
        border-top: 1px solid var(--border);
        border-radius: 16px 16px 0 0;
        background: var(--bg-subtle);
        z-index: 1500;
        transform: translateY(0);
        transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .sidebar.collapsed {
        max-height: 180px;
    }

    .sidebar.hidden {
        transform: translateY(calc(100% + 60px));
    }

    .sheet-handle { display: block; }
    .mobile-stats { display: flex; }

    .sidebar-search { padding: 8px 12px 6px; }
    .search-input { padding: 8px 10px 8px 34px; font-size: 14px; /* prevent iOS zoom */ }
    .search-wrap i { left: 10px; }

    .sidebar-filters { padding: 4px 12px 6px; gap: 5px; overflow-x: auto; flex-wrap: nowrap; }
    .sidebar-filters::-webkit-scrollbar { display: none; }
    .filter-btn { padding: 5px 14px; font-size: 12px; }

    .vehicle-list { padding: 2px 6px 80px; /* extra bottom for nav */ }

    .vehicle-card { padding: 10px; gap: 10px; }
    .v-icon { width: 36px; height: 36px; font-size: 16px; border-radius: 8px; }
    .v-icon .status-ring { width: 9px; height: 9px; }
    .vehicle-name { font-size: 13px; }
    .v-speed { font-size: 14px; }

    /* ── Map adjustments ── */
    .leaflet-control-zoom { display: none !important; }
    .leaflet-control-attribution { font-size: 8px !important; }

    .leaflet-popup-content { min-width: 200px; }
    .popup-inner { padding: 12px; }
    .popup-grid { gap: 6px; }
    .popup-stat { padding: 6px; }
    .popup-stat-value { font-size: 12px; }
    .popup-link { padding: 10px 0; font-size: 13px; }

    /* ── Vehicle Detail ── */
    .detail-layout {
        flex-direction: column;
        height: auto;
        min-height: calc(100dvh - var(--header-h) - 60px);
    }

    .detail-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 16px 14px 24px;
        overflow-y: visible;
        overflow-x: hidden;
        order: 2;
    }

    .detail-layout {
        overflow-y: auto;
        padding-bottom: 70px; /* space for mobile nav */
    }

    .detail-main {
        order: 1;
        flex: none;
    }

    #detail-map {
        height: 40dvh !important;
        min-height: 250px;
        flex: none !important;
    }

    .telemetry-panel {
        max-height: none;
        overflow-x: auto;
        order: 3;
    }

    .telem-table { min-width: 600px; }
    .telem-table th { padding: 8px 10px; font-size: 9px; white-space: nowrap; }
    .telem-table td { padding: 6px 10px; font-size: 10px; white-space: nowrap; }

    .detail-vehicle-header { gap: 12px; }
    .detail-vehicle-icon { width: 44px; height: 44px; font-size: 20px; border-radius: 12px; }
    .detail-title { font-size: 18px; }
    .detail-plate { font-size: 11px; }

    .back-link { margin-bottom: 14px; }
    .info-section { margin-top: 18px; }

    .stats-grid { gap: 6px; }
    .stat-card { padding: 12px; }
    .stat-card-value { font-size: 20px; }

    .info-row { padding: 9px 12px; font-size: 12px; }
    .info-row-value { font-size: 11px; }

    .packet-box { font-size: 8px; padding: 12px; line-height: 1.8; }
    .packet-box::before { font-size: 8px; }
    .packet-legend { gap: 8px; font-size: 9px; }

    /* ── Content Pages (Mileage, Alerts) ── */
    .content-page {
        padding: 16px 12px 80px;
        height: auto;
        min-height: calc(100dvh - var(--header-h) - 60px);
    }

    .page-title { font-size: 20px; margin-bottom: 16px; }

    /* Mileage table scroll */
    .data-table { display: block; overflow-x: auto; white-space: nowrap; }
    .data-table th { padding: 10px 14px; font-size: 10px; }
    .data-table td { padding: 10px 14px; font-size: 12px; }

    /* Alert cards */
    .alert-card { padding: 12px; gap: 10px; }
    .alert-icon { width: 34px; height: 34px; font-size: 14px; border-radius: 8px; }
    .alert-title { font-size: 13px; }
    .alert-desc { font-size: 11px; }
    .alert-time { font-size: 10px; }
}

/* ── Extra small phones (iPhone SE etc) ── */
@media (max-width: 380px) {
    .header { padding: 0 8px; }
    .logo-text { font-size: 13px; }

    .sidebar.collapsed { max-height: 160px; }

    .vehicle-card { padding: 8px; gap: 8px; }
    .v-icon { width: 32px; height: 32px; font-size: 14px; }
    .vehicle-name { font-size: 12px; }
    .vehicle-meta { font-size: 11px; }
    .v-speed { font-size: 13px; }

    .stat-card-value { font-size: 18px; }
    .info-row { font-size: 11px; }

    .popup-grid { grid-template-columns: 1fr; }
}

/* ── Landscape phone ── */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar.collapsed { max-height: 140px; }
    .sidebar { max-height: 45dvh; }
    #detail-map { height: 35dvh !important; min-height: 200px; }
}

/* ── Touch improvements ── */
@media (hover: none) and (pointer: coarse) {
    .vehicle-card { min-height: 56px; }
    .filter-btn { min-height: 32px; padding: 6px 14px; }
    .popup-link { min-height: 44px; display: flex; align-items: center; justify-content: center; }
    .alert-card { min-height: 56px; }
    .mobile-nav-item { min-height: 44px; }
    .back-link { min-height: 44px; padding: 8px 0; }
}
