/* --- Calculator Specific Styles --- */
#app-version {
    font-size: 11px;
    color: #b0b0b0;
    margin-top: -10px;
    margin-bottom: 20px;
    font-family: monospace;
    opacity: 0.8;
}

.calc-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.03);
    padding: 30px;
    transition: transform 0.2s;
}

/* Custom Switch Color Match */
.custom-control-input:checked~.custom-control-label::before {
    border-color: #7c7469;
    background-color: #7c7469;
}

.custom-switch .custom-control-label::before {
    cursor: pointer;
}

/* Form Styles */
.form-group label {
    font-weight: 700;
    font-size: 0.8rem;
    color: #212529;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.form-text {
    font-size: 0.75rem;
    color: #868e96;
    margin-top: 4px;
    line-height: 1.3;
}

.form-control {
    border-radius: 8px;
    border: 1px solid #ced4da;
    padding: 10px 15px;
    font-weight: 500;
    color: #495057;
}

.form-control:focus {
    border-color: #f7931a;
    box-shadow: 0 0 0 0.2rem rgba(247, 147, 26, 0.25);
}

.input-group-text {
    background-color: #f8f9fa;
    border-color: #ced4da;
    color: #6c757d;
    font-weight: 600;
}

.btn-group-toggle .btn {
    border-radius: 50px !important;
    margin: 0 5px;
    border: 1px solid #dee2e6;
    color: #6c757d;
    font-weight: 600;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-group-toggle .btn.active {
    background-color: #f7931a !important;
    color: #fff !important;
    border-color: #f7931a !important;
}

.result-box {
    background-color: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 5px solid #ced4da;
    transition: transform 0.2s, box-shadow 0.2s;
}

.result-box.success {
    border-left-color: #198754;
    background-color: #d1e7dd;
}

.result-box.warning {
    border-left-color: #f7931a;
    background-color: #fff3cd;
}

.result-box.danger {
    border-left-color: #dc3545;
    background-color: #f8d7da;
}

.interactive-result {
    cursor: pointer;
    position: relative;
}

.interactive-result:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}


.result-box.interactive-result {
    padding-top: 18px;
}

.result-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    font-weight: 700;
    margin-bottom: 5px;
}

.result-value {
    font-family: 'Inter', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: #212529;
    line-height: 1.1;
}

.result-sub {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 8px;
    font-weight: 500;
}

input[type=range]::-webkit-slider-thumb {
    background: #f7931a;
}

input[type=range]::-moz-range-thumb {
    background: #f7931a;
}

/* --- Utility Classes (extracted from inline styles) --- */
.privacy-notice {
    font-size: 0.7rem;
    color: #adb5bd;
    margin-top: -8px;
}

.container-calc {
    max-width: 1200px;
}

.color-dark {
    color: #212529;
}

.color-danger {
    color: #dc3545;
}

.color-success {
    color: #28a745;
}

.color-btc {
    color: #f7931a;
}

.color-blue {
    color: #007bff;
}

.strategy-guide {
    background-color: #f8f9fa;
    border-top: 4px solid #f7931a;
    border-radius: 8px;
    padding: 40px;
    margin-top: 40px;
}

.guide-title {
    font-weight: 800;
    color: #212529;
    margin-bottom: 20px;
}

.guide-card {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    height: 100%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    cursor: pointer;
    transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
    border: 1px solid transparent;
    position: relative;
}

.guide-card:hover {
    transform: translateY(-5px);
    border-color: #f7931a;
    box-shadow: 0 8px 20px rgba(247, 147, 26, 0.15);
}


.guide-icon {
    color: #f7931a;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.chart-container {
    position: relative;
    height: 450px;
    width: 100%;
    margin-top: 15px;
}

.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    border-bottom: 1px solid #f1f3f5;
    padding: 25px 30px;
    background-color: #e9ecef;
    border-radius: 16px 16px 0 0;
}

.modal-title {
    font-weight: 800;
    color: #212529;
}

.modal-body {
    padding: 30px;
    font-size: 1rem;
    line-height: 1.7;
    color: #495057;
}

.modal-footer {
    border-top: none;
    padding: 20px 30px;
}

.formula-box {
    background-color: #f8f9fa;
    border-left: 4px solid #f7931a;
    padding: 15px;
    font-family: 'Courier New', monospace;
    margin: 20px 0;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #333;
}

