:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-purple: #8b5cf6;
    --accent-red: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15) 0%, transparent 50%);
    background-attachment: fixed;
}

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 1.5rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-wrap: wrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.hidden {
    display: none;
}

/* Sidebar Menu */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    background: var(--bg-color);
    border-right: 1px solid var(--card-border);
    padding: 20px;
    z-index: 9999;
    transform: translateX(0);
    transition: transform 0.3s ease;
    box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sidebar.closed {
    transform: translateX(-100%);
    box-shadow: none;
}

.status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
}
.badge.warning { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge.success { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.highlight-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.8) 0%, rgba(59, 130, 246, 0.1) 100%);
    border-color: rgba(59, 130, 246, 0.3);
}

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.kpi-card h3 {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.kpi-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
}

.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.chart-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-header h3 {
    margin-bottom: 0;
}

.btn-expand {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: 0.2s;
    padding: 5px;
    border-radius: 4px;
}
.btn-expand:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.1);
}

/* Fullscreen Mode */
.chart-card.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 0;
    border: none;
    margin: 0;
    padding: 2rem 5%;
    display: flex;
    flex-direction: column;
}

.chart-card.fullscreen canvas {
    flex: 1;
    max-height: 85vh;
}
    max-height: 85vh;
}

/* Modal */
.modal {
    display: flex;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-color);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.modal.hidden .modal-content {
    transform: translateY(-20px);
}

.modal-content h2 { 
    margin-bottom: 1rem; 
    font-weight: 600;
}
.modal-content p { 
    color: var(--text-secondary); 
    margin-bottom: 1.5rem; 
    font-size: 0.9rem; 
    line-height: 1.5; 
}

input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-family: 'Inter', sans-serif;
    margin-bottom: 1.5rem;
    outline: none;
    transition: border-color 0.2s;
}

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

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}
.btn-primary:hover { background: #2563eb; }

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); }

/* Table Styles & Glossary */
.summary-section, .explanations, .forecasting-section {
    margin-top: 3rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.summary-section h3, .explanations h3, .forecasting-header h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    color: var(--text-primary);
}

/* Forecasting Section */
.forecasting-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.forecasting-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.control-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.control-value {
    font-weight: bold;
    color: var(--accent-blue);
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    margin-top: -8px;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.forecasting-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--card-border);
}

.fc-result-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
}

.fc-result-card.highlight {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.fc-result-card h4 {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.fc-vheader h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.menu-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 15px;
    text-align: left;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: 0.2s;
}

.menu-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.menu-item.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent-blue);
    font-weight: 600;
}

.fc-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

.fc-subtext {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 1rem;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    background: #1e293b; /* Solid background for sticky header */
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.explanations ul {
    list-style-type: none;
    padding-left: 0;
}

.explanations li {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.explanations strong {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .charts-grid { grid-template-columns: 1fr; }
    .kpi-grid { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 1rem; 
        margin-bottom: 2rem;
    }
    .kpi-card { padding: 1rem; }
    .kpi-card h3 { font-size: 0.8rem; margin-bottom: 0.5rem; }
    .kpi-value { font-size: 1.5rem; }
    
    .chart-card { padding: 1rem; }
    .chart-card h3 { font-size: 1.1rem; margin-bottom: 1rem; }
    
    h1 { font-size: 1.8rem; }
    .subtitle { font-size: 0.95rem; }
    .status { position: static; margin-top: 1rem; display: inline-block; }
    .dashboard-container { padding: 1rem; }
    
    .summary-section, .explanations, .forecasting-section { padding: 1rem; margin-top: 2rem; }
}

@media (max-width: 480px) {
    h1 { font-size: 1.5rem; }
}

/* Custom Select Dropdown Arrow */
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 32px !important;
}

/* Fix for select options text visibility */
select option {
    background-color: var(--bg-primary, #0f172a);
    color: var(--text-primary, #ffffff);
}

/* Monthly Summary Footer Styles */
.summary-total-row {
    background-color: rgba(255, 255, 255, 0.05);
    font-weight: bold;
    border-top: 2px solid var(--border-color);
}
.summary-total-row td {
    padding-top: 15px;
    padding-bottom: 15px;
}


/* Service Pills Tabs */
.service-tabs {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
    flex-wrap: wrap;
}
.service-tab-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.service-tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.service-tab-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: transparent;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
    transform: scale(1.05);
}



/* Mobile & Tablet Layout (Ultra Compact) */
@media (max-width: 1023px) {
    header {
        padding: 0.5rem 0;
        margin-bottom: 1rem;
        position: sticky;
        top: 0;
        z-index: 1000;
        justify-content: flex-start;
        align-items: center;
    }
    .subtitle {
        display: none;
    }
    h1 {
        font-size: 1.3rem;
        margin-right: 10px; /* Space before the status dot */
    }
    .status {
        margin-left: 0;
    }
    #connection-status {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        padding: 0;
        color: transparent;
        overflow: hidden;
        white-space: nowrap;
        display: block;
        min-width: 10px; /* Prevent flex squishing */
    }
    .service-tabs {
        width: 100%;
        margin-top: 5px;
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
        justify-content: flex-start;
        /* Hide scrollbar for cleaner look */
        scrollbar-width: none; 
    }
    .service-tabs::-webkit-scrollbar {
        display: none;
    }
    .service-tab-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
}

/* Desktop Responsive Header */
@media (min-width: 1024px) {
    header {
        flex-wrap: nowrap;
        padding: 0.5rem 0;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    .subtitle {
        display: none;
    }
    .header-left {
        flex: 0 0 auto;
        order: 1;
    }
    .service-tabs {
        flex: 1;
        justify-content: center;
        margin-top: 0;
        width: auto;
        order: 2;
    }
    .status {
        order: 3;
        flex: 0 0 auto;
    }
}

/* AI Spinner Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Chat styles */
.chat-msg {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 0.9rem;
    line-height: 1.5;
}
.chat-msg.user {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
    color: white;
}
.chat-msg.ai {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    color: #e2e8f0;
}

