:root {
    --primary-color: #2563eb;
    --secondary-color: #1e3a8a;
    --background-color: #f3f4f6;
    --surface-color: #ffffff;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --success-color: #10b981;
    --border-radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --border-color: #e5e7eb;
}

[data-theme="dark"] {
    --primary-color: #3b82f6;
    --secondary-color: #60a5fa;
    --background-color: #111827;
    --surface-color: #1f2937;
    --text-color: #f3f4f6;
    --text-muted: #9ca3af;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    --border-color: #374151;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ... existing code ... */

/* Login Form Structure */
.login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

header {
    background-color: var(--surface-color);
    padding: 1rem 0;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    transition: background-color 0.3s ease;
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

/* Upload Section */
.upload-card {
    background: var(--surface-color);
    padding: 3rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
    max-width: 600px;
    margin: 4rem auto;
    transition: transform 0.2s ease, background-color 0.3s ease;
}

.upload-area {
    border: 2px dashed var(--text-muted);
    border-radius: var(--border-radius);
    padding: 3rem;
    cursor: pointer;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.05);
}

.btn {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
    display: inline-block;
    margin-top: 1rem;
}

.btn:hover {
    background-color: var(--secondary-color);
}

.btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

background-color: rgba(37, 99, 235, 0.1);
}

.header-menu-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 140px;
    height: 40px;
    padding: 0 1rem;
    font-size: 0.9rem;
    text-align: center;
    white-space: nowrap;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 1px solid var(--primary-color);
    background-color: transparent;
    color: var(--primary-color);
}

[data-theme="dark"] .header-menu-btn {
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.header-menu-btn:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .header-menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}



/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.card {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
}

.full-width {
    grid-column: 1 / -1;
}

.charts-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}


.ai-insight {
    background: linear-gradient(135deg, rgba(224, 242, 254, 0.5) 0%, rgba(240, 249, 255, 0.5) 100%);
    border: 1px solid rgba(186, 230, 253, 0.5);
}

[data-theme="dark"] .ai-insight {
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.2) 0%, rgba(23, 37, 84, 0.2) 100%);
    border-color: rgba(30, 58, 138, 0.4);
}

.ai-insight h3 {
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    flex-direction: column;
}

[data-theme="dark"] .loading-overlay {
    background: rgba(17, 24, 39, 0.9);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- Login Page Redesign --- */

body.login-page {
    background: #000000;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

body.dashboard-page {
    background-color: var(--background-color);
    min-height: 100vh;
    /* Allow scrolling */
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.3s ease;
}

[data-theme="dark"] body.dashboard-page {
    background-color: #000000;
}

/* Header Styling */
.glass-header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 2rem;
    transition: all 0.3s ease;
}

[data-theme="dark"] .glass-header {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.dashboard-logo {
    color: var(--primary-color);
    text-shadow: none;
    transition: all 0.3s ease;
}

[data-theme="dark"] .dashboard-logo {
    color: white;
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.8);
}

/* Animated Background - Only for dark mode or login */
.login-background {
    position: absolute;
    width: 200vw;
    height: 200vh;
    background: radial-gradient(circle at 50% 50%, rgba(76, 29, 149, 0.3), transparent 60%),
        radial-gradient(circle at 10% 10%, rgba(219, 39, 119, 0.3), transparent 50%);
    animation: bgMove 20s infinite alternate;
    z-index: 0;
    opacity: 0;
    /* Hidden by default (Light Mode) */
    transition: opacity 0.5s ease;
    pointer-events: none;
}

body.login-page .login-background,
[data-theme="dark"] .login-background {
    opacity: 1;
    /* Visible in Login page OR Dark Mode */
}

@keyframes bgMove {
    0% {
        transform: translate(-10%, -10%) rotate(0deg);
    }

    100% {
        transform: translate(0, 0) rotate(10deg);
    }
}

/* Particles/Stars Canvas */
#particleCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Behind card */
}

/* Glassmorphism Card */
.login-glass-card {
    position: relative;
    z-index: 10;
    width: 480px;
    /* Increased slightly */
    height: 480px;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    color: white;
    text-align: center;
}

.login-glass-card h2 {
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 2rem;
    text-transform: uppercase;
    font-size: 1.5rem;
}

/* Inputs */
.login-input-group {
    position: relative;
    width: 320px;
    /* Fixed width for perfect centering */
    margin: 0 auto 1.2rem auto;
    /* Force horizontal centering */
}

.login-input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    /* Space for icon */
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: white;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s;
}

.login-input:focus {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.login-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.6);
}

/* Button */
.login-btn {
    width: 50%;
    padding: 0.8rem;
    border-radius: 25px;
    border: none;
    background: linear-gradient(90deg, #ec4899, #8b5cf6);
    color: white;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 1rem;
}

.login-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.6);
}

.login-links {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.login-links a {
    color: white;
    text-decoration: none;
    margin: 0 5px;
}

.login-links a:hover {
    text-decoration: underline;
}