/* ===== DESIGN TOKENS ===== */
:root {
    --bg: #F0EBE3;
    --bg-warm: #E8E1D6;
    --surface: #FDFAF6;
    --surface-raised: #FFFFFF;
    --ink: #1A1A2E;
    --ink2: #6B6880;
    --ink3: #9E9BB0;
    --accent: #2558C7;
    --accent-light: #3B6FE0;
    --accent-glow: rgba(37, 88, 199, 0.2);
    --green: #0F8A3F;
    --green-bg: #E6F5EC;
    --red: #C62828;
    --red-bg: #FBEAEA;
    --amber: #C77D06;
    --amber-bg: #FDF3E0;
    --radius: 16px;
    --radius-lg: 24px;
    --border-color: #DED8CE;
    --shadow-sm: 0 1px 2px rgba(26,26,46,0.04), 0 1px 3px rgba(26,26,46,0.06);
    --shadow-md: 0 2px 4px rgba(26,26,46,0.04), 0 4px 12px rgba(26,26,46,0.06);
    --shadow-lg: 0 4px 8px rgba(26,26,46,0.04), 0 8px 24px rgba(26,26,46,0.08);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.65;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* Paper grain texture */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 0.3;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3 {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

h4 { font-family: 'DM Sans', sans-serif; font-weight: 600; }

.mono {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ===== LAYOUT ===== */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem;
}

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

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

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

.app-header h1 {
    font-size: 1.75rem;
    color: var(--ink);
    position: relative;
}

.app-header h1 span {
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--ink3);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-top: 0.15rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

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

/* Staggered fade-in */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeSlideUp 0.4s ease both;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.01em;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px var(--accent-glow), 0 1px 2px rgba(0,0,0,0.1);
}

.btn-primary:hover {
    background: var(--accent-light);
    box-shadow: 0 4px 16px var(--accent-glow), 0 2px 4px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

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

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

/* ===== FORM INPUTS ===== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.8rem;
    color: var(--ink2);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.input-group input[type="number"],
.input-group select {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface-raised);
    color: var(--ink);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-variant-numeric: tabular-nums;
}

.input-group input[type="number"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group small {
    color: var(--ink3);
    font-size: 0.72rem;
    line-height: 1.4;
}

/* Remove number input spinners */
.input-group input[type="number"]::-webkit-inner-spin-button,
.input-group input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.input-group input[type="number"] { -moz-appearance: textfield; }

/* ===== SLIDER ===== */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, #E5E0D8 0%);
    outline: none;
    cursor: pointer;
    border: none;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface-raised);
    border: 2px solid var(--accent);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px var(--accent-glow);
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface-raised);
    border: 2px solid var(--accent);
    cursor: pointer;
}

/* ===== STEPPER ===== */
.stepper {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stepper button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--surface-raised);
    font-size: 1.25rem;
    color: var(--ink2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.stepper button:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: scale(1.05);
}

.stepper button:active {
    transform: scale(0.95);
}

.stepper span {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 2rem;
    font-weight: 500;
    min-width: 3ch;
    text-align: center;
    color: var(--ink);
}

/* ===== MODE TOGGLE ===== */
.mode-toggle {
    display: flex;
    background: var(--bg-warm);
    border-radius: 10px;
    padding: 3px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
}

.mode-toggle button {
    flex: 1;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    color: var(--ink2);
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.mode-toggle button.active {
    background: var(--surface-raised);
    color: var(--ink);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
    height: 3px;
    background: var(--bg-warm);
    border-radius: 2px;
    overflow: visible;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    right: -4px;
    top: -3.5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

/* ===== LIVE STRIP (Compact) ===== */
.live-strip {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(26, 26, 46, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 4px 20px rgba(26, 26, 46, 0.15);
    border: 1px solid rgba(255,255,255,0.06);
}

.live-strip .label {
    font-size: 0.6rem;
    opacity: 0.5;
    font-family: 'DM Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.15rem;
}

/* ===== RESULTS: ARC GAUGE ===== */
.arc-gauge-wrap {
    text-align: center;
    padding: 2rem 0 1rem;
}

.arc-gauge-wrap svg {
    max-width: 300px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.06));
}

/* Arc glow effect */
.arc-gauge-wrap .arc-value {
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    text-align: center;
}

.stats-grid .card {
    padding: 1.125rem 0.75rem;
}

.stat-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.15rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--ink3);
    margin-top: 0.25rem;
    letter-spacing: 0.02em;
}

