:root {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #263345;
    --bg-input: #334155;
    --border: #334155;
    --border-highlight: #475569;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --brand-primary: #10b981; /* Emerald */
    --brand-neg: #ef4444;     /* Red */
    --brand-glow: rgba(16, 185, 129, 0.15);
    --brand-target: #f59e0b;  /* Amber */
    --brand-target-glow: rgba(245, 158, 11, 0.15);
    
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    background-image: radial-gradient(circle at 50% 0%, #1e293b 0%, #0f172a 60%);
}

.app-container {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 0 2rem;
}

/* --- Header --- */
.header-area { 
    text-align: center; 
    margin-bottom: 0.75rem; 
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    position: relative;
}

.btn-action {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-action:hover {
    border-color: var(--border-highlight);
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #0f172a;
}
.btn-primary:hover {
    background: #34d399;
    border-color: #34d399;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.help-btn-circle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    transition: all 0.2s;
    opacity: 0.7;
}

.help-btn-circle:hover {
    color: var(--brand-primary);
    opacity: 1;
    transform: scale(1.1);
}

.status-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    opacity: 0;
    transition: opacity 0.3s;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    margin-left: 1rem;
}
.status-badge.visible { opacity: 1; }

.error-badge {
    font-size: 0.85rem;
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
    position: absolute;
    right: -180px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
}
.error-badge.visible { opacity: 1; }
.error-badge i { margin-right: 0.4rem; }

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--brand-primary);
    color: #0f172a;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 10px 30px -5px rgba(0,0,0,0.5);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100;
}
.toast.visible { transform: translateX(-50%) translateY(0); }

h1 { 
    font-size: 2.5rem; 
    font-weight: 800; 
    letter-spacing: -0.03em; 
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h1 span { 
    background: linear-gradient(to right, var(--brand-primary), #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.fire-icon {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 50%, #ffcc00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fireGlow 2s ease-in-out infinite alternate;
}

.oz-text {
    background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 50%, #93c5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.1em;
    margin-right: 0.3rem;
}

@keyframes fireGlow {
    0% { filter: drop-shadow(0 0 2px rgba(255, 107, 53, 0.5)); }
    100% { filter: drop-shadow(0 0 8px rgba(255, 204, 0, 0.8)); }
}

/* --- Phase Timeline --- */
.phase-timeline {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.timeline-header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .timeline-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .timeline-rates-group {
        flex-wrap: wrap;
    }
}

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

.timeline-age-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--bg-input);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
}

.timeline-age-group label {
    color: var(--text-muted);
}

.timeline-age-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.2rem 0.3rem;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    width: 3rem;
    text-align: center;
}

.timeline-age-input:focus {
    outline: none;
    border-bottom-color: var(--brand-primary);
}

.timeline-age-input::-webkit-inner-spin-button,
.timeline-age-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.timeline-rates-group {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.85rem;
}

.solve-fire-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--brand-primary) 0%, #059669 100%);
    border: none;
    border-radius: 20px;
    color: #0f172a;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.solve-fire-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

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

.solve-fire-btn.solving {
    opacity: 0.7;
    pointer-events: none;
}

.solve-fire-btn.solving i {
    animation: spin 1s linear infinite;
}

.solve-drawdown-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.solve-drawdown-btn:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

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

.timeline-rate-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-input);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
}

.timeline-rate-item label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.timeline-rate-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.2rem 0.3rem;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    width: 3.5rem;
    text-align: center;
}

.timeline-rate-input:focus {
    outline: none;
    border-bottom-color: var(--brand-primary);
}

