

/* ==================== 1. COLOR PALETTE & VARIABLES ==================== */
:root {
    /* Light Mode (Default) - Bright glassmorphism */
    --bg-gradient-start: #f0f4f8;
    --bg-gradient-end: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-bg-light: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-border-light: rgba(255, 255, 255, 0.9);

    /* Primary Brand Colors */
    --primary-brand: #3b82f6; /* Bright blue */
    --primary-brand-light: #60a5fa;
    --primary-brand-dark: #2563eb;
    --primary-brand-rgb: 59, 130, 246;

    /* Status Colors */
    --status-success: #10b981;
    --status-success-rgb: 16, 185, 129;
    --status-danger: #ef4444;
    --status-danger-rgb: 239, 68, 68;
    --status-warning: #f59e0b;
    --status-warning-rgb: 245, 158, 11;

    /* Text Colors (Dark for light background) */
    --text-color-dark: #1e293b; /* Dark for headings */
    --text-color: #475569; /* Medium gray for body */
    --text-color-light: #64748b; /* Muted gray for labels */

    /* Shadows - Soft for light mode */
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-glass-hover: 0 12px 48px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.06);

    /* Transitions */
    --transition-speed: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout & Spacing */
    --border-radius-glass: 20px;
    --border-radius-pill: 9999px;
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 20px;
    --spacing-lg: 30px;
    --spacing-xl: 40px;

    /* Chart Colors */
    --chart-bar-color: var(--primary-brand);
    --chart-pie-positive: var(--status-success);
    --chart-pie-negative: var(--status-danger);

    /* Tooltip */
    --tooltip-bg: rgba(15, 23, 42, 0.96); /* dark slate */
    --tooltip-text: #f9fafb;
}

/* Dark Mode - Glassmorphism */
body.dark-mode {
    /* Dark Mode Glassmorphism Colors */
    --bg-gradient-start: #050816;
    --bg-gradient-end: #111827;
    --glass-bg: rgba(255, 255, 255, 0.09);
    --glass-bg-light: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(255, 255, 255, 0.18);
    --glass-border-light: rgba(255, 255, 255, 0.25);

    /* Primary Brand Colors (Subtle for dark) */
    --primary-brand: #60a5fa;
    --primary-brand-light: #93c5fd;
    --primary-brand-dark: #3b82f6;
    --primary-brand-rgb: 96, 165, 250;

    /* Status Colors (Muted for dark) */
    --status-success: #34d399;
    --status-success-rgb: 52, 211, 153;
    --status-danger: #f87171;
    --status-danger-rgb: 248, 113, 113;
    --status-warning: #fbbf24;
    --status-warning-rgb: 251, 191, 36;

    /* Text Colors (Light for dark background) */
    --text-color-dark: #f9fafb;
    --text-color: #e5e7eb;
    --text-color-light: #9ca3af;

    /* Shadows - Darker for dark mode */
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-glass-hover: 0 12px 48px rgba(0, 0, 0, 0.16), 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.08);

    /* Tooltip override for dark mode */
    --tooltip-bg: rgba(15, 23, 42, 0.96);
    --tooltip-text: #f9fafb;
}

/* Auto dark mode based on system preference */
@media (prefers-color-scheme: dark) {
    body:not(.light-mode) {
        --bg-gradient-start: #050816;
        --bg-gradient-end: #111827;
        --glass-bg: rgba(255, 255, 255, 0.09);
        --glass-bg-light: rgba(255, 255, 255, 0.12);
        --glass-border: rgba(255, 255, 255, 0.18);
        --glass-border-light: rgba(255, 255, 255, 0.25);
        --primary-brand: #60a5fa;
        --primary-brand-light: #93c5fd;
        --primary-brand-dark: #3b82f6;
        --primary-brand-rgb: 96, 165, 250;
        --status-success: #34d399;
        --status-success-rgb: 52, 211, 153;
        --status-danger: #f87171;
        --status-danger-rgb: 248, 113, 113;
        --status-warning: #fbbf24;
        --status-warning-rgb: 251, 191, 36;
        --text-color-dark: #f9fafb;
        --text-color: #e5e7eb;
        --text-color-light: #9ca3af;
        --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
        --shadow-glass-hover: 0 12px 48px rgba(0, 0, 0, 0.16), 0 4px 16px rgba(0, 0, 0, 0.12);
        --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.08);
    }
    
    body:not(.light-mode)::before {
        background: 
            radial-gradient(circle at 20% 30%, rgba(96, 165, 250, 0.08) 0%, transparent 50%),
            radial-gradient(circle at 80% 70%, rgba(52, 211, 153, 0.06) 0%, transparent 50%),
            radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.3) 0%, transparent 70%);
    }
}

