:root {
    --bg-primary: #d5d5d5;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e5e5e5;
    --bg-card: #f5f5f5;
    --text-primary: #333333;
    --text-secondary: #616161;
    --text-muted: #757575;
    --border-color: #e0e0e0;
    --border-strong: #ddd;
    --primary-color: #0f2740;
    --primary-dark: #0c1f32;
    --primary-light: #d9e3f1;
    --success-bg: #e8f5e8;
    --error-bg: #ffebee;
    --error-color: #f44336;
    --success-color: #4caf50;
    --retirement-bg: #fff3e0;
    --table-header-bg: #546e7a;
    --table-header-text: #ffffff;
    --shadow-sm: rgba(0, 0, 0, 0.1);
    --shadow-md: rgba(0, 0, 0, 0.15);
    --shadow-lg: rgba(0, 0, 0, 0.25);
    --hover-overlay: rgba(0, 0, 0, 0.05);
    --flyout-width: 320px; /* width of floating left column on wide screens */
}

body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3e3e3e;
    --bg-card: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;
    --border-color: #404040;
    --border-strong: #505050;
    --primary-color: #8da8c7;
    --primary-dark: #6f89a8;
    --primary-light: #1d3450;
    --success-bg: #1b5e20;
    --error-bg: #b71c1c;
    --error-color: #ef5350;
    --success-color: #66bb6a;
    --retirement-bg: #4a3f2a;
    --table-header-bg: #546e7a;
    --table-header-text: #ffffff;
    --shadow-sm: rgba(0, 0, 0, 0.3);
    --shadow-md: rgba(0, 0, 0, 0.4);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --hover-overlay: rgba(255, 255, 255, 0.05);
}

/* Hide pension UI when disabled */
body.hide-pension #pensionCard,
body.hide-pension #wiz_pensionAgeGroup,
body.hide-pension #pensionAgeGroup {
    display: none !important;
}

/* Table columns are now dynamically filtered in JavaScript */

body {
    font-family: 'Roboto', sans-serif;
    margin: 20px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    padding-top: 116px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.mdc-card {
    margin-bottom: 20px;
    padding: 0;
    background-color: var(--bg-card);
    border-radius: 4px;
    box-shadow: 0 2px 4px var(--shadow-sm);
    position: relative; /* allow spinner overlay */
}

.draggable-card {
    transition: box-shadow 0.2s ease, opacity 0.2s ease;
}

.draggable-card.drag-over {
    box-shadow: 0 8px 16px var(--shadow-lg);
    opacity: 0.9;
}

.draggable-card.dragging {
    opacity: 0.5;
    background-color: var(--primary-light);
}

/* Card spinner overlay */
.card-spinner {
    position: absolute;
    inset: 0;
    display: none; /* shown while loading */
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.05);
    z-index: 5;
    border-radius: 4px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Monte Carlo stats grid - fluid responsive layout */
.mc-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.mc-stat-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    gap: 4px;
}

.mc-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
}

.mc-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 13px;
    text-align: left;
    word-break: break-word;
}

.section-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.input-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.input-group {
    width: 100%;
}

