        :root {
            /* Default: Light theme */
            --primary: #f5f5f5;
            --secondary: #ffffff;
            --accent: #e3f2fd;
            --highlight: #d32f2f;
            --text: #000000;
            --text-secondary: #666666;
            --success: #2e7d32;
            --warning: #f57c00;
            --error: #c62828;
            --border: #e0e0e0;
            --shadow: rgba(0, 0, 0, 0.1);
            --radius: 8px;
            --spacing: 16px;
            /* Performance optimization: force GPU acceleration */
            transform: translateZ(0);
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
/* Weather Hero Animation */
/* Container weather background classes */
.main-container.weather-clear {
    background: linear-gradient(180deg, #aee1ff 0%, #f8fbff 100%);
}
.main-container.weather-cloudy {
    background: linear-gradient(180deg, #cfd8dc 0%, #eceff1 100%);
}
.main-container.weather-rain {
    background: linear-gradient(180deg, #90caf9 0%, #e3f2fd 100%);
}
.main-container.weather-snow {
    background: linear-gradient(180deg, #e0f7fa 0%, #ffffff 100%);
}
.main-container.weather-thunder {
    background: linear-gradient(180deg, #b0bec5 0%, #ffccbc 100%);
}

        :root[data-theme="dark"] {
            --primary: #1a1a2e;
            --secondary: #16213e;
            --accent: #0f3460;
            --highlight: #e94560;
            --text: #ffffff;
            --text-secondary: #b0b0b0;
            --success: #4caf50;
            --warning: #ff9800;
            --error: #f44336;
            --border: #333;
            --shadow: rgba(0, 0, 0, 0.5);
        }

        .theme-toggle {
            display: flex;
            align-items: center;
            margin-left: 12px;
            padding-left: 12px;
            border-left: 1px solid var(--text-secondary);
            contain: layout style; /* CSS containment for performance */
        }

        .theme-toggle input {
            display: none;
        }

        .theme-toggle label {
            width: 50px;
            height: 24px;
            background: var(--accent);
            border-radius: 12px;
            position: relative;
            cursor: pointer;
            transition: background 0.1s;
            will-change: background; /* Optimize animation performance */
        }

        .theme-toggle label:after {
            content: '';
            position: absolute;
            top: 2px;
            left: 2px;
            width: 20px;
            height: 20px;
            background: var(--text);
            border-radius: 50%;
            transition: transform 0.1s;
            will-change: transform; /* Optimize transform animation */
        }

        .theme-toggle input:checked + label {
            background: var(--highlight);
        }

        .theme-toggle input:checked + label:after {
            transform: translateX(26px);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: var(--primary);
            color: var(--text);
            overflow-x: hidden;
        }

        .dashboard {
            display: grid;
            grid-template-columns: 1fr 300px;
            grid-template-rows: auto minmax(500px, 1fr) auto;
            min-height: 100vh;
            opacity: 0;
            animation: fadeIn 0.5s ease-in-out 0.5s forwards;
        }

        .dashboard.sidebar-left-mode {
            grid-template-columns: 300px 1fr;
        }

        /* Single-column mode when all cards are stacked in the sidebar */
        .dashboard.single-column-mode {
            grid-template-columns: 1fr;
        }

        .dashboard.single-column-mode .main-right {
            display: none;
        }

        .dashboard.single-column-mode .sidebar {
            grid-column: 1 / -1;
            width: 100%;
            max-width: 1200px;
            margin: 0 auto;
        }

        header {
            grid-column: 1 / -1;
            background: var(--secondary);
            padding: var(--spacing);
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid var(--border);
        }

        .logo {
            display: flex;
            align-items: center;
            gap: var(--spacing);
        }

        .logo-icon {
            width: 40px;
            height: 40px;
            background: var(--accent);
            border-radius: var(--radius);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            font-weight: bold;
        }

        .logo-image {
            width: 192px;
            height: auto;
            object-fit: contain;
            margin-right: 8px;
            filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
            image-rendering: -webkit-optimize-contrast;
            image-rendering: crisp-edges;
        }

        .logo-text {
            font-size: 24px;
            font-weight: bold;
        }

        .controls {
            display: flex;
            gap: var(--spacing);
        }

        .control-btn {
            background: var(--accent);
            color: var(--text);
            border: none;
            padding: 8px 16px;
            border-radius: var(--radius);
            cursor: pointer;
            transition: background 0.3s;
        }

        .control-btn:hover {
            background: var(--highlight);
        }

        .control-btn.active {
            background: var(--highlight);
            position: relative;
        }

        .control-btn.active:before {
            content: '';
            position: absolute;
            top: -2px;
            left: -2px;
            right: -2px;
            bottom: -2px;
            border: 2px solid var(--highlight);
            border-radius: calc(var(--radius) + 2px);
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0% { opacity: 1; }
            50% { opacity: 0.5; }
            100% { opacity: 1; }
        }

        main {
            position: relative;
            background: var(--primary);
            overflow: hidden;
            grid-column: 1;
            grid-row: 2;
        }

        main.main-right {
            grid-column: 2;
        }

        .main-container {
            position: relative;
            height: 100%;
            width: 100%;
            padding: var(--spacing);
            overflow-y: auto;
            background: var(--primary);
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: var(--spacing);
            align-content: start;
            transition: background 0.3s, box-shadow 0.3s;
        }

        /* Position canvas behind grid items */
        #weatherCanvas {
            position: absolute !important;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
            pointer-events: none;
        }

        /* Ensure all grid items appear above canvas */
        .main-container > * {
            position: relative;
            z-index: 1;
        }
        @media (min-width: 1400px) {
            .main-container {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        /* Accessibility: Skip link */
        .skip-link {
            position: absolute;
            top: -40px;
            left: 8px;
            background: var(--highlight);
            color: #fff;
            padding: 8px 12px;
            border-radius: 6px;
            z-index: 10000;
            text-decoration: none;
            font-weight: 600;
        }
        .skip-link:focus {
            top: 8px;
        }

        .main-container.drag-over-target {
            background: rgba(22, 120, 169, 0.05);
            box-shadow: inset 0 0 0 2px var(--highlight);
        }

        .main-container.drag-over-active {
            background: rgba(22, 120, 169, 0.15);
        }

        .daily-data-grid {
            display: contents;
        }

        .wide-card {
            grid-column: 1 / -1 !important;
            width: 100%;
        }

        /* (Reverted) Traffic card uses default grid behavior */

        .map-traffic {
            height: 420px;
            margin-top: 8px;
        }

        .daily-data-card {
            background: var(--secondary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: var(--spacing);
            position: relative;
            overflow-y: auto;
            max-height: 80vh;
            cursor: grab;
            transition: opacity 0.3s, transform 0.2s;
        }

        .daily-data-card:active {
            cursor: grabbing;
        }

        .daily-data-card[data-card-id="eventsPreviewCard"] {
            grid-column: 1 / -1;
        }

        .daily-data-card[data-card-id="eventsPreviewCard"] iframe {
            width: 100% !important;
            min-height: 400px;
        }

        .daily-data-card iframe {
            max-width: 100%;
        }

        .daily-data-card p,
        .daily-data-card div {
            word-wrap: break-word;
            overflow-wrap: break-word;
            max-width: 100%;
        }

        .daily-data-card-close {
            position: absolute;
            top: 12px;
            right: 12px;
            background: transparent;
            border: none;
            color: var(--text);
            width: auto;
            height: auto;
            padding: 4px 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            font-weight: bold;
            transition: opacity 0.3s, transform 0.2s;
            z-index: 10;
            line-height: 1;
        }

        .daily-data-card-close:hover {
            opacity: 0.6;
            transform: scale(1.15);
        }

        .daily-data-card h2 {
            color: var(--highlight);
            margin-bottom: var(--spacing);
            margin-top: 0;
            display: flex;
            align-items: center;
            gap: 8px;
            padding-right: 40px;
        }

        .card-link {
            cursor: pointer;
            transition: color 0.3s, opacity 0.3s;
        }

        .card-link:hover {
            opacity: 0.8;
            text-decoration: underline !important;
        }

        .about-container, .contact-container, .privacy-container, .terms-container, .events-container {
            position: relative;
            height: 100%;
            width: 100%;
            padding: var(--spacing);
            overflow-y: auto;
        }

        .map {
            height: 100%;
            width: 100%;
            background: url('https://tile.openstreetmap.org/{z}/{x}/{y}.png') no-repeat center center;
            background-size: cover;
            position: relative;
        }

        .map:before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: linear-gradient(45deg, rgba(26, 26, 46, 0.8), rgba(22, 33, 62, 0.8));
            pointer-events: none;
        }

        .grid-lines {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
        }

        .city-markers {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        .marker {
            position: absolute;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            cursor: pointer;
            transition: transform 0.3s, box-shadow 0.3s;
            border: 2px solid var(--text);
            animation: markerPulse 3s infinite;
        }

        .marker .pulse {
            position: absolute;
            top: -4px;
            left: -4px;
            width: 20px;
            height: 20px;
            border: 1px solid currentColor;
            border-radius: 50%;
            animation: markerPulse 3s infinite;
            opacity: 0.6;
        }

        .marker:hover {
            transform: scale(1.2);
            box-shadow: 0 0 10px var(--highlight);
        }

        .marker.traffic {
            background: var(--warning);
            color: var(--warning);
        }

        .marker.energy {
            background: var(--success);
            color: var(--success);
        }

        .marker.safety {
            background: var(--error);
            color: var(--error);
        }

        .marker.environmental {
            background: var(--highlight);
            color: var(--highlight);
        }

        @keyframes markerPulse {
            0% { transform: scale(1); opacity: 1; }
            50% { transform: scale(1.5); opacity: 0.5; }
            100% { transform: scale(1); opacity: 1; }
        }

        /* Performance optimization for frequently animated elements */
        .marker {
            will-change: transform, opacity;
        }

        .info-box {
            position: absolute;
            bottom: 20px;
            left: 20px;
            background: var(--secondary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: var(--spacing);
            max-width: 300px;
            opacity: 0;
            transform: translateY(20px);
            transition: opacity 0.3s, transform 0.3s;
            pointer-events: none;
            will-change: opacity, transform; /* Optimize slide-in animation */
        }

        .info-box.active {
            opacity: 1;
            transform: translateY(0);
            pointer-events: auto;
        }

        .info-box h4 {
            margin-bottom: 8px;
            color: var(--highlight);
        }

        .info-box p {
            margin-bottom: 4px;
            font-size: 14px;
        }

        .info-box .metric {
            display: flex;
            justify-content: space-between;
            margin-top: 8px;
        }

        .info-box .metric span {
            font-weight: bold;
        }

        .map-controls {
            position: absolute;
            top: 20px;
            right: 20px;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .map-control-btn {
            width: 40px;
            height: 40px;
            background: var(--secondary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.3s;
        }

        .map-control-btn:hover {
            background: var(--accent);
        }

        .sidebar {
            background: var(--secondary);
            padding: var(--spacing);
            overflow-y: auto;
            border-left: 1px solid var(--border);
            box-shadow: inset 3px 0 0 rgba(233, 69, 96, 0.25);
            transition: background 0.3s, box-shadow 0.3s;
            grid-column: 2;
            grid-row: 2;
            contain: layout style; /* Optimize sidebar reflows */
        }

        .sidebar-logo-container {
            position: sticky;
            top: 0;
            z-index: 50;
            background: var(--secondary);
            padding-bottom: var(--spacing);
            margin-bottom: var(--spacing);
            border-bottom: 2px solid var(--border);
        }

        .sidebar-logo {
            width: 100%;
            height: auto;
            display: block;
            border-radius: var(--radius);
            image-rendering: -webkit-optimize-contrast;
            image-rendering: crisp-edges;
        }

        /* Live Weather Card - Always visible at top of sidebar, only overridden by Amber Alerts (z-index:70+) */
        #sidebarWeather {
            position: sticky;
            top: 0;
            z-index: 65;
            background: var(--secondary);
            padding-bottom: var(--spacing);
            margin-bottom: var(--spacing);
            border-bottom: 2px solid var(--highlight);
            box-shadow: 0 2px 8px rgba(211, 47, 47, 0.15);
        }

        /* Fuel Prices - Below Live Weather Card */
        #sidebarFuel {
            position: sticky;
            top: calc(180px + var(--spacing));
            z-index: 55;
            background: var(--secondary);
            padding: 12px 14px;
            margin-bottom: var(--spacing);
            border: 1px solid var(--border);
            border-radius: 8px;
        }

        .sidebar.drag-over-target {
            background: rgba(22, 120, 169, 0.1);
            box-shadow: inset 0 0 0 2px var(--highlight);
        }

        .sidebar.drag-over-active {
            background: rgba(22, 120, 169, 0.2);
        }

        .sidebar.sidebar-left {
            grid-column: 1;
            border-left: none;
            border-right: 1px solid var(--border);
            box-shadow: inset -3px 0 0 rgba(233, 69, 96, 0.25);
        }

        .sidebar::-webkit-scrollbar {
            width: 8px;
        }

        .sidebar::-webkit-scrollbar-track {
            background: var(--primary);
        }

        .sidebar::-webkit-scrollbar-thumb {
            background: var(--accent);
            border-radius: 4px;
        }

        .sidebar-drag-handle {
            position: sticky;
            bottom: 0;
            left: 0;
            right: 0;
            background: linear-gradient(to top, var(--secondary) 75%, transparent);
            padding: var(--spacing) 0 0 0;
            margin-top: var(--spacing);
            display: flex;
            flex-direction: column;
            gap: 6px;
            align-items: center;
            z-index: 100;
        }

        .sidebar-drag-btn {
            background: var(--primary);
            border: 2px solid var(--highlight);
            border-radius: var(--radius);
            padding: 10px 18px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            transition: all 0.3s;
            color: var(--text);
            font-size: 14px;
            font-weight: 600;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
        }

        .sidebar-drag-btn:hover {
            background: var(--highlight);
            color: #fff;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(233, 69, 96, 0.35);
        }

        .sidebar-drag-btn:active {
            transform: translateY(0);
            box-shadow: 0 2px 6px rgba(233, 69, 96, 0.3);
        }

        .sidebar-drag-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .sidebar-drag-icon {
            font-size: 18px;
            font-weight: 700;
            animation: dragHint 2s infinite;
        }

        .sidebar-drag-btn:hover .sidebar-drag-icon {
            animation: none;
        }

        .sidebar-drag-hint {
            font-size: 12px;
            color: var(--text-secondary);
        }

        @keyframes dragHint {
            0%, 100% { transform: translateX(0); }
            50% { transform: translateX(4px); }
        }

        .data-card {
            background: var(--secondary);
            border: 2px solid var(--border);
            border-radius: var(--radius);
            padding: var(--spacing);
            margin-bottom: var(--spacing);
            cursor: grab;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            contain: layout style;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        }

        .data-card:hover {
            border-color: var(--highlight);
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
            transform: translateY(-2px);
        }

        .data-card:active {
            cursor: grabbing;
        }

        .data-card[data-in-daily-data="true"] {
            display: none !important;
        }

        /* Dynamic card border based on alert status */
        .data-card.alert-status {
            border: 2px solid var(--error) !important;
            animation: pulse-border 2s infinite;
            box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1), 0 4px 16px rgba(244, 67, 54, 0.2);
        }

        .data-card.warning-status {
            border: 2px solid var(--warning) !important;
            box-shadow: 0 0 0 3px rgba(245, 124, 0, 0.1), 0 4px 16px rgba(245, 124, 0, 0.15);
        }

        .data-card.success-status {
            border: 2px solid var(--success) !important;
            box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
        }

        @keyframes pulse-border {
            0%, 100% { 
                border-color: var(--error);
                box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.1), 0 4px 16px rgba(244, 67, 54, 0.2);
            }
            50% { 
                border-color: var(--error);
                box-shadow: 0 0 0 6px rgba(244, 67, 54, 0.2), 0 4px 16px rgba(244, 67, 54, 0.3);
            }
        }

        .data-card h1,
        .data-card h2,
        .data-card h3 {
            margin: 0 0 var(--spacing) 0;
            color: var(--highlight);
            display: flex;
            align-items: center;
            gap: 8px;
            word-break: break-word;
        }

        .data-card h3 {
            margin-bottom: var(--spacing);
            color: var(--highlight);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .status-indicator {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: var(--success);
            flex-shrink: 0;
            display: inline-block;
            animation: pulse-dot 2s infinite;
            box-shadow: 0 0 8px rgba(46, 125, 50, 0.5);
        }

        .status-indicator.alert {
            background: var(--error);
            box-shadow: 0 0 12px rgba(244, 67, 54, 0.8);
            animation: pulse-alert 1.5s infinite;
        }

        .status-indicator.warning {
            background: var(--warning);
            box-shadow: 0 0 10px rgba(245, 124, 0, 0.6);
            animation: pulse-warning 1.8s infinite;
        }

        .status-indicator.success {
            background: var(--success);
            box-shadow: 0 0 8px rgba(46, 125, 50, 0.5);
            animation: pulse-dot 2s infinite;
        }

        @keyframes pulse-dot {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }

        @keyframes pulse-alert {
            0%, 100% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.8; transform: scale(1.2); }
        }

        @keyframes pulse-warning {
            0%, 100% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.7; transform: scale(1.15); }
        }

        /* Sticky alert style for critical cards (Weather/Amber/Major Incidents) */
        .data-card.sticky-alert {
            position: sticky;
            top: -16px;
            z-index: 75;
            background: var(--primary);
            border: 2px solid var(--error);
            border-radius: var(--radius);
            box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.15), 0 6px 18px rgba(244, 67, 54, 0.3);
            animation: alertBorderFlash 10s infinite;
            margin-bottom: var(--spacing);
            padding: var(--spacing);
            contain: none; /* Allow reflow when positioning changes */
        }

        /* Animated glowing ring effect for critical alerts */
        .data-card.sticky-alert::before {
            content: '';
            position: absolute;
            top: -4px;
            left: -4px;
            right: -4px;
            bottom: -4px;
            border: 2px solid var(--error);
            border-radius: var(--radius);
            opacity: 0;
            animation: alertGlowRing 10s infinite;
            pointer-events: none;
            z-index: -1;
        }

        /* Border flashing animation - pulses every 10 seconds */
        @keyframes alertBorderFlash {
            0%, 100% {
                border-color: var(--error);
                box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.15), 0 6px 18px rgba(244, 67, 54, 0.3);
            }
            25% {
                border-color: var(--error);
                box-shadow: 0 0 0 5px rgba(244, 67, 54, 0.4), 0 6px 18px rgba(244, 67, 54, 0.5);
            }
            50% {
                border-color: var(--error);
                box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.15), 0 6px 18px rgba(244, 67, 54, 0.3);
            }
            75% {
                border-color: var(--error);
                box-shadow: 0 0 0 5px rgba(244, 67, 54, 0.4), 0 6px 18px rgba(244, 67, 54, 0.5);
            }
        }

        /* Glowing ring animation - circles the circumference */
        @keyframes alertGlowRing {
            0%, 100% {
                opacity: 0;
                box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.6);
            }
            25% {
                opacity: 1;
                box-shadow: 0 0 0 8px rgba(244, 67, 54, 0.3);
            }
            50% {
                opacity: 0.5;
                box-shadow: 0 0 0 16px rgba(244, 67, 54, 0);
            }
            75% {
                opacity: 1;
                box-shadow: 0 0 0 8px rgba(244, 67, 54, 0.3);
            }
        }

        /* Fuel sidebar live/fallback states */
        #sidebarFuel.live-state {
            border-color: var(--success);
            box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2);
        }

        #sidebarFuel.warning-state {
            border-color: var(--warning);
            box-shadow: inset 0 0 0 2px rgba(245, 124, 0, 0.25);
            background: linear-gradient(to bottom, rgba(245, 124, 0, 0.08), transparent);
        }

        /* Weather sidebar live/fallback states */
        #sidebarWeather.live-state {
            border-color: var(--success);
            box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2);
        }

        #sidebarWeather.warning-state {
            border-color: var(--warning);
            box-shadow: inset 0 0 0 2px rgba(245, 124, 0, 0.25);
            background: linear-gradient(to bottom, rgba(245, 124, 0, 0.08), transparent);
        }

        /* Generic card live/fallback states */
        .data-card.live-state {
            border-color: var(--success);
            box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.15);
        }

        .data-card.warning-state {
            border-color: var(--warning);
            box-shadow: inset 0 0 0 2px rgba(245, 124, 0, 0.2);
            background: linear-gradient(to bottom, rgba(245, 124, 0, 0.06), transparent);
        }

        @keyframes pulse-dot {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.6; }
        }

        .event-item {
            margin-bottom: var(--spacing);
            padding-bottom: var(--spacing);
            border-bottom: 1px solid var(--border);
        }

        .event-item:last-child {
            border-bottom: none;
            margin-bottom: 0;
            padding-bottom: 0;
        }

        .event-item h3 {
            color: var(--highlight);
            margin-bottom: 8px;
        }

        .event-item p {
            margin: 4px 0;
            color: var(--text-secondary);
        }

        .data-point {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
        }

        .data-value {
            font-weight: bold;
            color: var(--text);
        }

        .data-chart {
            height: 100px;
            background: var(--secondary);
            border-radius: var(--radius);
            margin-top: var(--spacing);
            position: relative;
        }

        .chart-bar {
            height: 100%;
            width: 20%;
            background: var(--highlight);
            border-radius: var(--radius);
            position: absolute;
            bottom: 0;
            animation: grow 1s ease-in-out;
        }

        .alerts {
            margin-top: var(--spacing);
        }

        .alert-item {
            background: var(--secondary);
            border-left: 4px solid var(--warning);
            padding: 8px;
            margin-bottom: 8px;
            border-radius: var(--radius);
        }

        .alert-item:last-child {
            margin-bottom: 0;
        }

        .alert-item.high {
            border-left-color: var(--error);
        }

        .alert-item.medium {
            border-left-color: var(--warning);
        }

        .alert-item.low {
            border-left-color: var(--success);
        }

        .alert-icon {
            display: inline-block;
            width: 16px;
            height: 16px;
            margin-right: 8px;
            border-radius: 50%;
        }

        .alert-item.high .alert-icon {
            background: var(--error);
        }

        .alert-item.medium .alert-icon {
            background: var(--warning);
        }

        .alert-item.low .alert-icon {
            background: var(--success);
        }

        .alert-content {
            display: inline;
        }

        .alert-time {
            font-size: 12px;
            color: var(--text-secondary);
            margin-top: 4px;
        }

        footer {
            grid-column: 1 / -1;
            background: var(--secondary);
            padding: var(--spacing);
            border-top: 1px solid var(--border);
        }

        .footer-content {
            display: flex;
            flex-direction: column;
            align-items: stretch;
            gap: 0;
            max-width: 1200px;
            margin: 0 auto;
        }

        .footer-top {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: var(--spacing);
            flex-wrap: wrap;
            margin-bottom: 24px;
        }

        .footer-logo {
            flex: 0 0 auto;
            display: flex;
            align-items: center;
        }

        .footer-logo-image {
            width: 192px;
            height: auto;
            object-fit: contain;
            filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
            image-rendering: -webkit-optimize-contrast;
            image-rendering: crisp-edges;
        }

        /* Sponsor Card Styling */
        .sponsor-card {
            width: 100%;
            padding: 12px;
            margin: 16px 0;
            border-radius: 4px;
        }

        .sponsor-card h4 {
            color: var(--highlight);
            margin-bottom: 8px;
        }

        .sponsor-card p {
            font-size: 13px;
            line-height: 1.6;
            margin-bottom: 8px;
        }

        .sponsor-card a {
            color: var(--highlight);
        }

        #sp1 {
            background: transparent;
            border: none;
        }

        #sp1 h4 {
            margin-bottom: 8px;
            color: var(--highlight);
        }

        #sp1 p {
            margin-bottom: 4px;
            font-size: 14px;
        }

        #sp2 {
            background: rgba(233, 69, 96, 0.05);
            border-left: 3px solid var(--highlight);
        }

        #sp3 {
            background: rgba(22, 120, 169, 0.05);
            border-left: 3px solid var(--highlight);
        }

        #sp4 {
            background: rgba(233, 196, 106, 0.05);
            border-left: 3px solid var(--highlight);
        }

        .disclaimer p {
            font-size: 12px;
            color: var(--text-secondary);
            max-width: 400px;
        }

        .page-links {
            text-align: center;
            margin-top: var(--spacing);
        }

        .page-links a {
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 14px;
        }

        .page-links a:hover {
            color: var(--highlight);
        }

        .social-media {
            display: flex;
            gap: 16px;
            align-items: center;
        }

        .social-media a {
            color: var(--text);
            transition: color 0.3s;
            display: flex;
            align-items: center;
        }

        .social-media a:hover {
            color: var(--highlight);
        }

        .social-media svg {
            width: 24px;
            height: 24px;
        }

        @media (max-width: 700px) {
            body {
                overflow-x: hidden;
            }

            .dashboard {
                grid-template-columns: 1fr !important;
                grid-template-rows: auto 1fr auto auto;
                height: auto;
                min-height: 100vh;
            }

            header {
                grid-column: 1;
                grid-row: 1;
                padding: 12px;
                flex-wrap: wrap;
            }

            .logo-image {
                width: 140px;
            }

            .logo {
                flex: 1 1 auto;
            }

            .controls {
                flex-wrap: wrap;
                gap: 8px;
                width: 100%;
            }

            .controls > div {
                margin-right: 0 !important;
                padding-right: 0 !important;
            }

            /* Hide social media icons in header on mobile */
            .controls > div:first-child {
                display: none !important;
            }

            #sponsorPlaceholder {
                display: none;
            }

            .language-switcher {
                border-left: none;
                padding-left: 0;
            }

            .theme-toggle {
                border-left: none;
                margin-left: 0;
                padding-left: 0;
            }

            main, main.main-right {
                grid-column: 1 !important;
                grid-row: 3;
                height: auto;
                min-height: 400px;
            }

            .main-container {
                grid-template-columns: 1fr !important;
                padding: 12px;
                height: auto;
                min-height: 400px;
            }

            .daily-data-card {
                max-height: none;
                padding: 14px;
            }

            .map-traffic {
                height: 350px;
            }

            .map-controls {
                top: 10px;
                right: 10px;
                scale: 0.85;
            }

            .sidebar, .sidebar.sidebar-left {
                grid-column: 1 !important;
                grid-row: 2;
                border-left: none !important;
                border-right: none !important;
                border-top: 2px solid var(--border);
                padding: 16px 12px;
                box-shadow: none;
                width: 100%;
            }

            .sidebar-drag-handle,
            .sidebar-drag-hint {
                display: none;
            }

            /* Mobile: Remove sticky from logo so weather card flows first */
            .sidebar-logo-container {
                position: relative;
                top: auto;
                display: none;
            }

            /* Mobile Card Styling */
            .data-card {
                padding: 14px;
                margin-bottom: 14px;
                border-radius: 10px;
                box-shadow: 0 1px 4px rgba(0,0,0,0.1);
            }

            .data-card h3 {
                font-size: 15px;
                margin-bottom: 10px;
                cursor: grab;
                user-select: none;
                touch-action: none;
            }

            .data-card p, .data-card ul {
                font-size: 13px;
                line-height: 1.5;
            }

            /* Drag indicators for mobile */
            .sortable-ghost {
                opacity: 0.4;
                background: var(--accent);
                border-radius: 6px;
            }
            
            .sortable-chosen {
                cursor: grabbing !important;
                background: var(--accent);
            }
            
            .sortable-drag {
                opacity: 1;
                box-shadow: 0 8px 24px rgba(0,0,0,0.3);
                transform: rotate(2deg);
                z-index: 1000;
            }

            .event-item {
                padding: 10px;
                margin-bottom: 8px;
                border-radius: 6px;
            }

            .event-item h4 {
                font-size: 13px;
                margin-bottom: 4px;
            }

            .event-item p {
                font-size: 12px;
            }

            footer {
                grid-column: 1;
                grid-row: 4;
            }

            .footer-content {
                flex-direction: column;
                align-items: center;
                text-align: center;
                padding: 12px;
            }

            .footer-logo-image {
                width: 120px;
            }

            .social-media {
                justify-content: center;
                flex-wrap: wrap;
            }

            #sp2, #sp3 {
                font-size: 12px !important;
            }
        }

        /* Animation for the dashboard load */
        .loading {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: var(--primary);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            transition: opacity 0.5s, visibility 0.5s;
        }

        .loading.hidden {
            opacity: 0;
            visibility: hidden;
        }

        .loading-icon {
            width: 50px;
            height: 50px;
            border: 4px solid var(--accent);
            border-top: 4px solid var(--highlight);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-bottom: var(--spacing);
        }

        .loading-icon-image {
            width: 80px;
            height: 80px;
            object-fit: contain;
            margin-bottom: var(--spacing);
            animation: fadeInPulse 1s ease-in-out;
            filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
        }

        @keyframes fadeInPulse {
            0% { opacity: 0.5; transform: scale(0.8); }
            50% { opacity: 1; }
            100% { opacity: 1; transform: scale(1); }
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }



        .loading-text {
            font-size: 18px;
            margin-bottom: var(--spacing);
        }

        .loading-progress {
            width: 200px;
            height: 4px;
            background: var(--secondary);
            border-radius: 2px;
            overflow: hidden;
        }

        .loading-progress-bar {
            height: 100%;
            background: var(--highlight);
            width: 0%;
            transition: width 0.3s;
        }

        /* Custom animations */
        .data-pulse {
            animation: dataPulse 2s infinite;
        }

        .pulse-dot {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--highlight);
            animation: dataPulse 2s infinite;
        }

        @keyframes dataPulse {
            0% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.5; transform: scale(1.2); }
            100% { opacity: 1; transform: scale(1); }
        }

        .grid-line {
            position: absolute;
            background: rgba(255, 255, 255, 0.1);
        }

        .grid-line-h {
            width: 100%;
            height: 1px;
            animation: scan-h 10s linear 1; /* Run once */
        }

        .grid-line-v {
            height: 100%;
            width: 1px;
            animation: scan-v 10s linear 1; /* Run once */
        }

        @keyframes scan-h {
            0% { top: 0; }
            100% { top: 100%; }
        }

        @keyframes scan-v {
            0% { left: 0; }
            100% { left: 100%; }
        }

        .notification {
            position: fixed;
            top: 20px;
            right: 20px;
            background: var(--secondary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: var(--spacing);
            max-width: 300px;
            transform: translateX(100%);
            transition: transform 0.3s;
            z-index: 1001;
        }

        .notification.show {
            transform: translateX(0);
        }

        .notification h4 {
            color: var(--highlight);
            margin-bottom: 8px;
        }

        .notification p {
            font-size: 14px;
        }

        @keyframes fadeIn {
            to { opacity: 1; }
        }

        .map iframe {
            width: 100%;
            height: 100%;
            min-width: 100%;
            min-height: 100%;
            border: 0;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1;
            display: block;
        }

        /* Tablet & Mobile stacking for sidebar toggle */
        @media (max-width: 1024px) {
            .main-container {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        @media (max-width: 768px) {
            .dashboard {
                grid-template-columns: 1fr;
                grid-template-rows: auto auto auto;
            }

            main, main.main-right {
                grid-column: 1;
                grid-row: 2;
            }

            .sidebar, .sidebar.sidebar-left {
                grid-column: 1;
                grid-row: 3;
                border-left: none;
                border-right: none;
                border-top: 1px solid var(--border);
                box-shadow: none;
                padding: 16px;
                max-height: none;
                width: 100%;
            }

            /* Card grid for tablets */
            .main-container {
                grid-template-columns: 1fr;
            }

            .data-card {
                padding: 18px;
                margin-bottom: 16px;
                width: 100%;
            }

            .sidebar-drag-btn {
                font-size: 13px;
                padding: 10px 14px;
                display: none;
            }

            .sidebar-drag-hint {
                display: none;
            }

            header {
                flex-wrap: wrap;
            }

            .logo {
                flex: 1 1 auto;
            }

            .controls {
                flex-wrap: wrap;
                width: 100%;
                gap: 8px;
            }
        }

        /* Extra small phones */
        @media (max-width: 480px) {
            .data-card {
                padding: 12px;
            }

            .data-card h3 {
                font-size: 13px;
            }

            .data-card p {
                font-size: 12px;
            }

            header .logo-image {
                width: 100px;
            }

            header .logo-text {
                font-size: 16px;
            }
        }

    /* Drag-and-Drop Visual Feedback */
    .data-card[draggable="true"] {
        cursor: move;
        transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
    }

    .data-card[draggable="true"]:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px var(--shadow);
    }

    .data-card.dragging {
        opacity: 0.5;
        transform: scale(0.98);
    }

    .data-card.drag-over {
        background-color: var(--accent);
        border: 2px solid var(--highlight);
        transform: scale(1.02);
    }

    /* Status Indicator Colors */
    .status-indicator {
        display: inline-block;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        margin-right: 8px;
        animation: pulse-status 2s infinite;
    }

    .status-indicator.success {
        background-color: var(--success);
    }

    .status-indicator.warning {
        background-color: var(--warning);
        animation: pulse-warning 1.5s infinite;
    }

    .status-indicator.alert {
        background-color: var(--error);
        animation: pulse-alert 0.8s infinite;
        box-shadow: 0 0 8px var(--error);
    }

    @keyframes pulse-status {
        0%, 100% {
            opacity: 1;
        }
        50% {
            opacity: 0.6;
        }
    }

    @keyframes pulse-warning {
        0%, 100% {
            opacity: 1;
            transform: scale(1);
        }
        50% {
            opacity: 0.8;
            transform: scale(1.1);
        }
    }

    @keyframes pulse-alert {
        0%, 100% {
            opacity: 1;
            transform: scale(1);
            box-shadow: 0 0 8px var(--error);
        }
        50% {
            opacity: 0.9;
            transform: scale(1.15);
            box-shadow: 0 0 16px var(--error);
        }
    }

    /* Daily Data Cards in Grid */
    #dailyDataContent.daily-data-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: var(--spacing);
        margin-top: var(--spacing);
    }

    #dailyDataContent.daily-data-grid .data-card {
        min-height: 200px;
    }

    #dailyDataContent.daily-data-grid .data-card.wide-card {
        grid-column: 1 / -1;
        min-height: 350px;
    }

    /* Civic Reports Feed Styling */
    #civicReportsList {
        scroll-behavior: smooth;
    }

    #civicReportsList::-webkit-scrollbar {
        width: 6px;
    }

    #civicReportsList::-webkit-scrollbar-track {
        background: var(--accent);
        border-radius: 3px;
    }

    #civicReportsList::-webkit-scrollbar-thumb {
        background: var(--highlight);
        border-radius: 3px;
    }

    #civicReportsList::-webkit-scrollbar-thumb:hover {
        background: var(--error);
    }

    /* Report item hover effect */
    #civicReportsList > div {
        transition: all 0.2s ease;
    }

    #civicReportsList > div:hover {
        background-color: var(--secondary) !important;
        transform: translateX(4px);
    }

    /* Social Media Sensor Status Panel */
    #sensorStatusPanel {
        animation: slideDown 0.3s ease-out;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    #sensorStatusPanel strong {
        font-weight: 700;
    }

    /* Sensor Status Indicators */
    .sensor-active {
        color: var(--success);
        text-shadow: 0 0 8px rgba(46, 125, 50, 0.3);
    }

    .sensor-fetching {
        color: var(--warning);
        animation: pulse-sensor 1s infinite;
    }

    .sensor-error {
        color: var(--error);
    }

    .sensor-pending {
        color: var(--text-secondary);
        opacity: 0.6;
    }

    @keyframes pulse-sensor {
        0%, 100% {
            opacity: 1;
        }
        50% {
            opacity: 0.6;
        }
    }

    /* Report engagement metrics */
    .report-metrics {
        display: flex;
        gap: 12px;
        font-size: 10px;
        color: var(--text-secondary);
        margin-top: 4px;
    }

    .report-metric {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }