:root {
    --bg-base: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --accent-primary: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    
    --status-critical: #ef4444;
    --status-high: #f97316;
    --status-medium: #eab308;
    --status-success: #22c55e;
    
    --font-sans: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Background Ambient Shapes */
.bg-shape {
    position: absolute;
    filter: blur(100px);
    z-index: -1;
    border-radius: 50%;
    opacity: 0.5;
}

.shape-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59,130,246,0.3) 0%, rgba(15,23,42,0) 70%);
    top: -200px;
    left: -200px;
}

.shape-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(239,68,68,0.15) 0%, rgba(15,23,42,0) 70%);
    bottom: -100px;
    right: 20%;
}

/* Layout */
.dashboard-container {
    display: flex;
    height: 100vh;
    padding: 1rem;
    gap: 1rem;
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

/* Sidebar */
.sidebar {
    width: 400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.brand .logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), #60a5fa);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--accent-glow);
}

.brand h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.brand span {
    color: var(--accent-primary);
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1.5rem;
}

.metric-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.2s ease, background 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.06);
}

.metric-card:last-child {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.metric-card .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-card .value {
    font-size: 1.5rem;
    font-weight: 600;
    font-family: var(--font-heading);
}

.text-warning { color: var(--status-medium); }
.text-critical { color: var(--status-critical); }
.text-success { color: var(--status-success); }

/* ===== TAB BAR ===== */
.tab-bar {
    display: flex;
    padding: 0 1rem;
    gap: 4px;
    border-bottom: 1px solid var(--border-glass);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 0.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255,255,255,0.03);
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* Tab Content */
.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

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

.priority-list-header {
    padding: 1rem 1.5rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.priority-list-header h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.btn-icon:hover { color: var(--text-main); }

.priority-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Custom Scrollbar */
.priority-list::-webkit-scrollbar,
.analytics-panel::-webkit-scrollbar,
.roi-panel::-webkit-scrollbar { width: 6px; }
.priority-list::-webkit-scrollbar-track,
.analytics-panel::-webkit-scrollbar-track,
.roi-panel::-webkit-scrollbar-track { background: transparent; }
.priority-list::-webkit-scrollbar-thumb,
.analytics-panel::-webkit-scrollbar-thumb,
.roi-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.priority-list::-webkit-scrollbar-thumb:hover,
.analytics-panel::-webkit-scrollbar-thumb:hover,
.roi-panel::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

.zone-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zone-card:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateX(4px);
}

.zone-card.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-primary);
}

.zone-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.zone-rank {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.rank-badge {
    background: var(--text-muted);
    color: var(--bg-base);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.rank-badge.critical { background: var(--status-critical); color: white; }
.rank-badge.high { background: var(--status-high); color: white; }

.zone-score {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
}

.zone-location {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zone-stats {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.zone-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.zone-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.zone-tag {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.zone-tag.no-parking {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-critical);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.zone-tag.has-signal {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.zone-tag.landmark {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ===== ANALYTICS PANEL ===== */
.analytics-panel {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chart-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: -4px;
}

.chart-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.chart-donut {
    max-height: 220px;
}

/* ===== ROI PANEL ===== */
.roi-panel {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.roi-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.roi-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.roi-input-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 130px;
}

.roi-input-group input[type="range"] {
    flex: 1;
    accent-color: var(--accent-primary);
    height: 6px;
}

.roi-value {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    min-width: 30px;
    text-align: right;
}

.roi-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.roi-stat {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.roi-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.roi-stat-value {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
}

.roi-stat-pct {
    font-size: 0.85rem;
    color: var(--status-success);
    font-weight: 600;
}

.roi-stat-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.roi-chart-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255,255,255,0.05);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    height: 72px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-left h2 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 500;
}

.badge-live {
    background: rgba(239, 68, 68, 0.1);
    color: var(--status-critical);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.badge-predictive {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.3);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    animation: pulse-purple 2s infinite;
}

@keyframes pulse-purple {
    0% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(168, 85, 247, 0); }
    100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); }
}

.layer-controls {
    display: flex;
    gap: 1.5rem;
}

/* Toggles */
.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle input { display: none; }

.slider {
    width: 36px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    position: relative;
    transition: 0.3s;
}

.slider::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: 0.3s;
}

.toggle input:checked + .slider {
    background: var(--accent-primary);
}

.toggle input:checked + .slider.glow {
    background: #a855f7;
    box-shadow: 0 0 10px #a855f7;
}

.toggle input:checked + .slider::after {
    transform: translateX(16px);
}

.toggle.predictive-toggle .text {
    color: #a855f7;
    font-weight: 600;
}

.toggle .text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    padding: 0;
}

#map {
    width: 100%;
    height: 100%;
    border-radius: 15px;
    background: #1a1a1a;
    z-index: 1;
}

/* Time Slider */
.time-slider-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 400px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-play {
    background: var(--accent-primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    transition: transform 0.2s;
}
.btn-play:hover {
    transform: scale(1.05);
}

.time-slider-track {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#time-label {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
}

#time-slider {
    width: 100%;
    accent-color: var(--accent-primary);
}

.time-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Leaflet Dark Theme Overrides */
.leaflet-layer,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out,
.leaflet-control-attribution {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.leaflet-container {
    background: #0f172a;
}

/* Floating Info Panel */
.floating-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 340px;
    max-height: calc(100% - 40px);
    overflow-y: auto;
    z-index: 1000;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: opacity 0.3s, transform 0.3s;
}

.floating-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover { color: white; }

#panel-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    padding-right: 20px;
}

/* Circular Chart */
.score-ring {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.score-ring span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 80%;
    max-height: 120px;
}

.circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 2.5;
}

.circle {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    transition: stroke-dasharray 1s ease-out;
}

.orange .circle { stroke: var(--status-critical); }
.yellow .circle { stroke: var(--status-medium); }

.percentage {
    fill: white;
    font-family: var(--font-heading);
    font-size: 0.6em;
    font-weight: 700;
    text-anchor: middle;
}

.detail-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-list li {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
}

.detail-list .lbl { color: var(--text-muted); }
.detail-list .val { font-weight: 600; font-size: 0.8rem; }

.panel-vehicle-chart {
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    padding: 0.5rem;
}

.recommendation-box {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--status-critical);
    padding: 10px 12px;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    line-height: 1.4;
}

.recommendation-box.high {
    background: rgba(249, 115, 22, 0.1);
    border-color: var(--status-high);
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Floating panel scrollbar */
.floating-panel::-webkit-scrollbar { width: 4px; }
.floating-panel::-webkit-scrollbar-track { background: transparent; }
.floating-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