.input-group label {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease;
    box-sizing: border-box;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.left-column h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    background-color: var(--bg-secondary);
    padding: 10px 12px;
    margin: 20px 0 12px 0;
    border-left: 4px solid var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mdc-button {
    margin: 10px 5px;
    background-color: var(--primary-color) !important;
    color: white !important;
    transition: background-color 0.2s ease;
}

.mdc-button:hover {
    background-color: var(--primary-dark) !important;
}

table {
    border-collapse: collapse;
    width: 100%;
    background-color: var(--bg-card);
}

.table-container {
    overflow-x: auto;
    max-height: 40vh;
    overflow-y: auto;
}

.table-container table {
    border-collapse: collapse;
    border-spacing: 0;
}

th,
td {
    border: 1px solid var(--border-strong);
    padding: 8px;
    text-align: left;
    font-size: 12px;
    color: var(--text-primary);
}

th {
    background-color: var(--table-header-bg);
    color: var(--table-header-text);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 2px -1px var(--shadow-sm);
    border-top: 2px;
}

/* First header row (grouping) */
thead tr:first-child th {
    top: 0;
    z-index: 12;
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 13px;
    padding: 10px 8px;
    border-bottom: none;
}

/* Second header row (column headers) */
thead tr:nth-child(2) th {
    top: 35px; /* Exact height: 10px + 13px line height + 10px = 33px */
    z-index: 11;
    background-color: var(--table-header-bg);
    font-weight: 500;
    border-top: none;
}

.retirement-row {
    background-color: var(--retirement-bg);
}

.net-worth-positive {
    background-color: var(--success-bg);
}

.net-worth-negative {
    background-color: var(--error-bg);
}

.summary {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    padding: 16px;
    min-height: 56px;
    display: flex;
    align-items: center;
    background: #0f2740;
    color: #ffffff;
    border-radius: 4px 4px 0 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.summary .positive {
    color: var(--success-color);
}

.summary .negative {
    color: var(--error-color);
}

.card-content {
    padding: 16px;
}

/* Dimming effect for card content while loading */
.mdc-card.card-loading .card-content {
    opacity: 0.5;
    pointer-events: none;
}

.collapsible {
    cursor: pointer;
    user-select: none;
}

.collapsible::before {
    content: '▼ ';
}

.collapsible.collapsed::before {
    content: '▶ ';
}

.collapsible-content {
    display: block;
}

.collapsible-content.collapsed {
    display: none;
}

#status {
    padding: 10px;
    margin: 10px 0;
    font-weight: 500;
}

#status.loading {
    color: var(--primary-color);
}

#status.error {
    color: var(--error-color);
    background-color: var(--error-bg);
    border-radius: 4px;
}

.input-error {
    border-color: var(--error-color) !important;
    background-color: var(--error-bg) !important;
}

body.dark-mode .input-error {
    border-color: rgba(239, 83, 80, 0.6) !important;
    background-color: rgba(211, 47, 47, 0.1) !important;
}

.validation-errors {
    color: var(--error-color);
    font-size: 12px;
    margin-top: 5px;
    padding: 10px;
    background-color: var(--error-bg);
    border-radius: 4px;
}

body.dark-mode .validation-errors {
    background-color: rgba(211, 47, 47, 0.15);
    color: #ffcdd2;
}

.affix-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.affix-wrapper input {
    width: 100%;
    box-sizing: border-box;
}

.affix-prefix,
.affix-suffix {
    position: absolute;
    color: var(--text-secondary);
    font-size: 12px;
    pointer-events: none;
}

.affix-prefix {
    left: 10px;
}

.affix-suffix {
    right: 10px;
}

input[data-prefix] {
    padding-left: 24px;
}

input[data-suffix] {
    padding-right: 24px;
}

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 900;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    margin: 0;
    background: #0f2740;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border-radius: 0;
    border-bottom: 1px solid #0f2740;
}

/* Ensure header stays visible when mobile keyboard appears */
@supports (height: 100dvh) {
    @media (max-width: 768px) {
        .top-nav {
            position: sticky;
            top: 0;
        }
        
        body {
            padding-top: 0;
        }
    }
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px var(--shadow-md);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.3s ease;
}

.menu-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--shadow-lg);
    background: var(--bg-secondary);
}

.menu-button .material-icons {
    font-size: 22px;
}

.nav-brand, .nav-brand-no-hover {
    display: flex;
    align-items: center;
    height: 40px;
    position: relative;
    cursor: pointer;
    border-radius: 4px;
    padding: 4px 8px;
    transition: background-color 0.2s ease;
}

