/* ==========================================================================
   Cars With Jack Road Trip Tracker - CSS Design System (Dark Mode Glassmorphism)
   ========================================================================== */

:root {
    --bg-color: #0b0f19;
    --panel-bg: rgba(15, 23, 42, 0.85); /* slate-900 glassmorphism */
    --panel-border: rgba(255, 255, 255, 0.08);
    --panel-glow: rgba(129, 140, 248, 0.08);
    --card-bg: rgba(30, 41, 59, 0.45); /* slate-800 transparency */
    --card-border: rgba(255, 255, 255, 0.06);
    
    --text-primary: #f8fafc;    /* slate-50 */
    --text-secondary: #cbd5e1;  /* slate-300 */
    --text-muted: #94a3b8;      /* slate-400 */
    
    --accent-indigo: #818cf8;   /* indigo-400 */
    --accent-indigo-rgb: 129, 140, 248;
    --accent-green: #34d399;
    --accent-orange: #fbbf24;
    --accent-red: #f87171;
    --youtube-red: #ff0000;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --shadow-premium: 0 10px 30px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-large: 0 20px 40px rgba(0, 0, 0, 0.4);
    
    --font-main: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-body: var(--font-main);
    --shadow-small: 0 4px 12px rgba(0, 0, 0, 0.18);
    --shadow-medium: 0 8px 20px rgba(0, 0, 0, 0.26);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Helper Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.margin-top { margin-top: 16px; }
.text-orange { color: var(--accent-orange); }
.text-indigo { color: var(--accent-indigo); }

.country-flags-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 6px 0;
}

.country-flag {
    display: block;
    width: 32px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}

/* ===========================================================================
   Leaflet map controls
   ========================================================================== */

#map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    background-color: var(--bg-color);
}

/* Custom Zoom Controls to Match Light Mode */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-premium) !important;
}

.leaflet-control-zoom a {
    background: var(--panel-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--panel-border) !important;
    backdrop-filter: blur(12px);
    transition: var(--transition-fast);
}

.leaflet-control-zoom a:hover {
    background: var(--accent-indigo) !important;
    color: #fff !important;
    border-color: var(--accent-indigo) !important;
}

/* Popup fallback (the complete dark popup styling lives with the map rules below). */
.leaflet-popup-content-wrapper {
    background: var(--panel-bg) !important;
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    color: var(--text-primary) !important;
    border-radius: 16px !important;
    box-shadow: var(--shadow-large) !important;
}

.leaflet-popup-tip {
    background: var(--panel-bg) !important;
    border-left: 1px solid var(--panel-border);
    border-bottom: 1px solid var(--panel-border);
}

.leaflet-popup-content {
    margin: 14px 18px !important;
    line-height: 1.5;
}

/* ==========================================================================
   Overlay Fullscreens (Waiting & Finished States)
   ========================================================================== */

.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
    box-sizing: border-box;
    transition: var(--transition-normal);
}

.overlay-screen.active {
    display: flex;
}

.splash-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 32px;
    padding: 36px 28px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-large);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin: auto;
}

.channel-logo {
    width: 80px;
    height: 80px;
    background: rgba(var(--accent-indigo-rgb), 0.08);
    border: 1px solid rgba(var(--accent-indigo-rgb), 0.15);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin-bottom: 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.splash-card h1 {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text-primary);
}

.trip-badge {
    font-family: var(--font-heading);
    background: rgba(var(--accent-indigo-rgb), 0.1);
    color: var(--accent-indigo);
    border: 1px solid rgba(var(--accent-indigo-rgb), 0.15);
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.trip-badge.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.15);
}

.splash-text {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 4px 0;
}

.status-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 12px 20px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Subscribe & Social buttons */
.social-links {
    width: 100%;
    margin-top: 10px;
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    font-weight: 600;
    text-decoration: none;
    font-size: 14px;
    transition: var(--transition-fast);
}

.social-btn.youtube {
    background: var(--youtube-red);
    color: #fff;
    box-shadow: 0 4px 14px rgba(255, 0, 0, 0.2);
}

.social-btn.youtube:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 0, 0, 0.3);
}

