/* ── Self-hosted DM Sans variable font (no Google Fonts request) ──
   DM Sans v17 is a variable font; Google serves 2 files covering
   the full weight axis. Declaring font-weight: 100 900 lets the
   browser use the variable axis for every weight (400–700). ── */
@font-face {
  font-family: 'DM Sans';
  src: url('fonts/dmsans-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Sans';
  src: url('fonts/dmsans-latin-ext.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Scoped box-sizing reset (theme-safe) ── */
.tf-wp-calculator *,
.tf-wp-calculator *::before,
.tf-wp-calculator *::after,
.tf-wp-combined *,
.tf-wp-combined *::before,
.tf-wp-combined *::after {
  box-sizing: border-box;
}

/* ── CSS custom properties — single source of truth ── */
.tf-wp-calculator,
.tf-wp-combined {
  --tf-brand:    #004e8d;
  --tf-dark:     #313b44;
  --tf-teal:     #82cfd1;
  --tf-gradient: linear-gradient(135deg, #313b44 0%, #004e8d 100%);
  --tf-border:   #dde3e8;
  --tf-text:     #1a2633;
  --tf-muted:    #6b7c8d;
}

/* ── Reset & base ── */
.tf-wp-calculator,
.tf-wp-combined,
.tf-wp-calculator *,
.tf-wp-combined * {
  box-sizing: border-box;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.tf-wp-calculator { margin: 0 auto; }

/* ── Combined tab nav ── */
.tf-wp-combined .tf-tabs {
  display: flex;
  border-bottom: 2px solid var(--tf-border);
  margin-bottom: 0;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
.tf-wp-combined .tf-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 12px 22px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--tf-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tf-wp-combined .tf-tab:hover { color: var(--tf-brand); }
.tf-wp-combined .tf-tab--active,
.tf-wp-combined .tf-tab[aria-selected="true"] { color: var(--tf-brand); border-bottom-color: var(--tf-brand); }
.tf-wp-combined .tf-tab:focus-visible {
  outline: 2px solid var(--tf-brand);
  outline-offset: -2px;
  border-radius: 3px;
}

/* ── Card wrapper ── */
.tf-wp-calculator .tf-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--tf-border);
  overflow: hidden;
}
.tf-wp-calculator .tf-card-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid #edf0f3;
}
.tf-wp-calculator .tf-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--tf-text);
  margin: 0 0 6px;
  padding: 0;
  line-height: 1.25;
}
.tf-wp-calculator .tf-card-desc {
  font-size: 0.88rem;
  color: var(--tf-muted);
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

/* ── Two-column grid ── */
.tf-wp-calculator .tf-calc-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
}

/* ── Inputs panel ── */
.tf-wp-calculator .tf-inputs-panel {
  padding: 24px 20px;
  border-right: 1px solid #edf0f3;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.tf-wp-calculator .tf-field { display: flex; flex-direction: column; gap: 6px; }
.tf-wp-calculator .tf-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #3d4f5e;
  letter-spacing: 0.01em;
  margin: 0;
  display: block;
}
.tf-wp-calculator .tf-label-hint {
  font-weight: 400;
  color: #8a9aaa;
  font-size: 0.78rem;
}

/* Dollar input */
.tf-wp-calculator .tf-dollar-wrap { position: relative; display: flex; align-items: center; }
.tf-wp-calculator .tf-dollar-sign {
  position: absolute;
  left: 12px;
  color: var(--tf-muted);
  font-size: 0.9rem;
  font-weight: 500;
  pointer-events: none;
  z-index: 1;
}
.tf-wp-calculator .tf-input {
  width: 100%;
  border: 1.5px solid var(--tf-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--tf-text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
  -webkit-appearance: none;
}
.tf-wp-calculator .tf-input::-webkit-outer-spin-button,
.tf-wp-calculator .tf-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tf-wp-calculator .tf-input:focus,
.tf-wp-calculator .tf-input:focus-visible {
  outline: none;
  border-color: var(--tf-brand);
  box-shadow: 0 0 0 3px rgba(0,78,141,0.1);
}
.tf-wp-calculator .tf-input--dollar { padding-left: 28px; }

/* Slider + number inline */
.tf-wp-calculator .tf-slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.tf-wp-calculator .tf-num-wrap { display: flex; align-items: center; gap: 4px; }
.tf-wp-calculator .tf-num-input {
  width: 72px;
  border: 1.5px solid var(--tf-border);
  border-radius: 6px;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--tf-text);
  background: #fff;
  text-align: right;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  -moz-appearance: textfield;
}
.tf-wp-calculator .tf-num-input::-webkit-outer-spin-button,
.tf-wp-calculator .tf-num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tf-wp-calculator .tf-num-input:focus,
.tf-wp-calculator .tf-num-input:focus-visible {
  outline: none;
  border-color: var(--tf-brand);
  box-shadow: 0 0 0 3px rgba(0,78,141,0.1);
}
.tf-wp-calculator .tf-num-unit { font-size: 0.82rem; color: var(--tf-muted); font-weight: 500; }

/* Range slider */
.tf-wp-calculator .tf-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--tf-brand) 0%, var(--tf-brand) var(--pct, 0%), var(--tf-border) var(--pct, 0%), var(--tf-border) 100%);
  cursor: pointer;
  outline: none;
  border: none;
  padding: 0;
  margin: 4px 0 0;
}
.tf-wp-calculator .tf-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--tf-brand);
  box-shadow: 0 1px 4px rgba(0,78,141,0.25);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.tf-wp-calculator .tf-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--tf-brand);
  box-shadow: 0 1px 4px rgba(0,78,141,0.25);
  cursor: pointer;
}
.tf-wp-calculator .tf-slider:hover::-webkit-slider-thumb { box-shadow: 0 2px 8px rgba(0,78,141,0.35); }
.tf-wp-calculator .tf-slider:focus-visible { outline: 2px solid var(--tf-brand); outline-offset: 2px; }
.tf-wp-calculator .tf-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #9aaab8;
  margin-top: 3px;
}

