:root {
    --bg-main: #f8fafc;
    /* slate-50 */
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    /* slate-200 */
    --text-primary: #0f172a;
    /* slate-900 */
    --text-secondary: #64748b;
    /* slate-500 */

    --primary: #0f172a;
    /* slate-900 */
    --primary-hover: #334155;
    /* slate-700 */
    --primary-foreground: #f8fafc;

    --secondary: #f1f5f9;
    /* slate-100 */
    --secondary-hover: #e2e8f0;
    /* slate-200 */
    --secondary-foreground: #0f172a;

    --accent-1: #2563eb;
    /* blue-600 */
    --accent-2: #4f46e5;
    /* indigo-600 */

    --success: #10b981;
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;

    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;

    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;

    --radius: 0.75rem;
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --transition: all 0.2s ease-in-out;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* ===== DARK MODE ===== */
html.dark {
    --bg-main: #0a0a0b;
    --bg-card: #111113;
    --border-color: #27272a;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;

    --primary: #fafafa;
    --primary-hover: #d4d4d8;
    --primary-foreground: #09090b;

    --secondary: #18181b;
    --secondary-hover: #27272a;
    --secondary-foreground: #fafafa;

    --accent-1: #60a5fa;
    --accent-2: #818cf8;

    --success: #34d399;
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-border: rgba(16, 185, 129, 0.3);

    --warning: #fbbf24;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --warning-border: rgba(245, 158, 11, 0.3);

    --danger: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --danger-border: rgba(239, 68, 68, 0.3);

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    padding: 2rem 1rem;
    line-height: 1.5;
}

/* Background Elements */
.bg-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at top right, #fbfbfe 0%, #f8fafc 100%);
    transition: background 0.3s ease;
}

html.dark .bg-elements {
    background: radial-gradient(circle at top right, #0d0d0f 0%, #0a0a0b 100%);
}

.blob {
    position: absolute;
    filter: blur(100px);
    border-radius: 50%;
    opacity: 0.15;
    animation: float 25s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--accent-1);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: var(--accent-2);
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 60%;
    width: 400px;
    height: 400px;
    background: var(--primary);
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

/* Layout containers */
.container {
    width: 100%;
    max-width: 800px;
    margin: 4vh auto;
    position: relative;
    z-index: 10;
}

.glass-panel,
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.glass-card {
    padding: 1.5rem;
    border-radius: calc(var(--radius) - 0.25rem);
}

.screen {
    opacity: 1;
    transition: opacity 0.4s ease, transform 0.4s ease;
    transform: translateY(0);
}

.screen.hidden {
    display: none;
    opacity: 0;
    transform: translateY(10px);
}

/* Icons & Utilities */
.lucide {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    vertical-align: middle;
}

.header-icon {
    width: 28px;
    height: 28px;
    color: var(--primary);
    margin-right: 0.25rem;
    vertical-align: -0.15em;
}

h3 .lucide {
    color: var(--accent-1);
    margin-right: 0.5rem;
}

.status-icon .lucide {
    width: 18px;
    height: 18px;
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

/* Typography & Utils */
h1 {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 1rem;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
    border-radius: calc(var(--radius) - 0.25rem);
}

button:focus-visible {
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

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

/* Question Flow Elements */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--secondary);
    border-radius: 999px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
    width: 0%;
    transition: width 0.4s ease;
}

.step-indicator {
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.option-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 500;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.option-btn:hover {
    background: var(--secondary);
    border-color: #cbd5e1;
    /* slate-300 */
    transform: translateY(-1px);
}

.option-btn.selected {
    background: #f8fafc;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
    color: var(--primary);
}

.option-btn.selected::after {
    content: '✓';
    color: var(--primary);
    font-weight: bold;
}

/* Input Styles */
.input-wrapper {
    margin-top: 1.5rem;
    position: relative;
    width: 100%;
}

.input-field {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.25rem;
    padding: 1.25rem;
    border-radius: calc(var(--radius) - 0.25rem);
    font-family: inherit;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.input-field::placeholder {
    color: #94a3b8;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary), 0 0 0 4px rgba(15, 23, 42, 0.1);
}

.input-prefix {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.has-prefix {
    padding-left: 2.5rem;
}

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 2.5rem;
}

/* Loading Screen */
.center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 4rem 2rem;
}

.loader {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 2rem;
}

.ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid transparent;
}

.ring:nth-child(1) {
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

.ring:nth-child(2) {
    border-right-color: #cbd5e1;
    animation: spin 1.5s linear infinite reverse;
}

.ring:nth-child(3) {
    border-bottom-color: var(--accent-1);
    animation: spin 2s linear infinite;
}

.dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 1;
    }
}

