/* ==========================================================================
   Mortgage Calculator - page-specific styles
   (Layout, inputs, result cards, and the Guide/FAQ accordions come from the
   global design system; only genuinely unique pieces live here: the charts,
   donut legend, and the amortization table.)
   ========================================================================== */

#calculation-formula-breakdown {
    white-space: pre-line;
}

/* Mode selector: segmented tab control */
.mode-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}
.mode-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.7rem 0.4rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
}
.mode-tab svg { width: 20px; height: 20px; }
.mode-tab:hover {
    border-color: var(--color-primary);
    color: var(--color-secondary);
}
.mode-tab.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 12px -4px var(--color-primary);
}
.mode-desc {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin: 0 0 1.5rem;
    line-height: 1.45;
}

/* Loan A / Loan B section tags in compare mode */
.loan-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-primary);
    background: var(--color-primary-light);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.7rem;
    margin-bottom: 0.6rem;
}
.loan-tag-b {
    color: #b26a1f;
    background: rgba(224, 128, 60, 0.14);
}

/* Compare mode: two symmetric loan cards */
.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}
.compare-loan {
    border: 1px solid var(--color-border);
    border-top-width: 3px;
    border-radius: var(--radius-md);
    padding: 0.9rem;
}
.compare-loan-a { border-top-color: var(--color-primary); }
.compare-loan-b { border-top-color: #e0803c; }
.compare-loan .stripe-form-field { margin-bottom: 0.7rem; }
.compare-loan .stripe-form-field:last-child { margin-bottom: 0; }
.compare-loan .loan-tag { margin-bottom: 0.75rem; }

@media (max-width: 560px) {
    .mode-tabs { grid-template-columns: repeat(2, 1fr); }
    .compare-grid { grid-template-columns: 1fr; }
}

/* Donut legend */
.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--color-border);
}
.donut-legend-item:last-child { border-bottom: none; }
.donut-swatch {
    width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
}
.donut-legend-label { flex: 1; color: var(--color-text-muted); }
.donut-legend-value { font-weight: 700; color: var(--color-secondary); }

/* Balance chart legend */
.chart-legend {
    display: flex; gap: 1.25rem; flex-wrap: wrap;
    margin-top: 0.5rem; font-size: 0.8rem; color: var(--color-text-muted);
}
.chart-legend .chart-swatch {
    display: inline-block; width: 12px; height: 3px; border-radius: 2px;
    margin-right: 0.35rem; vertical-align: middle;
}

/* Amortization + comparison tables */
.amort-table th {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--color-text-muted); font-weight: 700;
    padding: 0.5rem 0.4rem; border-bottom: 2px solid var(--color-border);
}
.amort-table td {
    padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--color-border);
    color: var(--color-secondary);
}
.amort-table tbody tr:hover { background: var(--color-bg-subtle); }
.amort-table .scenario-active { background: var(--color-bg-subtle); font-weight: 700; }

.cmp-table td:first-child { color: var(--color-text-muted); }
.cmp-table td { font-weight: 600; }

/* Scrollable amortization area so 360 rows don't dominate the page */
.amort-scroll { max-height: 460px; overflow-y: auto; }

/* Yearly/Monthly toggle */
.amort-toggle {
    display: inline-flex; border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); overflow: hidden;
}
.amort-toggle button {
    background: transparent; border: none; cursor: pointer;
    padding: 0.4rem 0.75rem; font-size: 0.8rem; font-weight: 600;
    color: var(--color-text-muted);
}
.amort-toggle button.active {
    background: var(--color-primary); color: #fff;
}

#donut-chart svg { display: block; }
