[data-theme="light"] .prediction-details {
    background: #f3f4f6; /* light grey panel */
    color: var(--text-secondary);
}

[data-theme="light"] .prediction-details .metric-row {
    color: var(--text-secondary);
}

[data-theme="light"] .prediction-direction {
    color: var(--danger);
}

[data-theme="light"] .ai-analysis-card {
    border-top-color: var(--secondary);
}
[data-theme="light"] {
    --primary: #2563eb; /* blue-600 */
    --primary-dark: #1e40af;
    --secondary: #7c3aed; /* violet */
    --success: #059669; /* green-600 */
    --danger: #dc2626; /* red-600 */
    --warning: #d97706; /* amber-600 */
    --info: #0284c7;

    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-modal: rgba(255, 255, 255, 0.95);

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #6b7280;

    --border-color: #e6eef8;
}
[data-theme="light"] .header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border-color);
}

[data-theme="light"] .logo h1 {
    background: none;
    -webkit-text-fill-color: unset;
    color: var(--text-primary);
}

[data-theme="light"] .hero-title {
    background: none;
    -webkit-text-fill-color: unset;
    color: var(--text-primary);
}

[data-theme="light"] .header .header-controls #themeToggle {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .card {
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}
/* ==================== CSS Variables ==================== */
:root {
    /* Colors */
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --success: #00c853;
    --danger: #ff3d00;
    --warning: #ffa726;
    --info: #29b6f6;

    /* Backgrounds */
    --bg-primary: #0a0e27;
    --bg-secondary: #1e2130;
    --bg-card: #151828;
    --bg-modal: rgba(10, 14, 39, 0.95);

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #b8c1ec;
    --text-muted: #6b7280;

    /* Borders */
    --border-color: #313545;
    --border-radius: 12px;
    --border-radius-lg: 16px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.4);

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
}

/* ==================== Global Styles ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.25s ease, color 0.25s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ==================== Light Theme Overrides ==================== */
[data-theme="light"] {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #7c3aed;
    --success: #0f9d58;
    --danger: #d32f2f;
    --warning: #f59e0b;
    --info: #0288d1;

    --bg-primary: #ffffff;
    --bg-secondary: #f7f9fc;
    --bg-card: #ffffff;
    --bg-modal: rgba(255, 255, 255, 0.95);

    --text-primary: #0a0e27;
    --text-secondary: #374151;
    --text-muted: #6b7280;

    --border-color: #e6e9f2;

    --shadow-sm: 0 1px 3px rgba(12, 12, 12, 0.04);
    --shadow-md: 0 4px 6px rgba(12, 12, 12, 0.06);
    --shadow-lg: 0 8px 12px rgba(12, 12, 12, 0.08);
    --shadow-xl: 0 12px 18px rgba(12, 12, 12, 0.1);
}

/* Header controls (theme toggle + join button) */
.header .header-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

#themeToggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.45rem 0.6rem;
    border-radius: 999px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1rem;
}

#themeToggle:hover {
    transform: translateY(-1px);
}