/* Stats dashboard inside cover */
.final-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
    margin: 8px 0;
}

.final-stat-card {
    background: var(--card-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.final-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.final-stat-val {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-indigo);
}

.final-stat-unit {
    font-size: 10px;
    color: var(--text-muted);
}

.action-buttons-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

.primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent-indigo);
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: 0 4px 14px rgba(var(--accent-indigo-rgb), 0.2);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--accent-indigo-rgb), 0.3);
}

/* ==========================================================================
   Sidebar overlay (Active State)
   ========================================================================== */

.sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    bottom: 20px;
    width: 380px;
    z-index: 10;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: var(--shadow-premium);
    transition: var(--transition-normal);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    transform: translateX(-400px);
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Sidebar Toggle button */
.sidebar-toggle-btn {
    position: absolute;
    right: -42px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 60px;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-left: none;
    border-radius: 0 12px 12px 0;
    color: var(--text-primary);
    cursor: pointer;
    z-index: 11;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 0 10px rgba(0,0,0,0.02);
    transition: var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    color: var(--accent-indigo);
    background: #fff;
}

.sidebar.collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

/* Header */
.app-header {
    padding: 24px 24px 20px;
    border-bottom: 1px solid var(--panel-border);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    cursor: pointer;
}

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(var(--accent-indigo-rgb), 0.08);
    border: 1px solid rgba(var(--accent-indigo-rgb), 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-indigo);
    font-size: 20px;
}

.logo-area h1 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.2;
    color: var(--text-primary);
}

.subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

/* Timer card block */
.live-status-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border-radius: 12px;
    padding: 10px 16px;
    border: 1px solid var(--panel-border);
}

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

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-dot.pulsing {
    animation: statusPulse 2s infinite;
}

