.loan-page {
  padding: var(--s-4) var(--s-3);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

/* Hero */
.loan-hero {
  background: linear-gradient(135deg, var(--surface-elevated) 0%, rgba(46,122,130,0.08) 100%);
  border: 1px solid rgba(46,122,130,0.18);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.loan-hero__label {
  font-size: var(--text-sm);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.loan-hero__total {
  font-family: 'DM Serif Display', serif;
  font-size: var(--text-3xl);
  color: var(--text-1);
}

.loan-hero__row {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-top: var(--s-1);
}

.loan-hero__metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.loan-hero__metric-value {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-1);
}

.loan-hero__metric-label {
  font-size: var(--text-xs);
  color: var(--text-2);
}

.loan-hero__debtfree {
  color: var(--positive);
}

/* Section title */
.loan-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--s-2);
}

/* Loan list */
.loan-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.loan-item {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  padding: var(--s-3) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  cursor: pointer;
  transition: background 0.15s, transform 200ms cubic-bezier(0.16,1,0.3,1), box-shadow 200ms ease;
}

.loan-item:hover {
  background: var(--surface);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.loan-item__main {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.loan-item__rank {
  font-size: var(--text-xs);
  color: var(--text-2);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.loan-item__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.loan-item__dot--high   { background: var(--negative); }
.loan-item__dot--mid    { background: var(--accent); }
.loan-item__dot--low    { background: var(--positive); }

.loan-item__info {
  flex: 1;
  min-width: 0;
}

.loan-item__name {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loan-item__meta {
  font-size: var(--text-xs);
  color: var(--text-2);
}

.loan-item__balance {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-1);
  text-align: right;
  flex-shrink: 0;
}

.loan-item__rate {
  font-size: var(--text-xs);
  color: var(--text-2);
  text-align: right;
}

/* Strategy toggle */
.loan-strategy {
  background: var(--surface-elevated);
  border: 1px solid rgba(46,122,130,0.12);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.loan-strategy-toggle {
  position: relative;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 0;
}

/* sliding indicator */
.loan-strategy-toggle::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--accent, #1F5E66);
  border-radius: calc(var(--r-md) - 3px);
  transition: transform 260ms cubic-bezier(0.16,1,0.3,1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.loan-strategy-toggle[data-active="snowball"]::before {
  transform: translateX(100%);
}

.loan-strategy-btn {
  flex: 1;
  padding: var(--s-2) var(--s-3);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 220ms ease;
  border-radius: calc(var(--r-md) - 3px);
}

.loan-strategy-btn.active {
  color: #fff;
  font-weight: 600;
  background: transparent;
}

.loan-strategy-result {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
}

.loan-strategy-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.loan-strategy-metric__value {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-1);
}

.loan-strategy-metric__label {
  font-size: var(--text-xs);
  color: var(--text-2);
}

/* Slider */
.loan-slider-row {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.loan-slider-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--text-2);
}

.loan-slider-value {
  font-weight: 600;
  color: var(--text-1);
}

.loan-slider-impact {
  font-size: var(--text-sm);
  color: var(--positive);
  margin-top: var(--s-1);
}

input[type="range"].loan-slider {
  width: 100%;
  accent-color: var(--primary-light);
}

/* Chart */
.loan-chart-wrap {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
  min-height: 220px;
}

/* Strategy comparison */
.loan-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.loan-compare-card {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  padding: var(--s-3);
}

.loan-compare-card__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--s-2);
}

.loan-compare-card__metric {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-1);
}

.loan-compare-card__sub {
  font-size: var(--text-xs);
  color: var(--text-2);
  margin-top: 2px;
}

/* Investera vs amortera */
.loan-invest-section {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.loan-invest-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.loan-invest-option {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--s-3);
}

.loan-invest-option__title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--s-1);
}

.loan-invest-option__return {
  font-family: 'DM Serif Display', serif;
  font-size: var(--text-xl);
  color: var(--text-1);
}

.loan-invest-option__desc {
  font-size: var(--text-xs);
  color: var(--text-2);
  margin-top: var(--s-1);
}

.loan-invest-warning {
  font-size: var(--text-xs);
  color: var(--accent);
  padding: var(--s-2) var(--s-3);
  background: rgba(245, 158, 11, 0.08);
  border-radius: var(--r-md);
}

/* Onboarding wizard */
.loan-wizard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s-6);
  max-width: 460px;
  margin: var(--s-4) auto;
  box-shadow: var(--shadow-md);
}