/* ==================== 2. BASE STYLES & LAYOUT ==================== */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    display: flex;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    background-attachment: fixed;
    color: var(--text-color);
    transition: background var(--transition-speed), color var(--transition-speed);
    line-height: 1.6;
    overflow: hidden;
    overflow-x: hidden;
    position: relative;
    width: 100vw;
    max-width: 100vw;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

body.dark-mode::before {
    background: 
        radial-gradient(circle at 20% 30%, rgba(96, 165, 250, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(52, 211, 153, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.3) 0%, transparent 70%);
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Universal focus styles for accessibility */
*:focus-visible {
    outline: 2px solid var(--primary-brand);
    outline-offset: 3px;
    border-radius: var(--border-radius-glass);
}
/* ==================== 3. SIDEBAR & SECTIONS ==================== */
#sidebar {
    width: 450px;
    min-width: 300px;
    max-width: 800px;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-glass);
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: width var(--transition-speed);
    z-index: 1001;
    flex-shrink: 0;
    flex-grow: 0;
    border-right: 1px solid var(--glass-border);
    overflow-anchor: none;
}

#sidebar.resizing {
    transition: none !important;
}

/* Resize handle - visible element for better interaction */
.sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: -4px;
    width: 12px;
    height: 100vh;
    background: transparent;
    cursor: col-resize;
    z-index: 1002;
    transition: background 0.2s;
    touch-action: none;
    user-select: none;
    pointer-events: auto;
}

.sidebar-resize-handle:hover {
    background: linear-gradient(to right, 
        transparent 0%, 
        rgba(255, 255, 255, 0.15) 50%, 
        rgba(255, 255, 255, 0.25) 100%);
}

#sidebar.resizing .sidebar-resize-handle {
    background: linear-gradient(to right, 
        transparent 0%, 
        rgba(255, 255, 255, 0.25) 50%, 
        rgba(255, 255, 255, 0.35) 100%);
}



/* Hide scrollbar but keep functionality */
#sidebar::-webkit-scrollbar {
    width: 8px;
}

#sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}



#sidebar h2 {
    font-weight: 500;
    font-size: 1.4rem;
    margin: 0;
    color: var(--text-color-dark);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: all var(--transition-speed);
    letter-spacing: -0.3px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-glass);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    color: var(--text-color-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed);
    box-shadow: var(--shadow-soft);
    padding: 0;
    flex-shrink: 0;
}

.theme-toggle-btn:hover {
    background: var(--glass-bg-light);
    border-color: var(--glass-border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glass-hover);
}

.theme-toggle-btn:active {
    transform: translateY(0);
}

.theme-toggle-btn i {
    font-size: 1.2rem;
    transition: transform var(--transition-speed);
}

.theme-toggle-btn:hover i {
    transform: rotate(15deg);
}

body.dark-mode .theme-toggle-btn i {
    transform: rotate(180deg);
}

@media (prefers-color-scheme: dark) {
    body:not(.light-mode) .theme-toggle-btn i {
        transform: rotate(180deg);
    }
}

#sidebar h2 i {
    font-size: 1.4rem;
    color: var(--primary-brand);
    opacity: 0.9;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.app-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: contain;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

.sidebar-section {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-glass);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--glass-border);
    transition: all var(--transition-speed);
    position: relative;
    overflow: visible;
    z-index: 1;
    isolation: isolate;
}

.sidebar-section:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glass-hover);
    border-color: var(--glass-border-light);
    background: var(--glass-bg-light);
}




.section-title {
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-color-dark);
    font-weight: 500;
    margin: 0 0 var(--spacing-md);
    transition: color var(--transition-speed);
    letter-spacing: -0.2px;
}

