.mf-back-link {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 6px;
    transition: color 0.15s var(--ease);
}

.mf-back-link:hover {
    color: var(--accent);
}

/* Step 1: view tabs + category/sector chips */

.mf-category-row {
    margin-top: 12px;
}

.mf-category-row .period-chip .mf-chip-count {
    opacity: 0.7;
    font-weight: 500;
    margin-left: 4px;
}

/* Step 3: fund picker */

.mf-selected-counter {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-2);
    border-radius: var(--radius-full);
    padding: 4px 12px;
}

.mf-selected-counter.at-cap {
    color: var(--accent-dim);
    background: var(--accent-soft);
}

.mf-sort-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.mf-sort-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 2px;
}

.mf-selected-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.mf-selected-chips:empty {
    display: none;
}

.mf-selected-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    color: var(--accent-dim);
    border-radius: var(--radius-full);
    padding: 5px 8px 5px 12px;
    font-size: 13px;
    font-weight: 600;
}

.mf-selected-chip .mf-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.mf-selected-chip button {
    background: transparent;
    color: var(--accent-dim);
    border: none;
    padding: 0 2px;
    font-size: 15px;
    line-height: 1;
    border-radius: var(--radius-full);
}

.mf-selected-chip button:hover {
    background: var(--accent-border);
    box-shadow: none;
}

.mf-scheme-list {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.mf-scheme-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s var(--ease);
}

.mf-scheme-row:last-child {
    border-bottom: none;
}

.mf-scheme-row:hover {
    background: var(--bg-2);
}

.mf-scheme-row.selected {
    background: var(--accent-soft);
}

.mf-scheme-row.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.mf-scheme-row input[type="checkbox"] {
    flex-shrink: 0;
    width: 17px;
    height: 17px;
    accent-color: var(--accent);
    cursor: inherit;
}

.mf-scheme-main {
    flex: 1;
    min-width: 0;
}

.mf-scheme-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mf-scheme-sub {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
}

.mf-scheme-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 1px 7px;
    flex-shrink: 0;
}

.mf-scheme-metrics {
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.mf-scheme-return {
    font-size: 13.5px;
    font-weight: 700;
}

.mf-scheme-nav {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Step 4: chart */

.mf-chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.mf-chart-wrapper {
    height: 320px;
}

.mf-chart-wrapper canvas {
    /* The JS sets width/height ATTRIBUTES to size*devicePixelRatio for crisp
       rendering on retina screens — without forcing the CSS display size back
       down to 100%/100% here, the browser renders the canvas at that raw
       buffer size instead of scaling it to fit the card, blowing up the
       layout (see the same note on .snapshot-chart-wrapper canvas in
       markets.css). */
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.mf-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.mf-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.mf-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.mf-legend-label {
    color: var(--text-muted);
    font-weight: 500;
}

.mf-legend-return {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.mf-chart-note {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.mf-tt-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    margin-top: 3px;
}

.mf-tt-row .mf-chip-dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.mf-tt-row .mf-tt-name {
    font-weight: 500;
    color: var(--text-muted);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Comparison table — funds as columns, metrics as rows. First column
   (metric label) is sticky so it stays readable while the fund columns
   scroll horizontally on narrow screens.

   Deliberately NOT table-layout:fixed: combined with .holdings-table's
   width:100%, a fixed layout keeps the table pinned to its container's
   width on any screen — including mobile — so instead of growing wider
   than the viewport and letting .table-wrapper's overflow-x:auto scroll
   it (like every other table in this app), it squished all 6 columns
   into ~360px, ignoring min-width (fixed-layout tables mostly ignore it).
   Auto layout + .holdings-table's inherited white-space:nowrap sizes
   columns to content and overflows properly instead. */

.mf-compare-table th,
.mf-compare-table td {
    min-width: 150px;
    text-align: right;
}

.mf-compare-table th:first-child,
.mf-compare-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    text-align: left;
    min-width: 170px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.mf-compare-table thead th:first-child {
    background: var(--bg-2);
    z-index: 2;
}

.mf-compare-table .mf-fund-header {
    text-align: right;
    vertical-align: top;
    padding-top: 14px;
    padding-bottom: 14px;
}

.mf-compare-table .mf-fund-header-name {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text);
    white-space: normal;
    line-height: 1.3;
}

.mf-compare-table .mf-fund-header-sub {
    margin-top: 4px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: normal;
}

.mf-compare-table .mf-group-row td {
    background: var(--bg-2);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding-top: 8px;
    padding-bottom: 8px;
}

.mf-compare-table .mf-group-row td:first-child {
    background: var(--bg-2);
}

.mf-compare-table .mf-metric-label {
    font-weight: 600;
    color: var(--text);
}

.mf-compare-table .mf-metric-hint {
    display: block;
    font-weight: 500;
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 1px;
}

/* Narrow phones only: reflow the 1Y return/NAV onto their own line under
   the fund name instead of squeezing it into the row (was previously
   `display: none` here, which hid the 1Y return on every phone — wrong;
   it should stay visible, just not fight the fund name for width). */
@media (max-width: 480px) {
    .mf-scheme-row {
        flex-wrap: wrap;
    }

    .mf-scheme-metrics {
        flex-basis: 100%;
        text-align: left;
        margin-left: 29px; /* aligns under the fund name, past the checkbox + gap */
    }

    .mf-scheme-nav,
    .mf-scheme-return {
        display: inline-block;
    }

    .mf-scheme-nav {
        margin-left: 10px;
    }
}
