/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; line-height: 1.6; min-height: 100vh; transition: background-color 0.4s ease, color 0.4s ease; }
img, svg { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input { font-family: inherit; }

/* === THEME TOKENS === */
:root {
    --color-blue: #00D4FF;
    --color-green: #00FF88;
    --color-purple: #8B5CF6;
    --color-gold: #FFD700;
    --color-coral: #FF6B6B;
    --color-silver: #94A3B8;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-glow-blue: 0 0 20px rgba(0, 212, 255, 0.15);
    --shadow-glow-green: 0 0 20px rgba(0, 255, 136, 0.15);
    --shadow-glow-purple: 0 0 20px rgba(139, 92, 246, 0.15);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-variant-numeric: tabular-nums lining-nums;
}

[data-theme="dark"] {
    --bg: #07071A;
    --bg-surface: #0E0E28;
    --bg-elevated: #151536;
    --bg-input: #0E0E28;
    --border: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(0, 212, 255, 0.2);
    --text: #E8ECF1;
    --text-secondary: #8B92A5;
    --text-muted: #565B6E;
    --positive: #00FF88;
    --negative: #FF6B6B;
    --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --glow-blue: rgba(0, 212, 255, 0.08);
    --glow-green: rgba(0, 255, 136, 0.06);
    --glow-purple: rgba(139, 92, 246, 0.06);
    --chart-grid: rgba(255, 255, 255, 0.04);
    --chart-text: #8B92A5;
}

[data-theme="light"] {
    --bg: #F4F7FB;
    --bg-surface: #FFFFFF;
    --bg-elevated: #F8FAFC;
    --bg-input: #FFFFFF;
    --border: rgba(0, 0, 0, 0.07);
    --border-accent: rgba(0, 150, 200, 0.2);
    --text: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --positive: #059669;
    --negative: #DC2626;
    --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --glow-blue: rgba(0, 180, 220, 0.06);
    --glow-green: rgba(0, 200, 100, 0.04);
    --glow-purple: rgba(139, 92, 246, 0.04);
    --chart-grid: rgba(0, 0, 0, 0.06);
    --chart-text: #64748B;
    --color-blue: #0099CC;
    --color-green: #059669;
    --color-purple: #7C3AED;
    --color-gold: #D97706;
    --color-coral: #DC2626;
    --color-silver: #64748B;
}

body { background: var(--bg); color: var(--text); }

/* === LAYOUT === */
.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.section { padding: 20px 0; }

/* === THEME TOGGLE === */
.theme-toggle {
    position: fixed; top: 20px; right: 20px; z-index: 100;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--bg-elevated); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: all var(--transition);
    box-shadow: var(--card-shadow);
}
.theme-toggle:hover { color: var(--color-blue); border-color: var(--border-accent); box-shadow: var(--shadow-glow-blue); }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }

/* === HEADER === */
.header { padding: 48px 0 16px; text-align: center; }
.header-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.header-title {
    font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 800; letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--color-blue), var(--color-purple));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.header-sub { font-size: 0.95rem; color: var(--text-secondary); font-weight: 400; margin-top: 4px; letter-spacing: 0.02em; }

/* === TICKER BANNER === */
.ticker-banner {
    background: var(--bg-surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
    padding: 16px 0; margin-bottom: 8px;
}
.ticker-content { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.ticker-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.ticker-main { display: flex; align-items: baseline; gap: 12px; margin-top: 2px; }
.ticker-value { font-size: clamp(1.6rem, 4vw, 2rem); font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.ticker-change { font-size: 0.9rem; font-weight: 600; padding: 3px 10px; border-radius: 6px; }
.ticker-change.positive { color: var(--positive); background: rgba(0, 255, 136, 0.1); }
.ticker-change.negative { color: var(--negative); background: rgba(255, 107, 107, 0.1); }
.ticker-right { text-align: right; }
.ticker-source, .ticker-updated { display: block; font-size: 0.72rem; color: var(--text-muted); }

/* === PERFORMANCE BOXES === */
.perf-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.perf-box {
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 16px; text-align: center; transition: all var(--transition);
}
.perf-box:hover { border-color: var(--border-accent); box-shadow: var(--shadow-glow-blue); }
.perf-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.perf-value { font-size: 1.25rem; font-weight: 700; }
.perf-value.positive { color: var(--positive); }
.perf-value.negative { color: var(--negative); }
.perf-note { font-size: 0.62rem; color: var(--text-muted); margin-top: 2px; }

/* === INPUT CARD === */
.input-card {
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 28px 32px; margin-bottom: 20px; text-align: center;
}
.input-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px; }
.input-wrapper {
    display: inline-flex; align-items: center; background: var(--bg-input);
    border: 2px solid var(--border); border-radius: var(--radius-md);
    padding: 0 20px; transition: all var(--transition); max-width: 320px; width: 100%;
}
.input-wrapper:focus-within { border-color: var(--color-blue); box-shadow: var(--shadow-glow-blue); }
.input-prefix { font-size: 1.4rem; font-weight: 700; color: var(--text-muted); margin-right: 4px; }
.capital-input {
    border: none; outline: none; background: transparent; color: var(--text);
    font-size: 1.4rem; font-weight: 700; padding: 14px 0; width: 100%;
    text-align: left;
}
.capital-input::placeholder { color: var(--text-muted); }

/* === PROFILE BUTTONS === */
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.profile-btn {
    background: var(--bg-surface); border: 2px solid var(--border); border-radius: var(--radius-lg);
    padding: 28px 20px; text-align: center; transition: all var(--transition);
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.profile-btn:hover { border-color: var(--border-accent); transform: translateY(-2px); box-shadow: var(--shadow-glow-blue); }
.profile-btn.active { border-color: var(--color-blue); background: var(--glow-blue); box-shadow: var(--shadow-glow-blue); }
.profile-btn[data-profile="balanced"].active { border-color: var(--color-green); background: var(--glow-green); box-shadow: var(--shadow-glow-green); }
.profile-btn[data-profile="aggressive"].active { border-color: var(--color-purple); background: var(--glow-purple); box-shadow: var(--shadow-glow-purple); }
.profile-icon { color: var(--text-secondary); transition: color var(--transition); }
.profile-btn.active .profile-icon { color: var(--color-blue); }
.profile-btn[data-profile="balanced"].active .profile-icon { color: var(--color-green); }
.profile-btn[data-profile="aggressive"].active .profile-icon { color: var(--color-purple); }
.profile-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.profile-desc { font-size: 0.75rem; color: var(--text-muted); }

/* === SYNTHESIS CARD === */
.synthesis-card {
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 28px 32px; overflow: hidden;
}
.synthesis-title {
    font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-secondary); margin-bottom: 20px;
}
.model-row {
    display: flex; align-items: center; gap: 14px; padding: 12px 0;
    border-bottom: 1px solid var(--border); opacity: 0.4; transition: opacity 0.5s ease;
}
.model-row.active { opacity: 1; }
.model-row.done { opacity: 1; }
.model-dot {
    width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted);
    flex-shrink: 0; transition: all 0.5s ease;
}
.model-row.active .model-dot { background: var(--color-blue); box-shadow: 0 0 10px var(--color-blue); animation: pulse-dot 1.2s infinite; }
.model-row.done .model-dot { background: var(--color-green); box-shadow: 0 0 10px var(--color-green); }
@keyframes pulse-dot { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.4); } }
.model-info { flex: 1; min-width: 0; }
.model-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.model-status { font-size: 0.75rem; color: var(--text-muted); margin-left: 8px; }
.model-progress { width: 120px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; flex-shrink: 0; }
.progress-fill { height: 100%; width: 0%; border-radius: 2px; background: linear-gradient(90deg, var(--color-blue), var(--color-green)); transition: width 0.3s ease; }
.model-check { color: var(--color-green); font-weight: 700; font-size: 1.1rem; opacity: 0; transition: opacity 0.3s ease; flex-shrink: 0; }
.model-row.done .model-check { opacity: 1; }
.model-row.done .progress-fill { width: 100% !important; }