/* Results Dashboard */
.results-container {
    width: 100%;
    max-width: 900px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.results-header h2 {
    margin-bottom: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.col-span-2 {
    grid-column: span 2;
}

.status-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.status-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.status-icon {
    font-size: 1.1rem;
}

.risk-badge {
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    border-radius: calc(var(--radius) - 0.25rem);
    font-weight: 600;
    text-align: center;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    background: var(--secondary);
}

.risk-badge.high {
    background: var(--danger-bg);
    color: #991b1b;
    border-color: var(--danger-border);
}

.risk-badge.medium {
    background: var(--warning-bg);
    color: #92400e;
    border-color: var(--warning-border);
}

.risk-badge.low {
    background: var(--success-bg);
    color: #065f46;
    border-color: var(--success-border);
}

.flex-card {
    display: flex;
    gap: 1.5rem;
}

.card-half {
    flex: 1;
}

.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--secondary);
}

.metric:last-child {
    border-bottom: none;
}

.metric .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.metric .value {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.metric.highlight .value {
    color: var(--success);
    font-weight: 700;
}

.metric.highlight-red .value {
    color: var(--danger);
    font-weight: 700;
}


/* Budget Section */
.budget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.cpl-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--secondary);
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.budget-bars {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.budget-item {
    flex: 1;
    background: var(--secondary);
    padding: 1.25rem;
    border-radius: calc(var(--radius) - 0.25rem);
    text-align: center;
    border: 1px solid var(--border-color);
}

.budget-item.optimal {
    border-color: var(--primary);
    background: #f8fafc;
    box-shadow: var(--shadow-sm);
}

.budget-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.budget-amount {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.penalty-box {
    background: var(--danger-bg);
    border: 1px dashed var(--danger-border);
    border-radius: calc(var(--radius) - 0.25rem);
    padding: 1.25rem;
}

.penalty-box h4 {
    color: #991b1b;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.penalty-list {
    list-style: none;
    margin-bottom: 1.25rem;
}

.penalty-list li {
    color: #7f1d1d;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.penalty-list li::before {
    content: '•';
    font-weight: bold;
    color: #dc2626;
}

.real-budget-alert {
    background: #fee2e2;
    padding: 1rem;
    border-radius: 6px;
    color: #991b1b;
    border-left: 4px solid var(--danger);
    font-size: 0.95rem;
    font-weight: 500;
}

.real-budget-alert strong {
    font-size: 1.15rem;
    font-weight: 700;
}

/* Recommendations */
.rec-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1.25rem;
}

.rec-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    border-radius: calc(var(--radius) - 0.25rem);
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.rec-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.rec-number {
    background: var(--primary);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.rec-text h4 {
    margin-bottom: 0.3rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.rec-text p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

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

    h1 {
        font-size: 2.25rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    .glass-panel {
        padding: 1.5rem;
    }

    .glass-card {
        padding: 1.25rem;
    }

    .btn-primary,
    .btn-secondary,
    .btn-outline {
        width: 100%;
        justify-content: center;
    }

    .navigation-buttons {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }

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

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .col-span-2 {
        grid-column: auto;
    }

    .flex-card {
        flex-direction: column;
        gap: 1.5rem;
    }

    .budget-bars {
        flex-direction: column;
        gap: 1rem;
    }

    .budget-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .budget-amount {
        font-size: 1.5rem;
    }

    .results-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}

/* ===== THEME TOGGLE BUTTON ===== */
.theme-toggle {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    padding: 0;
}

.theme-toggle:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-lg);
}

.theme-toggle .icon-moon,
.theme-toggle .icon-sun {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.theme-toggle .icon-moon .lucide,
.theme-toggle .icon-sun .lucide {
    width: 20px;
    height: 20px;
}

/* Light mode: show moon, hide sun */
.theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0deg);
}

.theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(-90deg);
}

/* Dark mode: show sun, hide moon */
html.dark .theme-toggle .icon-moon {
    opacity: 0;
    transform: rotate(90deg);
}

html.dark .theme-toggle .icon-sun {
    opacity: 1;
    transform: rotate(0deg);
}

/* ===== DARK MODE OVERRIDES FOR HARDCODED COLORS ===== */
html.dark .blob {
    opacity: 0.08;
}

html.dark .option-btn.selected {
    background: var(--secondary);
}

html.dark .option-btn:hover {
    border-color: #3f3f46;
}

html.dark .budget-item.optimal {
    background: var(--secondary);
    border-color: var(--accent-1);
}

html.dark .input-field::placeholder {
    color: #52525b;
}

html.dark .input-field:focus {
    box-shadow: 0 0 0 1px var(--accent-1), 0 0 0 4px rgba(96, 165, 250, 0.15);
    border-color: var(--accent-1);
}

html.dark .risk-badge.high {
    color: #fca5a5;
}

html.dark .risk-badge.medium {
    color: #fde68a;
}

html.dark .risk-badge.low {
    color: #6ee7b7;
}

html.dark .penalty-box h4 {
    color: #fca5a5;
}

html.dark .penalty-list li {
    color: #fecaca;
}

html.dark .penalty-list li::before {
    color: #f87171;
}

html.dark .real-budget-alert {
    background: rgba(239, 68, 68, 0.15);
    color: #fecaca;
}

html.dark .rec-card:hover {
    border-color: #3f3f46;
}

html.dark .ring:nth-child(2) {
    border-right-color: #3f3f46;
}