/* Frequency buttons */
.tf-wp-calculator .tf-freq-group { display: flex; gap: 6px; }
.tf-wp-calculator .tf-freq-btn {
  flex: 1;
  padding: 7px 6px;
  border: 1.5px solid var(--tf-border);
  border-radius: 7px;
  background: #fff;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--tf-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  white-space: nowrap;
}
.tf-wp-calculator .tf-freq-btn:hover { border-color: var(--tf-brand); color: var(--tf-brand); }
.tf-wp-calculator .tf-freq-btn--active {
  background: var(--tf-brand);
  border-color: var(--tf-brand);
  color: #fff;
  font-weight: 600;
}
.tf-wp-calculator .tf-freq-btn:focus-visible {
  outline: 2px solid var(--tf-brand);
  outline-offset: 2px;
}

/* ── Results panel ── */
.tf-wp-calculator .tf-results-panel {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tf-wp-calculator .tf-results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.tf-wp-calculator .tf-result-card {
  border: 1.5px solid var(--tf-border);
  border-radius: 10px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tf-wp-calculator .tf-result-card--primary {
  background: var(--tf-gradient);
  border-color: transparent;
}
.tf-wp-calculator .tf-result-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: #7a8fa6;
  letter-spacing: 0.01em;
  line-height: 1.3;
  margin: 0;
  display: block;
}
.tf-wp-calculator .tf-result-card--primary .tf-result-label { color: rgba(255,255,255,0.7); }
.tf-wp-calculator .tf-result-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--tf-text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  margin: 0;
  display: block;
}
.tf-wp-calculator .tf-result-card--primary .tf-result-value { color: #fff; }

/* ── Extra / highlight box ── */
.tf-wp-calculator .tf-extra-results {
  border: 2px solid var(--tf-brand);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,78,141,0.15);
  display: none;
}
.tf-wp-calculator .tf-extra-results.tf-visible { display: block; }
.tf-wp-calculator .tf-extra-header {
  background: var(--tf-gradient);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}
.tf-wp-calculator .tf-extra-grid {
  display: grid;
  background: #fff;
}
.tf-wp-calculator .tf-extra-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.tf-wp-calculator .tf-extra-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.tf-wp-calculator .tf-extra-stat {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid rgba(0,78,141,0.12);
}
.tf-wp-calculator .tf-extra-stat:last-child { border-right: none; }
.tf-wp-calculator .tf-extra-stat-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: #556070;
  letter-spacing: 0.01em;
  margin: 0;
  display: block;
}
.tf-wp-calculator .tf-extra-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--tf-brand);
  letter-spacing: -0.01em;
  white-space: nowrap;
  margin: 0;
  display: block;
}

/* ── Chart ── */
.tf-wp-calculator .tf-chart-wrap { position: relative; height: 320px; margin: 20px 0; }
.tf-wp-calculator .tf-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.tf-wp-calculator .tf-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--tf-muted);
  font-weight: 500;
}
.tf-wp-calculator .tf-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── CTA button ── */
.tf-wp-calculator .tf-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 24px;
  background: var(--tf-gradient);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 10px;
  letter-spacing: 0.01em;
  transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(0,78,141,0.3);
  border: none;
  cursor: pointer;
}
.tf-wp-calculator .tf-cta-btn:hover,
.tf-wp-calculator .tf-cta-btn:focus-visible {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,78,141,0.4);
  color: #fff;
  text-decoration: none;
  outline: none;
}
.tf-wp-calculator .tf-cta-arrow { font-size: 1.1rem; transition: transform 0.15s; }
.tf-wp-calculator .tf-cta-btn:hover .tf-cta-arrow { transform: translateX(3px); }