.timeline-rate-item .rate-suffix {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.timeline-rate-item.return-rate {
    border-left: 3px solid #10b981;
}

.timeline-rate-item.inflation-rate {
    border-left: 3px solid #f59e0b;
}

.timeline-bar-container {
    position: relative;
    height: 140px;
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.timeline-point-labels {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    pointer-events: none;
    z-index: 15;
}

.timeline-point-labels.top { top: 0; height: 40px; align-items: flex-end; }
.timeline-point-labels.bottom { bottom: 0; height: 40px; align-items: flex-start; }

.timeline-point-label {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.1s ease-out;
}

.point-date {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap; /* Force one line */
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.point-age {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap; /* Force one line */
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.point-tick {
    width: 2px;
    height: 12px;
    background: var(--text-muted);
    opacity: 0.4;
}

.timeline-bar {
    position: relative;
    height: 48px;
    background: var(--bg-input);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
    border: 1px solid var(--border);
}

.timeline-phase {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.timeline-phase.accumulation { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.timeline-phase.bridge { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
.timeline-phase.gogo { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.timeline-phase.slowgo { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }

.timeline-marker {
    position: absolute;
    top: 50%;
    width: 20px;
    height: 48px;
    cursor: ew-resize;
    z-index: 10;
    transform: translate(-50%, -50%);
}

.timeline-marker-line {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 48px;
    background: rgba(255,255,255,0.4);
    transform: translateX(-50%);
    pointer-events: none;
}

.timeline-marker-handle {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 32px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.timeline-marker:hover .timeline-marker-handle,
.timeline-marker.dragging .timeline-marker-handle {
    background: var(--brand-primary);
    height: 40px;
    width: 18px;
    box-shadow: 0 0 15px var(--brand-glow);
}

.timeline-marker-handle i {
    font-size: 10px;
    color: var(--bg-body);
    opacity: 0.6;
}

/* Date picker popup */
.timeline-date-picker {
    position: absolute;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 100;
    display: none;
}

.timeline-date-picker.visible {
    display: block;
}

.timeline-date-picker input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.timeline-date-picker input:focus {
    outline: none;
    border-color: var(--brand-primary);
}

/* Hide date inputs in phase columns - controlled via timeline */
.phase-solver-input-group:has(input[type="date"]) {
    display: none;
}

/* --- Phase Solver Columns --- */
.phase-solvers-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    width: 100%;
    margin-bottom: 2rem;
}

.phase-solver-column .split-inputs {
    gap: 0.75rem;
}

.phase-solver-column {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 4px 20px -2px rgba(0,0,0,0.2);
}

.phase-solver-column:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px -5px rgba(0,0,0,0.4);
    border-color: var(--border-highlight);
}

.phase-solver-column.has-negative-balance {
    border-color: rgba(239, 68, 68, 0.5) !important;
    background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(239, 68, 68, 0.05) 100%);
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2), 0 4px 20px -2px rgba(0,0,0,0.2);
}

.phase-solver-column.has-negative-balance:hover {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.15), 0 12px 30px -5px rgba(0,0,0,0.4);
}

.phase-solver-column.has-negative-balance .phase-solver-title {
    color: #ef4444;
}

.phase-solver-column.has-negative-balance .phase-solver-badge {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.phase-solver-column.accumulation { border-top: 3px solid #10b981; }
.phase-solver-column.bridge { border-top: 3px solid #3b82f6; }
.phase-solver-column.gogo { border-top: 3px solid #f59e0b; }
.phase-solver-column.slowgo { border-top: 3px solid #8b5cf6; }

.phase-solver-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.phase-solver-title {
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.phase-solver-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
}

.phase-solver-badge.accumulation { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.phase-solver-badge.bridge { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.phase-solver-badge.gogo { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.phase-solver-badge.slowgo { background: rgba(139, 92, 246, 0.2); color: #8b5cf6; }

.phase-solver-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.phase-solver-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.tooltip-icon {
    font-size: 0.7rem;
    color: var(--text-muted);
    cursor: help;
    opacity: 0.6;
    transition: opacity 0.2s, color 0.2s;
    position: relative;
}

.tooltip-icon:hover {
    opacity: 1;
    color: var(--brand-primary);
}

.tooltip-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.75rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateX(-50%) translateY(-4px);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    max-width: 320px;
    min-width: 200px;
    white-space: normal;
    text-align: left;
    line-height: 1.5;
    font-weight: 400;
    word-wrap: break-word;
    text-transform: none;
}

.tooltip-icon:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-8px);
}

.timeline-rate-item label,
.timeline-age-group label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.phase-solver-input {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.phase-solver-input:focus {
    outline: none;
    border-color: var(--brand-primary);
}

.phase-solver-input.is-negative {
    color: #ef4444 !important;
}

.phase-solver-input.is-positive {
    color: #10b981 !important;
}

.phase-solver-input[readonly] {
    background: var(--bg-surface);
    opacity: 0.7;
    cursor: not-allowed;
}

@media (max-width: 1400px) {
    .phase-solvers-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .phase-solvers-container {
        grid-template-columns: 1fr;
    }
    .app-container {
        padding: 0 1rem;
    }
}

/* --- Grid System --- */
.row-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    width: 100%;
}

/* --- Cards --- */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card:hover {
    border-color: var(--border-highlight);
    background-color: var(--bg-surface-hover);
}

/* Target State */
.card.is-target {
    border-color: var(--brand-target);
    background: linear-gradient(165deg, rgba(245, 158, 11, 0.05) 0%, var(--bg-surface) 100%);
    box-shadow: 0 0 0 1px var(--brand-target), 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.label {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card.is-target .label { color: var(--brand-target); text-shadow: 0 0 10px var(--brand-target-glow); }

/* Lock Button */
.lock-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.lock-btn:hover { border-color: var(--text-secondary); color: var(--text-primary); background: var(--bg-input); }

.card.is-target .lock-btn {
    background-color: var(--brand-target);
    border-color: var(--brand-target);
    color: #0f172a;
    pointer-events: none;
    box-shadow: 0 0 10px var(--brand-target-glow);
}

/* Inputs */
.input-group { display: flex; align-items: baseline; width: 100%; position: relative; }

input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.75rem;
    font-weight: 600;
    padding: 0.25rem 0;
    outline: none;
    font-family: var(--font-mono);
    letter-spacing: -0.03em;
    transition: color 0.2s;
}

input:focus { color: #fff; }
input[data-neg="true"] { color: var(--brand-neg); }
.card.is-target input { color: var(--brand-target); cursor: default; }
.unit { font-size: 0.9rem; color: var(--text-muted); margin-left: 0.5rem; white-space: nowrap; font-weight: 500; }

/* Split Inputs (Monthly/Yearly) */
.split-inputs {
    display: flex;
    gap: 1.5rem;
    align-items: baseline;
}
.split-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.split-col .input-group {
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}
.split-col:focus-within .input-group {
    border-bottom-color: var(--brand-primary);
}
.sub-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Real Rate Display */
.real-rate-display {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.real-rate-val {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--brand-primary);
    font-size: 1rem;
}

/* Loading indicator */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Date Inputs */
.date-input-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.date-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    width: 140px;
}

.date-input:focus {
    outline: none;
    border-color: var(--brand-primary);
}

/* --- Chart Area --- */
.chart-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    min-height: 450px;
    display: flex;
    flex-direction: column;
}

.projection-chart-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 400px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.chart-viz {
    flex: 1;
    display: grid;
    grid-template-columns: 50px 1fr;
    grid-template-rows: 1fr 30px;
}

.y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: right;
    padding-right: 15px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.x-axis {
    grid-column: 2;
    display: flex;
    justify-content: space-between;
    padding-top: 15px;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-left: 10px;
    padding-right: 10px;
    font-family: var(--font-mono);
}

#projection-x-axis {
    position: relative;
    display: block;
    height: 30px;
}

.plot-area {
    position: relative;
    border-left: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 10px;
    overflow: visible;
}

#projection-plot-area {
    min-height: 300px;
}

.grid-line {
    position: absolute;
    left: 0; right: 0;
    border-top: 1px dashed var(--border);
    opacity: 0.3;
    pointer-events: none;
}

/* Bars */
.bar-wrapper {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.bar {
    width: 70%;
    background: linear-gradient(180deg, #34d399 0%, var(--brand-primary) 100%);
    opacity: 0.7;
    border-radius: 4px 4px 0 0;
    transition: height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
}

.bar.is-lump { background: linear-gradient(180deg, var(--brand-target) 0%, var(--brand-primary) 100%); }

.bar-wrapper:hover .bar { opacity: 1; box-shadow: 0 0 20px var(--brand-glow); width: 90%; }

/* Tooltip */
.tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: #0f172a;
    border: 1px solid var(--border-highlight);
    padding: 1rem;
    border-radius: 12px;
    min-width: 200px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
    z-index: 20;
    box-shadow: 0 10px 30px -5px rgba(0,0,0,0.6);
}
.bar-wrapper:hover .tooltip { opacity: 1; }
.tooltip-row { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 4px; color: var(--text-secondary); }
.tooltip-val { font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); }

/* --- Table Styles --- */
.table-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.table-container {
    margin-top: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    white-space: nowrap;
}

.data-table th {
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
    padding: 14px 20px;
    position: sticky;
    top: 0;
    z-index: 5;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.data-table th:first-child { text-align: left; }

.data-table td {
    padding: 12px 20px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: var(--font-mono);
}
.data-table td:first-child { text-align: left; color: var(--text-primary); font-family: var(--font-sans); font-weight: 600; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background-color: rgba(255,255,255,0.03); color: var(--text-primary); }

.phase-marker-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    border-left: 2px dashed;
    z-index: 5;
    pointer-events: none;
}

.text-neg { color: var(--brand-neg) !important; }
.text-pos { color: var(--brand-primary) !important; }
.text-target { color: var(--brand-target) !important; }

/* --- Intro Section --- */
.intro-section {
    margin-bottom: 2rem;
}

.intro-section.hidden {
    display: none;
}

.intro-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
    border: 1px solid var(--brand-glow);
    border-radius: 16px;
    padding: 2rem;
    position: relative;
}

.intro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.intro-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.intro-header h2 i {
    color: var(--brand-primary);
}

.intro-close {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.intro-close:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-highlight);
    color: var(--text-primary);
}

.intro-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.intro-lead {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.intro-lead strong {
    color: var(--text-primary);
}

.intro-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.intro-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-number {
    width: 36px;
    height: 36px;
    background: var(--brand-primary);
    color: var(--bg-body);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

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

.step-content h3 i {
    color: var(--brand-primary);
    font-size: 0.9rem;
}

.step-content p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.intro-tip {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.intro-tip i {
    color: var(--brand-target);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.intro-tip strong {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .intro-card {
        padding: 1.5rem;
    }
    
    .intro-header h2 {
        font-size: 1.25rem;
    }
    
    .intro-steps {
        grid-template-columns: 1fr;
    }
    
    .intro-lead {
        font-size: 1rem;
    }
}

/* --- Guide Section --- */
.guide-section {
    margin-top: 3rem;
    border-top: 1px solid var(--border);
    padding-top: 3rem;
}

.guide-header {
    margin-bottom: 2rem;
    max-width: 700px;
}

.guide-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.guide-header p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
}

.concept-box {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid var(--brand-glow);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.concept-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-surface);
    border: 1px solid var(--brand-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-primary);
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* --- FIRE Grid --- */
.fire-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.fire-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.fire-card h3 { color: var(--text-primary); font-size: 1.1rem; display: flex; align-items: center; gap: 0.5rem; }
.fire-card p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.5; flex: 1; }

.fire-recipe {
    background: var(--bg-body);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border);
}

.recipe-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.5rem; font-weight: 700; }

.recipe-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}
.recipe-row span:last-child { font-family: var(--font-mono); color: var(--text-primary); }
.recipe-row.highlight span:last-child { color: var(--brand-target); font-weight: 700; }

/* Glossary */
.glossary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.glossary-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.glossary-term {
    color: var(--brand-primary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: block;
}

.glossary-def {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* --- Technical Details --- */
.tech-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
}

.tech-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tech-card.full-width {
    grid-column: 1 / -1;
}

.tech-card h3 {
    font-size: 1.1rem;
    color: var(--brand-primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
}

.tech-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.math-block {
    background: var(--bg-body);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    font-family: var(--font-mono);
    color: var(--text-primary);
    border: 1px solid var(--border);
    margin: 0.5rem 0;
}

.math-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tech-list {
    padding-left: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tech-list code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--brand-primary);
}

/* Flow Diagram */
.flow-diagram {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-body);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.flow-box {
    flex: 1;
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
}

.flow-box span {
    font-weight: 400;
    font-size: 0.75rem;
    opacity: 0.8;
}

.flow-box.build { background: #10b981; }
.flow-box.bridge { background: #3b82f6; }
.flow-box.active { background: #f59e0b; }
.flow-box.slow { background: #8b5cf6; }

/* Withdrawal Diagram Colors */
.flow-diagram.withdrawal .flow-box.super { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }
.flow-diagram.withdrawal .flow-box.invest { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.flow-diagram.withdrawal .flow-box.negative { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }

.flow-arrow {
    color: var(--text-muted);
    font-size: 1.2rem;
}

@media (max-width: 900px) {
    .tech-grid { grid-template-columns: 1fr; }
    .flow-diagram { flex-direction: column; }
    .flow-arrow { transform: rotate(90deg); }
}

@media (max-width: 768px) {
    .header-area h1 { font-size: 2rem; }
    .chart-viz { grid-template-columns: 40px 1fr; }
    .tooltip { display: none; }
    .split-inputs { flex-direction: column; gap: 0.5rem; }
    .data-table th, .data-table td { padding: 10px 12px; font-size: 0.8rem; }
    .concept-box { flex-direction: column; gap: 1rem; }
    
    .header-actions { flex-direction: column; }
    .status-badge, .error-badge { 
        position: static; 
        transform: none; 
        margin-left: 0; 
        margin-top: 0.5rem; 
    }
}

