:root {
    --primary-color: #2ecc71;
    --secondary-color: #34495e;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-color: #2c3e50;
    --tab-inactive: #e2e8f0;
    --lead-bg: #ebf5fb;
    --lead-border: #3498db;
    /* text-safe colours (WCAG AA >= 4.5:1 with white); the bright ones above are decorative only */
    --primary-dark: #1e7b45;
    --lead-button: #1f6aa5;
    --link-color: #1a5f96;
    --focus-color: #1a5f96;
    /* chart series: both reach >= 4.5:1 on white, and interest is also hatched so colour is not the only cue */
    --chart-principal: #1f6aa5;
    --chart-interest: #b45309;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

a { color: var(--link-color); }

header {
    background-color: var(--secondary-color);
    color: white;
    text-align: center;
    padding: 2rem 1rem;
}

.tabs-container {
    max-width: 1200px;
    margin: 1.5rem auto 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.tab-btn {
    flex: 1;
    min-width: 120px;
    min-height: 44px;
    padding: 0.8rem;
    background-color: var(--tab-inactive);
    color: var(--text-color);
    border: none;
    cursor: pointer;
    font: inherit;
    font-weight: bold;
}

.tab-btn.active {
    background-color: var(--card-background);
    color: var(--primary-dark);
    border-top: 4px solid var(--primary-color);
}

.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .container { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .tabs-container { display: grid; grid-template-columns: repeat(2, 1fr); }
    /* 7 tabs in 2 columns: let the last one span the full row instead of sitting alone */
    .tab-btn:nth-child(odd):last-child { grid-column: 1 / -1; }
}

.calculator-box, .results-box {
    background: var(--card-background);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.calc-content { display: none; }
.calc-content.active { display: block; }

.input-group { margin-bottom: 1rem; }
.input-group label { display: block; margin-bottom: 0.5rem; font-weight: bold; }
.input-group input { width: 100%; padding: 0.7rem; box-sizing: border-box; font: inherit; }

button#calculateBtn {
    width: 100%; min-height: 48px; padding: 1rem; background: var(--primary-dark);
    color: white; border: none; font: inherit; font-weight: bold; cursor: pointer;
}

.results-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.result-card { background: #f1f8ff; padding: 1rem; text-align: center; border-top: 4px solid var(--primary-color); }
.result-card h3 { font-size: 0.95rem; margin: 0 0 0.5rem; }
.result-card p { font-size: 1.4rem; font-weight: bold; margin: 0; overflow-wrap: anywhere; }

.lead-form-box { background: var(--lead-bg); border: 2px solid var(--lead-border); padding: 1rem; text-align: center; margin-top: 1rem; }
.form-row { display: flex; gap: 1rem; margin-bottom: 1rem; }
.form-row input { flex: 1; padding: 0.7rem; }
.submit-lead-btn { width: 100%; min-height: 44px; padding: 0.8rem; background: var(--lead-button); color: white; border: none; font: inherit; font-weight: bold; cursor: pointer; }

.seo-articles-container { max-width: 1200px; margin: 2rem auto; padding: 0 1rem; }
.articles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 768px) { .articles-grid { grid-template-columns: 1fr; } }
.article-card { background: white; padding: 1rem; border: 1px solid #ccc; }

footer { text-align: center; padding: 1rem; background: #34495e; color: white; }

/* --- validation, notes, disclaimer --- */
.field-error { color: #b00020; font-size: 0.9rem; margin-top: 0.3rem; min-height: 0; }
.field-error:empty { display: none; }
input[aria-invalid="true"] { border: 2px solid #b00020; }
.field-hint { font-size: 0.85rem; margin: 0.4rem 0 0; color: #4a5568; }
.form-status { color: #b00020; font-weight: bold; margin-bottom: 0.8rem; }
.form-status:empty { display: none; }

.breakdown { margin: 1rem 0; display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 1rem; max-width: 36rem; }
.breakdown[hidden] { display: none; }
.breakdown dt { margin: 0; }
.breakdown dd { margin: 0; font-weight: bold; text-align: left; }
.data-note { font-size: 0.9rem; color: #4a5568; }
.data-note:empty { display: none; }
.disclaimer { font-size: 0.85rem; color: #4a5568; border-top: 1px solid #e2e8f0; padding-top: 0.8rem; }

/* --- lead form --- */
.lead-field { flex: 1; text-align: right; }
.lead-field label { display: block; font-weight: bold; margin-bottom: 0.3rem; }
.lead-field input { width: 100%; box-sizing: border-box; padding: 0.7rem; font: inherit; }
.consent-row { display: flex; gap: 0.5rem; align-items: flex-start; text-align: right; margin-bottom: 0.5rem; }
.consent-row input { flex: none; width: 1.4rem; height: 1.4rem; margin: 0.1rem 0 0; }
.lead-status { margin: 0.6rem 0; font-weight: bold; }
.lead-status:empty { display: none; }
.lead-status.is-error { color: #b00020; }
.submit-lead-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.honeypot { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 768px) { .form-row { flex-direction: column; } }

footer a { color: #fff; }

/* --- narrow screens: keep the boxes inside the viewport --- */
@media (max-width: 768px) {
    .calculator-box, .results-box { padding: 1rem; min-width: 0; }
    .results-grid { grid-template-columns: 1fr; }
}

/* --- accessibility --- */
:focus-visible { outline: 3px solid var(--focus-color); outline-offset: 2px; }
main:focus { outline: none; }
.skip-link { position: absolute; top: 0; right: 0; padding: 0.7rem 1rem; background: var(--secondary-color); color: #fff;
             z-index: 10; transform: translateY(-120%); }
.skip-link:focus { transform: translateY(0); }
@media (prefers-reduced-motion: no-preference) { .skip-link { transition: transform 0.15s; } }

/* --- small screens --- */
@media (max-width: 480px) {
    header { padding: 1.2rem 1rem; }
    header h1 { font-size: 1.4rem; }
    .container, .seo-articles-container { margin-top: 1rem; }
}

/* --- selects, checkboxes, multi-track rows --- */
.input-group select { width: 100%; padding: 0.7rem; box-sizing: border-box; font: inherit; background: #fff; color: var(--text-color); }
.check-group { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.check-group input { flex: none; width: 1.4rem; height: 1.4rem; margin: 0; }
.check-group label { font-weight: bold; }
fieldset.track { border: 1px solid #cbd5e0; border-radius: 6px; margin: 0 0 1rem; padding: 0.8rem 1rem 0.2rem; }
fieldset.track[hidden] { display: none; }
fieldset.track legend { font-weight: bold; padding: 0 0.4rem; }
.track-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.secondary-btn { min-height: 44px; padding: 0.6rem 1rem; background: #fff; color: var(--link-color); border: 2px solid var(--link-color); border-radius: 4px; font: inherit; font-weight: bold; cursor: pointer; }
.secondary-btn:disabled { color: #4a5568; border-color: #a0aec0; cursor: not-allowed; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* --- amortization schedule and chart --- */
.schedule { margin: 1.5rem 0; }
.schedule[hidden] { display: none; }
.schedule h3 { margin: 0 0 0.5rem; }
.chart-legend { display: flex; gap: 1.2rem; margin: 0 0 0.5rem; font-size: 0.9rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch { display: inline-block; width: 1rem; height: 1rem; border-radius: 2px; }
.swatch-principal { background: var(--chart-principal); }
.swatch-interest { background: repeating-linear-gradient(45deg, var(--chart-interest) 0 3px, #fff 3px 5px); border: 1px solid var(--chart-interest); }
.chart-figure { margin: 0 0 1rem; }
.chart { width: 100%; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-grid { stroke: #d5dbe3; stroke-width: 1; }
.chart-label { font-size: 11px; fill: #4a5568; }
.chart-caption { font-size: 0.85rem; color: #4a5568; margin-top: 0.3rem; }
.table-wrap { overflow: auto; max-width: 100%; border: 1px solid #e2e8f0; }
.table-wrap:focus-visible { outline: 3px solid var(--focus-color); outline-offset: 2px; }
.monthly-details .table-wrap { max-height: 22rem; }
.monthly-details summary { cursor: pointer; font-weight: bold; padding: 0.6rem 0; min-height: 24px; }
.schedule-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.schedule-table caption { text-align: start; font-weight: bold; padding: 0.4rem 0.5rem; }
.schedule-table th, .schedule-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid #e2e8f0; text-align: start; white-space: nowrap; }
.schedule-table thead th { background: #edf2f7; position: sticky; top: 0; }
.schedule-table th[hidden] { display: none; }

/* --- site navigation and content pages (generated by scripts/build.js) --- */
.site-nav { margin-top: 0.8rem; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; justify-content: center; }
.site-nav a, header a { color: #fff; }
.site-nav a { display: inline-block; padding: 0.35rem 0.2rem; min-height: 24px; }
.site-title { color: #fff; text-decoration: none; }
.breadcrumbs { max-width: 1200px; margin: 1rem auto 0; padding: 0 1rem; font-size: 0.9rem; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.breadcrumbs li + li::before { content: "›"; margin-inline-end: 0.3rem; color: #4a5568; }
.page-content { max-width: 800px; margin: 1.5rem auto; padding: 0 1rem; }
.page-content.wide { max-width: 1200px; }
.page-content h1 { font-size: 1.8rem; line-height: 1.3; }
.page-content h2 { margin-top: 2rem; }
.page-content p, .page-content li { line-height: 1.8; }
.page-intro { font-size: 1.1rem; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; padding: 0; margin: 1rem 0; list-style: none; }
.card-link { display: block; height: 100%; box-sizing: border-box; background: #fff; border: 1px solid #cbd5e0; border-radius: 8px; padding: 1rem; text-decoration: none; color: var(--text-color); }
.card-link:hover { border-color: var(--link-color); }
.card-link strong { display: block; color: var(--link-color); margin-bottom: 0.3rem; }
.faq details { background: #fff; border: 1px solid #cbd5e0; border-radius: 6px; padding: 0.2rem 1rem; margin-bottom: 0.6rem; }
.faq summary { cursor: pointer; font-weight: bold; padding: 0.6rem 0; min-height: 24px; }
.notice { background: #fff8e1; border: 1px solid #f0ad00; border-radius: 6px; padding: 0.8rem 1rem; }
.calc-page .container { margin-top: 1.5rem; }
.updated { font-size: 0.85rem; color: #4a5568; }

/* --- privacy page --- */
.policy { max-width: 800px; margin: 2rem auto; padding: 0 1rem; line-height: 1.7; }
.policy h2 { margin-top: 2rem; }
.draft-banner { background: #fff8e1; border: 2px solid #f0ad00; padding: 1rem; font-weight: bold; }
.todo { background: #ffe9e9; padding: 0 0.3rem; border-radius: 3px; }

/* --- footer link lists and header brand --- */
.site-title-line { margin: 0; font-size: 1.4rem; font-weight: bold; }
.footer-links { max-width: 1200px; margin: 1rem auto 0; text-align: start; }
.footer-heading { font-size: 1rem; margin: 1rem 0 0.4rem; }
.footer-links ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.2rem 1.2rem; }
.footer-links a { display: inline-block; padding: 0.3rem 0; min-height: 24px; }

/* results that do not match the current (invalid) inputs: dashed instead of solid, contrast stays high */
.results-grid.is-stale .result-card { border-top-style: dashed; background: #eef1f4; }

/* --- business / partnership page --- */
.business-layout { display: grid; grid-template-columns: 1fr 1.2fr; gap: 2rem; align-items: start; }
@media (max-width: 900px) { .business-layout { grid-template-columns: 1fr; } }
.business-info { min-width: 0; }
.type-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.type-list li { display: flex; flex-direction: column; padding: 0.6rem 0; border-bottom: 1px solid #e2e8f0; }
.type-list strong { color: var(--text-color); }
.type-list span { color: #4a5568; }
.direct-contact { margin-top: 1.2rem; font-weight: bold; }
.business-box { min-width: 0; box-sizing: border-box; background: var(--card-background); padding: 2rem; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
@media (max-width: 768px) { .business-box { padding: 1rem; } }
.business-box h2 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0 1rem; }
.form-grid > .input-group { min-width: 0; }
.input-group textarea { width: 100%; box-sizing: border-box; padding: 0.7rem; font: inherit; resize: vertical; min-height: 8rem; }
.input-group input.ltr-input, .input-group textarea.ltr-input { text-align: left; }
.req { color: #b00020; font-weight: bold; }
.optional { font-weight: normal; font-size: 0.85rem; color: #4a5568; }
.char-count { display: inline-block; margin-inline-start: 0.5rem; }
.business-submit { width: 100%; min-height: 48px; padding: 1rem; background: var(--primary-dark); color: #fff; border: none; font: inherit; font-weight: bold; cursor: pointer; }
.business-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.form-result { margin: 0.8rem 0; padding: 0.8rem 1rem; border-radius: 6px; font-weight: bold; }
.form-result:empty { display: none; }
.form-result.is-success { background: #e9f6ef; border: 2px solid var(--primary-dark); color: #14532d; }
.form-result.is-error { background: #fdecee; border: 2px solid #b00020; color: #7a0019; }
.form-result.is-info { background: #edf2f7; border: 2px solid #4a5568; color: var(--text-color); }
.form-result:focus-visible { outline: 3px solid var(--focus-color); outline-offset: 2px; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border: 2px solid #b00020; }

/* --- "for businesses" call-to-action shown on every page --- */
.business-cta { box-sizing: border-box; width: calc(100% - 2rem); max-width: 1168px; margin: 2rem auto; padding: 1.2rem 1.5rem; background: #fff; border: 2px solid var(--primary-dark); border-radius: 8px; text-align: center; }
.business-cta h2 { margin: 0 0 0.4rem; }
.business-cta p { margin: 0 0 0.9rem; }
.cta-button { display: inline-block; min-height: 24px; padding: 0.7rem 1.4rem; background: var(--primary-dark); color: #fff; border-radius: 4px; font-weight: bold; text-decoration: none; }
.cta-button:hover { background: #17633a; }

/* --- advertising placement areas (hidden until a provider is connected; see ads.js) --- */
.ad-slot { box-sizing: border-box; width: calc(100% - 2rem); max-width: 1168px; margin: 1.2rem auto; text-align: center; }
.ad-slot[hidden] { display: none; }
.ad-label { margin: 0 0 0.25rem; font-size: 0.75rem; color: #4a5568; }
.ad-content { box-sizing: border-box; max-width: 100%; overflow: hidden; display: flex; justify-content: center; align-items: center; }
.ad-content > * { max-width: 100%; }
.ad-slot[data-ad-size="banner"] .ad-content { min-height: 90px; }
.ad-slot[data-ad-size="rectangle"] .ad-content { min-height: 250px; }
.ad-slot.is-preview .ad-content { min-height: 4rem; border: 2px dashed #4a5568; border-radius: 6px; background: #edf2f7; padding: 0.6rem 1rem; }
.ad-preview-note { margin: 0; font-size: 0.9rem; color: var(--text-color); }
.results-box .ad-slot { width: 100%; margin: 1.2rem 0; }
.page-content .ad-slot { width: 100%; }
@media (max-width: 480px) { .ad-slot[data-ad-size="banner"] .ad-content { min-height: 50px; } }
@media print { .ad-slot { display: none !important; } }

/* --- advertising consent (only present when advertising is enabled; see consent.js) --- */
.consent-banner { position: fixed; inset-inline: 0; bottom: 0; z-index: 50; box-sizing: border-box; max-height: 70vh; overflow-y: auto; padding: 0.9rem 1rem; background: #fff; color: var(--text-color); border-top: 3px solid var(--secondary-color); box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15); }
.consent-title { margin: 0 0 0.4rem; font-size: 1.1rem; }
.consent-title:focus { outline: 3px solid var(--focus-color); outline-offset: 2px; }
.consent-text { margin: 0 0 0.7rem; line-height: 1.6; max-width: 70ch; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.consent-button { min-height: 44px; padding: 0.5rem 1.2rem; font: inherit; font-size: 1rem; color: #fff; background: var(--secondary-color); border: 2px solid var(--secondary-color); border-radius: 6px; cursor: pointer; }
.consent-button:focus-visible, .ad-settings:focus-visible { outline: 3px solid var(--focus-color); outline-offset: 2px; }
html.consent-open body { padding-bottom: var(--consent-space, 0); }
html.consent-open { scroll-padding-bottom: var(--consent-space, 0); }
.ad-settings-row { margin: 0.6rem 0 0; }
.ad-settings { min-height: 44px; padding: 0.4rem 0.8rem; font: inherit; color: #fff; background: transparent; border: 1px solid #fff; border-radius: 6px; text-decoration: underline; cursor: pointer; }
@media print { .consent-banner, .ad-settings-row { display: none !important; } }