.status-dot.online {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.status-dot.offline {
    background-color: var(--accent-red);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.status-dot.warning {
    background-color: var(--accent-orange);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.status-text {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-indigo);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Timer SVG */
.countdown-wrapper {
    position: relative;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.countdown-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.countdown-bg {
    fill: none;
    stroke: rgba(0, 0, 0, 0.04);
    stroke-width: 3.5;
}

.countdown-bar {
    fill: none;
    stroke: var(--accent-indigo);
    stroke-width: 3.5;
    stroke-linecap: round;
    transition: stroke-dasharray 1s linear;
}

.countdown-number {
    position: absolute;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-heading);
    color: var(--text-primary);
}

/* ==========================================================================
   Sidebar: Content / Stats
   ========================================================================== */

.vehicles-section {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.vehicles-section::-webkit-scrollbar {
    width: 5px;
}

.vehicles-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Mileage Hero Display */
.mileage-hero-card {
    background: linear-gradient(135deg, rgba(var(--accent-indigo-rgb), 0.04) 0%, rgba(var(--accent-indigo-rgb), 0.01) 100%);
    border: 1px solid rgba(var(--accent-indigo-rgb), 0.15);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    box-shadow: inset 0 2px 4px rgba(var(--accent-indigo-rgb), 0.02);
}

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

.mileage-value-container {
    margin: 8px 0;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
}

.mileage-val {
    font-family: var(--font-heading);
    font-size: 38px;
    font-weight: 900;
    color: var(--accent-indigo);
    letter-spacing: -1px;
}

.mileage-unit {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

.mileage-sub {
    font-size: 10px;
    color: var(--text-muted);
}

/* Section Title */
.section-title {
    margin-top: 8px;
}

.section-title h2 {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Stats dashboard */
.status-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.status-metric-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.metric-value-large {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
}

.metric-unit {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Address detail card */
.address-container-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.address-details {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.4;
}

.address-details i {
    color: var(--accent-indigo);
    margin-top: 3px;
    font-size: 14px;
}

.last-ping-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    padding-top: 8px;
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-muted);
}

/* Privacy Mode overlay */
.privacy-active-banner {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 18px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: var(--accent-red);
}

.privacy-active-banner i {
    font-size: 20px;
    margin-top: 2px;
}

.privacy-active-banner h4 {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 2px;
}

.privacy-active-banner p {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 18px 24px;
    border-top: 1px solid var(--panel-border);
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 11px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.action-btn:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: var(--accent-indigo);
    color: var(--accent-indigo);
}

.action-btn i.loading {
    animation: fa-spin 1s infinite linear;
}

/* ==========================================================================
   Map Popup Style (Light Mode Override)
   ========================================================================== */

.map-popup-card {
    min-width: 200px;
}

.map-popup-card h4 {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 4px;
    color: var(--text-primary);
}

.popup-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 11px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
}

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

.popup-value {
    font-weight: 600;
    color: var(--text-primary);
}

.popup-value.moving { color: var(--accent-green); }
.popup-value.parked { color: var(--accent-orange); }

/* Leaflet Dark Mode Popup Overrides */
.leaflet-popup-content-wrapper {
    background: var(--panel-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--panel-border) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px !important;
    box-shadow: var(--shadow-large) !important;
}

.leaflet-popup-tip {
    background: var(--panel-bg) !important;
    border: 1px solid var(--panel-border) !important;
}

.leaflet-popup-close-button {
    color: var(--text-muted) !important;
}

.leaflet-popup-close-button:hover {
    color: var(--text-primary) !important;
}

/* Leaflet Dark Mode Zoom Controls */
.leaflet-bar {
    border: 1px solid var(--panel-border) !important;
    box-shadow: var(--shadow-premium) !important;
}

.leaflet-bar a {
    background-color: var(--panel-bg) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--panel-border) !important;
}

.leaflet-bar a:hover {
    background-color: rgba(30, 41, 59, 0.8) !important;
    color: var(--accent-indigo) !important;
}

/* ==========================================================================
   Modals & Admin panel controls
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.3); /* Slate dark tint */
    backdrop-filter: blur(8px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #fff;
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    width: 90%;
    max-width: 440px;
    box-shadow: var(--shadow-large);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

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

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

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.modal-close:hover {
    color: var(--accent-red);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--panel-border);
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
}

.modal-footer button {
    padding: 10px 20px;
}

/* Admin controls styled form */
.styled-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 10px;
    outline: none;
    font-size: 14px;
    transition: var(--transition-fast);
}

.styled-input:focus {
    border-color: var(--accent-indigo);
    background: rgba(15, 23, 42, 0.6);
    box-shadow: 0 0 0 3px rgba(var(--accent-indigo-rgb), 0.1);
}

.admin-controls-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-controls-grid.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.admin-controls-grid label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 700;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.admin-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.admin-btn:hover {
    background: rgba(30, 41, 59, 0.8);
    color: var(--accent-indigo);
    border-color: var(--accent-indigo);
}

.admin-btn.active {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.btn-start.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border-color: var(--accent-green);
}

.btn-stop.active {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border-color: var(--accent-red);
}

.btn-hide.active {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-orange);
    border-color: var(--accent-orange);
}

.btn-show.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--accent-indigo);
    border-color: var(--accent-indigo);
}

/* Reset button warning styling */
.btn-reset {
    background: rgba(248, 113, 113, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(248, 113, 113, 0.2);
}
.btn-reset:hover {
    background: rgba(248, 113, 113, 0.2);
    color: var(--accent-red);
    border-color: var(--accent-red);
}

/* ==========================================================================
   Toast Alerts (Popup notifications)
   ========================================================================== */

.toast-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    padding: 14px 20px;
    border-radius: 14px;
    box-shadow: var(--shadow-large);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    min-width: 280px;
    transform: translateY(-20px);
    opacity: 0;
    animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast i { font-size: 18px; }
.toast-success i { color: var(--accent-green); }
.toast-error i { color: var(--accent-red); }
.toast-info i { color: var(--accent-indigo); }
.toast-warning i { color: var(--accent-orange); }

.toast-content {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
}

/* ==========================================================================
   Custom Vehicle Marker
   ========================================================================== */

.vehicle-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-pulse-wrapper {
    position: relative;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-halo {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(var(--accent-indigo-rgb), 0.15);
}

.btn-speed-safe.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border-color: var(--accent-green);
}

.marker-halo.moving {
    animation: markerRadar 1.6s infinite ease-out;
}

.marker-halo.parked {
    background: rgba(245, 158, 11, 0.15);
}

.marker-center {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent-indigo);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 2;
    /* Limit transition to styles, NOT transform/position properties, to avoid Leaflet positioning conflicts */
    transition: border-color 0.15s ease, background-color 0.15s ease;
    overflow: hidden;
    /* Hardware acceleration rendering context to prevent zoom blurriness */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translate3d(0,0,0);
}

