/* ========================================
   RETIREMENT PLANNER CSS
   Retirement Planning Calculator Styles
   Follows In-Hand design system
   ======================================== */

/* ========================================
   COLOR HIERARCHY (Dignified & Consistent)
   ========================================
   
   --theme-text-primary:    Main content, editable values, user input text
   --theme-text-secondary:  Field labels, section headers, descriptions  
   --theme-text-muted:      Helper text, placeholders, subtle UI elements, read-only hints
   --theme-primary:         Important calculated values, highlights, CTAs
   
   USAGE GUIDE:
   - Labels (EPF, NPS, etc.): --theme-text-secondary
   - Editable inputs: --theme-text-primary
   - Read-only displays: --theme-text-muted or --theme-text-secondary
   - Important values: --theme-primary
   - Subtle UI (arrows, icons): --theme-text-muted
   ======================================== */

/* ============= LAYOUT ============= */

.panel-assumptions-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px; /* Spacious gap for readability */
    padding: 10px 20px;
    margin: 0 0 0 0; /* Flush with top and bottom */
    width: 100%;
    max-width: none;
    background: var(--theme-bg-tertiary); /* Subtle contrast background */
    border-bottom: 1px solid var(--theme-border); /* Divider line only */
    border-radius: 0; /* No rounded corners */
    box-shadow: none; /* Flat, structural look */
    box-sizing: border-box;
}

.panel-assumption-item {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

.panel-assumption-item:hover {
    opacity: 1;
}

.panel-assumption-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--theme-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: default;
}

.assumption-input-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.03); /* Subtle input background */
    transition: all 0.2s ease;
}

.assumption-input-wrapper:focus-within {
    background: var(--theme-bg-primary);
    box-shadow: 0 0 0 2px var(--theme-primary);
}

.assumption-input {
    font-size: 13px;
    font-weight: 600;
    color: var(--theme-text-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    background: transparent;
    border: none;
    width: 36px;
    padding: 0;
    text-align: right;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Dark theme: Match wrapper background to panel, make input slightly lighter */
[data-theme="dark"] .assumption-input-wrapper {
    background: var(--theme-bg-tertiary); /* Same as panel-assumptions-bar */
}

[data-theme="dark"] .assumption-input {
    background: rgba(255, 255, 255, 0.05); /* Slightly lighter than wrapper */
    border-radius: 4px;
    padding: 2px 4px;
}

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

.assumption-input:focus {
    outline: none;
}

.assumption-symbol {
    font-size: 13px;
    font-weight: 600;
    color: var(--theme-text-muted);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    margin-left: 2px;
}

.panel-assumption-divider {
    width: 1px;
    height: 16px;
    background: var(--theme-border);
    opacity: 0.5;
}

@media (max-width: 768px) {
    .panel-assumptions-bar {
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 16px;
        justify-content: space-around;
    }
    
    .panel-assumption-item {
        gap: 6px;
    }
    
    .panel-assumption-label {
        font-size: 10px;
    }
    
    .assumption-input-wrapper {
        padding: 2px 4px;
    }
    
    .assumption-input {
        font-size: 12px;
        width: 32px;
    }
    
    .panel-assumption-divider {
        display: none; /* Hide dividers on mobile */
    }
}

/* Retirement Planner now uses standard header styling from new-style-optimized.css */
/* FAQ link styling in header-controls */
.header-controls .header-link {
    color: var(--color-text-primary, var(--theme-text-primary));
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.3s ease;
    margin-right: 16px;
}

.header-controls .header-link:hover {
    color: var(--color-accent, var(--theme-primary));
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

.retirement-container {
    display: grid;
    grid-template-columns: 480px 1fr;
    gap: 0;
    height: calc(100vh - 60px);
    overflow: hidden;
    background: var(--theme-bg-primary);
    margin-top: 0;
}

/* Left Sidebar: Inputs */
.retirement-sidebar {
    background: var(--theme-bg-secondary);
    border-right: 1px solid var(--theme-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--theme-border);
    background: var(--theme-bg-primary);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.header-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-shrink: 0;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
}

.logo-link {
    text-decoration: none;
    color: var(--theme-text-primary);
    font-weight: 600;
    font-size: 18px;
    transition: color 0.2s ease;
}

.logo-link:hover {
    color: var(--theme-primary);
}

.logo-text {
    font-weight: 700;
    background: linear-gradient(135deg, var(--theme-primary), #007aff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.separator {
    color: var(--theme-text-muted);
    font-weight: 300;
}

.page-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--theme-text-secondary);
    margin: 0;
}

.back-to-calculator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    color: var(--theme-text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.back-to-calculator:hover {
    background: var(--theme-bg-tertiary);
    border-color: var(--theme-border-hover);
    color: var(--theme-text-primary);
}

/* Theme toggle button in header */
.theme-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 50%;
    color: var(--theme-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--theme-bg-tertiary);
    border-color: var(--theme-primary);
    transform: scale(1.05);
}

.theme-toggle .theme-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}


.sidebar-content {
    padding: 12px;
    flex: 1;
}

/* Right Panel: Results */
.retirement-results {
    background: var(--gradient-main, radial-gradient(ellipse at center, #1a1a1a 0%, #000 70%));
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.results-container {
    padding: 0 0 40px 0;
    width: 100%;
    margin: 0;
    position: relative;
    z-index: 2;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#resultsState {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    min-height: 0;
}

/* Floating particles background (like main calculator) */
.floating-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}


/* ============= CONSTRAINT SECTION ============= */

.constraint-section {
    margin-bottom: 20px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    transition: none;
}

.constraint-section:hover {
    border-color: transparent;
    box-shadow: none;
}

/* ============= STRATEGY PRESETS ============= */
.strategy-card {
    margin: 6px 0 14px;
    padding: 12px 14px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.72));
    border: 1px solid rgba(17, 17, 17, 0.08);
    border-radius: 14px;
    box-shadow:
        0 12px 30px rgba(17, 17, 17, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

[data-theme="dark"] .strategy-card {
    background: linear-gradient(145deg, rgba(28, 28, 30, 0.9), rgba(20, 20, 22, 0.85));
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.strategy-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.strategy-eyebrow {
    margin: 0 0 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    font-weight: 700;
    color: var(--theme-text-muted);
    transition: all 0.3s ease-in-out;
}

.strategy-eyebrow.low-usage-glow {
    animation: strategyEyebrowGlow 2s ease-in-out infinite;
    color: var(--theme-primary);
}

@keyframes strategyEyebrowGlow {
    0%, 100% {
        text-shadow: 0 0 5px rgba(77, 171, 247, 0.3);
        opacity: 1;
    }
    50% {
        text-shadow: 0 0 15px rgba(77, 171, 247, 0.7), 0 0 25px rgba(77, 171, 247, 0.4);
        opacity: 0.9;
    }
}

.strategy-title {
    margin: 0;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--theme-text-primary);
}

.strategy-pill-group {
    display: flex;
    align-items: stretch;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-top: 2px;
    padding-bottom: 2px;
}

.strategy-hint {
    margin: 8px 0 0 0;
    font-size: 11px;
    color: var(--theme-text-muted);
    opacity: 0.6;
    font-weight: 400;
    letter-spacing: -0.01em;
    text-align: center;
    transition: opacity 0.3s ease;
}

.strategy-pill {
    position: relative;
    text-align: center;
    padding: 8px 10px;
    border-radius: 9px;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.8), rgba(245, 245, 247, 0.7));
    border: 1px solid var(--theme-border);
    color: var(--theme-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    overflow: hidden;
    min-width: 0;
    flex: 1 1 0;
    white-space: nowrap;
}

[data-theme="dark"] .strategy-pill {
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}

.strategy-pill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
    opacity: 0.9;
    pointer-events: none;
}

[data-theme="dark"] .strategy-pill::after {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
}

.pill-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.01em;
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pill-info {
    font-size: 10px;
    font-weight: 700;
    color: var(--theme-text-muted);
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid var(--theme-border);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    aspect-ratio: 1 / 1;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    margin-left: 6px;
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

[data-theme="dark"] .pill-info {
    background: rgba(255, 255, 255, 0.06);
}

.pill-tooltip {
    position: absolute;
    left: 50%;
    bottom: 110%;
    transform: translateX(-50%) translateY(6px);
    background: rgba(17, 17, 17, 0.92);
    color: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.35;
    min-width: 160px;
    max-width: 240px;
    text-align: center;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 10;
}

.pill-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(17, 17, 17, 0.92) transparent transparent transparent;
}

.strategy-pill:hover .pill-tooltip,
.strategy-pill.show-tooltip .pill-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.strategy-pill:hover .pill-info,
.strategy-pill.show-tooltip .pill-info {
    color: var(--theme-primary);
    border-color: var(--theme-primary);
}

@media (max-width: 768px) {
    .pill-info {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    .pill-info {
        display: inline-flex;
    }
}

.strategy-pill:hover {
    transform: translateY(-1px);
    border-color: var(--theme-border-hover, var(--theme-primary));
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.1);
}

.strategy-pill:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
}

