:root {
    --fhac-accent:       #0ea5e9;
    --fhac-accent-dark:  #0369a1;
    --fhac-accent-light: #e0f2fe;
    --fhac-accent-hover: #bae6fd;
    --fhac-interest:     #fbbf24;
    --fhac-teal:         #14b8a6;
    --fhac-green:        #22c55e;
    --fhac-warning-text: #b45309;
    --fhac-warning-bg:   #fffbeb;
    --fhac-warning-brd:  #fde68a;
    --fhac-bg:           #ffffff;
    --fhac-bg-soft:      #f8fafc;
    --fhac-bg-muted:     #f1f5f9;
    --fhac-text-primary: #0f172a;
    --fhac-text-secondary:#475569;
    --fhac-text-muted:   #94a3b8;
    --fhac-border:       #e2e8f0;
    --fhac-border-soft:  #f1f5f9;
    --fhac-shadow-focus: 0 0 0 4px rgba(14,165,233,0.15);

    /* Donut segment colors */
    --fhac-c1: #0ea5e9; /* Principal */
    --fhac-c2: #f97316; /* Interest */
    --fhac-c3: #a78bfa; /* Property Tax */
    --fhac-c4: #14b8a6; /* Annual MIP */
    --fhac-c5: #f43f5e; /* Home Insurance */
    --fhac-c6: #fbbf24; /* HOA / Other */
}

/* ── Layout ── */
.fhac-widget { font-family: inherit; color: var(--fhac-text-primary); }

/* ── Grid: 2-col inputs ── */
.fhac-inputs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}
@media (max-width: 600px) { .fhac-inputs-grid { grid-template-columns: 1fr; } }

.fhac-section-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0 2px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fhac-text-muted);
}
.fhac-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--fhac-border);
}

/* ── Input group ── */
.fhac-input-group { display: flex; flex-direction: column; gap: 3px; }
.fhac-input-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--fhac-text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.fhac-input-hint {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--fhac-text-muted);
}
.fhac-input-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--fhac-border);
    border-radius: 6px;
    background: var(--fhac-bg);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.fhac-input-wrap:focus-within {
    border-color: var(--fhac-accent);
    box-shadow: var(--fhac-shadow-focus);
}
.fhac-input-prefix, .fhac-input-suffix {
    padding: 0 7px;
    font-size: 0.75rem;
    color: var(--fhac-text-muted);
    background: var(--fhac-bg-muted);
    border-right: 1px solid var(--fhac-border);
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}
.fhac-input-suffix { border-right: none; border-left: 1px solid var(--fhac-border); }
.fhac-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 6px 8px;
    font-size: 0.8rem;
    background: transparent;
    color: var(--fhac-text-primary);
    min-width: 0;
    width: 100%;
}
.fhac-input::-webkit-inner-spin-button,
.fhac-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.fhac-input[type=number] { -moz-appearance: textfield; }

/* Toggle unit buttons */
.fhac-unit-toggle {
    display: flex;
    border-left: 1px solid var(--fhac-border);
    flex-shrink: 0;
}
.fhac-unit-toggle button {
    border: none;
    background: transparent;
    padding: 0 7px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--fhac-text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
    height: 100%;
}
.fhac-unit-toggle button.fhac-active {
    background: var(--fhac-accent-light);
    color: var(--fhac-accent-dark);
}
.fhac-unit-toggle button:first-child { border-right: 1px solid var(--fhac-border); }