/* ===== GAP PILL ===== */
.gap-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1.25rem;
    border-radius: 999px;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.gap-pill.negative {
    background: var(--red-bg);
    color: var(--red);
}

.gap-pill.positive {
    background: var(--green-bg);
    color: var(--green);
}

/* ===== CHART TABS ===== */
.chart-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.25rem;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.chart-tabs button {
    flex: 1;
    padding: 0.625rem 1rem;
    border: none;
    background: transparent;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink2);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-tabs button + button {
    border-left: 1px solid var(--border-color);
}

.chart-tabs button.active {
    background: var(--accent);
    color: #fff;
}

.chart-tabs button:not(.active):hover {
    background: var(--bg-warm);
}

/* ===== ACTION CARD ===== */
.action-card {
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    border: 1px solid transparent;
}

.action-card strong {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: 1.1rem;
    display: block;
}

.action-card p {
    font-size: 0.85rem;
    margin-top: 0.5rem;
    opacity: 0.85;
}

.action-card.green {
    background: var(--green-bg);
    color: #14532D;
    border-color: #BBE5C9;
}

.action-card.amber {
    background: var(--amber-bg);
    color: #78350F;
    border-color: #F5DFB0;
}

.action-card.red {
    background: var(--red-bg);
    color: #7F1D1D;
    border-color: #F0C5C5;
}

/* ===== INCOME BARS ===== */
.income-bar-container {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.income-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.income-bar-label {
    width: 110px;
    font-size: 0.78rem;
    color: var(--ink2);
    text-align: right;
    flex-shrink: 0;
}

.income-bar-track {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-height: 28px;
}

.income-bar {
    height: 24px;
    border-radius: 6px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 6px;
    position: relative;
}

.income-bar-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ===== WIZARD ===== */
.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
}

.wizard-back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--surface-raised);
    font-size: 1.1rem;
    color: var(--ink2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.wizard-back-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.wizard-step-counter {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: var(--ink3);
    letter-spacing: 0.05em;
}

.wizard-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem calc(1rem + env(safe-area-inset-bottom, 0px));
    background: rgba(240, 235, 227, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    max-width: 720px;
    margin: 0 auto;
    z-index: 20;
}

/* ===== TOGGLE ===== */
.toggle-wrap { display: flex; align-items: center; gap: 0.75rem; }

.toggle {
    width: 48px;
    height: 28px;
    border-radius: 14px;
    background: #D1D5DB;
    position: relative;
    cursor: pointer;
    transition: background 0.25s ease;
}

.toggle.active { background: var(--accent); }

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle.active::after { transform: translateX(20px); }

/* ===== DISCLAIMER FOOTER ===== */
.disclaimer {
    text-align: center;
    font-size: 0.7rem;
    color: var(--ink3);
    padding: 2.5rem 1.5rem 2rem;
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.6;
    border-top: 1px solid var(--border-color);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .container { padding: 1rem; }

    .app-header h1 { font-size: 1.4rem; }

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

    .live-strip {
        grid-template-columns: repeat(2, 1fr);
        font-size: 0.78rem;
    }

    .stepper span { font-size: 1.5rem; }

    .income-bar-label { width: 80px; font-size: 0.7rem; }
}

/* ===== ANIMATION DELAYS FOR STAGGER ===== */
.card:nth-child(1) { animation-delay: 0s; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.12s; }
.card:nth-child(4) { animation-delay: 0.18s; }

/* Wizard step content padding for fixed footer */
.wizard-pad-bottom {
    padding-bottom: 5.5rem;
}