.marker-center.moving {
    animation: drivingGlow 1.5s infinite ease-in-out;
}

/* Disable keyframe animations temporarily during active map zoom transitions */
/* This solves browser transform compositing issues where markers clip or disappear */
.leaflet-zoom-anim .marker-center,
.leaflet-zoom-anim .marker-halo {
    animation: none !important;
    transition: none !important;
}

.marker-center.parked {
    border-color: var(--accent-orange);
}

@keyframes markerRadar {
    0% { transform: scale(0.5); opacity: 0.9; }
    70% { transform: scale(1.22); opacity: 0.12; }
    100% { transform: scale(1.35); opacity: 0; }
}

@keyframes drivingGlow {
    0%, 100% { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(129, 140, 248, 0.34); }
    50% { box-shadow: 0 5px 14px rgba(0, 0, 0, 0.32), 0 0 0 7px rgba(129, 140, 248, 0); }
}

.marker-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.marker-direction-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 10px solid var(--accent-indigo);
    top: -4px;
    left: calc(50% - 6px);
    z-index: 1;
}

.marker-direction-arrow.parked {
    border-bottom-color: var(--accent-orange);
}

.marker-direction-arrow.moving {
    animation: directionPulse 1.5s infinite ease-in-out;
}

@keyframes directionPulse {
    0%, 100% { filter: drop-shadow(0 0 0 rgba(129, 140, 248, 0)); }
    50% { filter: drop-shadow(0 0 5px rgba(129, 140, 248, 0.85)); }
}

/* ==========================================================================
   Animations & Transitions
   ========================================================================== */

