.calculator {
    max-width: 100%;
}

.calculator h2 {
    margin-top: 0;
    margin-bottom: 0.875rem;
    line-height: 1.2;
}

/* -----------------------------
   FORM GRID
----------------------------- */

#compound-form,
#loan-form,
#mortgage-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.875rem 1rem;
    align-items: end;
}

#compound-form label,
#loan-form label,
#mortgage-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.95rem;
}

/* -----------------------------
   INPUT + SELECT STYLING
----------------------------- */

#compound-form input,
#loan-form input,
#mortgage-form input,
#mortgage-form select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    font: inherit;
    border: 1px solid #ccc;
    background-color: #fff;
    box-sizing: border-box;
}

/* normalize select appearance */

#mortgage-form select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    background-image: url("data:image/svg+xml;utf8,<svg fill='black' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M5 7l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

/* -----------------------------
   BUTTONS
----------------------------- */

.button-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.button-row button {
    padding: 0.45rem 0.7rem;
    font-size: 0.9rem;
    line-height: 1.2;
    border: 1px solid #ccc;
    background: #f5f5f5;
    cursor: pointer;
}

.button-row button:hover {
    background: #eaeaea;
}

/* -----------------------------
   PIE CHART
----------------------------- */

.chart-note {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.5rem;
}

/* -----------------------------
   PMI TOGGLE
----------------------------- */

.pmi-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pmi-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: #555;
    white-space: nowrap;
}

.input-help {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.3;
}

/* -----------------------------
   STATE ROW (FIXED)
----------------------------- */

.state-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    margin-top: 0.25rem;
}

.state-row label {
    margin: 0;
}

.state-disclaimer {
    margin: 0;
    margin-top: 2rem;
    /* aligns with select input (not label text) */
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

/* -----------------------------
   RESULTS
----------------------------- */

.results {
    margin-top: 1.25rem;
}

.results-eyebrow {
    margin: 0 0 0.25rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.results-total {
    font-size: 2rem;
    line-height: 1.05;
    margin: 0 0 0.75rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.results-breakdown {
    display: grid;
    gap: 0.35rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 0;
}

.payoff-summary {
    margin: 0.9rem 0 0;
    color: #333;
}

/* -----------------------------
   AMORTIZATION
----------------------------- */

.amortization-section {
    margin-top: 1.25rem;
}

.amortization-toggle,
.amortization-mode-button {
    padding: 0.45rem 0.7rem;
    font-size: 0.9rem;
    line-height: 1.2;
    border: 1px solid #ccc;
    background: #f5f5f5;
    cursor: pointer;
}

.amortization-toggle:hover,
.amortization-mode-button:hover {
    background: #eaeaea;
}

.amortization-wrap {
    margin-top: 1rem;
}

.amortization-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.amortization-wrap h3 {
    margin: 0;
    line-height: 1.2;
}

.amortization-mode-toggle {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.amortization-mode-button.active-mode {
    background: #111;
    color: #fff;
    border-color: #111;
}

.amortization-intro {
    margin: 0 0 0.4rem;
    color: #333;
}

.amortization-label {
    margin: 0 0 0.75rem;
    color: #555;
    font-size: 0.9rem;
}

.amortization-table-wrap {
    overflow: auto;
    max-height: 420px;
    border: 1px solid #e5e5e5;
}

.amortization-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.amortization-table th,
.amortization-table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e5e5e5;
    font-size: 0.92rem;
}

.amortization-table th {
    background: #fafafa;
    position: sticky;
    top: 0;
    z-index: 1;
}

.amortization-table tbody tr:last-child td {
    border-bottom: none;
}

/* -----------------------------
   CHART
----------------------------- */

.chart-section {
    margin-top: 2rem;
}

.chart-section h3 {
    margin: 0 0 0.5rem;
    line-height: 1.2;
}

.chart-wrap {
    position: relative;
    width: 100%;
    height: 350px;
}

/* -----------------------------
   NAV
----------------------------- */

.active-nav {
    font-weight: 600;
    cursor: default;
}

/* -----------------------------
   MOBILE
----------------------------- */

@media (max-width: 640px) {

    #compound-form,
    #loan-form,
    #mortgage-form {
        grid-template-columns: 1fr;
    }

    .button-row {
        flex-direction: column;
    }

    .button-row button {
        width: 100%;
    }

    .results-total {
        font-size: 1.75rem;
    }

    .result-row {
        flex-direction: column;
        gap: 0.1rem;
    }

    .chart-wrap {
        height: 220px;
    }

    .amortization-header {
        align-items: flex-start;
    }

    .amortization-mode-toggle {
        width: 100%;
    }

    .amortization-mode-button {
        flex: 1 1 auto;
    }

    .amortization-table-wrap {
        max-height: 360px;
    }

    .state-row {
        grid-template-columns: 1fr;
        align-items: start;
    }
}