.chart-legend-dot {
    height: 12px;
    width: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

/* --- Multi-Asset Allocation Table --- */
.allocation-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.allocation-table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    font-weight: 700;
    padding: 6px 8px;
    border-bottom: 2px solid #dee2e6;
}

.allocation-table td {
    padding: 8px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f3f5;
    font-size: 0.85rem;
}

.allocation-table .asset-label {
    font-weight: 700;
    color: #212529;
    white-space: nowrap;
}

.allocation-table .asset-label i {
    width: 20px;
    text-align: center;
    margin-right: 6px;
}

.allocation-table .alloc-input {
    width: 65px;
    text-align: center;
    border-radius: 6px;
    border: 1px solid #ced4da;
    padding: 4px 6px;
    font-weight: 600;
    font-size: 0.85rem;
}

.allocation-table .alloc-input:focus {
    border-color: #f7931a;
    box-shadow: 0 0 0 0.15rem rgba(247, 147, 26, 0.25);
    outline: none;
}

.allocation-table .current-value {
    font-weight: 600;
    color: #495057;
    text-align: right;
    white-space: nowrap;
}

.allocation-table tfoot td {
    border-top: 2px solid #dee2e6;
    border-bottom: none;
    font-weight: 800;
    padding-top: 10px;
}

.allocation-total-ok {
    color: #198754;
}

.allocation-total-err {
    color: #dc3545;
}

.allocation-warning {
    color: #dc3545;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 8px;
    display: none;
}

.allocation-warning i {
    margin-right: 4px;
}

/* Run Simulation Button */
#runSimBtn {
    background-color: #f7931a;
    border: none;
    font-size: 1.1rem;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.15s ease,
        background-color 0.15s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

#runSimBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(247, 147, 26, 0.4);
    background-color: #e8860f;
}

#runSimBtn:active:not(:disabled) {
    transform: scale(0.95) translateY(1px);
    box-shadow: 0 2px 6px rgba(247, 147, 26, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.15);
    background-color: #d47a0a;
    transition-duration: 0.06s;
}

#runSimBtn:disabled {
    cursor: not-allowed;
}

/* === FI Snapshot Card === */
.fi-snapshot {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
    margin-top: 0.5rem;
}

.fi-snapshot-accent {
    height: 3px;
    background: linear-gradient(90deg, #f7931a 0%, #f7931a 40%, rgba(247, 147, 26, 0.15) 100%);
}

.fi-snapshot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px 8px;
}

.fi-snapshot-header .snap-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #212529;
    font-weight: 700;
}

.fi-snapshot-header .snap-title i {
    margin-right: 6px;
    color: #f7931a;
}

.fi-snapshot-header .snap-date {
    font-size: 0.7rem;
    color: #212529;
    font-weight: 500;
}

.fi-snapshot-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 0 16px;
}

.fi-snapshot-cell {
    background: #f8f9fa;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-radius: 10px;
}

.fi-snapshot-cell .cell-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #868e96;
    font-weight: 700;
    margin-bottom: 4px;
}

.fi-snapshot-cell .cell-hero {
    font-size: 1.5rem;
    font-weight: 800;
    color: #212529;
    line-height: 1.1;
    font-family: 'Inter', sans-serif;
}

.fi-snapshot-cell .cell-sub {
    font-size: 0.75rem;
    font-weight: 600;
    color: #495057;
    line-height: 1.3;
}

.fi-snapshot-cell .cell-detail {
    font-size: 0.65rem;
    color: #868e96;
    font-weight: 500;
    line-height: 1.4;
}

.fi-snapshot-bottom {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 10px 16px 0;
}

.fi-snapshot-bottom .fi-bottom-cell {
    background: #f8f9fa;
    padding: 12px 18px;
    border-radius: 10px;
}

.fi-snapshot-bottom .fi-bottom-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #868e96;
    font-weight: 700;
    margin-bottom: 2px;
}

.fi-snapshot-bottom .fi-bottom-value {
    font-size: 1rem;
    font-weight: 700;
    color: #212529;
    font-family: 'Inter', sans-serif;
}

.fi-snapshot-bottom .fi-bottom-sub {
    font-size: 0.6rem;
    color: #868e96;
    font-weight: 500;
}

/* Allocation Row */
.fi-snapshot-alloc {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 10px 16px 0;
}