.strategy-pill.active {
    border-color: var(--theme-primary);
    box-shadow:
        0 18px 36px rgba(77, 171, 247, 0.18),
        0 0 0 1px rgba(77, 171, 247, 0.18);
    background: linear-gradient(135deg, rgba(77, 171, 247, 0.12), rgba(255, 255, 255, 0.88));
}

[data-theme="dark"] .strategy-pill.active {
    box-shadow:
        0 20px 42px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(77, 171, 247, 0.35);
    background: linear-gradient(135deg, rgba(77, 171, 247, 0.14), rgba(26, 26, 28, 0.92));
}

.constraint-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--theme-border);
}

.constraint-label-with-amount {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.constraint-label-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--theme-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: all 0.3s ease-in-out;
}

.constraint-label-text.needs-input {
    animation: labelGlow 2s ease-in-out infinite;
    color: var(--theme-primary);
}

.constraint-value-inline {
    font-size: 16px;
    font-weight: 600;
    color: var(--theme-text-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    letter-spacing: -0.02em;
    cursor: pointer;
    position: relative;
    padding: 4px 8px;
    background: transparent;
    border-radius: 6px;
    min-width: 80px;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    border: 1px solid transparent;
    box-shadow: none;
    margin-right: 4px;
}

.constraint-value-inline:hover {
    background: var(--theme-bg-secondary);
    border-color: var(--theme-border);
    transform: none;
    box-shadow: none;
}

.constraint-value-inline:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

@keyframes subtleFlash {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.98);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.strategy-pill.allocating {
    animation: subtleFlash 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.constraint-value-input {
    font-size: 16px;
    font-weight: 600;
    color: var(--theme-text-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    letter-spacing: -0.02em;
    background: transparent;
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: 4px 8px;
    width: 100px;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.constraint-value-input:focus {
    outline: none;
    background: var(--theme-bg-secondary);
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.1);
}

.constraint-value-input.needs-input {
    animation: inputBorderGlow 2s ease-in-out infinite;
    border-color: var(--theme-primary);
}

@keyframes labelGlow {
    0%, 100% {
        text-shadow: 0 0 5px rgba(77, 171, 247, 0.3);
        opacity: 1;
    }
    50% {
        text-shadow: 0 0 15px rgba(77, 171, 247, 0.7), 0 0 25px rgba(77, 171, 247, 0.4);
        opacity: 0.9;
    }
}

@keyframes inputBorderGlow {
    0%, 100% {
        box-shadow: 0 0 0 1px rgba(77, 171, 247, 0.3), 0 0 5px rgba(77, 171, 247, 0.2);
        border-color: var(--theme-primary);
    }
    50% {
        box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.6), 0 0 15px rgba(77, 171, 247, 0.5);
        border-color: var(--theme-primary);
    }
}

.constraint-value-input::placeholder {
    color: var(--theme-text-muted);
    font-weight: 400;
    opacity: 0.5;
}

.period-toggle {
    display: inline-flex;
    background: var(--theme-bg-tertiary);
    border-radius: 8px;
    padding: 3px;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.period-toggle input[type="radio"] {
    display: none;
}

.period-toggle::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    bottom: 3px;
    width: calc(50% - 3px);
    background: var(--theme-bg-primary);
    border-radius: 6px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(0, 0, 0, 0.05);
    z-index: 1;
}

/* Active state for yearly toggle (moves the pill) */
.period-toggle:has(#yearlyToggle:checked)::before,
.period-toggle:has(#expensesYearlyToggle:checked)::before,
.period-toggle:has(input[type="radio"][value="yearly"]:checked)::before {
    transform: translateX(100%);
}

.period-toggle label {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    color: var(--theme-text-secondary);
    transition: color 0.2s ease;
    z-index: 2;
    position: relative;
    user-select: none;
    text-align: center;
    min-width: 28px;
}

.period-toggle input[type="radio"]:checked + label {
    color: var(--theme-text-primary);
}

.constraint-usage {
    margin-top: 12px;
}

.usage-text-inline {
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    width: 100%;
}

.usage-label {
    color: var(--theme-text-muted);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: color 0.3s ease;
}

.usage-label.status-safe {
    color: #34C759; /* Green - getting started */
}

.usage-label.status-medium {
    color: #007AFF; /* Blue - good progress */
}

.usage-label.status-warning {
    color: #FF9500; /* Orange - getting full */
}

.usage-label.status-danger {
    color: #FF3B30; /* Red - over budget */
}

.usage-values-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.usage-amount {
    font-weight: 600;
    color: var(--theme-text-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
}

.usage-separator {
    color: var(--theme-text-muted);
    opacity: 0.4;
    font-size: 12px;
    margin: 0 2px;
}

.usage-total {
    color: var(--theme-text-secondary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
}

.usage-percentage {
    color: var(--theme-text-muted);
    font-weight: 500;
    font-size: 11px;
    margin-left: 4px;
}

.usage-bar-bg {
    height: 4px;
    background: var(--theme-bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    box-shadow: none;
}

.usage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #34C759, #30d158);
    border-radius: 2px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
}

.usage-bar-fill.warning {
    background: linear-gradient(90deg, #FF9500, #ff9f0a);
    box-shadow: none;
}

.usage-bar-fill.danger {
    background: linear-gradient(90deg, #FF3B30, #ff453a);
    box-shadow: none;
}

.usage-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--theme-text-secondary);
    margin-top: 6px;
}

.constraint-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(250, 82, 82, 0.1);
    border: 1px solid rgba(250, 82, 82, 0.3);
    border-radius: 6px;
    color: #e03131;
    font-size: 12px;
    font-weight: 600;
}

.constraint-warning svg {
    flex-shrink: 0;
}

/* Clickable breakdown sections */
.constraint-invested [onclick] {
    border-radius: 6px;
    padding: 4px 8px;
    margin: -4px -8px;
    transition: background-color 0.2s ease;
}

.constraint-invested [onclick]:hover {
    background-color: var(--theme-bg-tertiary);
}

.constraint-invested [onclick]:active {
    background-color: var(--theme-bg-quaternary, rgba(0, 0, 0, 0.05));
}

/* Force breakdown sections to be hidden by default */
#retiralsBreakdown,
#investmentsBreakdown {
    display: none !important;
}

/* Override when explicitly shown via JavaScript */
#retiralsBreakdown.show-breakdown,
#investmentsBreakdown.show-breakdown {
    display: block !important;
}


/* ============= INPUT SECTIONS ============= */

/* Smooth focus-visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

button:focus-visible,
input:focus-visible {
    outline-offset: 3px;
}

.input-section {
    margin-bottom: 12px;
}

/* Reduce space between Net Worth and Monthly Investments */
#net-worth-section {
    margin-bottom: 4px;
}

/* Hide Calculation Assumptions on desktop (shown in results panel instead) */
@media (min-width: 769px) {
    .input-section.assumptions-section {
        display: none !important;
    }
}

/* Age Slider - Compact Single Line */
.age-slider-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 14px 0;
    border-bottom: 1px solid var(--theme-border);
    margin-bottom: 16px;
}

.age-prefix,
.age-suffix {
    font-size: 14px;
    font-weight: 400;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    letter-spacing: -0.01em;
}

.age-suffix {
    margin-left: -5px; /* Pull comma closer to age number */
}

/* Light theme colors */
.age-prefix,
.age-suffix {
    color: #64748b; /* Professional slate-500 */
}

.age-value-compact {
    color: #0f172a; /* Slate-900 for strong contrast */
}

/* Dark theme colors */
[data-theme="dark"] .age-prefix,
[data-theme="dark"] .age-suffix {
    color: #94a3b8; /* Lighter slate-400 for dark mode */
}

[data-theme="dark"] .age-value-compact {
    color: #f1f5f9; /* Slate-100 for readability */
}

.age-value-compact {
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    letter-spacing: -0.02em;
    min-width: 28px;
    text-align: center;
    cursor: text;
    transition: all 0.2s ease;
    outline: none;
    border-radius: 6px;
    padding: 4px 6px;
    flex-shrink: 0;
}

.age-value-compact.editable-age:hover {
    background: var(--theme-bg-tertiary);
}

.age-value-compact.editable-age:focus,
.age-value-compact.editable-age.editing {
    color: var(--theme-text-primary);
    background: var(--theme-input-bg);
    border: 1px solid var(--theme-input-border);
    box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.1);
}

