#map {
    position: absolute;
    top: 0; bottom: 0;
    left: 0; right: 0;
    width: 100%;
    height: 100%;
}

/* ── Popup shell ── */
.mapboxgl-popup.pinpoint-popup .mapboxgl-popup-content {
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px !important;
    padding: 0 !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6) !important;
    min-width: 200px;
}

.mapboxgl-popup.pinpoint-popup .mapboxgl-popup-tip {
    border-top-color: rgba(15, 23, 42, 0.95) !important;
}

.mapboxgl-popup.pinpoint-popup .mapboxgl-popup-close-button {
    color: rgba(255, 255, 255, 0.4);
    font-size: 18px;
    padding: 6px 10px;
    right: 2px;
    top: 2px;
    background: transparent;
}

.mapboxgl-popup.pinpoint-popup .mapboxgl-popup-close-button:hover {
    color: white;
    background: transparent;
}

/* ── Scale control ── */
.mapboxgl-ctrl-scale {
    background: rgba(15, 23, 42, 0.7) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    font-family: Inter, sans-serif !important;
    font-size: 10px !important;
}

/* ── Vehicle markers ── */
.vehicle-marker-wrapper {
    cursor: pointer;
    position: relative;
}

.vehicle-icon-inner {
    cursor: pointer;
}

.vehicle-marker-wrapper:hover .vehicle-icon-inner {
    filter:
        drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6))
        brightness(1.15) !important;
}

.vehicle-name-label {
    pointer-events: none;
    user-select: none;
}

/* ── Live pulse dot ── */
.live-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #10B981;
    border-radius: 50%;
    margin-right: 5px;
    animation: livePulse 1.5s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1;   transform: scale(1);   }
    50%       { opacity: 0.5; transform: scale(1.4); }
}

/* ── Style switcher ── */
.map-style-switcher {
    position: absolute;
    bottom: 40px;
    right: 16px;
    z-index: 10;
    display: flex;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 4px;
    gap: 2px;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.15),
        0 1px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.style-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 12px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: #6B7280;
    cursor: pointer;
    font-family: Inter, sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
    min-width: 54px;
}

.style-btn i {
    font-size: 15px;
    transition: color 0.2s ease;
}

.style-btn:hover {
    background: rgba(0, 207, 213, 0.08);
    color: #00CFD5;
}

.style-btn:hover i {
    color: #00CFD5;
}

/* Day active */
.style-btn.active {
    background: #00CFD5;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 207, 213, 0.4);
}

.style-btn.active i {
    color: white;
}

/* Night active */
.style-btn.night-btn.active {
    background: #1e293b;
    color: #94a3b8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.style-btn.night-btn.active i {
    color: #e2e8f0;
}

/* Satellite active */
.style-btn.satellite-btn.active {
    background: #0f4c2a;
    color: #4ade80;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.style-btn.satellite-btn.active i {
    color: #4ade80;
}

@media (max-width: 640px) {
    .map-style-switcher {
        bottom: 60px;
        right: 12px;
    }

    .style-btn {
        padding: 7px 10px;
        min-width: 48px;
        font-size: 9px;
    }

    .style-btn i {
        font-size: 13px;
    }
}

/* ════════════════════════════════════════════════════════════════
   FLIGHTRADAR-STYLE OVERLAY UI  (sidebar / detail drawer / sheets)
   Panels are offset below the frosted top bar (top: 72px).
   ════════════════════════════════════════════════════════════════ */

/* ── Theme variables (switched by map.js applyPanelTheme) ── */
.theme-day {
    --panel-bg:      rgba(255, 255, 255, 0.96);
    --panel-border:  rgba(0, 0, 0, 0.08);
    --panel-text:    #111827;
    --panel-subtext: #6B7280;
    --panel-divider: rgba(0, 0, 0, 0.06);
    --panel-hover:   rgba(0, 207, 213, 0.06);
    --panel-shadow:  0 8px 32px rgba(0, 0, 0, 0.12);
    --search-bg:     #F9FAFB;
}

.theme-night {
    --panel-bg:      rgba(15, 23, 42, 0.96);
    --panel-border:  rgba(255, 255, 255, 0.08);
    --panel-text:    #F1F5F9;
    --panel-subtext: #64748B;
    --panel-divider: rgba(255, 255, 255, 0.06);
    --panel-hover:   rgba(0, 207, 213, 0.08);
    --panel-shadow:  0 8px 32px rgba(0, 0, 0, 0.4);
    --search-bg:     rgba(255, 255, 255, 0.05);
}

/* ── Sidebar toggle button ── */
.sidebar-toggle-btn {
    position: absolute;
    top: 72px;
    left: 16px;
    z-index: 16;
    width: 40px;
    height: 40px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    color: var(--panel-text);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease, color 0.2s ease;
}

.sidebar-toggle-btn:hover {
    background: var(--panel-hover);
    color: #00CFD5;
}

.sidebar-toggle-btn.shifted {
    left: 328px;
}

/* ── Sidebar / drawer shell ── */
.map-sidebar {
    position: absolute;
    top: 72px;
    left: 16px;
    bottom: 96px;
    width: 300px;
    z-index: 15;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(-340px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.map-sidebar.open {
    transform: translateX(0);
    pointer-events: all;
}

/* ── Sidebar header ── */
.sidebar-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--panel-divider);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--panel-text);
    font-family: Inter, sans-serif;
    letter-spacing: 0.2px;
    display: block;
    margin-bottom: 8px;
}

.sidebar-counts {
    display: flex;
    gap: 8px;
}

.count-badge {
    font-size: 11px;
    font-weight: 600;
    font-family: Inter, sans-serif;
    padding: 3px 8px;
    border-radius: 20px;
}

.count-badge.active {
    background: rgba(16, 185, 129, 0.12);
    color: #10B981;
}

.count-badge.inactive {
    background: rgba(107, 114, 128, 0.12);
    color: var(--panel-subtext);
}

/* ── Search ── */
.sidebar-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--panel-divider);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    background: var(--search-bg);
}

.sidebar-search i {
    color: var(--panel-subtext);
    font-size: 13px;
    flex-shrink: 0;
}

.sidebar-search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 13px;
    font-family: Inter, sans-serif;
    color: var(--panel-text);
    min-width: 0;
}

.sidebar-search input::placeholder {
    color: var(--panel-subtext);
}

.sidebar-search button {
    background: transparent;
    border: none;
    color: var(--panel-subtext);
    cursor: pointer;
    padding: 2px;
    font-size: 12px;
}

/* ── Vehicle list ── */
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--panel-border) transparent;
}

.list-section-label {
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--panel-subtext);
    font-family: Inter, sans-serif;
}

.list-section-label.mt-4 {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--panel-divider);
}

.vehicle-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.vehicle-list-item:hover {
    background: var(--panel-hover);
}

.vehicle-list-item.selected {
    background: rgba(0, 207, 213, 0.08);
    border-left: 3px solid #00CFD5;
    padding-left: 13px;
}

.vehicle-list-item.offline {
    opacity: 0.6;
}

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

.vehicle-status-dot.active {
    background: #10B981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    animation: activePulse 2s infinite;
}

.vehicle-status-dot.inactive {
    background: #9CA3AF;
}

@keyframes activePulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }
    50%      { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.05); }
}

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

.vehicle-list-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--panel-text);
    font-family: Inter, sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vehicle-list-sub {
    font-size: 11px;
    color: var(--panel-subtext);
    font-family: Inter, sans-serif;
    margin-top: 1px;
}

.vehicle-list-meta {
    color: var(--panel-subtext);
    font-size: 11px;
    flex-shrink: 0;
}

.sidebar-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 20px;
    color: var(--panel-subtext);
    font-family: Inter, sans-serif;
    font-size: 13px;
}

.sidebar-empty i {
    font-size: 32px;
    opacity: 0.4;
}

/* ── Detail drawer ── */
.detail-drawer {
    overflow-y: auto;
    scrollbar-width: thin;
}

.drawer-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--panel-divider);
    cursor: pointer;
    color: #00CFD5;
    font-size: 13px;
    font-weight: 600;
    font-family: Inter, sans-serif;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.drawer-back:hover { opacity: 0.7; }

.drawer-image-section {
    position: relative;
    background: linear-gradient(135deg, rgba(0, 207, 213, 0.08), rgba(0, 207, 213, 0.03));
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.drawer-boat-image {
    height: 120px;
    width: auto;
    max-width: none;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
    transform: rotate(90deg);
}

.drawer-boat-image.inactive-image {
    filter: grayscale(80%) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
    opacity: 0.6;
}

.drawer-live-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10B981;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: Inter, sans-serif;
}