.nav-brand:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.nav-logo-container {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-logo-no-hover {
    height: 45px;
    width: auto;
    display: block;
}

.nav-logo {
    height: 45px;
    width: auto;
    display: block;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.nav-brand-text {
    margin-left: 12px;
    font-size: 18px;
    font-weight: 500;
    color: white;
    letter-spacing: 0.5px;
    transition: opacity 0.3s ease;
}

.nav-chevron {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    color: #fff;
    font-size: 28px;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.nav-brand:hover .nav-logo {
    opacity: 0;
    transform: scale(0.9);
}

.nav-brand:hover .nav-chevron {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.nav-metrics {
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.nav-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 140px;
}

.nav-metric-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    white-space: nowrap;
    text-align: center;
    width: 100%;
    display: block;
}

.nav-metric-value {
    font-size: 16px;
    color: white;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    line-height: 1.1;
    width: 100%;
    display: block;
}

.nav-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.results-summary-box {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--primary-light);
    border-radius: 4px;
    border-left: 4px solid var(--primary-color);
}

.flat-rate-summary {
    margin: 0;
    background: transparent;
    display: grid;
    gap: 12px;
}

.results-summary-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.results-summary-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.results-summary-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.results-summary-value.positive {
    color: var(--success-color);
}

.results-summary-value.negative {
    color: var(--error-color);
}

.nav-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background-color: transparent;
    color: inherit;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.nav-icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.summary .nav-icon-btn {
    color: #ffffff;
    width: 32px;
    height: 32px;
}

.summary .nav-icon-btn .material-icons {
    font-size: 20px;
}

.nav-calc-compact {
    display: none;
    width: 100%;
    justify-content: center;
    grid-column: span 2;
}

.nav-calc-small {
    margin: 0;
    padding: 8px 12px;
    min-width: 0;
}

.mc-summary-table {
    width: 100%;
    border-collapse: collapse;
}

.mc-summary-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-color);
}

.mc-summary-table td:first-child {
    color: var(--text-secondary);
    font-weight: 500;
    width: 55%;
}

.mc-summary-table td:last-child {
    font-weight: 600;
}

@media (max-width: 768px) {
    .mc-container {
        grid-template-columns: 1fr !important;
    }
}


.top-nav .mdc-button {
    background: var(--bg-card) !important;
    color: var(--primary-color) !important;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.top-nav .mdc-button:hover {
    background: var(--bg-secondary) !important;
    transform: translateY(-1px);
}

/* Toast styles */
.toast-container {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    min-width: 280px;
    max-width: 420px;
    background: #fff;
    color: #111;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 12px 16px;
    font-size: 14px;
    display: none;
}

.toast-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 200ms;
}

.toast-close:hover {
    opacity: 1;
}