.consensus-row {
    padding: 16px 0 4px; opacity: 0.4; transition: opacity 0.5s ease;
}
.consensus-row.active { opacity: 1; }
.consensus-label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.consensus-progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.consensus-progress .progress-fill { background: linear-gradient(90deg, var(--color-blue), var(--color-purple), var(--color-green)); }

/* === RESULTS === */
.section-title {
    font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 20px;
    display: flex; align-items: center; gap: 8px;
}
.section-title::before {
    content: ''; width: 4px; height: 20px; border-radius: 2px;
    background: linear-gradient(180deg, var(--color-blue), var(--color-purple));
}
.results-layout { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
.chart-wrap {
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 24px; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    position: sticky; top: 20px;
}
.alloc-cards { display: flex; flex-direction: column; gap: 10px; }
.alloc-card {
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 16px 20px; display: grid; grid-template-columns: 10px 1fr auto; gap: 14px; align-items: center;
    transition: all var(--transition);
}
.alloc-card:hover { border-color: var(--border-accent); box-shadow: var(--card-shadow); }
.alloc-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.alloc-info { min-width: 0; }
.alloc-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.alloc-example { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.alloc-numbers { text-align: right; flex-shrink: 0; }
.alloc-pct { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.alloc-dollar { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; }

/* === CHARTS === */
.chart-card-wide {
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 24px; margin-bottom: 16px;
}
.chart-card-wide canvas { width: 100% !important; height: 280px !important; }

/* === SCENARIOS === */
.scenario-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.scenario-card {
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 18px 20px; text-align: center;
}
.scenario-name { font-size: 0.82rem; font-weight: 700; margin-bottom: 4px; }
.scenario-name.bull { color: var(--color-green); }
.scenario-name.base { color: var(--color-blue); }
.scenario-name.bear { color: var(--color-coral); }
.scenario-prob { font-size: 1.4rem; font-weight: 800; color: var(--text); margin: 4px 0; }
.scenario-range { font-size: 0.75rem; color: var(--text-muted); }

/* === FOOTER === */
.footer {
    margin-top: 24px; padding: 24px 0; border-top: 1px solid var(--border);
}
.footer-content { text-align: center; }
.footer-content p { font-size: 0.72rem; color: var(--text-muted); line-height: 1.8; }

/* === ANIMATIONS === */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .perf-grid { grid-template-columns: repeat(2, 1fr); }
    .profile-grid { grid-template-columns: 1fr; }
    .results-layout { grid-template-columns: 1fr; }
    .chart-wrap { position: static; aspect-ratio: auto; padding: 20px; }
    .chart-wrap canvas { max-height: 280px; }
    .scenario-grid { grid-template-columns: 1fr; }
    .ticker-content { flex-direction: column; text-align: center; }
    .ticker-right { text-align: center; }
    .input-card { padding: 20px; }
    .synthesis-card { padding: 20px; }
    .model-progress { width: 80px; }
}

@media (max-width: 480px) {
    .perf-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .header-title { font-size: 1.3rem; }
    .ticker-value { font-size: 1.5rem; }
    .alloc-card { grid-template-columns: 8px 1fr auto; gap: 10px; padding: 12px 14px; }
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
