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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0a0e17;
    color: #e0e6ed;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
}

/* Header */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: rgba(10, 14, 23, 0.92);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #60a5fa;
}

.logo h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #f0f4f8;
}

.live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.pulse {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

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

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

.last-updated {
    font-size: 12px;
    color: #64748b;
}

.layer-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.layer-label {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

#layerSelect {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #e0e6ed;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

#layerSelect:hover {
    border-color: rgba(96, 165, 250, 0.4);
}

#layerSelect option {
    background: #1a1f2e;
    color: #e0e6ed;
}

/* Map */
#map {
    position: fixed;
    inset: 0;
    top: 0;
    z-index: 1;
}

.leaflet-control-attribution {
    background: rgba(10, 14, 23, 0.8) !important;
    color: #64748b !important;
    font-size: 10px !important;
    backdrop-filter: blur(10px);
}

.leaflet-control-attribution a {
    color: #60a5fa !important;
}

.leaflet-control-zoom {
    border: none !important;
    margin-top: 70px !important;
}

.leaflet-control-zoom a {
    background: rgba(10, 14, 23, 0.85) !important;
    backdrop-filter: blur(10px);
    color: #e0e6ed !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
    transition: background 0.2s;
}

.leaflet-control-zoom a:hover {
    background: rgba(30, 40, 60, 0.9) !important;
}

/* Legend */
.legend {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 1000;
    background: rgba(10, 14, 23, 0.92);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px 18px;
}

.legend-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    margin-bottom: 10px;
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #cbd5e1;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Stats Panel */
.stats-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    gap: 10px;
}

.stat-card {
    background: rgba(10, 14, 23, 0.92);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px 20px;
    min-width: 120px;
    text-align: center;
    transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(96, 165, 250, 0.3);
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #f0f4f8;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
    font-weight: 500;
}

/* Station Detail Panel */
.station-detail {
    position: fixed;
    top: 60px;
    right: 24px;
    z-index: 1001;
    width: 360px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: rgba(10, 14, 23, 0.95);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 24px;
    transition: opacity 0.3s, transform 0.3s;
}

.station-detail.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(20px);
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #f0f4f8;
}

.detail-header {
    margin-bottom: 20px;
}

.detail-station-name {
    font-size: 16px;
    font-weight: 600;
    color: #f0f4f8;
    margin-bottom: 4px;
    padding-right: 30px;
}

.detail-time {
    font-size: 12px;
    color: #64748b;
}

.detail-aqi-display {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.detail-aqi-number {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.detail-aqi-info {
    flex: 1;
}

.detail-aqi-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.detail-aqi-desc {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.4;
}

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

.pollutant-card {
    padding: 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.pollutant-name {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pollutant-value {
    font-size: 20px;
    font-weight: 600;
    color: #f0f4f8;
    margin-top: 2px;
}

.pollutant-unit {
    font-size: 11px;
    color: #64748b;
    font-weight: 400;
}

/* Search Box */
.search-box {
    position: fixed;
    top: 70px;
    left: 24px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(10, 14, 23, 0.92);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 14px;
    width: 300px;
    transition: border-color 0.2s;
}

.search-box:focus-within {
    border-color: rgba(96, 165, 250, 0.5);
}

.search-icon {
    color: #64748b;
    flex-shrink: 0;
}

#searchInput {
    flex: 1;
    background: none;
    border: none;
    color: #e0e6ed;
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

#searchInput::placeholder {
    color: #475569;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 6px;
    background: rgba(10, 14, 23, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(96, 165, 250, 0.08);
}

.search-result-name {
    font-size: 13px;
    color: #e0e6ed;
}

.search-result-aqi {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
}

/* Custom marker styles */
.aqi-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
    font-size: 11px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.aqi-marker:hover {
    transform: scale(1.3);
    z-index: 10000 !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #0a0e17;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transition: opacity 0.5s;
}

.loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(96, 165, 250, 0.2);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 14px;
    color: #64748b;
}

/* Responsive */
@media (max-width: 768px) {
    #header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 16px;
    }

    .header-left, .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .stats-panel {
        left: 16px;
        right: 16px;
        bottom: 16px;
        justify-content: space-between;
    }

    .stat-card {
        min-width: auto;
        flex: 1;
        padding: 10px 12px;
    }

    .stat-value {
        font-size: 18px;
    }

    .legend {
        bottom: 90px;
        left: 16px;
    }

    .search-box {
        top: auto;
        bottom: 90px;
        right: 16px;
        left: auto;
        width: 260px;
    }

    .station-detail {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
    }

    .station-detail.hidden {
        transform: translateY(20px);
    }

    .logo h1 {
        font-size: 15px;
    }
}