/* Inline Dual Range Slider */
.dual-slider-inline {
    position: relative;
    height: 24px;
    flex: 1;
    min-width: 120px;
}

.slider-track {
    position: absolute;
    width: 100%;
    height: 3px;
    background: var(--theme-bg-tertiary);
    border-radius: 1.5px;
    top: 50%;
    transform: translateY(-50%);
}

.slider-range {
    position: absolute;
    height: 3px;
    background: linear-gradient(90deg, var(--theme-primary), #007aff);
    border-radius: 1.5px;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 6px rgba(77, 171, 247, 0.15);
}

.slider {
    position: absolute;
    width: 100%;
    height: 24px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    top: 0;
    left: 0;
    pointer-events: none;
    margin: 0;
    padding: 0;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: all;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--theme-primary);
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 0 0 rgba(77, 171, 247, 0);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(77, 171, 247, 0.1);
}

.slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 6px rgba(77, 171, 247, 0.15);
}

.slider::-moz-range-thumb {
    pointer-events: all;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--theme-primary);
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 0 0 rgba(77, 171, 247, 0);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(77, 171, 247, 0.1);
}

.slider::-moz-range-thumb:active {
    cursor: grabbing;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 6px rgba(77, 171, 247, 0.15);
}

/* Mobile responsive for age slider */
@media (max-width: 768px) {
    .age-slider-compact {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 0;
    }

    .age-prefix {
        font-size: 13px;
    }

    .age-suffix {
        font-size: 13px;
        width: 100%;
        text-align: center;
        margin-top: -4px;
    }

    .age-value-compact {
        font-size: 18px;
    }

    .dual-slider-inline {
        order: 10;
        width: 100%;
        min-width: unset;
    }
}

/* Main section headers (Age Details, Total Monthly Savings, Investment Breakdown) */
.section-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-text-primary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header .help-icon {
    margin-left: 0;
}

/* Legacy section title (keep for other sections that might use it) */
.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-text-primary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-description {
    font-size: 13px;
    color: var(--theme-text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.input-group {
    margin-bottom: 8px;
    padding: 4px 0;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-group:hover {
    background: rgba(77, 171, 247, 0.02);
    padding-left: 8px;
    padding-right: 8px;
    margin-left: -8px;
    margin-right: -8px;
}

/* Desktop: Horizontal layout for space efficiency */
@media (min-width: 769px) {
    .investment-breakdown-content .input-group {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
        align-items: center;
        margin-bottom: 4px;
    }

    .input-label {
        margin-bottom: 0;
        font-size: 13px;
    }
}

.input-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--theme-text-secondary);
    margin-bottom: 8px;
    transition: color 0.2s ease;
    cursor: default;
}

.input-group:hover .input-label {
    color: var(--theme-text-primary);
}

.input-hint {
    font-size: 11px;
    color: var(--theme-text-muted);
    margin-top: 6px;
    line-height: 1.4;
}

/* Net Worth Section */
.net-worth-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
}

.net-worth-mode-toggle {
    margin-left: auto;
    display: none;
}

.net-worth-mode-toggle label {
    font-size: 11px;
    font-weight: 600;
    padding: 6px 12px;
}

.net-worth-mode-toggle input:checked + label {
    font-weight: 700;
}

.net-worth-header-hint {
    font-size: 11px;
    color: var(--theme-text-muted);
    font-weight: 400;
    font-style: italic;
    margin-left: auto;
}

.net-worth-header.expanded .net-worth-mode-toggle {
    display: inline-flex;
}

.net-worth-header.expanded .net-worth-header-hint {
    display: none;
}

.net-worth-group {
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.net-worth-group:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--theme-border-hover);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.net-worth-group .group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--theme-text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.8px;
    opacity: 0.8;
}

.net-worth-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 10px;
    align-items: center;
    padding: 4px 0;
    transition: all 0.2s ease;
}

.net-worth-row:hover {
    transform: translateX(2px);
}

.net-worth-row-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--theme-text-primary);
    transition: color 0.2s ease;
}

.net-worth-row:hover .net-worth-row-label {
    color: var(--theme-primary);
}

.net-worth-row-inputs {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

.net-worth-row.liability .net-worth-row-label {
    color: #ff6b6b;
}

.net-worth-row.liability:hover .net-worth-row-label {
    color: #ff5252;
}

.net-worth-row.liability .rate-input {
    color: #ff5f5f;
}

.input-with-prefix.compact {
    flex: 0 0 75px;
    position: relative;
}

.input-with-prefix.compact .input-field {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 6px 8px 6px 20px;
    font-size: 11px;
}

.input-with-prefix.compact .input-prefix {
    left: 8px;
    font-size: 11px;
}

.input-with-prefix.compact .input-field:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.1);
}

.rate-input-wrapper.compact {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: transparent;
    border-radius: 6px;
    padding: 2px 4px;
    transition: all 0.2s ease;
}

.rate-input-wrapper.compact:hover {
    background: transparent;
}

.rate-input-wrapper.compact:focus-within {
    background: var(--theme-bg-tertiary);
}

.net-worth-detailed .rate-input {
    width: 32px;
    padding: 2px 1px;
    font-size: 11px;
    background: transparent;
    border: none;
    text-align: right;
}

.net-worth-detailed .rate-input:focus {
    background: transparent;
    outline: none;
}

.net-worth-display {
    margin-top: 12px;
    padding: 16px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.net-worth-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--theme-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.net-worth-value {
    font-size: 32px;
    font-weight: 100;
    color: var(--theme-primary);
    margin-bottom: 6px;
    line-height: 1;
    letter-spacing: -0.02em;
}

.net-worth-note {
    font-size: 11px;
    color: var(--theme-text-muted);
}

.net-worth-detailed {
    margin-top: 8px;
}

@media (max-width: 768px) {
    .net-worth-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .net-worth-row-inputs {
        flex-wrap: wrap;
    }
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--theme-bg-tertiary);
    color: var(--theme-text-secondary);
    font-size: 11px;
    cursor: help;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.help-icon:hover {
    background: var(--theme-primary);
    color: white;
    transform: scale(1.15) rotate(15deg);
    box-shadow: 0 2px 8px rgba(77, 171, 247, 0.3);
}

.help-icon:active {
    transform: scale(1.05);
}

.rate-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--theme-bg-tertiary);
    color: var(--theme-text-secondary);
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    margin-left: 6px;
}

.input-field {
    width: 100%;
    padding: 12px 14px;
    background: var(--theme-input-bg);
    border: 1px solid var(--theme-input-border);
    border-radius: 8px;
    color: var(--theme-text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}

/* Desktop: Smaller font for more compact look */
@media (min-width: 769px) {
    .input-field {
        font-size: 12px;
        padding: 7px 10px;
    }

    .input-label {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .input-hint {
        font-size: 10px;
        margin-top: 4px;
    }
}

.input-field:focus {
    outline: none;
    border-color: var(--theme-input-focus);
    box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.1);
    transform: translateY(-1px);
}

.input-field:hover:not(:focus) {
    border-color: var(--theme-border-hover);
    background: var(--theme-bg-secondary);
}

.input-field:active {
    transform: scale(0.995);
}

.input-with-prefix {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix {
    position: absolute;
    left: 10px;
    color: var(--theme-text-secondary);
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 1;
}

.input-with-prefix:focus-within .input-prefix {
    color: var(--theme-primary);
    transform: scale(0.95);
}

.input-field.with-prefix {
    padding-left: 24px;  /* Reduced from 32px */
}

/* Investment Input Row - Money + Return Rate side by side */
.investment-input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

/* Desktop: More compact spacing and fixed input width */
@media (min-width: 769px) {
    .investment-input-row {
        grid-template-columns: 75px auto;
        gap: 6px;
    }
    
    .input-with-prefix {
        width: 75px;
        position: relative;
    }
    
    .input-with-prefix::after {
        content: '';
        position: absolute;
        inset: -1px;
        border-radius: 8px;
        background: linear-gradient(135deg, transparent, rgba(77, 171, 247, 0.1));
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
    }
    
    .input-with-prefix:focus-within::after {
        opacity: 1;
    }
}

.rate-input-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: transparent;
    border-radius: 6px;
    padding: 2px 4px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.rate-input-wrapper:hover {
    background: transparent;
}

.rate-input-wrapper:focus-within {
    background: var(--theme-bg-tertiary);
    box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.1);
}

/* Desktop: Tighter spacing */
@media (min-width: 769px) {
    .rate-input-wrapper {
        gap: 0;
        padding: 2px 2px;
    }
}

/* Legacy rate-display styles - removed in favor of always-visible input */

/* Rate Input (always visible, simple textbox) */
.rate-input {
    width: 32px;
    padding: 3px 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--theme-text-primary);
    font-size: 12px;
    font-weight: 600;
    text-align: right;
    font-family: inherit;
    transition: all 0.2s ease;
    cursor: text;
    touch-action: manipulation;
}