@keyframes statusPulse {
    0% { transform: scale(0.95); opacity: 0.5; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.0); }
    100% { transform: scale(0.95); opacity: 0.5; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes toastIn {
    to { transform: translateY(0); opacity: 1; }
}

@keyframes markerPulse {
    0% { transform: scale(0.3); opacity: 0.8; }
    100% { transform: scale(1.1); opacity: 0; }
}

/* ==========================================================================
   Mobile Responsive Adjustments
   ========================================================================== */

@media (max-width: 500px) {
    .sidebar {
        top: auto;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 44vh;
        border-radius: 20px 20px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: 0 -10px 30px rgba(0,0,0,0.08);
    }
    
    .sidebar.collapsed {
        transform: translateY(100%) translateY(-60px);
    }
    
    .sidebar-toggle-btn {
        right: 20px;
        top: -30px;
        width: 56px;
        height: 30px;
        border-radius: 10px 10px 0 0;
        border-bottom: none;
        border-right: 1px solid var(--panel-border);
        border-left: 1px solid var(--panel-border);
        transform: none;
    }
    
    .sidebar.collapsed .sidebar-toggle-btn i {
        transform: rotate(90deg);
    }
    
    .sidebar-toggle-btn i {
        transform: rotate(-90deg);
    }
    
    .app-header {
        padding: 10px 16px;
        border-bottom: 1px solid var(--panel-border);
    }
    
    .app-header h1 {
        font-size: 18px;
    }
    
    .app-header .subtitle {
        font-size: 10px;
    }
    
    .vehicles-section {
        padding: 12px 16px;
        gap: 10px;
    }
    
    .section-title {
        margin-bottom: 4px;
    }
    
    .section-title h2 {
        font-size: 11px;
    }
    
    /* Compact mileage hero */
    .mileage-hero-card {
        padding: 12px 16px;
        border-radius: 16px;
    }
    
    .mileage-label {
        font-size: 9px;
        margin-bottom: 2px;
    }
    
    .mileage-value-container {
        gap: 4px;
    }
    
    .mileage-val {
        font-size: 26px;
    }
    
    .mileage-unit {
        font-size: 12px;
    }
    
    .mileage-sub {
        font-size: 8px;
        margin-top: 2px;
    }
    
    /* 4-column metric row on mobile */
    .status-cards-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px;
    }
    
    .status-metric-card {
        padding: 6px 4px;
        border-radius: 12px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    
    .metric-label {
        font-size: 8px;
        margin-bottom: 2px;
    }
    
    .metric-value-large {
        font-size: 13px !important;
        line-height: 1.2 !important;
    }
    
    .metric-unit {
        font-size: 8px;
    }
    
    /* Compact location and flag details */
    .address-container-card {
        padding: 8px 12px;
        border-radius: 12px;
    }
    
    .country-flags-list {
        padding: 2px 0 !important;
    }

    .country-flag {
        width: 28px;
        height: 21px;
    }
    
    .address-details {
        font-size: 12px;
        gap: 6px;
    }
    
    .last-ping-footer {
        font-size: 9px;
        margin-top: 4px;
    }
    
    /* Compact YouTube subscribe button */
    .youtube-sidebar-card {
        margin-top: 4px;
    }
    
    .youtube-sidebar-btn {
        padding: 10px 12px;
        font-size: 12px;
        border-radius: 12px;
    }
    
    /* Compact splash wait/completed covers */
    .splash-card {
        width: 90% !important;
        padding: 24px 16px !important;
        border-radius: 20px !important;
        gap: 12px !important;
    }
    
    .splash-card h1 {
        font-size: 22px !important;
    }
    
    .splash-card p {
        font-size: 12px !important;
    }
    
    .channel-logo.avatar-logo {
        width: 80px !important;
        height: 80px !important;
        margin-bottom: 8px !important;
    }
    
    .final-stats-grid {
        gap: 6px !important;
        margin-bottom: 10px !important;
    }
    
    .final-stat-card {
        padding: 8px 6px !important;
        border-radius: 12px !important;
    }
    
    .final-stat-label {
        font-size: 9px !important;
    }
    
    .final-stat-val {
        font-size: 18px !important;
    }
    
    .final-stat-unit {
        font-size: 10px !important;
    }
    
    .final-countries-container {
        padding: 8px 12px !important;
        border-radius: 12px !important;
        margin-bottom: 12px !important;
    }
    
    /* Hide Leaflet zoom controls on mobile for a clean canvas */
    .leaflet-control-zoom {
        display: none !important;
    }
}

/* Custom Avatar Logo for Waiting Splash Screen */
.channel-logo.avatar-logo {
    width: 110px;
    height: 110px;
    background: none;
    border: none;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 16px;
    border: 3px solid var(--accent-indigo);
    animation: avatarPulse 3s infinite;
}

.splash-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

@keyframes avatarPulse {
    0% { box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(129, 140, 248, 0); }
    100% { box-shadow: 0 0 0 0 rgba(129, 140, 248, 0); }
}

/* YouTube Subscription Sidebar Card styling */
.youtube-sidebar-card {
    margin-top: 16px;
    width: 100%;
}

.youtube-sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px;
    border-radius: 16px;
    background: #ff0000; /* YouTube Red */
    color: #ffffff;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.2);
    transition: all 0.2s ease-in-out;
}

.youtube-sidebar-btn:hover {
    background: #e60000;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 0, 0, 0.3);
}

.youtube-sidebar-btn i {
    font-size: 18px;
}

/* ==========================================================================
   Live Travel Updates Timeline Feed
   ========================================================================== */
.updates-timeline {
    position: relative;
    padding-left: 20px;
    margin-left: 10px;
    border-left: 2px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 10px;
    padding-bottom: 10px;
}

.timeline-item {
    position: relative;
}

/* Timeline dot */
.timeline-item::before {
    content: '';
    position: absolute;
    left: -27px; /* Align precisely on the line: 20px padding + 10px margin - 3px half width */
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-indigo);
    border: 3px solid var(--panel-bg);
    box-shadow: 0 0 0 2px rgba(var(--accent-indigo-rgb), 0.15);
    z-index: 2;
}

