:root {
    --bg: #090d16;
    --surface: #111827;
    --surface-card: #1e293b;
    --border: #334155;
    --border-hover: #475569;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-blue: #38bdf8;
    --accent-purple: #a855f7;
    --danger: #ef4444;
    --warning: #f59e0b;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.brand-title h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #34d399, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-title p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.header-badges {
    display: flex;
    gap: 0.5rem;
}

.badge-cf {
    background: rgba(243, 128, 32, 0.15);
    color: #f38020;
    border: 1px solid rgba(243, 128, 32, 0.3);
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.badge-d1 {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Navigation Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    padding-bottom: 2px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s ease;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}

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

.tab-btn.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
    background: rgba(16, 185, 129, 0.06);
}

/* Tab Panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Grids & Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-val {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--accent);
    margin: 0.4rem 0;
}

.kpi-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin: 1rem 0 0.5rem 0;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

th, td {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border);
}

th {
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.75rem;
    display: inline-block;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

/* Slider Controls for Policy Simulator */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    background: #0f172a;
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.control-item label {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.control-item .val-disp {
    color: var(--accent);
    font-weight: 700;
}

input[type=range] {
    width: 100%;
    accent-color: var(--accent);
    height: 6px;
    background: var(--border);
    border-radius: 4px;
    outline: none;
}

input[type=text], select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border 0.2s;
}

input[type=text]:focus, select:focus {
    border-color: var(--accent);
}

/* Waterfall Rows */
.waterfall-box {
    background: #0f172a;
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid var(--border);
}

.wf-row {
    display: flex;
    justify-content: space-between;
    padding: 0.55rem 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.9rem;
}

.wf-total {
    font-weight: bold;
    color: var(--accent);
    border-top: 1px solid var(--border);
    border-bottom: none;
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}

/* Tree visualization */
.tree-node {
    background: #0f172a;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-blue);
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    font-size: 0.88rem;
}

/* Leaflet OpenStreetMap Customization */
#burbank-map {
    height: 520px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border);
    z-index: 10;
}

.leaflet-popup-content-wrapper {
    background: #0f172a !important;
    color: var(--text) !important;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-tip {
    background: #0f172a !important;
}

.leaflet-popup-content {
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 12px 14px;
}

.leaflet-popup-content h4 {
    font-size: 1rem;
    color: var(--accent-blue);
    margin-bottom: 4px;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: 0.75rem 1rem;
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-top: 0.75rem;
    font-size: 0.82rem;
    align-items: center;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

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