/* Select */
.fhac-select-wrap {
    border: 1.5px solid var(--fhac-border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--fhac-bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.fhac-select-wrap:focus-within {
    border-color: var(--fhac-accent);
    box-shadow: var(--fhac-shadow-focus);
}
.fhac-select {
    width: 100%;
    border: none;
    outline: none;
    padding: 6px 8px;
    font-size: 0.78rem;
    background: transparent;
    color: var(--fhac-text-primary);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

/* Date row */
.fhac-date-row { display: flex; gap: 6px; }
.fhac-date-row .fhac-select-wrap { flex: 1; }

/* Advanced toggle */
.fhac-advanced-toggle {
    grid-column: 1 / -1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1.5px dashed var(--fhac-border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--fhac-accent-dark);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-top: 4px;
}
.fhac-advanced-toggle:hover { background: var(--fhac-accent-light); border-color: var(--fhac-accent); }
.fhac-advanced-toggle svg { transition: transform 0.2s; }
.fhac-advanced-toggle.fhac-open svg { transform: rotate(180deg); }

.fhac-advanced-panel { grid-column: 1 / -1; display: none; }
.fhac-advanced-panel.fhac-open {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
}
@media (max-width: 600px) { .fhac-advanced-panel.fhac-open { grid-template-columns: 1fr; } }

/* Buttons */
.fhac-btn-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    margin-top: 6px;
}
.fhac-btn-clear {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    border: 1.5px solid var(--fhac-border);
    background: var(--fhac-bg);
    color: var(--fhac-text-secondary);
}
.fhac-btn-clear:hover { background: var(--fhac-bg-muted); border-color: var(--fhac-text-muted); }

/* ── RESULTS ── */
.fhac-results { margin-top: 20px; }

.fhac-results-top {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 640px) { .fhac-results-top { grid-template-columns: 1fr; } }

/* Donut */
.fhac-donut-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 148px;
}
.fhac-donut-svg { width: 148px; height: 148px; }
.fhac-donut-center {
    text-align: center;
    margin-top: -4px;
}
.fhac-donut-center-label { font-size: 0.6rem; color: var(--fhac-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.fhac-donut-center-value { font-size: 1rem; font-weight: 700; color: var(--fhac-text-primary); line-height: 1.2; }

/* Legend */
.fhac-legend {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.7rem;
}
.fhac-legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 3px 7px;
    border-radius: 5px;
    background: var(--fhac-bg-soft);
}
.fhac-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.fhac-legend-name { flex: 1; color: var(--fhac-text-secondary); font-weight: 500; }
.fhac-legend-val { font-weight: 700; color: var(--fhac-text-primary); }
.fhac-legend-pct { color: var(--fhac-text-muted); margin-left: 4px; font-weight: 500; }

/* Summary cards */
.fhac-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 14px;
}
@media (max-width: 700px) { .fhac-summary-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 380px) { .fhac-summary-cards { grid-template-columns: 1fr; } }

.fhac-scard {
    background: var(--fhac-bg-soft);
    border: 1.5px solid var(--fhac-border);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fhac-scard.fhac-scard-primary {
    background: var(--fhac-accent-light);
    border-color: var(--fhac-accent);
}
.fhac-scard-label { font-size: 0.63rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fhac-text-muted); }
.fhac-scard.fhac-scard-primary .fhac-scard-label { color: var(--fhac-accent-dark); }
.fhac-scard-value { font-size: 1.05rem; font-weight: 800; color: var(--fhac-text-primary); line-height: 1.2; }
.fhac-scard.fhac-scard-primary .fhac-scard-value { color: var(--fhac-accent-dark); }
.fhac-scard-sub { font-size: 0.62rem; color: var(--fhac-text-muted); }

/* Breakdown table */
.fhac-breakdown-table-wrap { margin-top: 14px; overflow-x: auto; }
.fhac-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
}
.fhac-breakdown-table th {
    background: var(--fhac-bg-muted);
    color: var(--fhac-text-muted);
    font-weight: 700;
    font-size: 0.63rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 5px 10px;
    text-align: left;
}
.fhac-breakdown-table td { padding: 5px 10px; border-bottom: 1px solid var(--fhac-border-soft); color: var(--fhac-text-secondary); }
.fhac-breakdown-table tr:last-child td { border-bottom: none; }
.fhac-breakdown-table tr.fhac-total td {
    font-weight: 700;
    color: var(--fhac-text-primary);
    background: var(--fhac-bg-soft);
    border-top: 2px solid var(--fhac-border);
}
.fhac-breakdown-table td:last-child, .fhac-breakdown-table th:last-child { text-align: right; }
.fhac-breakdown-table td:nth-child(2), .fhac-breakdown-table th:nth-child(2) { text-align: right; }

/* Loan summary detail */
.fhac-loan-detail {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
@media (max-width: 480px) { .fhac-loan-detail { grid-template-columns: 1fr; } }
.fhac-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: var(--fhac-bg-soft);
    border-radius: 6px;
    font-size: 0.71rem;
}
.fhac-detail-label { color: var(--fhac-text-muted); }
.fhac-detail-value { font-weight: 700; color: var(--fhac-text-primary); }

/* Warning box */
.fhac-mip-note {
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--fhac-warning-bg);
    border: 1px solid var(--fhac-warning-brd);
    border-radius: 7px;
    font-size: 0.7rem;
    color: var(--fhac-warning-text);
    display: flex;
    gap: 7px;
    align-items: flex-start;
    line-height: 1.5;
}
.fhac-mip-note svg { flex-shrink: 0; margin-top: 1px; }

/* ── AMORTIZATION ── */
.fhac-amort { margin-top: 20px; }
.fhac-amort-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--fhac-border);
    margin-bottom: 10px;
}
.fhac-amort-tab {
    padding: 6px 16px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--fhac-text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.fhac-amort-tab.fhac-active {
    color: var(--fhac-accent-dark);
    border-bottom-color: var(--fhac-accent);
}

.fhac-amort-table-wrap { overflow-x: auto; max-height: 320px; overflow-y: auto; border-radius: 7px; border: 1px solid var(--fhac-border); }
.fhac-amort-table { width: 100%; border-collapse: collapse; font-size: 0.7rem; }
.fhac-amort-table thead { position: sticky; top: 0; z-index: 2; }
.fhac-amort-table th {
    background: var(--fhac-bg-muted);
    color: var(--fhac-text-muted);
    font-weight: 700;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 5px 8px;
    text-align: right;
    white-space: nowrap;
}
.fhac-amort-table th:first-child { text-align: left; }
.fhac-amort-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--fhac-border-soft);
    color: var(--fhac-text-secondary);
    text-align: right;
    white-space: nowrap;
}
.fhac-amort-table td:first-child { text-align: left; font-weight: 600; color: var(--fhac-text-primary); }
.fhac-amort-table tr:hover td { background: var(--fhac-bg-soft); }
.fhac-amort-table tr.fhac-year-row td {
    background: var(--fhac-accent-light);
    font-weight: 700;
    color: var(--fhac-accent-dark);
    border-top: 1.5px solid var(--fhac-accent-hover);
}
.fhac-amort-table tr.fhac-year-row td:first-child { border-radius: 0; }
.fhac-amort-table tr:last-child td { border-bottom: none; }