:root {
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --accent-color: #4c51bf;
    /* Indigo */
    --accent-light: #ebf4ff;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Prevent vertical stretching */
    overflow-x: hidden;
    position: relative;
    /* Removed min-height: 100vh to prevent expansion loops */
}

.dashboard-container {
    max-width: 1200px;
    width: 100%;
}

header {
    margin-bottom: 2rem;
}

header h1 {
    font-weight: 600;
    margin: 0 0 0.5rem 0;
}

header p {
    color: var(--text-secondary);
    margin: 0;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

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

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

.kpi-card .value {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--accent-color);
}

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

/* Force the first chart (Growth) to be full width */
.charts-grid>.card:first-child {
    grid-column: 1 / -1;
}

.chart-card {
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.chart-card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}

/* ... */

/* Constrain Chart Height to prevent infinite growth */
.chart-container-fixed {
    position: relative;
    height: 320px;
    width: 100%;
}

.chart-container-fixed canvas {
    max-height: 100% !important;
    width: 100% !important;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #edf2f7;
}

th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.8rem;
}

/* Responsive */
/* Auth Overlay */
.auth-overlay {
    position: fixed;
    /* Pin to the iframe viewport */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(248, 249, 250, 1);
    /* Fully opaque */
    backdrop-filter: blur(15px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    z-index: 10000;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.auth-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.auth-card {
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-card h2 {
    margin-top: 0;
    color: var(--accent-color);
}

.auth-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-card input {
    padding: 0.85rem;
    border: 1px solid #edf2f7;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.auth-card input:focus {
    border-color: var(--accent-color);
}

.auth-card button {
    padding: 0.85rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}

.auth-card button:active {
    transform: scale(0.98);
}

.auth-card button:hover {
    background: #434190;
}

.error-text {
    color: #e53e3e;
    font-size: 0.85rem;
    margin-top: 1rem;
    font-weight: 500;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hide dashboard content while blurred */
body:has(.auth-overlay:not(.hidden)) .dashboard-container {
    filter: blur(5px);
    pointer-events: none;
}

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}