/* ==================== 5. STATISTICS & CARDS ==================== */
.stats-container {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.15) 0%, rgba(52, 211, 153, 0.12) 100%);
    border: 1px solid var(--glass-border);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-glass);
    color: var(--text-color-dark);
    position: relative;
    overflow: visible;
    z-index: 1;
    isolation: isolate;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}


.stats-container .section-title {
    color: var(--text-color-dark);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: var(--spacing-sm);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
}
.stats-grid .stat-card-large {
    grid-column: 1;
}
.stats-grid .stat-card-positive {
    grid-column: 1;
}
.stats-grid .stat-card-negative {
    grid-column: 1;
}
@media (min-width: 400px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-grid .stat-card-large {
        grid-column: 1 / -1;
    }
    .stats-grid .stat-card-positive {
        grid-column: 1;
    }
    .stats-grid .stat-card-negative {
        grid-column: 2;
    }
}
.stat-card {
    text-align: center;
    padding: var(--spacing-md);
    border-radius: var(--border-radius-glass);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    transition: all var(--transition-speed);
    box-shadow: var(--shadow-soft);
    color: var(--text-color-dark);
    position: relative;
    overflow: hidden;
}

.stat-card-large {
    grid-column: 1;
    padding: var(--spacing-lg);
    background: var(--glass-bg-light);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glass-hover);
    border-color: var(--glass-border-light);
    background: var(--glass-bg-light);
}
.stat-card-large:hover {
    transform: translateY(-3px);
}

/* Clickable stat cards */
.clickable-stat {
    cursor: pointer;
    user-select: none;
}

.clickable-stat:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glass-hover);
}

.stat-card-active {
    border: 2px solid var(--primary-brand) !important;
    box-shadow: 0 0 0 2px rgba(var(--primary-brand-rgb), 0.3), var(--shadow-glass-hover) !important;
    background: var(--glass-bg-light) !important;
}

.stat-card-positive.stat-card-active {
    border-color: var(--status-danger) !important;
    box-shadow: 0 0 0 2px rgba(var(--status-danger-rgb), 0.3), var(--shadow-glass-hover) !important;
}

.stat-card-negative.stat-card-active {
    border-color: var(--status-success) !important;
    box-shadow: 0 0 0 2px rgba(var(--status-success-rgb), 0.3), var(--shadow-glass-hover) !important;
}
.stat-icon {
    font-size: 2.5rem;
    color: var(--primary-brand);
    margin-bottom: var(--spacing-sm);
    transition: all var(--transition-speed);
    display: inline-block;
    opacity: 0.9;
}

.stat-card:hover .stat-icon {
    transform: scale(1.05);
    opacity: 1;
}
.stat-card-positive .stat-icon {
    color: var(--status-danger);
}
.stat-card-negative .stat-icon {
    color: var(--status-success);
}
.stat-card-large .stat-icon {
    font-size: 2.2rem;
    color: var(--primary-brand);
}
.stat-card-large .stat-number {
    font-size: 2.8rem;
}
.stat-number {
    font-size: 2.5rem;
    font-weight: 500;
    color: var(--text-color-dark);
    margin-bottom: var(--spacing-xs);
    transition: all var(--transition-speed);
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.stat-card:hover .stat-number {
    transform: scale(1.03);
}

.stats-container .stat-number {
    color: var(--text-color-dark);
}
.stat-label {
    font-size: 0.9rem;
    color: var(--text-color-light);
    font-weight: 400;
}

/* ==================== 5b. FILTERS ==================== */
.filters-section {
    margin-top: var(--spacing-md);
}

.filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
}

@media (min-width: 480px) {
    .filters-grid {
        grid-template-columns: 1fr 1fr;
    }

    .filters-grid .filter-field-inline {
        grid-column: 1 / -1;
    }
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.filter-field label {
    font-size: 0.8rem;
    color: var(--text-color-light);
}

.filter-field input,
.filter-field select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg-light);
    color: var(--text-color);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    width: 100%;
    box-sizing: border-box;
}

.filter-field input::placeholder {
    color: var(--text-color-light);
}

.filter-dates-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-dates-row input {
    flex: 1;
    min-width: 0;
}

.filter-date-separator {
    font-size: 0.8rem;
    color: var(--text-color-light);
}

/* Sample type checkboxes - compact, pill-like layout */
.sample-type-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
}