body.dark-mode .toast {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.toast.show {
    display: block;
    animation: fadeIn 180ms ease-out;
}

.toast.loading {
    border-left: 4px solid var(--primary-color);
}

.toast.success {
    border-left: 4px solid #4caf50;
}

.toast.error {
    border-left: 4px solid #f44336;
}

body.dark-mode .toast.error {
    border-left-color: rgba(239, 83, 80, 0.8);
    background: rgba(211, 47, 47, 0.1);
}

.toast .validation-errors {
    margin: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile: show metrics, hide brand text */
@media (max-width: 768px) {
    .nav-brand-text {
        display: none !important;
    }
    .nav-metrics {
        display: flex !important;
        gap: 8px;
        flex-wrap: nowrap;
    }
    .nav-metric {
        min-width: auto;
        flex: 1;
    }
    .nav-metric-label {
        font-size: 0 !important;
        line-height: 0;
    }
    .nav-metric-label::before {
        content: attr(data-mobile);
        font-size: 8px;
        display: block;
        line-height: normal;
    }
    .nav-metric-value {
        font-size: 13px;
    }
}

/* Very small screens: ultra-compact metrics */
@media (max-width: 480px) {
    .nav-metrics {
        gap: 4px;
    }
    .nav-metric {
        min-width: 0;
    }
    .nav-metric-label::before {
        font-size: 7px;
        letter-spacing: 0.2px;
    }
    .nav-metric-value {
        font-size: 11px;
    }
}

@media (max-width: 1200px) {
    .top-nav {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        text-align: left;
        padding-left: 12px;
        padding-right: 12px;
    }
    .nav-left {
        justify-content: flex-start;
    }
    .nav-actions {
        justify-content: flex-end;
    }
    body {
        padding-top: 60px;
    }
    .nav-calc-compact {
        display: flex;
        grid-column: 1 / -1;
    }
}

/* Two-column layout */
.content-container {
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Shift right column when flyout is open so it does not sit under the floating panel */
.content-container.panel-flyout:not(.flyout-minimized) {
    padding-left: var(--flyout-width);
}

.left-column {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 8px;
    min-width: 0; /* allow grid item to shrink without causing overflow */
}

/* Input panel mode styles */
.content-container.panel-hidden .left-column {
    display: none;
}

.content-container.panel-hidden {
    grid-template-columns: 1fr;
}

.content-container.panel-flyout {
    grid-template-columns: 1fr;
}

.content-container.panel-flyout .left-column {
    position: fixed;
    left: 0;
    top: 91px;
    width: var(--flyout-width);
    height: calc(100vh - 91px);
    max-height: none;
    z-index: 100;
    background-color: var(--bg-tertiary);
    border-right: 1px solid var(--border-color);
    padding-right: 8px;
    padding-left: 8px;
    box-shadow: 2px 0 4px var(--shadow-md);
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Flyout-specific card and header adjustments */
.content-container.panel-flyout .left-column .mdc-card {
    margin-left: 0;
    margin-right: 0;
    padding: 12px;
}

.content-container.panel-flyout .left-column .section-title {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
    margin-bottom: 12px;
}

.content-container.panel-flyout .left-column h4 {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
}

.content-container.panel-flyout .right-column {
    /* Content takes full width, flyout floats on top */
}

/* Minimized flyout state */
.content-container.panel-flyout.flyout-minimized .left-column {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.content-container.panel-flyout.flyout-minimized .right-column {
    /* Content takes full width */
}

.inputs-control-bar {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    background-color: #0f2740;
    position: sticky;
    top: 0;
    z-index: 101;
}

.inputs-control-title {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: 500;
    color: white;
    letter-spacing: 0.5px;
    background-color: #0f2740
}

.inputs-mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 18px;
}

.inputs-mode-btn:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.inputs-mode-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.inputs-mode-btn .material-icons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Left-edge controls removed; header toggle replaces them */

.right-column {
    display: flex;
    flex-direction: column;
    min-width: 0; /* prevent content from forcing horizontal scroll */
    margin-top: -50px; /* reduce excessive top spacing below nav bar in desktop */
}

/* Responsive design */
@media (max-width: 1200px) {
    .content-container:not(.panel-hidden) {
        grid-template-columns: 1fr;
    }

    :root {
        --flyout-width: 280px;
    }
    
    /* Reset margin for medium screens to prevent overlap */
    .right-column {
        margin-top: 0;
        padding-top: 10px;
    }
}

@media (max-width: 768px) {
    .content-container.panel-flyout .left-column {
        width: 100vw;
        max-width: 100%;
        top: 80px;
        height: calc(100dvh - 80px);
        max-height: calc(100dvh - 80px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 2px 0 8px var(--shadow-lg);
    }

    /* On small screens let content span full width even when flyout is visible */
    .content-container.panel-flyout {
        padding-left: 0;
    }

    /* Hide right column when flyout is active and expanded on mobile */
    .content-container.panel-flyout:not(.flyout-minimized) .right-column {
        display: none;
    }

    .right-column {
        padding-top: 10px;
    }
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

body.dark-mode .modal-overlay {
    background: rgba(0,0,0,0.75);
}

.modal-overlay.show {
    display: flex;
}

.modal-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-width: 820px;
    width: 92%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
}

.modal-title {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--hover-overlay);
    border-radius: 50%;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    background: var(--bg-card);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: var(--bg-secondary);
}

/* Monte Carlo Modal Two-Column Layout */
#monteCarloModal .modal-body {
    max-height: 70vh;
}

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

    #inflationInputsRow {
        display: none;
    }

.file-upload-area {
    border: 2px dashed #bdbdbd;
    border-radius: 4px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.file-upload-area.dragover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.file-upload-icon {
    font-size: 48px;
    color: #bdbdbd;
    margin-bottom: 12px;
}

.file-upload-text {
    font-size: 14px;
    color: #616161;
    margin-bottom: 8px;
}

.file-upload-hint {
    font-size: 12px;
    color: #9e9e9e;
}

.error-list {
    background: #ffebee;
    border: 1px solid #f44336;
    border-radius: 4px;
    padding: 16px;
    margin-top: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.error-list h4 {
    margin: 0 0 12px 0;
    color: #f44336;
    font-size: 14px;
}

.error-list ul {
    margin: 0;
    padding-left: 20px;
}

.error-list li {
    font-size: 13px;
    color: #c62828;
    margin-bottom: 6px;
}

.success-message {
    background: #e8f5e9;
    border: 1px solid #4caf50;
    border-radius: 4px;
    padding: 16px;
    margin-top: 16px;
    color: #2e7d32;
    font-size: 14px;
}

.empty-state {
    background: var(--bg-card);
    border-radius: 4px;
    padding: 48px 32px;
    text-align: center;
    box-shadow: 0 2px 4px var(--shadow-sm);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.8;
}

.empty-state-title {
    font-size: 24px;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.empty-state-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
    max-width: 520px;
    margin: 0 auto;
}

.side-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 940;
}

.side-menu {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 280px;
    background: var(--bg-card);
    box-shadow: -4px 0 12px var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.2s ease, background 0.3s ease;
    z-index: 950;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.side-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.side-menu-sub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 0 16px;
    
    .full-padding {
        padding-bottom: 16px;
    }
}

.side-menu-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--primary-color);
}

.side-menu-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.side-menu-links {
    list-style: none;
    margin: 0;
    padding: 12px 0;
}

.side-menu-links li a {
    display: block;
    padding: 12px 20px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s ease;
}

.side-menu-links li a:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

.side-menu-separator {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

.dark-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    margin: 0;
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    user-select: none;
}

.dark-mode-toggle:hover {
    background: var(--primary-light);
}

.dark-mode-label {
    font-size: 14px;
}

.toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background-color: var(--border-color);
    border-radius: 12px;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch.active {
    background-color: var(--primary-color);
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px var(--shadow-sm);
}

.toggle-switch.active .toggle-slider {
    transform: translateX(24px);
}

body.menu-open .side-menu {
    transform: translateX(0);
}

body.menu-open .side-menu-backdrop {
    opacity: 1;
    pointer-events: auto;
}

/* Readability improvements for disabled/readonly inputs in dark mode */
body.dark-mode .input-group input[disabled],
body.dark-mode .input-group input[readonly],
body.dark-mode .input-group select[disabled] {
    background-color: #3a3a3a !important;
    color: var(--text-primary) !important;
    border-color: var(--border-strong) !important;
    opacity: 1 !important; /* ensure full text visibility */
    -webkit-text-fill-color: var(--text-primary) !important; /* Safari */
}

/* Affix labels should remain readable in dark mode */
body.dark-mode .affix-prefix,
body.dark-mode .affix-suffix {
    color: var(--text-muted);
}

/* Placeholder visibility in dark mode */
body.dark-mode .input-group input::placeholder,
body.dark-mode .input-group select::placeholder {
    color: var(--text-muted);
    opacity: 0.9;
}

/* Tooltip styles */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    margin-left: 6px;
    flex-shrink: 0;
    transition: all 0.2s ease;
    padding: 0;
    vertical-align: middle;
    align-self: center;
}