.fi-alloc-col {
    background: #f8f9fa;
    padding: 12px 18px;
    position: relative;
    border-radius: 10px;
}

.fi-alloc-col .alloc-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #868e96;
    font-weight: 700;
    margin-bottom: 8px;
}

.fi-alloc-bar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
    background: #e9ecef;
}

.fi-alloc-bar .bar-seg {
    height: 100%;
    transition: width 0.4s ease;
}

.fi-alloc-items {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.fi-alloc-item {
    display: flex;
    align-items: center;
    font-size: 0.62rem;
    font-weight: 600;
    color: #495057;
    gap: 6px;
}

.fi-alloc-item .alloc-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fi-alloc-item .alloc-pct {
    margin-left: auto;
    font-weight: 700;
    color: #212529;
    min-width: 30px;
    text-align: right;
}

.fi-alloc-item .alloc-val {
    color: #868e96;
    font-weight: 500;
    min-width: 55px;
    text-align: right;
}

.fi-snapshot-footer {
    text-align: center;
    padding: 10px 16px 14px;
    font-size: 0.6rem;
    color: #adb5bd;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.fi-snapshot-footer a {
    color: #f7931a;
    text-decoration: none;
    font-weight: 600;
}

/* Parameters Strip */
.fi-snapshot-params {
    margin: 10px 16px 0;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px 16px;
    position: relative;
}

.fi-params-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #868e96;
    font-weight: 700;
    margin-bottom: 8px;
}

.fi-params-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fi-param-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6rem;
    font-weight: 600;
    color: #495057;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 3px 8px;
    white-space: nowrap;
}

.fi-param-tag .param-key {
    color: #868e96;
    font-weight: 500;
}

.fi-param-tag .param-val {
    color: #212529;
    font-weight: 700;
}

/* === Mobile Responsive === */

@media (max-width: 768px) {

    /* Hide Save as Image button on mobile (html2canvas unreliable on iOS) */
    .fi-snapshot-footer button {
        display: none !important;
    }

    /* Page header */
    .container>.text-center h1 {
        font-size: 1.4rem;
    }

    .container>.text-center p {
        font-size: 0.85rem;
    }

    /* Strategy Inputs Card */
    .calc-card {
        padding: 20px 15px !important;
    }

    .calc-card .form-group label {
        font-size: 0.8rem;
    }

    .calc-card .form-control {
        font-size: 0.9rem;
    }

    /* Make the basic input rows full-width on small screens */
    .calc-card .row>.col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Allocation table */
    .allocation-table th {
        font-size: 0.65rem;
        padding: 5px 4px;
    }

    .allocation-table td {
        padding: 6px 4px;
        font-size: 0.8rem;
    }

    .allocation-table .alloc-input {
        width: 52px;
        font-size: 0.8rem;
        padding: 3px 4px;
    }

    .allocation-table .current-value {
        font-size: 0.75rem;
    }

    .allocation-table .asset-label {
        font-size: 0.8rem;
    }

    .allocation-table .asset-label i {
        width: 16px;
        margin-right: 4px;
        font-size: 0.75rem;
    }

    /* Results section */
    .result-box {
        padding: 12px !important;
    }

    .result-box .result-value {
        font-size: 1.3rem !important;
    }

    /* FI Snapshot */
    .fi-snapshot-grid {
        grid-template-columns: 1fr !important;
    }

    .fi-snapshot-cell .cell-hero {
        font-size: 1.3rem !important;
    }

    .fi-snapshot-bottom {
        grid-template-columns: 1fr !important;
    }

    .fi-snapshot-alloc {
        grid-template-columns: 1fr !important;
    }

    /* Chart */
    .chart-container,
    [style*="height: 500px"] {
        height: 320px !important;
        min-height: 280px;
    }

    /* Guide section. Horizontal padding must match Bootstrap's .row
       negative margin (12px) or its .row children bleed past the
       viewport edge by the difference (#122). */
    .strategy-guide {
        padding: 30px 12px !important;
    }

    .guide-card {
        padding: 15px !important;
    }

    .guide-title {
        font-size: 1.3rem;
    }

    .guide-icon {
        font-size: 2rem !important;
    }

    .col-md-4 {
        padding-left: 5px;
        padding-right: 5px;
    }

    /* Advanced Settings Modal - full-width on mobile */
    #advancedSettingsModal .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    #advancedSettingsModal .modal-body {
        padding: 16px !important;
    }

    #advancedSettingsModal .modal-header {
        padding: 14px 16px;
    }

    #advancedSettingsModal .modal-header h5 {
        font-size: 1rem;
    }

    #advancedSettingsModal .modal-body h6 {
        font-size: 0.72rem;
    }

    #advancedSettingsModal .modal-body .row>.col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    #advancedSettingsModal .modal-body .form-group label {
        font-size: 0.75rem;
    }

    #advancedSettingsModal .modal-body .form-text {
        font-size: 0.68rem;
    }

    #advancedSettingsModal .modal-footer {
        padding: 10px 16px;
    }

    #advancedSettingsModal .modal-footer small {
        font-size: 0.7rem;
    }

    /* Strategy modal */
    #strategyModal .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }

    #strategyModal .modal-body {
        padding: 20px 16px;
        font-size: 0.9rem;
    }
}