/* Hide spinner arrows on number inputs for all browsers */
.rate-input::-webkit-outer-spin-button,
.rate-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.rate-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.rate-input:focus {
    outline: none;
    color: var(--theme-primary);
}

.rate-input:hover {
    color: var(--theme-primary);
}

/* Rate suffix (% symbol) */
.rate-suffix-inline {
    font-size: 11px;
    color: var(--theme-text-muted);
    font-weight: 600;
    margin-left: 0px;
    user-select: none;
}


/* ============= INVESTMENT BREAKDOWN (COLLAPSIBLE) ============= */

.section-header .investment-breakdown-toggle {
    flex: 1;
    background: none;
    border: none;
    padding: 0;
    color: var(--color-accent, #007AFF);
    font-size: 15px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    text-align: left;
}

.section-header .investment-breakdown-toggle:hover {
    color: var(--color-primary, #0066CC);
    transform: translateX(2px);
}

.section-header .investment-breakdown-toggle:active {
    transform: scale(0.98);
}

.investment-breakdown-hint {
    font-size: 10px;
    color: var(--theme-text-muted);
    font-weight: 400;
    margin-left: 8px;
    font-style: italic;
}

.investment-breakdown-toggle .expand-chevron {
    transition: color 0.3s ease;
    font-size: 12px;
    color: var(--theme-text-muted);
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 8px;
    width: 20px;
    text-align: center;
    display: inline-block;
}

.investment-breakdown-toggle.active .expand-chevron {
    color: var(--theme-primary);
}

.investment-breakdown-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.investment-breakdown-content.active {
    max-height: 2000px;
    opacity: 1;
    padding-top: 4px;
}

/* Add subtle dividers between investment items */
.investment-breakdown-content .input-group {
    position: relative;
}

.investment-breakdown-content .input-group:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        var(--theme-border) 20%, 
        var(--theme-border) 80%, 
        transparent
    );
    opacity: 0.25;
}

/* Subsections (Return Rates, Assumptions) */
.subsection-toggle {
    margin: 16px 0;
}

.subsection-toggle-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    color: var(--theme-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.subsection-toggle-button:hover {
    background: var(--theme-bg-tertiary);
    border-color: var(--theme-border-hover);
}

.subsection-toggle-button.active .toggle-icon {
    transform: rotate(180deg);
}

.subsection-content {
    margin-top: 12px;
    padding: 16px;
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
}

.input-group-compact {
    display: grid;
    grid-template-columns: 1fr 100px;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.input-label-compact {
    font-size: 12px;
    color: var(--theme-text-secondary);  /* Consistent with all labels */
}

.input-field-compact {
    padding: 8px 10px;
    background: var(--theme-input-bg);
    border: 1px solid var(--theme-input-border);
    border-radius: 6px;
    color: var(--theme-text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.input-field-compact:focus {
    outline: none;
    border-color: var(--theme-input-focus);
}


/* ============= ACTION BUTTONS ============= */

.action-buttons {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-primary,
.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border: none;
    /* Separate transitions for different properties */
    transition: transform 0.15s ease, font-weight 0.3s ease, box-shadow 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--theme-primary), #007aff);
    color: white;
    box-shadow: 0 4px 12px rgba(77, 171, 247, 0.3);
}

.btn-primary:hover {
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(77, 171, 247, 0.4);
}

.btn-primary:active {
    transform: translateY(3px);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(77, 171, 247, 0.3);
    /* Fast transition down, normal transition up */
    transition: transform 0.08s ease, font-weight 0s, box-shadow 0.08s ease;
}

/* Glow animation for Calculate button when recalculation is needed */
.btn-primary.needs-recalculation {
    animation: buttonGlow 2s ease-in-out infinite;
    box-shadow: 0 4px 20px rgba(77, 171, 247, 0.6);
}

@keyframes buttonGlow {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(77, 171, 247, 0.6);
    }
    50% {
        box-shadow: 0 6px 30px rgba(77, 171, 247, 0.9), 0 0 15px rgba(77, 171, 247, 0.5);
    }
}

.btn-secondary {
    background: var(--theme-bg-tertiary);
    color: var(--theme-text-primary);
    border: 1px solid var(--theme-border);
}

.btn-secondary:hover {
    background: var(--theme-bg-primary);
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

.saved-plans-info {
    margin-top: 10px;
    padding: 12px;
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--theme-text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-icon {
    font-size: 16px;
}


/* ============= RESULTS - EMPTY STATE ============= */

.empty-state {
    text-align: center;
    padding: 80px 40px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.empty-state-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--theme-text-primary);
    margin-bottom: 16px;
}

.empty-state-description {
    font-size: 16px;
    color: var(--theme-text-secondary);
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto 32px;
}

.quick-facts {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 400px;
    margin: 0 auto;
}

.quick-fact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.quick-fact:hover {
    transform: translateX(4px);
    border-color: var(--theme-primary);
}

.fact-icon {
    font-size: 24px;
}

.fact-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--theme-text-primary);
}


/* ============= RESULTS - HERO SECTION ============= */

.hero-section {
    padding: 24px 40px 40px;
    text-align: center;
    z-index: 2;
    position: relative;
}

/* Results panel hero: full-width inside panel, no extra top spacing */
.results-panel .hero-section {
    margin: 0 -24px 0;
    padding: 0 24px 12px;
}

/* Assumptions Bar */
.assumptions-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
    margin: 0 40px 20px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 10px;
    position: relative;
    z-index: 2;
}

.assumption-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.assumption-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--theme-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.assumption-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--theme-primary);
}

.assumption-divider {
    width: 1px;
    height: 32px;
    background: linear-gradient(
        to bottom,
        transparent,
        var(--theme-border) 20%,
        var(--theme-border) 80%,
        transparent
    );
}

.result-showcase {
    text-align: center;
    z-index: 2;
}

.result-title {
    font-size: 18px;
    color: var(--color-text-secondary, var(--theme-text-secondary));
    margin-bottom: 10px;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.pension-perspective-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    color: var(--theme-text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    opacity: 0.7;
}

.pension-perspective-toggle:hover {
    opacity: 1;
    background: var(--theme-bg-tertiary);
    border-color: var(--theme-primary);
    color: var(--theme-text-secondary);
}

.pension-perspective-toggle.active {
    opacity: 1;
    background: var(--theme-bg-secondary);
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

.pension-perspective-toggle .toggle-icon {
    font-size: 12px;
    line-height: 1;
}

.pension-perspective-toggle .toggle-label {
    white-space: nowrap;
}

.result-amount {
    font-size: 72px;
    font-weight: 100;
    color: var(--color-text-primary, var(--theme-text-primary));
    margin-bottom: 16px;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
    animation: glow 3s ease-in-out infinite alternate;
    line-height: 1.1;
}

@keyframes glow {
    from { text-shadow: 0 0 30px rgba(255, 255, 255, 0.1); }
    to { text-shadow: 0 0 40px rgba(0, 122, 255, 0.3); }
}

.pension-subtitle {
    font-size: 16px;
    color: var(--theme-text-secondary);
    margin-bottom: 8px;
    font-weight: 300;
}

.withdrawal-rate {
    font-weight: 500;
    color: var(--theme-success, #30d158);
}

.corpus-amount {
    font-size: 24px;
    font-weight: 400;
    color: var(--theme-text-primary);
}

.retirement-age-label {
    font-size: 14px;
    color: var(--theme-text-muted);
    margin-top: 4px;
}


/* ============= RESULTS - SLIDER SECTION ============= */

.slider-section {
    padding: 24px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.slider-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-text-primary);
}

.slider-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--theme-primary);
    padding: 4px 12px;
    background: var(--theme-bg-primary);
    border-radius: 6px;
}

.retirement-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--theme-bg-tertiary);
    outline: none;
    border-radius: 4px;
    margin-bottom: 8px;
}

.retirement-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--theme-primary), #007aff);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(77, 171, 247, 0.4);
    transition: all 0.2s ease;
}

.retirement-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(77, 171, 247, 0.6);
}

.retirement-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--theme-primary), #007aff);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(77, 171, 247, 0.4);
    border: none;
    transition: all 0.2s ease;
}