.timeline-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.timeline-time {
    font-weight: 700;
    color: var(--accent-indigo);
}

.timeline-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 14px;
    box-shadow: var(--shadow-small);
    transition: all 0.25s ease-in-out;
    text-align: left;
}

.timeline-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.timeline-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    margin: 0;
    word-break: break-word;
}

.timeline-location {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-indigo);
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.timeline-img-container {
    width: 100%;
    margin-top: 10px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
}

.timeline-img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), filter 0.22s ease;
}

.timeline-img:hover {
    transform: scale(1.02);
    filter: brightness(1.06);
}

.pre-trip-img:hover {
    transform: scale(1.02);
}

/* Tab contents toggling */
.tab-content {
    display: none;
}

.tab-content.active {
    display: flex;
}

/* Media Query Overrides for Timeline on Mobile */
@media (max-width: 500px) {
    .updates-timeline {
        padding-left: 16px;
        margin-left: 6px;
        gap: 14px;
    }
    
    .timeline-item::before {
        left: -22px;
        width: 10px;
        height: 10px;
        border-width: 2px;
    }
    
    .timeline-card {
        padding: 10px 12px;
        border-radius: 12px;
    }
    
    .timeline-text {
        font-size: 12px;
    }
    
    .timeline-img-container {
        margin-top: 8px;
    }
}

/* Blurry Polyline and Privacy Circle Zones */
.blurry-polyline {
    filter: blur(3px) opacity(0.65);
    stroke-dasharray: 4, 10;
    transition: filter 0.3s ease, opacity 0.3s ease;
}

.privacy-zone-circle {
    filter: blur(5px);
    transition: filter 0.3s ease, opacity 0.3s ease;
}

.privacy-zone-tooltip {
    background: transparent !important;
    border: none !important;
    color: var(--accent-indigo) !important;
    font-family: var(--font-heading) !important;
    font-weight: 800 !important;
    font-size: 11px !important;
    text-transform: uppercase !important;
    letter-spacing: 1.2px !important;
    box-shadow: none !important;
    text-shadow: 0 0 10px rgba(0,0,0,0.6), 0 0 4px rgba(129,140,248,0.5) !important;
}

/* Spotify Widget Card */
.spotify-widget {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.6) 0%, rgba(29, 185, 84, 0.05) 100%);
    border: 1px solid rgba(29, 185, 84, 0.2);
    border-radius: 18px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.spotify-widget::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(29, 185, 84, 0.03) 0%, transparent 70%);
    pointer-events: none;
}

.spotify-art-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.06);
    position: relative;
}

.spotify-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.spotify-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.spotify-now-playing {
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #1db954;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
}

.spotify-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    display: block;
}

.spotify-title:hover {
    color: #1db954;
}

.spotify-artist {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Micro Equalizer Animation */
.spotify-equalizer {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    width: 12px;
    height: 10px;
}

.eq-bar {
    width: 2px;
    height: 100%;
    background-color: #1db954;
    border-radius: 1px;
    animation: bounceEq 0.8s ease-in-out infinite alternate;
    transform-origin: bottom;
}

.eq-bar:nth-child(1) { height: 30%; animation-delay: -0.2s; }
.eq-bar:nth-child(2) { height: 60%; animation-delay: -0.4s; }
.eq-bar:nth-child(3) { height: 90%; animation-delay: -0.6s; }

@keyframes bounceEq {
    0% { transform: scaleY(0.3); }
    100% { transform: scaleY(1); }
}

/* Spotify Play History Widget Styling */
.spotify-history-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    z-index: 10;
}

.spotify-history-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.spotify-history-panel {
    width: 100%;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideDown 0.3s ease forwards;
}

.spotify-history-panel.hidden {
    display: none;
}

.spotify-history-panel h4 {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin: 0 0 2px 0;
}