.sample-type-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg-light);
    font-size: 0.75rem;
    color: var(--text-color);
    cursor: pointer;
    user-select: none;
    flex: 0 0 auto; /* keep each chip only as wide as its content */
}

.sample-type-chip input[type="checkbox"] {
    width: 12px;
    height: 12px;
}

.reset-filters-btn {
    margin-top: var(--spacing-sm);
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--border-radius-pill);
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-color);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.reset-filters-btn:hover {
    background: var(--glass-bg-light);
    border-color: var(--primary-brand);
    color: var(--primary-brand);
}

/* ==================== 5c. VIEW MODE TOGGLE ==================== */
.view-mode-toggle {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: var(--spacing-md);
}

.view-mode-btn {
    border-radius: var(--border-radius-pill);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    padding: 6px 8px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-color);
    transition: all var(--transition-speed);
    white-space: nowrap;
}

.view-mode-btn i {
    font-size: 0.8rem;
}

.view-mode-btn span {
    display: none;
}

@media (min-width: 520px) {
    .view-mode-btn span {
        display: inline;
    }
}

.view-mode-btn.active {
    background: linear-gradient(135deg, rgba(var(--primary-brand-rgb), 0.15) 0%, rgba(var(--primary-brand-rgb), 0.1) 100%);
    border-color: var(--primary-brand);
    color: var(--primary-brand-dark);
    box-shadow: var(--shadow-soft);
}

.view-mode-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.map-reset-btn {
    border-radius: 0;
    border: none;
    background: var(--glass-bg);
    padding: 0;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    cursor: pointer;
    color: var(--text-color);
    transition: all var(--transition-speed);
    box-shadow: none;
}

.map-reset-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glass-hover);
    border-color: var(--primary-brand);
    color: var(--primary-brand);
}

/* ==================== 6. CHARTS ==================== */
.charts-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    width: 100%;
    max-width: 100%;
    flex-shrink: 0; /* Prevent container from being cut off */
}

.chart-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-glass);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--glass-border);
    width: 100%;
    max-width: 100%;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    margin-bottom: var(--spacing-md);
}

.chart-card canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: 250px !important;
    min-height: 200px !important;
    max-height: 300px !important;
    display: block;
    flex-shrink: 0; /* Prevent charts from shrinking */
}

/* Make category chart clickable */
#categoryChart {
    cursor: pointer;
}

/* ==================== 6b. TIMELINE ==================== */
.timeline-section {
    margin-top: var(--spacing-md);
}

.timeline-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.timeline-btn {
    border-radius: var(--border-radius-pill);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    padding: 6px 10px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-color);
    transition: all var(--transition-speed);
}

.timeline-btn.icon-only span {
    display: none;
}

.timeline-btn i {
    font-size: 0.8rem;
}

.timeline-btn:hover {
    background: var(--glass-bg-light);
    border-color: var(--primary-brand);
    color: var(--primary-brand);
}

.timeline-slider-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.timeline-slider-row input[type="range"] {
    width: 100%;
}

.timeline-label {
    font-size: 0.8rem;
    color: var(--text-color-light);
    text-align: center;
}

/* Sidebar footer */
.sidebar-footer {
    margin-top: auto;
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-color-light);
}

.sidebar-footer-text strong {
    color: var(--text-color-dark);
    font-weight: 500;
}

/* ==================== 7. SHOW DEVICES BUTTON ==================== */
.show-devices-btn {
    width: 100%;
    padding: 14px 24px;
    margin-top: var(--spacing-md);
    background: linear-gradient(135deg, rgba(var(--primary-brand-rgb), 0.15) 0%, rgba(var(--primary-brand-rgb), 0.1) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-pill);
    color: var(--text-color-dark);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--transition-speed);
    box-shadow: var(--shadow-soft);
}

.show-devices-btn i {
    font-size: 18px;
    opacity: 0.9;
}

.show-devices-btn:hover {
    background: linear-gradient(135deg, rgba(var(--primary-brand-rgb), 0.25) 0%, rgba(var(--primary-brand-rgb), 0.18) 100%);
    border-color: var(--primary-brand);
    color: var(--primary-brand-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glass-hover);
}

.show-devices-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-soft);
}



/* ==================== 8. MAP & CONTROLS ==================== */