.retirement-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(77, 171, 247, 0.6);
}

.slider-milestones {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--theme-text-muted);
    font-weight: 500;
    padding: 0 10px;
    margin-top: 0;
    width: 100%;
    position: relative;
    z-index: 1;
}


/* ============= RESULTS - BREAKDOWN SECTION ============= */

/* Graphs Panel - Compact Apple-like Design */
.graphs-panel .breakdown-section {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.graphs-panel .graphs-heading {
    font-size: 15px;
    font-weight: 600;
    color: var(--theme-text-primary);
    margin-bottom: 8px;
    width: 100%;
    text-align: left;
}

/* Corpus Donut Chart */
.corpus-donut-container {
    display: flex;
    justify-content: center;
    margin: 0 auto 16px auto;
    width: 100%;
}

.donut-chart-wrapper {
    position: relative;
    width: 280px;
    height: 280px;
}

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-center-label {
    font-size: 12px;
    color: var(--theme-text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.donut-center-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--theme-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    line-height: 1.2;
}

/* Donut segment animations and effects */
.corpus-segment {
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    cursor: pointer;
}

.corpus-segment:hover {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2)) brightness(1.1);
    stroke-width: 22;
}

/* Donut tooltip */
.donut-tooltip {
    position: absolute;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    color: var(--theme-text-primary);
    min-width: 180px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.donut-tooltip.show {
    opacity: 1;
}

.donut-tooltip .tooltip-title {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
}

.donut-tooltip .tooltip-value {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.donut-tooltip .tooltip-percentage {
    font-size: 12px;
    color: var(--theme-text-secondary);
}

/* Corpus Component List Table */
.corpus-table-container {
    background: var(--theme-bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin: 24px auto;
    width: 560px; /* 2x the donut width (280px) */
    max-width: 100%; /* Responsive on smaller screens */
}

.corpus-table {
    width: 100%;
}

.corpus-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--theme-border);
    opacity: 0.8;
    transition: opacity 0.2s ease;
    font-size: 13px;
}

.corpus-row:hover {
    opacity: 1;
}

.corpus-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-text-primary);
    opacity: 1 !important;
}

.corpus-total {
    font-weight: 600;
    color: var(--theme-text-primary);
    background: var(--theme-bg-tertiary);
    border-radius: 8px;
    margin-top: 8px;
    padding-left: 16px;
    padding-right: 16px;
    border-bottom: none;
    opacity: 1 !important;
}

.breakdown-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.breakdown-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.breakdown-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--theme-text-primary);
}

.breakdown-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--theme-text-primary);
    margin-bottom: 4px;
}

.breakdown-percentage {
    font-size: 12px;
    color: var(--theme-text-secondary);
}

/* Investment type colors */
.breakdown-card[data-type="epf"] .breakdown-icon {
    background: rgba(77, 171, 247, 0.15);
    color: #4dabf7;
}

.breakdown-card[data-type="nps"] .breakdown-icon {
    background: rgba(81, 207, 102, 0.15);
    color: #51cf66;
}

.breakdown-card[data-type="equity"] .breakdown-icon {
    background: rgba(255, 146, 43, 0.15);
    color: #ff922b;
}

.breakdown-card[data-type="debt"] .breakdown-icon {
    background: rgba(134, 142, 150, 0.15);
    color: #868e96;
}

.breakdown-card[data-type="fd"] .breakdown-icon {
    background: rgba(250, 176, 5, 0.15);
    color: #fab005;
}

.breakdown-card[data-type="ppf"] .breakdown-icon {
    background: rgba(121, 80, 242, 0.15);
    color: #7950f2;
}


/* ============= RESULTS - CHART SECTION ============= */

.chart-toggle-section {
    margin-bottom: 16px;
    text-align: center;
}

.chart-toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--theme-bg-tertiary);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    color: var(--theme-text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.chart-toggle-button:hover {
    background: var(--theme-bg-primary);
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

.chart-toggle-button.active .toggle-icon {
    transform: rotate(180deg);
}

.graphs-panel .chart-section {
    margin-top: 0;
    margin-bottom: 0;
    animation: slideDown 0.3s ease;
}

.chart-container {
    padding: 16px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    min-height: 350px;
}

/* Chart Tabs - Portfolio Tab Style */
.chart-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 8px 8px 0 8px;
    margin-bottom: 0;
    border: 1px solid var(--theme-border);
    border-bottom: 2px solid var(--theme-border);
    border-radius: 12px 12px 0 0;
    position: relative;
    background: var(--theme-bg-primary);
}

.chart-tab {
    flex: 1 1 0; /* Equal width tabs */
    background: transparent;
    border-top: 1px solid var(--theme-border);
    border-left: 1px solid var(--theme-border);
    border-right: none;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 6px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--theme-text-muted);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: 0;
    text-align: center;
    text-transform: capitalize;
    margin-bottom: -2px; /* overlap the chart-tabs bottom border */
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}

.chart-tab:last-child {
    border-right: 1px solid var(--theme-border);
}

.chart-tab:hover:not(.active) {
    background: var(--theme-bg-secondary);
    color: var(--theme-text-secondary);
    border-color: var(--theme-border);
}

.chart-tab.active {
    background: var(--theme-bg-primary);
    color: var(--theme-primary);
    border-top-color: var(--theme-primary);
    border-left-color: var(--theme-primary);
    border-bottom: 2px solid var(--theme-bg-primary);
    box-shadow: none;
    z-index: 1;
}

.chart-tab.active:last-child {
    border-right-color: var(--theme-primary);
}

.tab-label {
    font-weight: 600;
    white-space: nowrap;
    font-size: 11px;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}

.tab-preview {
    width: 60px;
    height: 30px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 4px;
    opacity: 1;
    transition: opacity 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure canvas and SVG elements are visible */
.tab-preview canvas,
.tab-preview svg {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 60px;
    max-height: 30px;
}

/* Fallback styles when previews haven't loaded yet */
.tab-preview[data-preview="distribution"]:empty {
    background: conic-gradient(
        #4dabf7 0deg 90deg,
        #51cf66 90deg 180deg,
        #ff922b 180deg 270deg,
        #868e96 270deg 360deg
    );
    opacity: 0.8;
}

.tab-preview[data-preview="growth"]:empty {
    background: linear-gradient(135deg, 
        var(--theme-bg-secondary) 0%,
        var(--theme-primary) 50%,
        var(--theme-bg-secondary) 100%
    );
}

.tab-preview[data-preview="contributions"]:empty {
    background: linear-gradient(to top,
        var(--theme-primary) 0%,
        var(--theme-primary) 60%,
        var(--theme-bg-secondary) 60%
    );
}

.tab-preview[data-preview="allocation"]:empty {
    background: 
        repeating-linear-gradient(90deg,
            #4dabf7 0px 8px,
            #51cf66 8px 16px,
            #ff922b 16px 24px,
            #868e96 24px 32px
        );
}

.tab-preview[data-preview="sustainability"]:empty {
    background: linear-gradient(135deg,
        #30d158 0%,
        #ff9500 50%,
        #ff3b30 100%
    );
}

/* Chart Content */
.chart-content {
    position: relative;
    min-height: 400px;
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 0 16px 16px 16px;
    margin-top: -1px;
}

/* Ensure legend is always connected to content for all tabs */
.graphs-legend:not([style*="display: none"]) {
    display: flex !important;
}

.chart-tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.chart-tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Shared Legend */
.graphs-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 12px 16px;
    margin-bottom: 0;
    margin-top: 0;
    border-left: 1px solid var(--theme-border);
    border-right: 1px solid var(--theme-border);
    border-bottom: 1px solid var(--theme-border);
    border-radius: 0;
    background: var(--theme-bg-primary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--theme-text-secondary);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-label {
    white-space: nowrap;
}

#growthChart {
    max-height: 400px;
}


/* ============= RESULTS - ASSUMPTIONS ============= */

.assumptions-display {
    padding: 24px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
}

.assumptions-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--theme-text-primary);
    margin-bottom: 16px;
}

.assumptions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.assumption-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--theme-bg-primary);
    border-radius: 8px;
}

.assumption-label {
    font-size: 12px;
    color: var(--theme-text-secondary);
}

.assumption-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--theme-text-primary);
}

.assumptions-note {
    font-size: 11px;
    color: var(--theme-text-muted);
    font-style: italic;
    line-height: 1.5;
    margin: 0;
}


/* ============= LOADING & ERROR STATES ============= */

.loading-state,
.error-state {
    text-align: center;
    padding: 80px 40px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--theme-bg-tertiary);
    border-top-color: var(--theme-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
}

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

