:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --danger: #ef4444;
    --success: #22c55e;
    --sidebar-width: 280px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Animated Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite alternate;
}

.blob-1 { width: 400px; height: 400px; background: #3b82f6; top: -100px; left: -100px; animation-delay: 0s; }
.blob-2 { width: 300px; height: 300px; background: #8b5cf6; bottom: -50px; right: -50px; animation-delay: -5s; }
.blob-3 { width: 350px; height: 350px; background: #10b981; top: 40%; left: 50%; transform: translate(-50%, -50%); animation-delay: -10s; }

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Upload Container */
.upload-container {
    max-width: 800px;
    margin: 100px auto;
    padding: 60px 40px;
    border-radius: 24px;
    text-align: center;
}

.glass-panel {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.upload-container header h1 {
    font-size: 2.5rem;
    font-weight: 700;
}
.upload-container header h1 span { color: var(--accent-color); }
.upload-container header p { color: var(--text-secondary); margin-top: 8px; margin-bottom: 40px; }

.upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px;
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
}

.upload-section:hover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--accent-color);
    color: white;
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
}

.upload-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.file-name { color: var(--text-secondary); font-size: 0.9rem; }

/* Loader */
.loader { display: flex; flex-direction: column; align-items: center; gap: 16px; margin: 40px 0; }
.spinner {
    width: 40px; height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-header h2 { font-size: 1.5rem; font-weight: 700; }
.sidebar-header h2 span { color: var(--accent-color); }

.nav-menu { padding: 24px 0; }
.nav-group { margin-bottom: 24px; }
.nav-group h3 {
    padding: 0 24px;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--accent-color);
    color: var(--accent-color);
    font-weight: 600;
}

/* Accordion */
.accordion-content {
    display: none;
    background: rgba(0, 0, 0, 0.2);
}
.accordion.open .accordion-content { display: block; }
.accordion.open .chevron { transform: rotate(180deg); }
.chevron { font-size: 0.8rem; transition: transform 0.3s; }
.nav-child {
    padding-left: 48px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.nav-child:hover, .nav-child.active {
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    min-width: 0; /* CRITICAL: Prevents flex child from growing infinitely */
    margin-left: var(--sidebar-width);
    padding: 40px;
}

.content-header { margin-bottom: 32px; }
.content-header h1 { font-size: 2rem; font-weight: 700; }
.content-header p { color: var(--text-secondary); margin-top: 4px; }

.dashboard-content {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
}
.kpi-card h3 { font-size: 0.9rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; }
.kpi-value { font-size: 1.8rem; font-weight: 700; margin-top: 8px; }
.kpi-value.positive { color: var(--success); }
.kpi-value.negative { color: var(--danger); }

/* Critique Section */
.critique-section h2 { margin-bottom: 16px; font-size: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 12px; }
.critique-content p { color: #e2e8f0; line-height: 1.7; margin-bottom: 16px; }
.critique-content strong { color: var(--accent-color); }

/* Table Section */
.table-section {
    min-width: 0;
    max-width: 100%;
}
.table-section h2 { margin-bottom: 16px; font-size: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 12px; }
.table-responsive { 
    overflow-x: auto; 
    max-width: 100%; 
    width: 100%;
    border-radius: 8px; 
    padding-bottom: 10px; /* Space for scrollbar */
}

/* Custom Scrollbar for tables */
.table-responsive::-webkit-scrollbar {
    height: 12px;
}
.table-responsive::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 8px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

.wide-table {
    white-space: nowrap;
    min-width: 1500px;
}

.pnl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.pnl-table th, .pnl-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* Sticky first column */
.pnl-table th:first-child, .pnl-table td:first-child {
    position: sticky;
    left: 0;
    background-color: var(--card-bg);
    z-index: 2;
    border-right: 2px solid var(--border-color);
    font-weight: 600;
}

/* Sub-headers for Budget/Realized */
.pnl-table .sub-header {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.02);
}

.pnl-table th {
    text-align: right;
    color: var(--text-secondary);
    font-weight: 600;
}
.pnl-table th:first-child { text-align: left; }

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.pnl-table tbody tr:hover td { background: rgba(59, 130, 246, 0.1); }
.pnl-table tbody tr:hover td:first-child { background-color: var(--card-bg); filter: brightness(1.2); }

.pnl-table td.negative { color: var(--danger); font-weight: 600; }
.pnl-table td.positive { color: var(--success); font-weight: 600; }

.macro-row {
    font-size: 0.95rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.03);
}

/* Charts */
.charts-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}
@media (max-width: 1200px) { .charts-section { grid-template-columns: 1fr; } }
.chart-container h3 { margin-bottom: 16px; font-size: 1.2rem; text-align: center; }