.drawer-offline-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(107, 114, 128, 0.15);
    border: 1px solid rgba(107, 114, 128, 0.3);
    color: #9CA3AF;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: 20px;
    font-family: Inter, sans-serif;
}

.drawer-header {
    padding: 16px 16px 12px;
    flex-shrink: 0;
}

.drawer-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--panel-text);
    font-family: Inter, sans-serif;
    margin-bottom: 6px;
}

.drawer-type-badge {
    display: inline-block;
    color: white;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-family: Inter, sans-serif;
    margin-bottom: 4px;
}

.drawer-reg {
    font-size: 12px;
    color: var(--panel-subtext);
    font-family: Inter, sans-serif;
    margin-top: 4px;
}

.drawer-divider {
    height: 1px;
    background: var(--panel-divider);
    margin: 0 16px;
    flex-shrink: 0;
}

/* ── Stats grid ── */
.drawer-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 4px 0;
    flex-shrink: 0;
}

.stat-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--panel-divider);
}

.stat-item:nth-child(odd) {
    border-right: 1px solid var(--panel-divider);
}

.stat-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--panel-subtext);
    font-family: Inter, sans-serif;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--panel-text);
    font-family: Inter, sans-serif;
    line-height: 1;
}

.stat-value.small {
    font-size: 14px;
}

.stat-unit {
    font-size: 11px;
    font-weight: 400;
    color: var(--panel-subtext);
}

/* ── Coordinates ── */
.drawer-coords {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 12px;
    color: var(--panel-subtext);
    font-family: Inter, monospace;
    flex-shrink: 0;
}

.drawer-coords i {
    color: #00CFD5;
    font-size: 13px;
}

/* ── ETA section ── */
.drawer-eta-section {
    padding: 16px;
    flex-shrink: 0;
}

.drawer-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--panel-subtext);
    font-family: Inter, sans-serif;
    margin-bottom: 10px;
}

.eta-btn {
    width: 100%;
    background: #00CFD5;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: Inter, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.eta-btn:hover { background: #00a8ad; }

.eta-result {
    margin-top: 12px;
    background: var(--search-bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    overflow: hidden;
}

.eta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    font-size: 13px;
    font-family: Inter, sans-serif;
    border-bottom: 1px solid var(--panel-divider);
    color: var(--panel-text);
}

.eta-row:last-child { border-bottom: none; }

.eta-row span {
    color: var(--panel-subtext);
    font-size: 12px;
}

/* ── Mobile (hidden on desktop) ── */
.mobile-menu-btn { display: none; }
.mobile-sheet-backdrop { display: none; }
.mobile-bottom-sheet { display: none; }

@media (max-width: 768px) {
    .map-sidebar { display: none; }
    .sidebar-toggle-btn { display: none; }

    .mobile-menu-btn {
        display: flex;
        position: absolute;
        top: 72px;
        left: 16px;
        z-index: 20;
        width: 40px;
        height: 40px;
        background: var(--panel-bg);
        border: 1px solid var(--panel-border);
        border-radius: 10px;
        color: var(--panel-text);
        font-size: 16px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        box-shadow: var(--panel-shadow);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .mobile-menu-btn.hidden { display: none; }

    .mobile-sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 25;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .mobile-sheet-backdrop.open {
        opacity: 1;
        pointer-events: all;
    }

    .mobile-bottom-sheet {
        display: flex;
        flex-direction: column;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 30;
        background: var(--panel-bg);
        border-radius: 20px 20px 0 0;
        max-height: 75vh;
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: var(--panel-shadow);
    }

    .mobile-bottom-sheet.open { transform: translateY(0); }

    .sheet-handle {
        width: 36px;
        height: 4px;
        background: var(--panel-border);
        border-radius: 2px;
        margin: 12px auto 8px;
        flex-shrink: 0;
    }

    /* Detail drawer becomes a bottom sheet on mobile */
    .detail-drawer.open {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-height: 80vh;
        border-radius: 20px 20px 0 0;
        z-index: 30;
        transform: translateX(0);
        width: auto;
    }

    .map-style-switcher {
        bottom: 20px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}