.loading-text {
    font-size: 16px;
    color: var(--theme-text-secondary);
}

.error-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.error-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--theme-danger);
    margin-bottom: 12px;
}

.error-message {
    font-size: 14px;
    color: var(--theme-text-secondary);
    margin-bottom: 24px;
}


/* ============= LAPTOP/TABLET RESPONSIVENESS ============= */

/* Medium screens (laptops, smaller displays like e450) */
@media (max-width: 1600px) {
    .retirement-container {
        grid-template-columns: 380px 1fr;
    }

    .result-amount {
        font-size: 56px;
    }

    .corpus-amount {
        font-size: 20px;
    }

    .result-title {
        font-size: 16px;
    }

    .pension-subtitle {
        font-size: 14px;
    }

    .donut-chart-wrapper {
        width: 260px;
        height: 260px;
    }

    .donut-center-value {
        font-size: 24px;
    }

    .results-container {
        padding: 0 0 32px 0;
    }
}

/* Smaller laptops */
@media (max-width: 1366px) {
    .retirement-container {
        grid-template-columns: 360px 1fr;
    }

    .result-amount {
        font-size: 48px;
    }

    .corpus-amount {
        font-size: 18px;
    }

    .pension-subtitle {
        font-size: 13px;
    }

    .result-title {
        font-size: 15px;
    }

    .donut-chart-wrapper {
        width: 240px;
        height: 240px;
    }

    .donut-center-value {
        font-size: 22px;
    }

    .donut-center-label {
        font-size: 13px;
    }

    .results-container {
        padding: 0 0 28px 0;
    }

    .constraint-value {
        font-size: 29px;
    }

    .sidebar-content {
        padding: 10px;
    }

    .section-heading {
        font-size: 16px;
    }

    .empty-state-title {
        font-size: 24px;
    }

    .empty-state-description {
        font-size: 15px;
    }
}

/* ============= MOBILE RESPONSIVENESS ============= */

@media (max-width: 768px) {
    .retirement-container {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100vh;
    }

    /* Constraint section mobile adjustments */
    .constraint-section {
        padding: 0;
    }

    .constraint-header-row {
        flex-wrap: wrap;
        gap: 8px;
        padding-bottom: 6px;
    }

    .constraint-label-with-amount {
        width: 100%;
    }

    .constraint-value-inline {
        font-size: 20px;
    }

    .period-toggle {
        width: 100%;
        display: flex;
    }

    .period-toggle label {
        flex: 1;
        padding: 6px 12px;
        font-size: 11px;
        min-width: unset;
    }

    .constraint-value {
        font-size: 19px;
    }

    .retirement-sidebar {
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--theme-border);
    }

    .retirement-results {
        height: auto;
    }

    .results-container {
        padding: 0 0 24px 0;
    }

    .sidebar-header {
        padding: 16px;
    }

    .sidebar-content {
        padding: 8px;
    }

    /* Adjust theme button size on mobile */
    .theme-toggle {
        width: 32px;
        height: 32px;
    }

    .theme-toggle .theme-icon {
        width: 16px;
        height: 16px;
    }


    .hero-section {
        padding: 20px 20px 24px;
    }

    /* Assumptions bar mobile */
    .assumptions-bar {
        margin: 0 20px 16px;
        padding: 10px 16px;
        gap: 12px;
    }

    .assumption-item {
        gap: 2px;
    }

    .assumption-label {
        font-size: 10px;
    }

    .assumption-value {
        font-size: 14px;
    }

    .assumption-divider {
        height: 28px;
    }

    .result-amount {
        font-size: clamp(40px, 10vw, 56px);
    }

    .corpus-amount {
        font-size: clamp(18px, 4vw, 22px);
    }
    
    /* Pension perspective toggle on mobile */
    .pension-perspective-toggle {
        font-size: 10px;
        padding: 3px 8px;
        gap: 4px;
    }
    
    .pension-perspective-toggle .toggle-icon {
        font-size: 11px;
    }
    
    .result-title {
        gap: 8px;
    }

    /* Donut chart responsive */
    .donut-chart-wrapper {
        width: 240px !important;
        height: 240px !important;
    }

    .donut-center-label {
        font-size: 11px;
        max-width: 180px;
    }

    .donut-center-value {
        font-size: 20px;
        max-width: 180px;
    }

    .corpus-table-container {
        width: 480px; /* 2x the mobile donut width (240px) */
        max-width: 100%; /* Responsive on smaller screens */
    }

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

    .empty-state {
        padding: 60px 24px;
    }

    .empty-state-title {
        font-size: 22px;
    }

    .empty-state-description {
        font-size: 14px;
    }

    /* Age range responsive */
    .age-range-container {
        padding: 12px 16px;
    }

    .age-display {
        margin-bottom: 12px;
        gap: 12px;
    }

    .age-value {
        font-size: 24px;
        font-weight: 200;
    }

    .age-label {
        font-size: 9px;
        letter-spacing: 0.6px;
    }

    .arrow-separator {
        margin: 0;
    }

    .arrow-separator svg {
        width: 28px;
        height: 14px;
    }
    
    .dual-slider {
        height: 28px;
    }

    /* Section headers on mobile */
    .section-header {
        font-size: 14px;
        margin-bottom: 16px;
    }

    /* Investment breakdown toggle on mobile */
    .section-header .investment-breakdown-toggle {
        font-size: 14px;
    }

    /* Investment input row on mobile */
    .investment-input-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .rate-input-wrapper {
        justify-content: flex-end;
        gap: 2px;
        align-self: flex-end;
    }

    .rate-input {
        width: 40px;
        padding: 4px 2px;
        font-size: 16px; /* Keep 16px to prevent zoom on mobile */
    }

    .rate-suffix-inline {
        font-size: 11px;
    }
    
    /* Disable hover effects on touch devices */
    .input-group:hover {
        background: none;
        padding: 8px 0;
        margin: 0;
    }
    
    .net-worth-row:hover {
        transform: none;
    }
    
    .net-worth-group {
        padding: 10px 12px;
        margin-bottom: 10px;
    }

    /* Mobile panel navigation */
    .mobile-panel-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--theme-bg-secondary);
        border-top: 1px solid var(--theme-border);
        padding: 8px;
        gap: 8px;
        z-index: 100;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    }

    .panel-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 10px;
        border-radius: 8px;
        background: var(--theme-bg-primary);
        border: 1px solid var(--theme-border);
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .panel-nav-item.active {
        background: var(--theme-primary);
        border-color: var(--theme-primary);
        color: white;
    }

    .panel-nav-icon {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .panel-nav-label {
        font-size: 11px;
        font-weight: 500;
    }

    /* Hide non-active panels on mobile */
    body[data-mobile-panel="inputs"] .retirement-results {
        display: none;
    }

    body[data-mobile-panel="results"] .retirement-sidebar {
        display: none;
    }
}

@media (max-width: 480px) {
    .sidebar-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .logo-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .header-controls {
        justify-content: center;
    }

    .separator {
        display: none;
    }

    .result-amount {
        font-size: clamp(32px, 12vw, 48px);
    }

    .corpus-amount {
        font-size: clamp(16px, 5vw, 20px);
    }

    .chart-container {
        padding: 16px;
        min-height: 300px;
    }

    #growthChart {
        max-height: 300px;
    }
}

/* ============= MONTE CARLO SIMULATION ============= */

.monte-carlo-container {
    margin: 24px 0;
    padding: 24px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
}

.monte-carlo-header {
    margin-bottom: 20px;
}

.monte-carlo-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--theme-text-primary);
    margin-bottom: 8px;
}

.monte-carlo-header p {
    font-size: 13px;
    color: var(--theme-text-secondary);
    margin: 0;
}

.monte-carlo-loading {
    text-align: center;
    padding: 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--theme-bg-tertiary);
    border-top-color: var(--theme-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.monte-carlo-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    padding: 16px;
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
}

.metric-label {
    font-size: 12px;
    color: var(--theme-text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--theme-text-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
}

.metric-value.success {
    color: #30d158;
}

.metric-value.warning {
    color: #ff9500;
}

.metric-value.danger {
    color: #ff3b30;
}

.monte-carlo-chart-container {
    height: 400px;
    position: relative;
}

/* ============= FIRE CALCULATOR ============= */

.fire-container {
    margin: 24px 0;
    padding: 24px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
}

.fire-header {
    margin-bottom: 20px;
}

.fire-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--theme-text-primary);
    margin-bottom: 8px;
}

.fire-header p {
    font-size: 13px;
    color: var(--theme-text-secondary);
    margin: 0;
}

.fire-progress {
    margin-bottom: 24px;
}

