/* Shared styles for the six mortgage calculator pages (articles/calculadora_hipoteca.html and the
   pages built on articles/includes/_mortgage_calc.html). Theme tokens first, then the hp- components. */
:root {
    --primary-color: #2E86C1;
    --primary-light: rgba(46, 134, 193, 0.1);
    --primary-dark: #1a5276;
    --accent-color: #10b981;
    --accent-light: rgba(16, 185, 129, 0.1);
    --warning-color: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.12);
    --warning-text: #92400e;
    --danger-color: #dc2626;
    --card-bg: #ffffff;
    --card-border: rgba(15, 23, 42, 0.1);
    --text-primary: #1a1a2e;
    --text-secondary: #5b6472;
    --text-muted: #6b7280;
    --bg-subtle: #f6f8fb;
    --input-bg: #ffffff;
    --hover-bg: rgba(46, 134, 193, 0.06);
    --interest-color: #e8930c;
    --principal-color: #2E86C1;
    --seo-hero-bg-start: #eaf2fb;
    --seo-hero-bg-end: #f5f9fd;
    --seo-hero-text: #1a5276;
    --seo-hero-subtitle: #475569;
}
html.dark,
body.dark-theme,
body.premium-dark-theme {
    --card-bg: var(--premium-bg-secondary, #161b22);
    --card-border: var(--premium-border, #30363d);
    --text-primary: var(--premium-text-primary, #e6edf3);
    --text-secondary: var(--premium-text-secondary, #a8b2bd);
    --text-muted: #7d8590;
    --bg-subtle: var(--premium-bg-primary, #0d1117);
    --input-bg: #0d1117;
    --hover-bg: var(--premium-bg-tertiary, #1c2128);
    --primary-light: rgba(88, 166, 255, 0.12);
    --warning-light: rgba(245, 158, 11, 0.14);
    --warning-text: #fbbf24;
    --danger-color: #f87171;
    --interest-color: #f5a524;
    --interest-text: #f5a524;
    --accent-text: #34d399;
    --principal-color: #4ea3dc;
    --seo-hero-bg-start: #11202f;
    --seo-hero-bg-end: #162a3d;
    --seo-hero-text: #cfe3f5;
    --seo-hero-subtitle: var(--premium-text-secondary, #a8b2bd);
}
body.dark-theme:not(.premium-dark-theme) { --card-bg: #1e1e1e; --bg-subtle: #121212; --hover-bg: #2a2a2a; --input-bg: #161616; }

.hp-page { max-width: 1080px; margin: 0 auto; padding: 24px 16px 32px; background: var(--bg-subtle); min-height: 100vh; color: var(--text-primary); }
.hp-page *, .hp-page *::before, .hp-page *::after { box-sizing: border-box; }

/* Hero */
.hp-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; margin: 8px 0 16px; }
.hp-page nav.hp-crumbs, .hp-page nav.hp-langs, .hp-page nav.hp-jump { width: auto; justify-content: flex-start; }
.hp-page nav.hp-crumbs { display: block; }
.hp-crumbs { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.hp-crumbs a { color: var(--text-secondary); text-decoration: none; }
.hp-crumbs a:hover { color: var(--primary-color); }
.hp-hero h1 { font-size: 30px; font-weight: 800; line-height: 1.15; margin: 0 0 6px; color: var(--text-primary); letter-spacing: -0.3px; }
.hp-hero .hp-sub { font-size: 15px; line-height: 1.5; margin: 0; color: var(--text-secondary); max-width: 640px; }
.hp-langs { display: flex; flex-wrap: wrap; gap: 2px; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 3px; }
.hp-langs a { padding: 4px 9px; border-radius: 6px; font-size: 12px; font-weight: 700; color: var(--text-secondary); text-decoration: none; }
.hp-langs a:hover { color: var(--primary-color); background: var(--primary-light); }
.hp-langs a.active { background: var(--primary-color); color: #fff; }

/* Tool shell */
.hp-tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; overflow: hidden; }
.hp-form { padding: 22px 22px 20px; }
.hp-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; align-items: start; }
.hp-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hp-field.full { grid-column: 1 / -1; }
.hp-field label, .hp-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.hp-input { position: relative; }
.hp-input input, .hp-select { width: 100%; height: 48px; padding: 0 40px 0 14px; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); background: var(--input-bg); border: 1.5px solid var(--card-border); border-radius: 10px; outline: none; transition: border-color .15s, box-shadow .15s; -moz-appearance: textfield; }
.hp-select { padding-right: 12px; font-size: 15px; font-weight: 600; }
.hp-input input:focus, .hp-select:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.25); }
.hp-input .hp-unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; font-weight: 700; color: var(--text-muted); pointer-events: none; }
.hp-field.invalid input { border-color: var(--danger-color); }
.hp-err { font-size: 12px; color: var(--danger-color); min-height: 0; }
.hp-err:empty { display: none; }
.hp-hint { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.hp-hint a { color: var(--primary-color); }
.hp-seg { display: inline-flex; width: 100%; background: var(--bg-subtle); border: 1px solid var(--card-border); border-radius: 10px; padding: 3px; gap: 3px; }
.hp-seg button { flex: 1; height: 38px; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); font-size: 14px; font-weight: 700; cursor: pointer; }
.hp-seg button[aria-pressed="true"] { background: var(--primary-color); color: #fff; }
.hp-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.hp-chip { border: 1px solid var(--card-border); background: var(--card-bg); color: var(--text-secondary); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.hp-chip[aria-pressed="true"] { border-color: var(--primary-color); color: var(--primary-color); background: var(--primary-light); }

/* Answer panel */
.hp-answer { background: linear-gradient(135deg, #2E86C1 0%, #1a5276 100%); color: #fff; padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.hp-answer .hp-loanline { font-size: 13px; color: rgba(255,255,255,.85); }
.hp-answer .hp-loanline strong { color: #fff; }
.hp-big-label { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.85); }
.hp-big { font-size: 46px; font-weight: 800; line-height: 1.05; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.hp-big small { font-size: 18px; font-weight: 600; letter-spacing: 0; opacity: .85; }
.hp-big-sub { font-size: 13px; color: rgba(255,255,255,.85); margin-top: 4px; }
.hp-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hp-stat { background: rgba(255,255,255,.12); border-radius: 10px; padding: 10px 12px; }
.hp-stat .k { font-size: 12px; color: rgba(255,255,255,.85); }
.hp-stat .v { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hp-cash { background: #fff; color: #1a1a2e; border-radius: 12px; padding: 12px 14px; }
.hp-cash .k { font-size: 12px; font-weight: 700; color: #1a5276; text-transform: uppercase; letter-spacing: .4px; }
.hp-cash .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hp-cash .d { font-size: 12px; color: #5b6472; line-height: 1.45; }
.hp-cash .d a { color: #1a5276; font-weight: 700; white-space: nowrap; }
.hp-flag { background: #fff7e6; color: #7c4a03; border-radius: 10px; padding: 9px 12px; font-size: 13px; line-height: 1.45; }
.hp-flag:empty { display: none; }
.hp-answer.is-empty .hp-big, .hp-answer.is-empty .hp-stat .v, .hp-answer.is-empty .hp-cash .v { opacity: .45; }

/* Section nav */
.hp-jump { display: flex; gap: 8px; overflow-x: auto; padding: 14px 2px 4px; scrollbar-width: none; }
.hp-jump::-webkit-scrollbar { display: none; }
.hp-jump a { flex: 0 0 auto; padding: 7px 12px; border-radius: 999px; background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-primary); font-size: 13px; font-weight: 600; text-decoration: none; }
.hp-jump a:hover { border-color: var(--primary-color); color: var(--primary-color); }

/* Tool sections */
.hp-sec { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 22px; margin-top: 16px; scroll-margin-top: 80px; }
.hp-sec > h2 { font-size: 21px; font-weight: 800; margin: 0 0 4px; color: var(--text-primary); }
.hp-sec > .hp-lead { font-size: 14px; color: var(--text-secondary); margin: 0 0 16px; line-height: 1.5; }
.hp-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.hp-row > .hp-field { flex: 1 1 160px; }
.hp-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.hp-card { border: 1.5px solid var(--card-border); border-radius: 12px; padding: 14px 16px; background: var(--card-bg); }
.hp-card.win { border-color: var(--accent-color); background: var(--accent-light); }
.hp-card.sel { border-color: var(--primary-color); background: var(--primary-light); }
.hp-card .t { font-size: 13px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.hp-card .m { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-primary); line-height: 1.1; }
.hp-card .m small { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.hp-card .s { font-size: 13px; color: var(--text-secondary); margin-top: 6px; line-height: 1.5; }
.hp-card .s strong { color: var(--text-primary); }
.hp-card .tag { display: inline-block; font-size: 11px; font-weight: 800; color: #fff; background: #047857; border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: 2px; }
button.hp-card { text-align: left; cursor: pointer; font: inherit; color: inherit; width: 100%; }
button.hp-card:hover { border-color: var(--primary-color); }
.hp-note { font-size: 14px; color: var(--text-primary); background: var(--bg-subtle); border-radius: 10px; padding: 12px 14px; margin-top: 14px; line-height: 1.55; }
.hp-note:empty { display: none; }
.hp-note a { color: var(--primary-color); font-weight: 700; }
.hp-small { font-size: 12px; color: var(--text-muted); margin: 12px 0 0; line-height: 1.5; }
.hp-small a { color: var(--text-secondary); }

/* Tables */
.hp-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--card-border); border-radius: 12px; }
.hp-table-wrap.tall { max-height: 460px; overflow-y: auto; }
.hp-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.hp-table th { position: sticky; top: 0; background: var(--bg-subtle); color: var(--text-secondary); font-size: 12px; font-weight: 700; text-align: right; padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--card-border); z-index: 1; }
.hp-table th:first-child, .hp-table td:first-child { text-align: left; }
.hp-table td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--card-border); white-space: nowrap; color: var(--text-primary); }
.hp-table tbody tr:last-child td { border-bottom: 0; }
.hp-table tr.hl td { background: var(--primary-light); font-weight: 700; }
.hp-table tr.tot td { font-weight: 800; background: var(--bg-subtle); }
.hp-table td.int { color: var(--interest-text, #b45309); font-weight: 600; }
.hp-table td.cap { color: var(--principal-color); font-weight: 600; }
.hp-table td.up { color: var(--danger-color); font-weight: 700; }
.hp-table td.down { color: var(--accent-text, #047857); font-weight: 700; }
.hp-table td.cpt { white-space: normal; }
.hp-table td.cpt small { display: block; font-size: 12px; font-weight: 400; color: var(--text-muted); margin-top: 2px; }
.hp-table td.wrap { white-space: normal; text-align: left; color: var(--text-secondary); font-size: 13px; min-width: 180px; }

/* Chart */
.hp-chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.hp-legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-secondary); }
.hp-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.hp-chart { position: relative; height: 280px; }
.hp-toggle { display: inline-flex; background: var(--bg-subtle); border: 1px solid var(--card-border); border-radius: 8px; padding: 3px; gap: 3px; }
.hp-toggle button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 700; color: var(--text-secondary); cursor: pointer; }
.hp-toggle button[aria-pressed="true"] { background: var(--primary-color); color: #fff; }
.hp-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--primary-color); color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; }
.hp-btn:hover { background: var(--primary-dark); }
.hp-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-primary); min-height: 48px; cursor: pointer; }
.hp-check input { width: 18px; height: 18px; accent-color: var(--primary-color); }

/* Article */
.hp-article { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 28px 30px; margin-top: 24px; }
.hp-article h2 { font-size: 22px; font-weight: 800; color: var(--text-primary); margin: 34px 0 12px; scroll-margin-top: 80px; }
.hp-article h2:first-child { margin-top: 0; }
.hp-article h3 { font-size: 17px; font-weight: 700; color: var(--text-primary); margin: 22px 0 8px; }
.hp-article p, .hp-article li { font-size: 16px; line-height: 1.7; color: var(--text-primary); }
.hp-article p { margin: 0 0 14px; }
.hp-article ul { padding-left: 20px; margin: 0 0 14px; }
.hp-article a { color: var(--primary-color); }
.hp-formula { background: var(--bg-subtle); border-radius: 10px; padding: 12px 16px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; overflow-x: auto; }
.hp-faq details { border: 1px solid var(--card-border); border-radius: 10px; margin-bottom: 8px; background: var(--card-bg); }
.hp-faq summary { padding: 14px 16px; font-weight: 700; font-size: 15px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 10px; color: var(--text-primary); }
.hp-faq summary::-webkit-details-marker { display: none; }
.hp-faq summary::after { content: '+'; color: var(--text-muted); font-weight: 800; }
.hp-faq details[open] summary::after { content: '−'; }
.hp-faq .a { padding: 0 16px 14px; font-size: 15px; line-height: 1.65; color: var(--text-secondary); }
.hp-sources { font-size: 13px; color: var(--text-secondary); }
.hp-sources li { font-size: 13px; line-height: 1.55; margin-bottom: 4px; color: var(--text-secondary); }
.hp-cta { background: linear-gradient(135deg, var(--seo-hero-bg-start) 0%, var(--seo-hero-bg-end) 100%); border-radius: 14px; padding: 26px; text-align: center; margin-top: 28px; }
.hp-cta h2 { margin: 0 0 6px !important; font-size: 21px; color: var(--seo-hero-text) !important; }
.hp-cta p { color: var(--seo-hero-subtitle) !important; font-size: 15px; max-width: 520px; margin: 0 auto 14px !important; }
.hp-cta a.hp-btn { text-decoration: none; color: #fff; }
.hp-related { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.hp-related a { display: block; border: 1px solid var(--card-border); border-radius: 12px; padding: 14px 16px; text-decoration: none; background: var(--card-bg); }
.hp-related a:hover { border-color: var(--primary-color); }
.hp-related strong { display: block; color: var(--text-primary); font-size: 15px; margin-bottom: 4px; }
.hp-related span { color: var(--text-secondary); font-size: 13px; line-height: 1.45; }

@media (max-width: 860px) {
    .hp-tool { grid-template-columns: 1fr; }
    .hp-related { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .hp-page { padding: 12px 12px 24px; }
    .hp-hero { margin-top: 4px; }
    .hp-hero h1 { font-size: 25px; }
    .hp-hero .hp-sub { font-size: 14px; }
    .hp-form { padding: 16px 14px 16px; }
    .hp-grid2 { gap: 12px 10px; }
    .hp-input input { font-size: 16px; padding-left: 12px; padding-right: 34px; }
    .hp-input .hp-unit { right: 11px; }
    .hp-answer { padding: 18px 16px; gap: 12px; }
    .hp-big { font-size: 40px; }
    .hp-stat .v { font-size: 18px; }
    .hp-sec { padding: 18px 14px; border-radius: 14px; }
    .hp-sec > h2 { font-size: 19px; }
    .hp-card .m { font-size: 23px; }
    .hp-chart { height: 240px; }
    .hp-article { padding: 20px 16px; }
    .hp-table { font-size: 13px; }
    .hp-table th, .hp-table td { padding: 8px 9px; }
    .hp-table .xs-hide { display: none; }
    .hp-cards { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; }
    .hp-card { padding: 12px; }
    .hp-row > .hp-field { flex-basis: 140px; }
    .hp-langs a { padding: 9px 10px; font-size: 12px; }
    .hp-jump { flex-wrap: wrap; overflow: visible; }
    .hp-ccaa-table thead { display: none; }
    .hp-ccaa-table tr, .hp-ccaa-table td { display: block; text-align: left !important; white-space: normal; min-width: 0; }
    .hp-ccaa-table tr { padding: 8px 10px; border-bottom: 1px solid var(--card-border); }
    .hp-ccaa-table td { border: 0; padding: 2px 0; }
    .hp-ccaa-table td:first-child { font-weight: 700; }
    .hp-ccaa-table td[data-label]::before { content: attr(data-label) ': '; font-weight: 600; color: var(--text-primary); }
}

/* Shared calculator (EN, PT, IT, FR, DE): principal and interest split in the answer panel */
.hp-split { display: flex; height: 12px; border-radius: 999px; overflow: hidden; margin: 8px 0 8px; background: #e5e7eb; }
.hp-split[hidden] { display: none; }
.hp-split .cap { background: #2E86C1; }
.hp-split .int { background: #e8930c; }
.hp-table td small { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.hp-cur { flex-direction: row; align-items: center; gap: 10px; }
.hp-cur .hp-chip { padding: 5px 12px; font-size: 13px; }
.hp-row > .hp-field.hp-freq { flex-basis: 280px; }
.hp-cash[hidden] { display: none; }
.hp-freq .hp-seg button { height: auto; min-height: 38px; padding: 6px 8px; line-height: 1.15; }
@media (max-width: 600px) {
    .hp-row.hp-selects > .hp-field { flex-basis: 100%; }
    #rates .hp-table th, #schedule .hp-table th { white-space: normal; }
    #schedule .hp-table th, #schedule .hp-table td { padding: 8px 6px; font-size: 12.5px; }
}
