.aip-calculator,
.aip-table-wrap,
.aip-stat-card,
.aip-apr-breakdown {
  margin: 1.5rem 0;
}

.aip-calculator,
.aip-apr-breakdown,
.aip-stat-card {
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(24, 38, 54, 0.06);
}

.aip-calculator {
  padding: 1rem;
}

.aip-calculator__grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.aip-calculator label,
.aip-calculator__result {
  display: grid;
  gap: 0.45rem;
}

.aip-calculator span,
.aip-calculator output,
.aip-apr-breakdown__summary span,
.aip-stat-card span {
  color: #526071;
  font-size: 0.925rem;
}

.aip-calculator input[type="number"] {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid #c7d0dc;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.aip-calculator input[type="range"] {
  /* Restore native rendering (overrides the theme's @layer appearance:none).
     accent-color controls the filled-track and thumb color. */
  -webkit-appearance: auto;
  appearance: auto;
  accent-color: hsl(215, 60%, 25%);
  width: 100%;
  height: 1.5rem;
  cursor: pointer;
  outline: none;
}

/* Restore native thumb appearance that the theme's @layer overrides */
.aip-calculator input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: auto;
  appearance: auto;
}

.aip-calculator input[type="range"]::-webkit-slider-runnable-track {
  height: 0.5rem;
  border-radius: 9999px;
}

.aip-calculator input[type="range"]::-moz-range-track {
  height: 0.5rem;
  border-radius: 9999px;
}

.aip-calculator input[type="range"]::-moz-range-progress {
  height: 0.5rem;
  border-radius: 9999px;
}

.aip-calculator__result {
  border-radius: 6px;
  background: #eef6ff;
  padding: 0.85rem;
}

.aip-calculator__result strong,
.aip-apr-breakdown__summary strong,
.aip-stat-card strong {
  color: #152033;
  font-size: 1.4rem;
  line-height: 1.2;
}

.aip-table-wrap {
  overflow-x: auto;
}

.aip-comparison-table,
.aip-apr-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: #fff;
}