/* Very small screens (phones in portrait) */
@media (max-width: 420px) {
    .container>.text-center h1 {
        font-size: 1.15rem;
    }

    .allocation-table .alloc-input {
        width: 46px;
        font-size: 0.75rem;
    }

    .allocation-table .current-value {
        font-size: 0.7rem;
    }

    .allocation-table .asset-label {
        font-size: 0.75rem;
    }

    /* Stack advanced settings inputs vertically on very small screens */
    #advancedSettingsModal .modal-body .row>.col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .chart-container,
    [style*="height: 500px"] {
        height: 260px !important;
    }

    .guide-card h5 {
        font-size: 0.95rem;
    }

    .guide-card p {
        font-size: 0.75rem !important;
    }
}

/* --- Sensitivity Analysis --- */
.scenario-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.scenario-col {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px 14px;
    text-align: center;
    border-top: 4px solid #dee2e6;
    transition: background 0.3s ease;
}

.scenario-col.highlight-funded {
    background: rgba(40, 167, 69, 0.06);
}

.scenario-col.highlight-gap {
    background: rgba(220, 53, 69, 0.05);
}

.scenario-col.bear {
    border-top-color: #dc3545;
}

.scenario-col.base {
    border-top-color: #f7931a;
}

.scenario-col.trend {
    border-top-color: #28a745;
}

.scenario-col.bull {
    border-top-color: #007bff;
}

.scenario-col .scenario-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.scenario-col.bear .scenario-label {
    color: #dc3545;
}

.scenario-col.base .scenario-label {
    color: #f7931a;
}

.scenario-col.trend .scenario-label {
    color: #28a745;
}

.scenario-col.bull .scenario-label {
    color: #007bff;
}

.scenario-col .scenario-sub {
    font-size: 0.65rem;
    color: #868e96;
    margin-bottom: 10px;
}

.scenario-metric {
    margin-bottom: 8px;
}

.scenario-metric .metric-label {
    font-size: 0.65rem;
    color: #868e96;
    margin-bottom: 1px;
}

.scenario-metric .metric-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: #212529;
}

.scenario-status {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    margin-top: 4px;
}

.scenario-status.funded {
    background: rgba(40, 167, 69, 0.12);
    color: #198754;
}

.scenario-status.gap {
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
}

/* --- Monte Carlo Results --- */
.mc-results-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #dee2e6;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.mc-probability {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
}

.mc-probability-label {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 4px;
}

.mc-percentile-table {
    width: 100%;
    font-size: 0.8rem;
    margin-top: 12px;
}

.mc-percentile-table th {
    color: #868e96;
    font-weight: 600;
    padding: 6px 0;
    border-bottom: 1px solid #dee2e6;
}

.mc-percentile-table td {
    padding: 6px 0;
    font-weight: 700;
    color: #212529;
}

.mc-note {
    font-size: 0.7rem;
    color: #adb5bd;
    margin-top: 12px;
}

@media (max-width: 768px) {
    .scenario-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .mc-probability {
        font-size: 2.2rem;
    }
}

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

/* Phones in landscape are wide but short: the portrait heights above
   (450px, and the 320px/260px overrides) are taller than the whole
   viewport, forcing the page to scroll past the chart (#122). */
@media (orientation: landscape) and (max-height: 500px) {
    .chart-container,
    [style*="height: 500px"] {
        height: 220px !important;
        min-height: 180px;
    }
}