.progress-bar {
    height: 8px;
    background: var(--theme-bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--theme-primary), #007aff);
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 12px;
    color: var(--theme-text-secondary);
    text-align: center;
}

.fire-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.fire-card {
    padding: 16px;
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    text-align: center;
    transition: all 0.2s ease;
}

.fire-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.fire-card.lean {
    border-left: 3px solid #ff9500;
}

.fire-card.regular {
    border-left: 3px solid var(--theme-primary);
}

.fire-card.fat {
    border-left: 3px solid #30d158;
}

.fire-card.coast {
    border-left: 3px solid #ff922b;
}

.fire-card.barista {
    border-left: 3px solid #7950f2;
}

.fire-label {
    font-size: 11px;
    color: var(--theme-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.fire-number {
    font-size: 18px;
    font-weight: 600;
    color: var(--theme-text-primary);
    margin-bottom: 8px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
}

.fire-years {
    font-size: 12px;
    color: var(--theme-text-muted);
}

/* ============= COLLAPSIBLE SECTIONS (RESULTS PANEL) ============= */

.advanced-analysis-sections {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.collapsible-section {
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.collapsible-section:hover {
    border-color: var(--theme-border-hover);
}

.collapsible-section.expanded {
    border-color: var(--theme-primary);
    box-shadow: 0 2px 8px rgba(77, 171, 247, 0.1);
}

.collapsible-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: left;
}

.collapsible-header:hover {
    background: var(--theme-bg-tertiary);
}

.collapsible-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--theme-text-primary);
}

.collapsible-icon {
    font-size: 16px;
    opacity: 0.8;
}

.collapsible-chevron {
    font-size: 10px;
    color: var(--theme-text-muted);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: rotate(0deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    padding: 0 14px;
    border-top: 1px solid transparent;
    background: var(--theme-bg-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
}

.collapsible-section.expanded .collapsible-content {
    max-height: 2000px; /* Large enough for content */
    padding: 12px 14px;
    border-top-color: var(--theme-border);
    opacity: 1;
}

/* ============= SUSTAINABILITY INSIGHTS (COMPACT) ============= */

.sustainability-insights-compact {
    padding: 0;
}

.insights-grid-compact {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.insight-item-compact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: var(--theme-bg-primary);
    border-radius: 6px;
    border: 1px solid var(--theme-border);
}

.insight-item-compact.full-width {
    grid-column: 1 / -1;
}

.insight-label-compact {
    font-size: 11px;
    color: var(--theme-text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.insight-value-compact {
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-text-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
}

/* ============= FIRE CALCULATOR (COMPACT) ============= */

.fire-container-compact {
    padding: 0;
}

.fire-header-label {
    text-align: center;
    padding-top: 12px;
    margin-bottom: 6px;
    border-top: 1px solid var(--theme-border);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.fire-header-label svg {
    max-width: 144px;
    width: auto;
    height: auto;
    max-height: 48px;
}

/* Reduce font sizes in FIRE section */
#fireSection .portfolio-item-name {
    font-size: 12px;
}

#fireSection .period-toggle label {
    font-size: 10px;
}

#fireSection .portfolio-item-amount-input {
    font-size: 13px;
}

/* FIRE inline controls: keep on one line */
.fire-inline-btn.btn-primary {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(77, 171, 247, 0.28);
    flex: 0 0 auto;
    white-space: nowrap;
}

.fire-progress-compact {
    margin-bottom: 12px;
}

.progress-bar-compact {
    height: 6px;
    background: var(--theme-bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill-compact {
    height: 100%;
    background: linear-gradient(90deg, var(--theme-primary), #007aff);
    transition: width 0.5s ease;
}

.progress-text-compact {
    font-size: 11px;
    color: var(--theme-text-secondary);
    text-align: center;
    line-height: 1.4;
}

.progress-percentage {
    display: block;
    font-size: 10px;
    color: var(--theme-text-muted);
}

/* ============= PLAN ACTIONS (SAVE/LOAD) ============= */

.plan-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.plan-actions .btn-secondary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--theme-border);
    background: var(--theme-bg-secondary);
    color: var(--theme-text-primary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.plan-actions .btn-secondary:hover:not(:disabled) {
    background: var(--theme-bg-tertiary);
    border-color: var(--theme-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.plan-actions .btn-secondary:active:not(:disabled) {
    transform: translateY(0);
}

.plan-actions .btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--theme-bg-tertiary);
    color: var(--theme-text-muted);
}

/* ============= LOAD PLAN MODAL ============= */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--theme-bg-primary);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--theme-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--theme-text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--theme-text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--theme-bg-secondary);
    color: var(--theme-text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.plans-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.plan-item {
    padding: 16px;
    border: 1px solid var(--theme-border);
    border-radius: 8px;
    background: var(--theme-bg-secondary);
    transition: all 0.2s ease;
    cursor: pointer;
}

.plan-item:hover {
    border-color: var(--theme-primary);
    background: var(--theme-bg-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.plan-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.plan-item-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--theme-text-primary);
}

.favorite-badge {
    color: #ffd700;
    font-size: 18px;
    margin-left: 8px;
}

.plan-item-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--theme-text-secondary);
}

.corpus-amount {
    font-weight: 600;
    color: var(--theme-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
}

.plan-item-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--theme-text-muted);
    margin-bottom: 12px;
}

.btn-load-plan {
    width: 100%;
    padding: 10px 16px;
    background: var(--theme-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-load-plan:hover {
    background: #007aff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(77, 171, 247, 0.3);
}

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

.plan-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-delete-plan {
    padding: 10px 12px;
    background: transparent;
    color: var(--theme-text-muted);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-delete-plan:hover {
    background: #ff3b30;
    color: white;
    border-color: #ff3b30;
    transform: translateY(-1px);
}

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

.plan-item-actions .btn-load-plan {
    flex: 1;
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--theme-text-muted);
    font-size: 14px;
}

.no-plans {
    text-align: center;
    padding: 40px;
    color: var(--theme-text-muted);
    font-size: 14px;
}

.error-message {
    text-align: center;
    padding: 40px;
    color: #ff3b30;
    font-size: 14px;
}

/* Save Plan Modal Input */
#planNameInput {
    font-family: inherit;
    color: var(--theme-text-primary);
    background: var(--theme-bg-primary);
}

#planNameInput:focus {
    outline: none;
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.1);
}

.modal-actions .btn-primary {
    background: linear-gradient(135deg, var(--theme-primary), #007aff);
    color: white;
    border: none;
}

.modal-actions .btn-primary:hover {
    background: linear-gradient(135deg, #007aff, var(--theme-primary));
    box-shadow: 0 4px 12px rgba(77, 171, 247, 0.3);
}

.modal-actions .btn-secondary {
    background: var(--theme-bg-secondary);
    color: var(--theme-text-primary);
    border: 1px solid var(--theme-border);
}

.modal-actions .btn-secondary:hover {
    background: var(--theme-bg-tertiary);
    border-color: var(--theme-primary);
    margin-top: 2px;
}

.fire-grid-compact {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.fire-card-compact {
    padding: 10px;
    background: var(--theme-bg-primary);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    text-align: center;
    transition: all 0.2s ease;
}

.fire-card-compact:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.fire-card-compact.lean {
    border-left: 3px solid #ff9500;
}

.fire-card-compact.regular {
    border-left: 3px solid var(--theme-primary);
}

.fire-card-compact.fat {
    border-left: 3px solid #30d158;
}

.fire-card-compact.coast {
    border-left: 3px solid #ff922b;
}

.fire-card-compact.barista {
    border-left: 3px solid #7950f2;
}

.fire-label-compact {
    font-size: 10px;
    color: var(--theme-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
    font-weight: 600;
}

.fire-number-compact {
    font-size: 13px;
    font-weight: 600;
    color: var(--theme-text-primary);
    margin-bottom: 4px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    line-height: 1.2;
}

.fire-years-compact {
    font-size: 10px;
    color: var(--theme-text-muted);
}

/* ============= FIRE JOURNEY VISUALIZATION ============= */

.fire-journey-container {
    margin: 0;
}

/* FIRE Results Container */
#fireResults {
    position: relative;
}

.fire-journey-card {
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin: 0;
    position: relative;
    overflow: visible;
    border: none;
}

.fire-journey-svg {
    width: 100%;
    height: 600px;
    max-height: 600px;
    margin: 0;
    padding: 0;
}

.fire-journey-svg svg {
    width: 100%;
    height: 100%;
    display: block;
}

.fire-path-bg {
    fill: none;
    stroke: var(--theme-bg-tertiary);
    stroke-width: 60;
    stroke-linecap: round;
}

.fire-path-progress {
    fill: none;
    stroke: url(#fire-path-gradient);
    stroke-width: 50;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.fire-connector {
    fill: none;
    stroke: var(--theme-text-primary);
    stroke-width: 2.5;
    stroke-dasharray: 5, 4;
    opacity: 0.65;
}

.fire-milestone-node {
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}

.fire-node-outer {
    fill: var(--theme-bg-primary);
    stroke: var(--node-color);
    stroke-width: 4;
}

.fire-node-inner {
    fill: var(--node-color);
}

.fire-node-pulse {
    fill: var(--node-color);
    opacity: 0.3;
    animation: fire-pulse 2s ease-out infinite;
}

@keyframes fire-pulse {
    0% { r: 0; opacity: 0.6; }
    100% { r: 40; opacity: 0; }
}

.fire-milestone-label {
    font-size: 18px;
    font-weight: 800;
    fill: var(--theme-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fire-milestone-amount {
    font-size: 20px;
    font-weight: 700;
    fill: var(--theme-text-secondary);
}

.fire-milestone-status {
    font-size: 11px;
    font-weight: 600;
    fill: #10b981;
}

.fire-milestone-years {
    font-size: 16px;
    font-weight: 500;
    fill: var(--theme-text-secondary);
    opacity: 0.75;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
}

/* FIRE Error Overlay - Empathetic guidance message */
.fire-error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 10;
    padding: 24px;
    padding-top: 40px;
    pointer-events: auto;
}

.fire-error-content {
    max-width: 520px;
    width: 100%;
    background: var(--theme-bg-primary);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--theme-shadow-heavy);
    border: 1px solid var(--theme-border);
    text-align: center;
    animation: fire-error-fade-in 0.4s ease-out;
    opacity: 0.85;
}

.fire-error-message {
    font-size: 15px;
    color: var(--theme-text-primary);
    line-height: 1.7;
    margin: 0;
}

@keyframes fire-error-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Light theme adjustments for error overlay */
html[data-theme="light"] .fire-error-content {
    background: #ffffff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border-color: #e0e0e5;
}

/* Dark theme adjustments */
html[data-theme="dark"] .fire-error-content {
    background: var(--theme-bg-secondary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    border-color: var(--theme-border);
}

.fire-current-position {
    filter: drop-shadow(0 6px 12px rgba(245, 158, 11, 0.4));
}

.fire-current-ring {
    fill: none;
    stroke: #d97706;
    stroke-width: 3;
    animation: fire-ring-pulse 2s ease-in-out infinite;
}

@keyframes fire-ring-pulse {
    0%, 100% { r: 30; opacity: 1; }
    50% { r: 40; opacity: 0.5; }
}

.fire-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 20px;
}

.fire-stat {
    text-align: center;
    padding: 16px;
    background: var(--theme-bg-secondary);
    border-radius: 8px;
}

.fire-stat-value {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.fire-stat-label {
    font-size: 11px;
    color: var(--theme-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.fire-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    padding: 16px;
    background: var(--theme-bg-secondary);
    border-radius: 8px;
}

.fire-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fire-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.fire-legend-text {
    font-size: 11px;
    color: var(--theme-text-secondary);
    font-weight: 500;
}

/* Legacy styles for results panel (keep for backward compatibility) */
.sustainability-insights {
    margin-top: 20px;
    padding: 20px;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
}

.insights-header {
    margin-bottom: 16px;
}

.insights-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--theme-text-primary);
    margin: 0;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.insight-item {
    padding: 12px;
    background: var(--theme-bg-primary);
    border-radius: 8px;
}

.insight-item.full-width {
    grid-column: 1 / -1;
}

.insight-label {
    font-size: 12px;
    color: var(--theme-text-secondary);
    margin-bottom: 6px;
    display: block;
}

.insight-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--theme-text-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
}

/* ============= SUSTAINABILITY CONTROLS ============= */

.sustainability-controls {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.sustainability-toggle-group {
    display: inline-flex;
    background: var(--theme-bg-tertiary);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.sustainability-toggle {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--theme-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.sustainability-toggle:hover {
    background: var(--theme-bg-primary);
    color: var(--theme-text-primary);
}

.sustainability-toggle.active {
    background: var(--theme-primary);
    color: white;
    box-shadow: 0 2px 4px rgba(77, 171, 247, 0.3);
}

/* Ensure both sustainability charts are properly sized */
#sustainabilityChart,
#monteCarloSustainabilityChart {
    max-height: 400px;
}

/* Custom Legend for Sustainability Chart (Outside Canvas) */
.custom-chart-legend {
    margin-top: 12px;
    padding: 0;
}

.custom-legend-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    justify-items: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.custom-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--theme-text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
    max-width: 100%;
    justify-content: center;
    min-width: 0;
}

.legend-line {
    width: 24px;
    height: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.legend-label {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    text-align: center;
}

/* 2x2 Layout for smaller screens */
@media (max-width: 800px) {
    .custom-legend-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .legend-label {
        max-width: 150px;
    }
}

/* Single column for very small screens */
@media (max-width: 500px) {
    .custom-legend-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .legend-label {
        max-width: 100%;
    }
}

.chart-container {
    position: relative;
}

.chart-container .monte-carlo-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    text-align: center;
    background: var(--theme-bg-secondary);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--theme-border);
}

/* ============= MONTE CARLO PROGRESS BAR ============= */

.chart-content {
    position: relative;
}

.monte-carlo-progress-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    background: var(--theme-bg-secondary);
    border: 1px solid var(--theme-border);
    border-radius: 12px;
    padding: 24px;
    min-width: 400px;
    max-width: 90%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.monte-carlo-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.monte-carlo-progress-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--theme-text-primary);
}

.monte-carlo-cancel-btn {
    padding: 6px 14px;
    background: var(--theme-bg-tertiary);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    color: var(--theme-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.monte-carlo-cancel-btn:hover:not(:disabled) {
    background: var(--theme-bg-primary);
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

.monte-carlo-cancel-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.monte-carlo-progress-bar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.monte-carlo-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--theme-bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.monte-carlo-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--theme-primary), #007aff);
    border-radius: 4px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(77, 171, 247, 0.4);
}

.monte-carlo-progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--theme-text-secondary);
}

.monte-carlo-progress-percentage {
    font-weight: 600;
    color: var(--theme-primary);
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
}

.monte-carlo-progress-details {
    color: var(--theme-text-muted);
    font-size: 11px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .monte-carlo-progress-container {
        min-width: 300px;
        padding: 20px;
    }
    
    .monte-carlo-progress-title {
        font-size: 14px;
    }
    
    .monte-carlo-cancel-btn {
        padding: 5px 12px;
        font-size: 11px;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .monte-carlo-metrics,
    .fire-grid {
        grid-template-columns: 1fr;
    }
    
    .monte-carlo-chart-container {
        height: 300px;
    }
    
    .sustainability-toggle {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .advanced-analysis-sections {
        margin: 12px 0;
    }
    
    .collapsible-header {
        padding: 10px 12px;
    }
    
    .collapsible-title {
        font-size: 12px;
    }
    
    .fire-grid-compact {
        grid-template-columns: 1fr;
    }
}

/* Hide Corpus Breakdown section */
#corpusBreakdownSection {
    display: none !important;
}

/* ============= CHART FULLSCREEN EXPANSION ============= */

.chart-expand-btn {
    display: inline-block;
    font-size: 18px;
    padding: 4px 8px;
    margin: 0 0 0 4px;
    border: none;
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: normal;
    vertical-align: middle;
    transition: all 0.2s ease;
    opacity: 0.7;
    line-height: 1;
    font-feature-settings: normal;
    text-rendering: optimizeLegibility;
}

.chart-expand-btn:hover {
    color: var(--theme-primary);
    background: rgba(77, 171, 247, 0.1);
    opacity: 1;
    transform: scale(1.1);
}

.chart-expand-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Fullscreen Chart Modal */
.chart-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chart-fullscreen-overlay.active {
    opacity: 1;
    visibility: visible;
}

.chart-fullscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-fullscreen-title {
    font-size: 24px;
    font-weight: 600;
    color: #FFFFFF;
    margin: 0;
}

.chart-fullscreen-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.chart-fullscreen-close:hover {
    background: rgba(255, 59, 48, 0.8);
    border-color: rgba(255, 59, 48, 1);
    transform: scale(1.1);
}

.chart-fullscreen-close:active {
    transform: scale(0.95);
}

.chart-fullscreen-content {
    flex: 1;
    background: var(--theme-bg-primary);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chart-fullscreen-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
}

.chart-fullscreen-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}