/* ==================== Header ==================== */
.header {
    background: rgba(21, 24, 40, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo h1 {
    font-size: var(--font-size-2xl);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==================== Hero Section ==================== */
.hero {
    padding: var(--spacing-xl) 0;
    text-align: center;
}

.hero-title {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    background: linear-gradient(135deg, #ffffff 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* ==================== Main Content ==================== */
.main-content {
    /* Add top offset equal to header height to avoid overlap when header is sticky.
       The `--header-offset` variable is set by JS on load/resize. */
    padding: calc(var(--spacing-lg) + var(--header-offset, 0px)) 0 var(--spacing-xl);
}

/* ==================== Cards ==================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.card h3 {
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

/* ==================== Controls Section ==================== */
.controls-section {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.control-group {
    display: flex;
    flex-direction: column;
}

.control-group label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
}

.control-group select,
.control-group input[type="date"] {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    color: var(--text-primary);
    font-size: var(--font-size-base);
    transition: border-color 0.3s ease;
}

.control-group select:focus,
.control-group input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    transition: background 0.3s ease;
}

.checkbox-label:hover {
    background: rgba(102, 126, 234, 0.1);
}

.checkbox-label input[type="checkbox"] {
    margin-right: var(--spacing-sm);
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: var(--font-size-base);
    color: var(--text-primary);
}

/* ==================== Buttons ==================== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: var(--font-size-lg);
    width: 100%;
}

/* ==================== Loading State ==================== */
.loading-state {
    text-align: center;
    padding: var(--spacing-xl);
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto var(--spacing-md);
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== Error State ==================== */
.error-state {
    background: rgba(255, 61, 0, 0.1);
    border: 1px solid var(--danger);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    color: var(--danger);
    text-align: center;
}

/* ==================== Results Grid ==================== */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

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

/* ==================== Forecast Card ==================== */
.forecast-card {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.regime-indicators {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
}

.regime-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-xs);
}

.regime-item:last-child {
    margin-bottom: 0;
}

.regime-label {
    color: var(--text-secondary);
}

.regime-value {
    font-weight: 600;
    text-transform: uppercase;
}

.prediction-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
}

.prediction-direction {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin: var(--spacing-md) 0;
}

.prediction-details {
    margin-top: var(--spacing-md);
}

.prediction-details p {
    margin-bottom: var(--spacing-xs);
}

.matched-pattern-info {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
}

.matched-pattern-info p {
    margin-bottom: var(--spacing-xs);
}

.accuracy-check {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    font-weight: 600;
    text-align: center;
}

/* ==================== Charts ==================== */
.charts-column {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* ==================== AI Analysis ==================== */
.ai-analysis-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.agreement-indicator {
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-md);
    font-weight: 600;
    text-align: center;
}

.pattern-identification {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

.pattern-identification h4 {
    margin-bottom: var(--spacing-sm);
}

.technical-levels {
    margin-bottom: var(--spacing-md);
}

.levels-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.levels-grid h4 {
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-base);
}

.analysis-comparison {
    margin-bottom: var(--spacing-md);
}

.ai-details {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    cursor: pointer;
}

.ai-details summary {
    font-weight: 600;
    cursor: pointer;
}

.ai-details p {
    margin-top: var(--spacing-sm);
    color: var(--text-secondary);
}

.trading-recommendation {
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    border: 2px solid;
}

/* ==================== CTA Section ==================== */
.cta-section {
    text-align: center;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
}

.cta-section h3 {
    margin-bottom: var(--spacing-sm);
}

.cta-section p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

/* ==================== Modal ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-modal);
    backdrop-filter: blur(10px);
}

.modal-content {
    background: var(--bg-card);
    margin: 10% auto;
    padding: var(--spacing-xl);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);

    animation: slideIn 0.3s ease;
}

/* Forecast Grid Layout */
.forecast-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.forecast-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.prediction-details {
    margin-top: auto;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.2rem;
    border-radius: 12px;
}

/* Indicators Grid */
.indicators-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.indicator-card {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    text-align: center;
    padding: 1.5rem;
}

/* Metric Styling */
.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.metric-row:last-child {
    margin-bottom: 0;
}

.metric-value {
    font-weight: 700;
    font-size: 1.1rem;
}

/* Color Utilities */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

/* Responsive adjustments */
@media (max-width: 768px) {

    .forecast-grid,
    .indicators-grid {
        grid-template-columns: 1fr;
    }
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

/* AI Details adjustments */
.ai-analysis-card {
    border-top: 4px solid var(--secondary);
}

.matched-pattern-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

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

.close {
    color: var(--text-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    margin-bottom: var(--spacing-md);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

#emailForm {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

#emailInput {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--font-size-base);
}

#emailInput:focus {
    outline: none;
    border-color: var(--primary);
}

.message {
    padding: var(--spacing-sm);
    border-radius: var(--border-radius);
    text-align: center;
    margin-top: var(--spacing-sm);
}

.message.success {
    background: rgba(0, 200, 83, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.message.error {
    background: rgba(255, 61, 0, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

/* ==================== Footer ==================== */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-lg) 0;
    text-align: center;
    color: var(--text-muted);
    margin-top: var(--spacing-xl);
}

.footer p {
    margin-bottom: var(--spacing-xs);
}

/* ==================== Responsive Design ==================== */
@media (max-width: 768px) {
    .hero-title {
        font-size: var(--font-size-2xl);
    }

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

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

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}