.spotify-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.spotify-history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.spotify-history-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.spotify-history-art {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.spotify-history-details {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.spotify-history-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.spotify-history-artist {
    font-size: 9px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Premium Full-Page Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0b0f19;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(79, 70, 229, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-indigo);
    animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Update Map Marker */
.update-map-marker {
    width: 28px;
    height: 28px;
    background: var(--accent-indigo);
    border: 2px solid #ffffff;
    border-radius: 50%;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.update-map-marker:hover {
    transform: scale(1.18);
    background: #4338ca;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.6);
}

/* Update Map Popup Card overrides */
.update-popup-card {
    padding: 4px;
    font-family: var(--font-body);
}

.update-popup-time {
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 700;
    color: var(--accent-indigo);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}

.update-popup-text {
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;
}

.update-popup-image {
    width: 100%;
    border-radius: 8px;
    margin-top: 8px;
    object-fit: cover;
    max-height: 120px;
    border: 1px solid var(--panel-border);
    cursor: pointer;
    transition: transform 0.22s ease, filter 0.22s ease;
}

.update-popup-image:hover {
    transform: scale(1.02);
    filter: brightness(1.06);
}

/* Premium Darkened Map Base Pane Filter */
.leaflet-darkBasePane-pane,
.leaflet-darkBasePaneFinished-pane {
    filter: invert(0.9) hue-rotate(180deg) brightness(0.95) contrast(1.2) saturate(1.35);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile-first refinements: preserve map space while making controls easy to tap. */
@media (max-width: 700px) {
    body, #map {
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
    }

    .sidebar {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: min(68dvh, 580px);
        max-height: calc(100dvh - 64px);
        border-width: 1px 0 0;
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.28);
    }

    .sidebar.collapsed {
        transform: translateY(calc(100% - 68px));
    }

    .sidebar-toggle-btn {
        top: -44px;
        right: 16px;
        width: 72px;
        height: 44px;
        border: 1px solid var(--panel-border);
        border-bottom: 0;
        border-radius: 14px 14px 0 0;
        transform: none;
    }

    .sidebar.collapsed .sidebar-toggle-btn i { transform: rotate(90deg); }
    .sidebar-toggle-btn i { transform: rotate(-90deg); }

    .app-header {
        padding: 12px 16px 10px;
    }

    .logo-area {
        gap: 10px;
        margin-bottom: 10px;
    }

    .logo-icon { width: 38px; height: 38px; }
    .app-header h1 { font-size: 17px; }
    .live-status-container { padding: 9px 12px; }
    .status-text { font-size: 10px; }

    .sidebar-tab-btn {
        min-height: 46px;
        font-size: 12px !important;
    }

    .vehicles-section {
        padding: 12px 16px;
        gap: 10px;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .status-cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px;
    }

    .status-metric-card { min-height: 66px; padding: 9px 8px; }
    .metric-label { font-size: 8px; }
    .metric-value-large { font-size: 18px !important; }

    .sidebar-footer {
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    }

    .action-btn, .primary-btn, .admin-btn, .social-btn, .youtube-sidebar-btn {
        min-height: 44px;
    }

    .overlay-screen {
        position: fixed;
        width: 100vw;
        height: 100dvh;
        padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
        align-items: center;
    }

    .splash-card {
        width: 100% !important;
        max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    #analyticsScreen .splash-card {
        align-items: stretch;
        text-align: left !important;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-card {
        width: 100%;
        max-width: none;
        max-height: min(86dvh, 720px);
        border-radius: 22px 22px 0 0;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .modal-header, .modal-body, .modal-footer { padding-right: 16px; padding-left: 16px; }
    .modal-footer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }

    .toast-container {
        position: fixed;
        top: max(12px, env(safe-area-inset-top));
        right: 12px;
        left: 12px;
    }

    .toast { min-width: 0; width: 100%; padding: 12px 14px; }

    #closeLightboxBtn { top: max(16px, env(safe-area-inset-top)) !important; right: max(16px, env(safe-area-inset-right)) !important; }
    #lightboxImage { max-width: calc(100% - 28px) !important; max-height: calc(100dvh - 112px) !important; }

    .leaflet-control-attribution { max-width: calc(100vw - 110px); font-size: 9px; }
}
