/* ===== DESIGN TOKENS ===== */
:root {
    /* Colors - Light Mode */
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --border-color: rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);

    /* Accent Gradient */
    --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    --gradient-accent: linear-gradient(135deg, #10b981, #06b6d4);
    --gradient-warm: linear-gradient(135deg, #f59e0b, #ef4444);
    --gradient-bg: linear-gradient(135deg, #e0e7ff 0%, #f0f4f8 50%, #d5f5e3 100%);

    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --green: #10b981;
    --green-light: #34d399;
    --blue: #3b82f6;
    --orange: #f59e0b;
    --red: #ef4444;

    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --header-h: 64px;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.85);
    --bg-card-hover: rgba(30, 41, 59, 0.95);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: rgba(255, 255, 255, 0.06);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.25);
    --gradient-bg: linear-gradient(135deg, #0f172a 0%, #1a1a3e 50%, #0f2922 100%);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gradient-bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.4s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* ===== BACKGROUND ORBS ===== */
.bg-orbs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

[data-theme="dark"] .orb {
    opacity: 0.15;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: #6366f1;
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 350px;
    height: 350px;
    background: #10b981;
    bottom: -80px;
    left: -80px;
    animation-delay: -7s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: #8b5cf6;
    top: 50%;
    left: 50%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(40px, 30px) scale(1.02); }
}

/* ===== HEADER ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

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

.logo-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ===== MAIN CONTAINER ===== */
.main-container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== HERO ===== */
.hero {
    text-align: center;
    padding: 48px 16px 36px;
}

.hero h1 {
    font-size: clamp(1.75rem, 5vw, 2.75rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 12px;
}

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 540px;
    margin: 0 auto;
    font-weight: 400;
}

/* ===== APP GRID ===== */
.app-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 28px;
    align-items: start;
}

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

/* ===== CARD ===== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.3s ease, background 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.card-title svg {
    color: var(--accent);
}

/* ===== INPUT STYLES ===== */
.input-card {
    position: sticky;
    top: calc(var(--header-h) + 20px);
}

@media (max-width: 900px) {
    .input-card {
        position: static;
    }
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-group label svg {
    color: var(--accent-light);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.input-prefix, .input-suffix {
    padding: 0 14px;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-muted);
    user-select: none;
    white-space: nowrap;
}

.input-prefix {
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.input-suffix {
    border-left: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 13px 16px;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-primary);
    font-family: inherit;
    width: 100%;
    min-width: 0;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===== SCENARIO CHIPS ===== */
.scenario-chips {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.chip {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    white-space: nowrap;
}

.chip:hover {
    border-color: var(--accent-light);
    color: var(--accent);
}

.chip.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

/* ===== PRIMARY BUTTON ===== */
.btn-primary {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    color: white;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: inherit;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    margin-top: 8px;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover::before {
    opacity: 1;
}

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

/* ===== RESULTS SECTION ===== */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
}

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

/* ===== RESULTS GRID ===== */
.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.result-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
}

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

.result-total {
    grid-column: 1 / -1;
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 28px 30px;
}

.result-total::before {
    display: none;
}

.result-total .result-label {
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
}

.result-total .result-value {
    font-size: 2.2rem;
    color: white;
}

.result-invested::before { background: var(--blue); }
.result-interest::before { background: var(--green); }
.result-monthly::before { background: var(--orange); }

.result-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: var(--accent);
}

.result-invested .result-icon { color: var(--blue); }
.result-interest .result-icon { color: var(--green); }
.result-monthly .result-icon { color: var(--orange); }

.result-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.result-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 5px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.2);
    font-size: 0.82rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

/* Small screen: stack 3 bottom cards */
@media (min-width: 600px) {
    .results-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .result-total {
        grid-column: 1 / -1;
    }
}

/* ===== MOTIVATIONAL CARD ===== */
.motivational-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.motivational-emoji {
    font-size: 2rem;
    flex-shrink: 0;
}

.motivational-card p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.5;
}

/* ===== CHARTS ===== */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.chart-card {
    padding: 24px;
}

.chart-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.chart-container-pie {
    position: relative;
    max-width: 260px;
    margin: 0 auto;
}

.chart-container-line {
    position: relative;
    height: 260px;
}

/* ===== SECONDARY BUTTON ===== */
.btn-secondary {
    width: 100%;
    padding: 14px 24px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: inherit;
    transition: all 0.3s ease;
    backdrop-filter: blur(16px);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

/* ===== FOOTER ===== */
.footer {
    text-align: center;
    padding: 40px 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

/* ===== ANIMATIONS ===== */
.input-card {
    animation: fadeInUp 0.5s ease forwards;
}

.result-card {
    animation: fadeInUp 0.5s ease forwards;
}

.result-card:nth-child(2) { animation-delay: 0.1s; }
.result-card:nth-child(3) { animation-delay: 0.15s; }
.result-card:nth-child(4) { animation-delay: 0.2s; }

/* ===== NUMBER INPUT ARROWS ===== */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.5;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 99px;
}

/* ===== RESPONSIVE POLISH ===== */
@media (max-width: 480px) {
    .main-container {
        padding: 12px;
    }

    .hero {
        padding: 32px 8px 24px;
    }

    .card {
        padding: 20px;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

    .result-total .result-value {
        font-size: 1.7rem;
    }

    .result-value {
        font-size: 1.25rem;
    }

    .scenario-chips {
        flex-direction: column;
    }

    .chip {
        text-align: center;
    }
}
