/* ═══════════════════════════════════════════════════
   REFINANCE CALCULATOR — Scoped Styles (.rfc-*)
   All selectors prefixed with .rfc- to avoid conflicts
═══════════════════════════════════════════════════ */

/* ── Layout: two-column inputs ── */
.rfc-widget {
    font-family: inherit;
}

.rfc-widget-heading {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--clr-text-primary);
    margin: 0 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--clr-border);
}

/* Loan panels side-by-side */
.rfc-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 700px) {
    .rfc-panels { grid-template-columns: 1fr; }
}

.rfc-panel {
    background: var(--clr-bg-soft);
    border: 1.5px solid var(--clr-border);
    border-radius: 10px;
    padding: 1rem 1rem 0.75rem;
}

.rfc-panel-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
    margin: 0 0 0.85rem;
}

.rfc-panel--current .rfc-panel-title {
    color: var(--clr-text-muted);
}

.rfc-panel--new .rfc-panel-title {
    color: var(--clr-accent-dark);
}

.rfc-panel--new {
    border-color: var(--clr-accent);
    background: var(--clr-accent-light);
}

/* Input groups inside panels */
.rfc-input-group {
    margin-bottom: 0.75rem;
}

.rfc-input-group:last-child {
    margin-bottom: 0;
}

.rfc-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--clr-text-secondary);
    margin-bottom: 0.3rem;
}

.rfc-label-hint {
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--clr-text-muted);
}

.rfc-input-wrap {
    display: flex;
    align-items: center;
    background: var(--clr-bg);
    border: 1.5px solid var(--clr-border);
    border-radius: 7px;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.rfc-input-wrap:focus-within {
    border-color: var(--clr-accent);
    box-shadow: var(--shadow-focus);
}

.rfc-prefix,
.rfc-suffix {
    padding: 0 0.55rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--clr-text-muted);
    background: var(--clr-bg-muted);
    align-self: stretch;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--clr-border);
    flex-shrink: 0;
}

.rfc-suffix {
    border-right: none;
    border-left: 1px solid var(--clr-border);
}

.rfc-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 0.42rem 0.6rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--clr-text-primary);
    min-width: 0;
    width: 100%;
}

.rfc-input::-webkit-inner-spin-button,
.rfc-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.rfc-input[type=number] { -moz-appearance: textfield; }

/* Closing costs row — spans full width */
.rfc-closing-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: end;
}

@media (max-width: 500px) {
    .rfc-closing-row { grid-template-columns: 1fr; }
}

/* Clear button */
.rfc-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.4rem;
    border: 1.5px solid var(--clr-border);
    border-radius: 8px;
    background: var(--clr-bg);
    color: var(--clr-text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.rfc-clear-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}

/* ── Results ── */
.rfc-results {
    margin-top: 1.25rem;
}

.rfc-results-heading {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
    margin: 0 0 0.85rem;
}

/* Primary stat cards row */
.rfc-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.65rem;
    margin-bottom: 1rem;
}

@media (max-width: 900px) {
    .rfc-stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
    .rfc-stat-grid { grid-template-columns: 1fr 1fr; }
}

.rfc-stat-card {
    background: var(--clr-bg-soft);
    border: 1.5px solid var(--clr-border);
    border-radius: 9px;
    padding: 0.8rem 0.85rem 0.75rem;
    text-align: center;
    transition: border-color 0.15s;
}

.rfc-stat-card--primary {
    background: var(--clr-accent);
    border-color: var(--clr-accent);
    color: #fff;
}

.rfc-stat-card--savings {
    background: #f0fdf4;
    border-color: var(--clr-green);
}

.rfc-stat-card--warning {
    background: var(--clr-warning-bg);
    border-color: var(--clr-warning-brd);
}

.rfc-stat-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
    margin-bottom: 0.3rem;
}

.rfc-stat-card--primary .rfc-stat-label { color: rgba(255,255,255,0.8); }
.rfc-stat-card--savings  .rfc-stat-label { color: #15803d; }
.rfc-stat-card--warning  .rfc-stat-label { color: var(--clr-warning-text); }

.rfc-stat-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--clr-text-primary);
    line-height: 1.1;
}