.tooltip-icon .material-icons {
    font-size: 16px;
    transition: all 0.2s ease;
    line-height: 1;
}

.tooltip-icon:hover {
    color: var(--primary-dark);
    transform: scale(1.1);
}

.tooltip-icon:hover .material-icons {
    transform: scale(1.1);
}

.tooltip-icon:active {
    transform: scale(0.95);
}

/* Custom Tippy.js theme */
.tippy-box[data-theme~='custom'] {
    background-color: var(--bg-tooltip, #333);
    color: var(--text-tooltip, white);
    border: 1px solid var(--border-tooltip, #555);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tippy-box[data-theme~='custom'][data-placement^='top'] > .tippy-arrow::before {
    border-top-color: var(--bg-tooltip, #333);
}

.tippy-box[data-theme~='custom'][data-placement^='bottom'] > .tippy-arrow::before {
    border-bottom-color: var(--bg-tooltip, #333);
}

.tippy-box[data-theme~='custom'][data-placement^='left'] > .tippy-arrow::before {
    border-left-color: var(--bg-tooltip, #333);
}

.tippy-box[data-theme~='custom'][data-placement^='right'] > .tippy-arrow::before {
    border-right-color: var(--bg-tooltip, #333);
}

/* Dark mode tooltip adjustments */
body.dark-mode .tippy-box[data-theme~='custom'] {
    background-color: var(--bg-tooltip, #2d2d2d);
    color: var(--text-tooltip, #e0e0e0);
    border-color: var(--border-tooltip, #444);
}

body.dark-mode .tippy-box[data-theme~='custom'][data-placement^='top'] > .tippy-arrow::before {
    border-top-color: var(--bg-tooltip, #2d2d2d);
}

body.dark-mode .tippy-box[data-theme~='custom'][data-placement^='bottom'] > .tippy-arrow::before {
    border-bottom-color: var(--bg-tooltip, #2d2d2d);
}

body.dark-mode .tippy-box[data-theme~='custom'][data-placement^='left'] > .tippy-arrow::before {
    border-left-color: var(--bg-tooltip, #2d2d2d);
}

body.dark-mode .tippy-box[data-theme~='custom'][data-placement^='right'] > .tippy-arrow::before {
    border-right-color: var(--bg-tooltip, #2d2d2d);
}

/* Light mode tooltip adjustments */
body:not(.dark-mode) .tippy-box[data-theme~='custom'] {
    background-color: var(--bg-tooltip, #1a1a1a);
    color: var(--text-tooltip, white);
    border-color: var(--border-tooltip, #333);
}

body:not(.dark-mode) .tippy-box[data-theme~='custom'][data-placement^='top'] > .tippy-arrow::before {
    border-top-color: var(--bg-tooltip, #1a1a1a);
}

body:not(.dark-mode) .tippy-box[data-theme~='custom'][data-placement^='bottom'] > .tippy-arrow::before {
    border-bottom-color: var(--bg-tooltip, #1a1a1a);
}

body:not(.dark-mode) .tippy-box[data-theme~='custom'][data-placement^='left'] > .tippy-arrow::before {
    border-left-color: var(--bg-tooltip, #1a1a1a);
}

body:not(.dark-mode) .tippy-box[data-theme~='custom'][data-placement^='right'] > .tippy-arrow::before {
    border-right-color: var(--bg-tooltip, #1a1a1a);
}

/* Withdrawal Order List Styles */
.withdrawal-order-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.withdrawal-order-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: move;
    transition: all 0.2s;
    user-select: none;
}

.withdrawal-order-item:hover {
    background: var(--hover-overlay);
    box-shadow: 0 2px 4px var(--shadow-sm);
}

.withdrawal-order-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.withdrawal-order-item.drag-over {
    border-color: var(--primary-color);
    border-width: 2px;
    background: var(--primary-light);
}

.withdrawal-item-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.withdrawal-item-drag-icon {
    color: var(--text-secondary);
    font-size: 20px;
    cursor: grab;
}

.withdrawal-item-position {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
}

.withdrawal-item-name {
    flex: 1;
}

/* Ensure column header row maintains consistent styling */
thead tr.column-header-row th {
    background: var(--table-header-bg);
    color: var(--table-header-text);
    padding: 12px 8px;
    font-weight: 600;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

/* ======================================
   Column Manager Styles
   ====================================== */

.column-manager-instructions {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.column-manager-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 0;
}

.column-manager-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: grab;
    transition: all 0.2s ease;
    user-select: none;
}

.column-manager-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.column-manager-item.dragging {
    opacity: 0.5;
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.column-manager-item.drag-over {
    background: var(--primary-light);
    border: 2px dashed var(--primary-color);
    padding: 11px;
}

.column-drag-handle {
    color: var(--text-secondary);
    font-size: 20px;
    cursor: grab;
    flex-shrink: 0;
}

.column-drag-handle:active {
    cursor: grabbing;
}

.column-visibility-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--primary-color);
}

.column-label {
    flex: 1;
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 500;
    margin: 0;
}

.column-manager-item:hover .column-label {
    color: var(--primary-color);
}