.aip-comparison-table th,
.aip-comparison-table td,
.aip-apr-table th,
.aip-apr-table td {
  border: 1px solid #d8e0ea;
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

.aip-comparison-table th,
.aip-apr-table th {
  background: #f5f8fb;
  color: #152033;
  font-weight: 700;
}

.aip-comparison-table th button {
  all: unset;
  cursor: pointer;
  display: block;
  width: 100%;
}

.aip-stat-card {
  display: flex;
  align-items: stretch;
  margin: 1.5rem 0;
  border-radius: 0.625rem;
  overflow: hidden;
  border: 1px solid hsl(210 15% 85%);
  box-shadow: 0 2px 8px -2px hsl(220 30% 15% / 0.08);
}

.aip-stat-card__value {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 1.25rem 1.5rem;
  min-width: 7rem;
  text-align: center;
  border-right: 1px solid transparent;
}

.aip-stat-card strong {
  display: block;
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.aip-stat-card__icon {
  display: block;
  font-size: 1rem;
  opacity: 0.7;
}

.aip-stat-card__label {
  flex: 1;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 1rem 1.25rem;
  background: hsl(0 0% 100%);
  color: hsl(220 15% 38%);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Color variants — soft tinted left panel, dark legible text */
.aip-stat-card--blue  { border-color: hsl(215 60% 25% / 0.25); }
.aip-stat-card--blue  .aip-stat-card__value { background: hsl(215 60% 95%); border-right-color: hsl(215 60% 25% / 0.15); }
.aip-stat-card--blue  strong { color: hsl(215 60% 22%); }

.aip-stat-card--green  { border-color: hsl(155 50% 40% / 0.3); }
.aip-stat-card--green  .aip-stat-card__value { background: hsl(155 45% 93%); border-right-color: hsl(155 50% 40% / 0.15); }
.aip-stat-card--green  strong { color: hsl(155 55% 25%); }

.aip-stat-card--orange { border-color: hsl(30 85% 50% / 0.3); }
.aip-stat-card--orange .aip-stat-card__value { background: hsl(38 92% 94%); border-right-color: hsl(30 85% 50% / 0.2); }
.aip-stat-card--orange strong { color: hsl(30 85% 28%); }

.aip-stat-card--red    { border-color: hsl(0 72% 46% / 0.3); }
.aip-stat-card--red    .aip-stat-card__value { background: hsl(0 72% 96%); border-right-color: hsl(0 72% 46% / 0.15); }
.aip-stat-card--red    strong { color: hsl(0 72% 34%); }

@media (max-width: 500px) {
  .aip-stat-card {
    flex-direction: column;
  }

  .aip-stat-card__value {
    min-width: unset;
    padding: 1rem 1.25rem;
    border-right: none;
    border-bottom: 1px solid transparent;
  }

  .aip-stat-card--blue   .aip-stat-card__value { border-bottom-color: hsl(215 60% 25% / 0.15); }
  .aip-stat-card--green  .aip-stat-card__value { border-bottom-color: hsl(155 50% 40% / 0.15); }
  .aip-stat-card--orange .aip-stat-card__value { border-bottom-color: hsl(30 85% 50% / 0.2); }
  .aip-stat-card--red    .aip-stat-card__value { border-bottom-color: hsl(0 72% 46% / 0.15); }
}

.aip-apr-breakdown {
  padding: 1rem;
}

.aip-apr-breakdown__summary {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.aip-apr-breakdown__note {
  margin-bottom: 0;
  color: #526071;
  font-size: 0.925rem;
}

@media (max-width: 640px) {
  .aip-calculator__grid {
    grid-template-columns: 1fr;
  }

  .aip-apr-breakdown__summary {
    display: grid;
  }
}

/* ── Timeline ──────────────────────────────────────────────── */
.aip-timeline-wrap {
  padding: 1.25rem 1.25rem 0.25rem;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(24,38,54,.06);
}

.aip-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.aip-timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 1rem;
  width: 2px;
  background: #d8e0ea;
}

.aip-timeline__step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  position: relative;
}

.aip-timeline__dot {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid #d8e0ea;
  background: #fff;
  margin-top: 2px;
  position: relative;
  z-index: 1;
}

.aip-timeline__step--low    .aip-timeline__dot { border-color: #16a34a; background: #dcfce7; }
.aip-timeline__step--medium .aip-timeline__dot { border-color: #d97706; background: #fef3c7; }
.aip-timeline__step--high   .aip-timeline__dot { border-color: #ea580c; background: #ffedd5; }
.aip-timeline__step--critical .aip-timeline__dot { border-color: #dc2626; background: #fee2e2; }

.aip-timeline__content {
  display: grid;
  gap: 0.2rem;
  padding-bottom: 0.25rem;
}

.aip-timeline__title {
  color: #152033;
  font-size: 1rem;
  line-height: 1.3;
}

.aip-timeline__timeframe {
  color: #526071;
  font-size: 0.825rem;
  font-style: italic;
}

.aip-timeline__detail {
  color: #374151;
  font-size: 0.925rem;
  margin: 0;
  line-height: 1.55;
}

/* ── Debt Validation Letter Generator ─────────────────────── */
.aip-letter-generator {
  display: grid;
  gap: 1rem;
}

.aip-letter-generator__fields {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.aip-letter-generator label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: #374151;
}

.aip-letter-generator input,
.aip-letter-generator select {
  width: 100%;
  min-height: 2.6rem;
  border: 1px solid #c7d0dc;
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
  color: #152033;
  background: #fff;
}

.aip-letter-generator__output {
  position: relative;
  background: #f5f8fb;
  border: 1px solid #d8e0ea;
  border-radius: 6px;
  padding: 1.25rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  color: #152033;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 14rem;
}

.aip-letter-generator__copy {
  margin-top: 0.5rem;
  padding: 0.55rem 1.25rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.aip-letter-generator__copy:hover { background: #1d4ed8; }
.aip-letter-generator__copy--copied { background: #16a34a; }

/* ── SOL Table extras ──────────────────────────────────────── */
.aip-sol-table__highlight td {
  background: #eff6ff;
  font-weight: 600;
}

.aip-sol-table__disclaimer {
  margin: 0.75rem 0 0;
  color: #526071;
  font-size: 0.825rem;
}

/* ── Repayment Scenarios ───────────────────────────────────── */
.aip-repayment-scenarios {
  padding: 1rem;
}

.aip-scenarios-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.aip-scenarios-term {
  padding: 0.4rem 0.9rem;
  border: 1px solid #c7d0dc;
  border-radius: 20px;
  background: #f5f8fb;
  color: #374151;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.aip-scenarios-term:hover {
  background: #eef2f7;
  border-color: #2563eb;
}

.aip-scenarios-term--active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  font-weight: 600;
}

.aip-scenarios-table-wrap {
  overflow-x: auto;
}

.aip-scenarios-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  background: #fff;
}

.aip-scenarios-table th,
.aip-scenarios-table td {
  border: 1px solid #d8e0ea;
  padding: 0.65rem 0.8rem;
  text-align: left;
  font-size: 0.9rem;
}

.aip-scenarios-table th {
  background: #f5f8fb;
  color: #152033;
  font-weight: 700;
}

.aip-scenarios-apr {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.aip-scenarios-apr--green  { background: #dcfce7; color: #15803d; }
.aip-scenarios-apr--orange { background: #fef3c7; color: #92400e; }
.aip-scenarios-apr--red    { background: #fee2e2; color: #b91c1c; }

.aip-scenarios-note {
  margin: 0.75rem 0 0;
  color: #526071;
  font-size: 0.825rem;
}

/* ── Affordability Checker ─────────────────────────────────── */
.aip-affordability-checker {
  padding: 1rem;
}

.aip-afford-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1rem;
}

.aip-afford-label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: #374151;
}

.aip-afford-label input,
.aip-afford-label select {
  width: 100%;
  min-height: 2.6rem;
  border: 1px solid #c7d0dc;
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
  color: #152033;
  background: #fff;
}

.aip-afford-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.aip-afford-item {
  flex: 1 1 130px;
  display: grid;
  gap: 0.25rem;
  background: #eef6ff;
  border-radius: 6px;
  padding: 0.75rem;
}

.aip-afford-item span {
  color: #526071;
  font-size: 0.825rem;
}

.aip-afford-item strong {
  color: #152033;
  font-size: 1.3rem;
  line-height: 1.2;
}

.aip-afford-status {
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

.aip-afford-status p {
  margin: 0.25rem 0 0;
  color: inherit;
  font-size: 0.875rem;
}

.aip-afford-status--good    { background: #dcfce7; color: #14532d; border-left: 4px solid #16a34a; }
.aip-afford-status--caution { background: #fef3c7; color: #78350f; border-left: 4px solid #d97706; }
.aip-afford-status--high    { background: #fee2e2; color: #7f1d1d; border-left: 4px solid #dc2626; }
.aip-afford-status--neutral { background: #f5f8fb; color: #526071; border-left: 4px solid #c7d0dc; }

@media (max-width: 480px) {
  .aip-afford-summary { flex-direction: column; }
}