/* ── View toggle (Amortisation) ── */
.tf-wp-calculator .tf-view-toggle {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 4px;
}
.tf-wp-calculator .tf-view-btn {
  flex: 1;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--tf-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.tf-wp-calculator .tf-view-btn--active {
  background: #fff;
  color: var(--tf-brand);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.tf-wp-calculator .tf-view-btn:focus-visible {
  outline: 2px solid var(--tf-brand);
  outline-offset: 1px;
}

/* ── Table ── */
.tf-wp-calculator .tf-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tf-wp-calculator .tf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 420px;
}
.tf-wp-calculator .tf-table thead tr { background: #f8fafc; }
.tf-wp-calculator .tf-table th {
  padding: 8px 10px;
  text-align: right;
  font-weight: 600;
  color: var(--tf-muted);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1.5px solid #edf0f3;
  white-space: nowrap;
}
.tf-wp-calculator .tf-table th:first-child { text-align: left; }
.tf-wp-calculator .tf-table td {
  padding: 7px 10px;
  text-align: right;
  border-bottom: 1px solid #f3f6f8;
  color: #3d4f5e;
  white-space: nowrap;
}
.tf-wp-calculator .tf-table td:first-child { text-align: left; color: var(--tf-muted); }
.tf-wp-calculator .tf-table tbody tr:hover td { background: #fafbfc; }
.tf-wp-calculator .tf-table tbody tr:last-child td { border-bottom: none; }

/* ── Pagination ── */
.tf-wp-calculator .tf-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 0 4px;
  flex-wrap: wrap;
}
.tf-wp-calculator .tf-page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1.5px solid var(--tf-border);
  border-radius: 7px;
  background: #fff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--tf-muted);
  cursor: pointer;
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tf-wp-calculator .tf-page-btn:hover:not(:disabled) { border-color: var(--tf-brand); color: var(--tf-brand); }
.tf-wp-calculator .tf-page-btn--active { background: var(--tf-brand); border-color: var(--tf-brand); color: #fff; font-weight: 600; }
.tf-wp-calculator .tf-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tf-wp-calculator .tf-page-btn:focus-visible {
  outline: 2px solid var(--tf-brand);
  outline-offset: 1px;
}
.tf-wp-calculator .tf-page-ellipsis { color: #9aaab8; font-size: 0.82rem; padding: 0 4px; }

/* ── Disclaimer ── */
.tf-wp-calculator .tf-disclaimer {
  font-size: 0.75rem;
  color: #9aaab8;
  text-align: center;
  line-height: 1.6;
  padding: 12px 20px;
  border-top: 1px solid #edf0f3;
  margin: 0;
}

/* ════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════ */
@media (min-width: 640px) and (max-width: 899px) {
  .tf-wp-calculator .tf-calc-grid { grid-template-columns: 1fr; }
  .tf-wp-calculator .tf-inputs-panel { border-right: none; border-bottom: 1px solid #edf0f3; }
  .tf-wp-calculator .tf-results-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 639px) {
  .tf-wp-calculator .tf-card-header { padding: 18px 16px 14px; }
  .tf-wp-calculator .tf-card-title { font-size: 1.05rem; }
  .tf-wp-calculator .tf-calc-grid { grid-template-columns: 1fr; }
  .tf-wp-calculator .tf-inputs-panel { padding: 16px; border-right: none; border-bottom: 1px solid #edf0f3; gap: 16px; }
  .tf-wp-calculator .tf-results-panel { padding: 16px; gap: 12px; }
  .tf-wp-calculator .tf-results-grid { grid-template-columns: 1fr; gap: 8px; }
  .tf-wp-calculator .tf-result-value { font-size: 1.15rem; }
  .tf-wp-calculator .tf-extra-grid.cols-3 { grid-template-columns: 1fr; }
  .tf-wp-calculator .tf-extra-grid.cols-2 { grid-template-columns: 1fr; }
  .tf-wp-calculator .tf-extra-stat { border-right: none; border-bottom: 1px solid rgba(0,78,141,0.08); }
  .tf-wp-calculator .tf-extra-stat:last-child { border-bottom: none; }
  .tf-wp-calculator .tf-cta-btn { font-size: 0.85rem; padding: 13px 16px; }
  .tf-wp-calculator .tf-slider::-webkit-slider-thumb { width: 22px; height: 22px; }
  .tf-wp-calculator .tf-slider::-moz-range-thumb { width: 22px; height: 22px; }
  .tf-wp-calculator .tf-freq-btn { font-size: 0.75rem; padding: 7px 4px; }
  .tf-wp-combined .tf-tab { padding: 10px 14px; font-size: 0.85rem; }
}

@media (max-width: 379px) {
  .tf-wp-calculator .tf-results-grid { grid-template-columns: 1fr; }
  .tf-wp-calculator .tf-num-input { width: 60px; }
}