.rfc-stat-card--primary .rfc-stat-value { color: #fff; }
.rfc-stat-card--savings  .rfc-stat-value { color: #15803d; }
.rfc-stat-card--warning  .rfc-stat-value { color: var(--clr-warning-text); }

.rfc-stat-sub {
    display: block;
    font-size: 0.68rem;
    color: var(--clr-text-muted);
    margin-top: 0.2rem;
}

.rfc-stat-card--primary .rfc-stat-sub { color: rgba(255,255,255,0.7); }
.rfc-stat-card--savings  .rfc-stat-sub { color: #16a34a; }

/* ── Comparison table ── */
.rfc-comparison {
    background: var(--clr-bg-soft);
    border: 1.5px solid var(--clr-border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.rfc-comparison-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
    padding: 0.7rem 1rem 0.6rem;
    border-bottom: 1px solid var(--clr-border);
    background: var(--clr-bg-muted);
}

.rfc-comp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.rfc-comp-table thead th {
    padding: 0.5rem 0.9rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
    background: var(--clr-bg-muted);
    border-bottom: 1px solid var(--clr-border);
}

.rfc-comp-table thead th:not(:first-child) { text-align: right; }

.rfc-comp-table tbody td {
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--clr-border-soft);
    color: var(--clr-text-secondary);
}

.rfc-comp-table tbody tr:last-child td { border-bottom: none; }

.rfc-comp-table tbody td:not(:first-child) {
    text-align: right;
    font-weight: 600;
    color: var(--clr-text-primary);
    font-variant-numeric: tabular-nums;
}

.rfc-comp-table .rfc-td-savings {
    color: var(--clr-green) !important;
    font-weight: 700 !important;
}

.rfc-comp-table .rfc-td-loss {
    color: #ef4444 !important;
    font-weight: 700 !important;
}

/* ── Charts row ── */
.rfc-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

@media (max-width: 640px) {
    .rfc-charts-row { grid-template-columns: 1fr; }
}

.rfc-chart-card {
    background: var(--clr-bg-soft);
    border: 1.5px solid var(--clr-border);
    border-radius: 10px;
    padding: 0.85rem 1rem 0.75rem;
width: 300px;
}

.rfc-chart-title {
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
    margin-bottom: 0.7rem;
}

.rfc-chart-canvas {
    width: 100%;
    display: block;
}

/* ── Break-even timeline ── */
.rfc-breakeven-bar-wrap {
    margin-bottom: 0;
}

.rfc-be-track {
    height: 10px;
    background: var(--clr-bg-muted);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
    margin-bottom: 0.45rem;
}

.rfc-be-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--clr-accent), var(--clr-green));
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
    min-width: 4px;
}

.rfc-be-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--clr-text-muted);
}

/* ── Verdict banner ── */
.rfc-verdict {
    border-radius: 9px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--clr-text-primary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
    line-height: 1.45;
}

.rfc-verdict--good {
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    color: #15803d;
}

.rfc-verdict--caution {
    background: var(--clr-warning-bg);
    border: 1.5px solid var(--clr-warning-brd);
    color: var(--clr-warning-text);
}

.rfc-verdict--bad {
    background: #fef2f2;
    border: 1.5px solid #fecaca;
    color: #b91c1c;
}

.rfc-verdict-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Amortisation table */
.rfc-amort-wrap {
    margin-top: 0.5rem;
    border: 1.5px solid var(--clr-border);
    border-radius: 10px;
    overflow: hidden;
}

.rfc-amort-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1rem;
    background: var(--clr-bg-muted);
    border-bottom: 1px solid var(--clr-border);
}

.rfc-amort-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
}

.rfc-amort-toggle {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--clr-accent-dark);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.rfc-amort-table-wrap {
    max-height: 260px;
    overflow-y: auto;
}

.rfc-amort-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.rfc-amort-table th {
    position: sticky;
    top: 0;
    background: var(--clr-bg-muted);
    padding: 0.45rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--clr-text-muted);
    text-align: right;
    border-bottom: 1px solid var(--clr-border);
    z-index: 1;
}

.rfc-amort-table th:first-child { text-align: left; }

.rfc-amort-table td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--clr-border-soft);
    color: var(--clr-text-secondary);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.rfc-amort-table td:first-child { text-align: left; color: var(--clr-text-primary); font-weight: 600; }
.rfc-amort-table tbody tr:last-child td { border-bottom: none; }
.rfc-amort-table tbody tr:hover td { background: var(--clr-bg-soft); }

.rfc-amort-hidden { display: none; }

/* ── Article styles (scoped) ── */
.rfc-article .formula-block {
    background: var(--clr-bg-muted);
    border-left: 3px solid var(--clr-teal);
    border-radius: 0 8px 8px 0;
    padding: 0.75rem 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--clr-text-primary);
    margin: 1rem 0;
    overflow-x: auto;
}

/* Tip box inside article */
.rfc-tip-box {
    background: var(--clr-warning-bg);
    border: 1px solid var(--clr-warning-brd);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
    color: var(--clr-warning-text);
    margin: 1rem 0;
    line-height: 1.55;
}
.rfc-comp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    /* Forces the table to respect the container width */
    table-layout: fixed; 
    word-wrap: break-word;
}

@media screen and (max-width: 600px) {
    .rfc-comp-table {
        /* Reduce font size further for small screens */
        font-size: 0.7rem; 
    }

    .rfc-comp-table th, 
    .rfc-comp-table td {
        /* Reduce padding to reclaim horizontal space */
        padding: 4px 2px; 
        /* Ensures long strings don't push the table out */
        word-break: break-all; 
    }
}
.rfc-tip-box strong { color: var(--clr-warning-text); }