
:root {
    --primary: #1a1a2e;
    --accent: #4361ee;
    --accent-light: #4895ef;
    --success: #2a9d8f;
    --warning: #f4a261;
    --danger: #e76f51;
    --info: #457b9d;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6c757d;
    --border: #dee2e6;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

/* Header */
.header {
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.header .badge {
    background: var(--warning);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Layout */
.container {
    display: flex;
    height: calc(100vh - 52px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 6px;
}

/* Layer Toggles */
.layer-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}
.layer-toggle:hover { background: #e9ecef; }
.layer-toggle.active { border-color: var(--accent); background: #eef2ff; }
.layer-toggle .label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.layer-toggle .color-dot { width: 12px; height: 12px; border-radius: 50%; }
.toggle-switch {
    width: 36px; height: 20px; background: #ccc; border-radius: 10px;
    position: relative; transition: 0.3s;
}
.toggle-switch::after {
    content: ''; position: absolute; width: 16px; height: 16px;
    background: white; border-radius: 50%; top: 2px; left: 2px; transition: 0.3s;
}
.layer-toggle.active .toggle-switch { background: var(--accent); }
.layer-toggle.active .toggle-switch::after { left: 18px; }

/* Temporal Slider */
.temporal-control {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.temporal-control label {
    font-size: 0.85rem;
    font-weight: 600;
    display: block;
    margin-bottom: 10px;
}
.year-slider {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
}
.year-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}
.year-display {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 8px;
}

/* AI Metrics */
.ai-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.metric-card {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border);
}
.metric-card .value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}
.metric-card .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Map */
.map-container {
    flex: 1;
    position: relative;
    min-height: 0;
}
#map { width: 100%; height: 100%; }

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 16px;
    padding: 12px 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border);
    white-space: nowrap;
}
.stat-item .icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.stat-item .info .number {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}
.stat-item .info .desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Bottom Panel */
.bottom-panel {
    height: 260px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 16px;
    padding: 16px;
    overflow-x: auto;
}
.chart-card {
    min-width: 320px;
    flex: 1;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 12px;
    display: flex;
    flex-direction: column;
}
.chart-card h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.chart-container {
    flex: 1;
    position: relative;
}

/* Legend */
.map-legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255,255,255,0.95);
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    z-index: 500;
    font-size: 0.8rem;
}
.map-legend h4 { margin-bottom: 8px; font-size: 0.85rem; }
.legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.legend-color { width: 14px; height: 14px; border-radius: 3px; }

/* Popup styles */
.popup-content { min-width: 220px; }
.popup-content h4 { margin-bottom: 8px; color: var(--primary); font-size: 1rem; }
.popup-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #eee; font-size: 0.85rem; }
.popup-row:last-child { border-bottom: none; }
.popup-label { color: var(--text-muted); }
.popup-value { font-weight: 600; }
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.status-illegal { background: #ffebee; color: #c62828; }
.status-abandoned { background: #fff3e0; color: #ef6c00; }
.status-dormant { background: #e8f5e9; color: #2e7d32; }
.status-emerging { background: #e3f2fd; color: #1565c0; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { width: 240px; }
    .bottom-panel { height: 200px; }
}