.loan-wizard__header {
  text-align: center;
  margin-bottom: var(--s-5);
}

.loan-wizard__header-icon {
  width: 52px;
  height: 52px;
  background: var(--accent-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--s-3);
  font-size: 24px;
  color: var(--accent);
}

.loan-wizard__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--text-1);
  margin-bottom: var(--s-1);
}

.loan-wizard__sub {
  font-size: var(--text-sm);
  color: var(--text-2);
}

.loan-wizard__type-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: var(--s-2);
}

.loan-wizard__type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  margin-bottom: var(--s-5);
}

.loan-type-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-3) var(--s-2);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.loan-type-tile i {
  font-size: 20px;
}

.loan-type-tile:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.loan-type-tile.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 700;
}

.loan-wizard__form {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.loan-wizard__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.loan-wizard__field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.loan-wizard__field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.loan-wizard__field input {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  color: var(--text-1);
  font-size: var(--text-md);
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 150ms ease;
  width: 100%;
  box-sizing: border-box;
}

.loan-wizard__field input:focus {
  border-color: var(--accent);
}

.loan-wizard__actions {
  margin-top: var(--s-2);
}

.loan-wizard__btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 150ms ease;
}

.loan-wizard__btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(31, 94, 102, 0.3);
}

.loan-wizard__btn:active {
  transform: scale(0.97);
  transition-duration: 80ms;
}

/* ── Hero redesign additions ── */
.loan-hero__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s-3);
}

.loan-hero__free-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-3);
  background: rgba(34, 197, 94, 0.1);
  color: var(--positive);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.loan-hero__metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--s-2);
}

.loan-hero__metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  transition: box-shadow 200ms ease;
}

.loan-hero__metric-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.loan-hero__metric-card .loan-hero__metric-value {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
}

.loan-hero__metric-unit {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--text-2);
}

.loan-hero__metric-card .loan-hero__metric-label {
  font-size: var(--text-xs);
  color: var(--text-2);
  margin-top: 2px;
}

/* ── Loan item additions ── */
.loan-item__rank-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.loan-item__rank-badge--high { background: rgba(239,68,68,.12); color: var(--negative); }
.loan-item__rank-badge--mid  { background: rgba(31,94,102,.12); color: var(--accent); }
.loan-item__rank-badge--low  { background: rgba(34,197,94,.12); color: var(--positive); }

.loan-item__type-icon {
  font-size: 18px;
  color: var(--text-2);
  flex-shrink: 0;
}

.loan-item__right {
  text-align: right;
  flex-shrink: 0;
}

.loan-item__bar-wrap {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.loan-item__bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 700ms cubic-bezier(0.16,1,0.3,1);
}

.loan-item__bar-fill--high { background: var(--negative); }
.loan-item__bar-fill--mid  { background: var(--accent); }
.loan-item__bar-fill--low  { background: var(--positive); }

/* ── Compare card additions ── */
.loan-compare-card--winner {
  border: 1.5px solid var(--positive);
}

.loan-compare-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s-2);
}

.loan-compare-card__badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--positive);
  background: rgba(34,197,94,.12);
  padding: 2px var(--s-2);
  border-radius: 99px;
  white-space: nowrap;
}

/* AI section */
.loan-ai-section {
  background: var(--surface-elevated);
  border: 1px solid rgba(46,122,130,0.14);
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
}

.loan-ai-header {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  background: rgba(46,122,130,0.06);
}

.loan-ai-header__icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(46,122,130,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 15px;
  flex-shrink: 0;
}

.loan-ai-header__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  flex: 1;
}

.loan-ai-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
  animation: loan-ai-pulse 2s ease-in-out infinite;
}

@keyframes loan-ai-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

.loan-ai-body {
  padding: var(--s-4);
}

.loan-ai-loading {
  color: var(--text-2);
  font-size: var(--text-sm);
}

/* AI response text styles */
.ai-response--text .ai-response__para {
  font-size: var(--text-sm);
  color: var(--text-1);
  line-height: 1.65;
  margin: 0 0 var(--s-2);
}

.ai-response--text .ai-response__para:last-child {
  margin-bottom: 0;
}

.ai-response--text .ai-response__item {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--border);
}

.ai-response--text .ai-response__item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ai-response__item-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(46,122,130,0.12);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-response__item-body {
  font-size: var(--text-sm);
  color: var(--text-1);
  line-height: 1.65;
  flex: 1;
}

.ai-response__inline-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  background: rgba(46,122,130,0.10);
  color: var(--accent);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  margin: 0 2px;
}