/* Custom Scrollbar Styling */




/* Hover State */

/* Active State */


/* --- Item Content --- */



/* Dynamically generated RGB values for category background/border */


/* --- No Results Placeholder --- */

/* ==================== 9. MAP & CONTROLS ==================== */
#map {
    flex-grow: 1;
    height: 100vh;
    position: relative;
    transition: left var(--transition-speed), width var(--transition-speed);
}

.map-legend {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1004;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--glass-border);
    font-size: 0.8rem;
    color: var(--text-color);
    display: none;
    max-width: 260px;
}

.map-legend-title {
    font-weight: 500;
    color: var(--text-color-dark);
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.map-legend-gradient-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.map-legend-gradient {
    flex: 1;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(
        to right,
        hsl(220, 90%, 50%),
        hsl(140, 90%, 50%),
        hsl(60, 90%, 50%),
        hsl(0, 90%, 50%)
    );
}

.map-legend-scale-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-color-light);
    margin-bottom: 4px;
}

.map-legend-note {
    font-size: 0.7rem;
    color: var(--text-color-light);
    line-height: 1.3;
}
#countryBarChart {
    max-height: 250px;
    height: 250px;
}
.loading {
    display: none;
    text-align: center;
    padding: var(--spacing-md);
    color: var(--primary-brand);
    font-weight: 500;
    font-size: 1.1rem;
}
.loading.active {
    display: block;
}


/* --- Custom Marker Icon (from JS) --- */
.custom-marker {
    box-shadow: none; /* Removed the box-shadow */
    border: 3px solid white;
}

/* ==================== 10. LEAFLET POPUP STYLES ==================== */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-glass);
    border-radius: var(--border-radius-glass);
    border: 1px solid var(--glass-border);
}
.leaflet-popup-content {
    margin: var(--spacing-md);
    line-height: 1.6;
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
}
.popup-header {
    font-weight: 500;
    color: var(--text-color-dark);
    margin-bottom: var(--spacing-xs);
    font-size: 1.1rem;
}
.popup-detail {
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.9rem;
    color: var(--text-color);
}
.popup-detail i {
    width: 16px;
    color: var(--primary-brand);
    opacity: 0.8;
}

/* ==================== 11. DETAILED INFORMATION PANEL ==================== */
.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-glass);
    z-index: 1005;
    transform: translateX(100%);
    transition: transform var(--transition-speed) ease-in-out;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--glass-border);
}

.detail-panel.active {
    transform: translateX(0); /* Slide in */
}


.detail-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--glass-border);
    background: var(--glass-bg-light);
    color: var(--text-color-dark);
    flex-shrink: 0;
}

.detail-panel-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-color-dark);
}

.detail-panel-header .close-btn {
    background: none;
    border: none;
    color: var(--text-color-light);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color var(--transition-speed);
}

.detail-panel-header .close-btn:hover {
    color: var(--text-color-dark);
}

.detail-panel-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.detail-section {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--border-radius-glass);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--glass-border);
}


.detail-section h4 {
    font-size: 1rem;
    color: var(--text-color-dark);
    margin: 0 0 var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-weight: 500;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: var(--spacing-xs);
}

.detail-section p {
    margin: 0 0 var(--spacing-xs);
    font-size: 0.9rem;
    color: var(--text-color);
}

.detail-section p strong {
    color: var(--text-color-dark);
    font-weight: 500;
    margin-right: 5px;
}









/* Add to styles.css */











.pulse-dot {
  width: 20px;           /* bigger size */
  height: 20px;
  background-color: #FF6B6B;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.8); /* stronger glow */
}



.pulse-dot {
  width: 15px;
  height: 15px;
  background-color: #FF6B6B;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.8);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.8);
  }
  50% {
    transform: scale(1.3);
    opacity: 0.6;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
  }
  100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.8);
  }
}



.custom-marker {
  transition: opacity 0.3s ease;
  opacity: 1;
}

.custom-marker.dimmed {
  opacity: 0.2;
}


/* Base: keep it hidden until globe mode */

/* When globe is active, show full-screen */

/* Optional: when globe is active, hide the Leaflet map container just in case */

/* Optional: the sidebar is already hidden in JS; this keeps layout tidy even if JS changes */
