/* ── College Affordability Calculator ───────────────────────── */
/* All values map to the shared Lewte design tokens in styles.css so this
   page matches the rest of the app exactly. */
.afd-wrap {
  --afd-purple: var(--primary);
  --afd-purple-soft: #EDE9FE;
  --afd-green: var(--success);
  --afd-yellow: var(--warning);
  --afd-orange: var(--warning);
  --afd-red: var(--error);
  --afd-line: var(--border);
  --afd-ink: var(--text);
  --afd-mute: var(--text-secondary);
}


.afd-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 18px;
}
.afd-top-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.afd-btn {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 40px; padding: 0 14px;
  border-radius: var(--r-full); border: 1px solid var(--afd-line);
  background: var(--card); color: var(--afd-ink);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}
.afd-btn:hover { border-color: var(--primary-light); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.afd-btn:focus-visible { outline: 3px solid rgba(124,58,237,.35); outline-offset: 2px; }
.afd-btn-primary { background: var(--primary-gradient); border-color: transparent; color: #fff; box-shadow: var(--shadow-md); }
.afd-btn-primary:hover { background: var(--primary-gradient-hover); box-shadow: var(--shadow-lg); }
.afd-btn-danger { color: var(--afd-red); }
.afd-btn-sm { min-height: 32px; font-size: 13px; padding: 0 11px; }

.afd-progress-card {
  background: var(--card); border: 1px solid var(--afd-line); border-radius: var(--r-lg);
  padding: 14px 16px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.afd-progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; color: var(--afd-mute); }
.afd-progress-head strong { color: var(--afd-ink); font-size: 15px; }
.afd-progress-track { height: 8px; border-radius: var(--r-full); background: var(--bg); margin-top: 9px; overflow: hidden; }
.afd-progress-fill { height: 100%; border-radius: var(--r-full); background: var(--primary-gradient); transition: width .5s cubic-bezier(.2,.8,.2,1); }

.afd-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1080px) { .afd-layout { grid-template-columns: minmax(0, 1fr); } }

.afd-col { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.afd-col-right { position: sticky; top: 84px; }
@media (max-width: 1080px) { .afd-col-right { position: static; } }

/* Cards */
.afd-card {
  background: var(--card); border: 1px solid var(--afd-line); border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.afd-card-pad { padding: 18px; }
.afd-intro h2 { margin: 0 0 6px; font-size: 21px; line-height: 1.25; }
.afd-intro p { margin: 0; color: var(--afd-mute); font-size: 14px; line-height: 1.55; }
.afd-benefits { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 9px; }
.afd-benefits li { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; color: var(--afd-ink); }
.afd-benefits li .icon { color: var(--afd-purple); flex: 0 0 auto; margin-top: 1px; }

/* Section (collapsible) */
.afd-sec-head {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 15px 16px; background: var(--card); border: 0; border-bottom: 1px solid transparent;
  font: inherit; text-align: left; cursor: pointer; color: var(--afd-ink);
}
.afd-sec.open .afd-sec-head { border-bottom-color: var(--afd-line); }
.afd-sec-head:focus-visible { outline: 3px solid rgba(124,58,237,.35); outline-offset: -3px; }
.afd-sec-badge {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: var(--r-md);
  display: grid; place-items: center; background: var(--afd-purple-soft); color: var(--afd-purple);
}
.afd-sec-titles { min-width: 0; flex: 1; }
.afd-sec-titles h3 { margin: 0; font-size: 16px; font-weight: 700; }
.afd-sec-titles span { display: block; font-size: 12.5px; color: var(--afd-mute); margin-top: 2px; }
.afd-sec-chev { flex: 0 0 auto; color: var(--afd-mute); transition: transform .25s ease; }
.afd-sec.open .afd-sec-chev { transform: rotate(180deg); }
.afd-sec-body { padding: 16px; display: none; animation: afdFade .28s ease both; }
.afd-sec.open .afd-sec-body { display: block; }
@keyframes afdFade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.afd-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.afd-grid-1 { grid-template-columns: minmax(0,1fr); }
@media (max-width: 560px) { .afd-grid { grid-template-columns: minmax(0,1fr); } }

.afd-field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.afd-field > label { font-size: 12.5px; font-weight: 600; color: var(--afd-ink); display: flex; align-items: center; gap: 6px; }
.afd-field input, .afd-field select {
  width: 100%; min-height: 42px; padding: 0 12px;
  border: 1px solid var(--afd-line); border-radius: var(--r-md); background: var(--card);
  font: inherit; font-size: 14.5px; color: var(--afd-ink);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.afd-field input:focus, .afd-field select:focus {
  outline: none; border-color: var(--afd-purple); box-shadow: 0 0 0 3px rgba(124,58,237,.16);
}
.afd-field.afd-money input { padding-left: 26px; }
.afd-money { position: relative; }
.afd-money .afd-money-sign {
  position: absolute; left: 11px; top: 34px; font-size: 14px; color: var(--afd-mute); pointer-events: none;
}
.afd-err { font-size: 11.5px; color: var(--afd-red); min-height: 0; }
.afd-field.invalid input { border-color: var(--afd-red); }
.afd-radios { display: flex; flex-wrap: wrap; gap: 6px; }
.afd-radios label {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 11px;
  border: 1px solid var(--afd-line); border-radius: var(--r-full); font-size: 12.5px; line-height: 1;
  white-space: nowrap; cursor: pointer; background: var(--card);
}
.afd-radios input[type="radio"] {
  accent-color: var(--afd-purple);
  width: 13px; height: 13px; min-width: 13px; min-height: 13px; margin: 0; flex: none;
}
.afd-radios label:has(input:checked) { border-color: var(--afd-purple); background: var(--afd-purple-soft); color: var(--afd-purple); font-weight: 600; }


/* Tooltip */
.afd-tip { position: relative; display: inline-flex; }
.afd-tip > button {
  border: 0; background: none; padding: 0; margin: 0; cursor: help; color: var(--afd-mute);
  display: inline-flex; line-height: 0;
}
.afd-tip > span {
  position: absolute; left: 50%; bottom: 130%; transform: translateX(-50%) translateY(4px);
  width: max-content; max-width: 240px; padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--afd-ink); color: #fff; font-size: 12px; font-weight: 500; line-height: 1.4;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; z-index: 40;
}
.afd-tip:hover > span, .afd-tip > button:focus-visible + span { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Repeatable scholarships */
.afd-rows { display: grid; gap: 10px; }
.afd-row {
  display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,.9fr) minmax(0,1fr) auto; gap: 8px; align-items: end;
  padding: 10px; border: 1px solid var(--afd-line); border-radius: var(--r-md); background: var(--bg);
}
@media (max-width: 700px) { .afd-row { grid-template-columns: minmax(0,1fr) minmax(0,1fr); } }
.afd-row .afd-row-del { align-self: center; }

.afd-total-strip {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--afd-purple-soft); color: var(--afd-purple);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-weight: 700; font-size: 15px;
}
.afd-total-strip small { display: block; font-weight: 600; font-size: 12px; color: var(--primary-dark); }

/* Dashboard */
.afd-gauge-card { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 18px; align-items: center; padding: 18px; }
@media (max-width: 480px) { .afd-gauge-card { grid-template-columns: minmax(0,1fr); text-align: center; justify-items: center; } }
.afd-gauge { position: relative; width: 150px; height: 150px; flex: 0 0 auto; }
.afd-gauge svg { width: 150px; height: 150px; transform: rotate(-90deg); }
.afd-gauge-ring { fill: none; stroke: var(--bg); stroke-width: 13; }
.afd-gauge-val { fill: none; stroke-width: 13; stroke-linecap: round; transition: stroke-dashoffset .7s cubic-bezier(.2,.8,.2,1), stroke .4s ease; }
.afd-gauge-num {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.afd-gauge-num b { font-size: 34px; line-height: 1; }
.afd-gauge-num span { font-size: 11.5px; color: var(--afd-mute); letter-spacing: .04em; text-transform: uppercase; }
.afd-rating { font-size: 18px; font-weight: 800; margin: 0 0 6px; }
.afd-rating-note { margin: 0; font-size: 13.5px; color: var(--afd-mute); line-height: 1.55; }

.afd-kpis { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.afd-kpi { padding: 15px; border-radius: var(--r-lg); border: 1px solid var(--afd-line); background: var(--card); }
.afd-kpi span { display: block; font-size: 12px; color: var(--afd-mute); font-weight: 600; }
.afd-kpi b { display: block; font-size: 24px; margin-top: 4px; letter-spacing: -.01em; }
.afd-kpi small { display: block; font-size: 11.5px; color: var(--afd-mute); margin-top: 3px; }
.afd-kpi-hero { grid-column: span 2; background: var(--primary-gradient); border-color: transparent; color: #fff; }
.afd-kpi-hero span, .afd-kpi-hero small { color: rgba(255,255,255,.82); }
.afd-kpi-hero b { font-size: 34px; }
.afd-pos { color: var(--afd-green); }
.afd-neg { color: var(--afd-red); }

.afd-card h4 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.afd-lines { display: grid; gap: 8px; }
.afd-lines div { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--afd-ink); }
.afd-lines div span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.afd-lines .afd-sub span { color: var(--afd-mute); font-weight: 500; }
.afd-lines .afd-eq { border-top: 1px solid var(--afd-line); padding-top: 8px; font-weight: 800; }

/* Charts */
.afd-donut-wrap { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.afd-donut { width: 170px; height: 170px; flex: 0 0 auto; }
.afd-donut path { transition: transform .2s ease, opacity .2s ease; transform-origin: 85px 85px; cursor: pointer; }
.afd-donut path:hover { transform: scale(1.05); }
.afd-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; flex: 1; min-width: 160px; }
.afd-legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.afd-legend i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.afd-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.afd-legend li.dim { opacity: .45; }

.afd-stack { display: flex; height: 30px; border-radius: var(--r-sm); overflow: hidden; background: var(--bg); }
.afd-stack i { display: block; height: 100%; transition: width .55s cubic-bezier(.2,.8,.2,1); }
.afd-stack i:hover { filter: brightness(1.08); }

.afd-linechart { width: 100%; height: 190px; }
.afd-linechart .afd-area { transition: opacity .4s ease; }
.afd-linechart .afd-dot { transition: r .2s ease; }
.afd-linechart .afd-dot:hover { r: 6; }
.afd-linechart text { font-size: 10px; fill: var(--afd-mute); }
.afd-debt-meta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 13px; color: var(--afd-mute); }
.afd-debt-meta b { color: var(--afd-ink); }

/* Recommendations + AI */
.afd-recs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.afd-recs li {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px;
  border-radius: var(--r-md); border: 1px solid var(--afd-line); background: var(--bg); font-size: 13.5px; line-height: 1.5;
  animation: afdFade .3s ease both;
}
.afd-recs li .icon { color: var(--afd-purple); flex: 0 0 auto; margin-top: 1px; }
.afd-rec-chip {
  display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: var(--r-full);
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  vertical-align: 1px; white-space: nowrap;
}
.afd-rec-sch { background: #EDE9FE; color: var(--primary-dark); }
.afd-rec-loan { background: #FEE7E7; color: #B91C1C; }
.afd-rec-bud { background: #E4F3EA; color: #15803D; }
.afd-rec-aid { background: #E3EEFD; color: #1D4ED8; }
.afd-rec-cost { background: #FDF0DC; color: #B45309; }
.afd-ai { border: 1px solid var(--border); background: linear-gradient(180deg, var(--bg), var(--card)); }
.afd-ai p { margin: 0 0 10px; font-size: 14px; line-height: 1.6; }
.afd-ai p:last-child { margin-bottom: 0; }
.afd-ai-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--afd-purple);
  background: var(--afd-purple-soft); border-radius: var(--r-full); padding: 4px 9px; margin-bottom: 10px;
}

/* Saved profiles + compare */
.afd-saved { display: grid; gap: 10px; }
.afd-saved-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 11px 12px; border: 1px solid var(--afd-line); border-radius: var(--r-md); background: var(--card);
}
.afd-saved-row.active { border-color: var(--afd-purple); background: var(--afd-purple-soft); }
.afd-saved-row .afd-saved-name { font-weight: 700; font-size: 14px; min-width: 0; flex: 1; }
.afd-saved-row .afd-saved-name small { display: block; font-weight: 500; color: var(--afd-mute); font-size: 12px; }
.afd-compare { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.afd-compare th, .afd-compare td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--afd-line); white-space: nowrap; }
.afd-compare th:first-child, .afd-compare td:first-child { text-align: left; }
.afd-compare thead th { color: var(--afd-mute); font-size: 12px; font-weight: 700; }
.afd-compare-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.afd-empty { color: var(--afd-mute); font-size: 13.5px; margin: 0; }

/* Mobile sticky summary */
.afd-sticky {
  display: none; position: sticky; top: 62px; z-index: 30;
  background: color-mix(in srgb, var(--card) 93%, transparent); backdrop-filter: blur(10px);
  border: 1px solid var(--afd-line); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 14px;
  gap: 10px; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-md);
}
.afd-sticky b { font-size: 17px; }
.afd-sticky span { display: block; font-size: 11px; color: var(--afd-mute); font-weight: 600; }
@media (max-width: 1080px) { .afd-sticky { display: flex; } }

@media (prefers-reduced-motion: reduce) {
  .afd-wrap *, .afd-wrap *::before, .afd-wrap *::after { transition: none !important; animation: none !important; }
}

.afd-field.afd-full { grid-column: 1 / -1; }
.afd-radio-label { font-size: 12.5px; font-weight: 600; color: var(--afd-ink); display: flex; align-items: center; gap: 6px; }
.afd-sticky > div { text-align: center; flex: 1; }
