/* Public Loan EMI Calculator (/loan-emi-calculator).
 *
 * Built on theme-dark.css and auth.css (aurora backdrop, gold button, ghost
 * buttons, --auth-* tokens), like /short-link and /mqllock; this file adds
 * the hero, the calculator panels, the results (cards, donut, balance bars,
 * comparison, yearly accordion) and the explanatory content.
 *
 * Layout, mobile first: hero, the form, the results summary, the comparison,
 * the schedule, then the content. From 1024px the form and the summary sit
 * side by side and the comparison and schedule span both columns below. The
 * results partial's wrapper uses `display: contents`, so its sections are
 * placed directly on the calculator grid.
 *
 * Motion (transform and opacity only, nothing under prefers-reduced-motion):
 * the decorative coin motif, the turning light on the EMI card, the donut
 * and bars growing in when a result arrives, and the scroll reveal of the
 * content (start states only after loan-emi-page.js marks <html> with
 * `emi-js`). The heading and the intro never animate in.
 */

.emi-body {
  --emi-max: clamp(64rem, 50rem + 24vw, 84rem);
  --emi-gap: clamp(1rem, 0.7rem + 1.2vw, 2rem);
  --emi-surface: rgba(17, 18, 24, 0.82);
  --emi-surface-raised: rgba(255, 255, 255, 0.035);
  --emi-principal: var(--auth-gold);
  --emi-interest: #7c9cff;
  --emi-interest-soft: rgba(124, 156, 255, 0.14);
  --emi-good: var(--auth-success);
  --emi-touch: 44px;
}

.emi-main {
  display: block;
  padding-bottom: clamp(3rem, 2rem + 4vw, 6rem);
  overflow-x: clip;
}

.emi-container {
  width: 100%;
  max-width: calc(var(--emi-max) + 2 * var(--site-header-gutter));
  margin-inline: auto;
  padding-inline: var(--site-header-gutter);
}

/* ----------------------------------------------------------------- Hero */

.emi-hero {
  position: relative;
  isolation: isolate;
  padding-block: clamp(1.5rem, 1rem + 2.5vw, 4rem) clamp(1.5rem, 1rem + 2vw, 3rem);
  overflow: hidden;
}

.emi-hero__inner {
  display: grid;
  justify-items: start;
  gap: clamp(0.75rem, 0.55rem + 0.6vw, 1.25rem);
}

.emi-breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
}

.emi-breadcrumb__list li + li::before {
  content: "/";
  margin-right: 0.5rem;
  color: var(--auth-line-strong);
}

.emi-breadcrumb__list a {
  color: var(--auth-muted);
  text-decoration: none;
}

.emi-breadcrumb__list a:hover {
  color: var(--auth-gold);
}

.emi-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--radius-pill);
  background-color: var(--auth-gold-soft);
  color: var(--auth-gold);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.emi-kicker__pulse {
  position: relative;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background-color: var(--auth-gold);
}

.emi-kicker__pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-color: var(--auth-gold);
  opacity: 0;
}

.emi-hero__title {
  font-family: var(--font-brand);
  font-size: clamp(2.1rem, 1.2rem + 3vw, 4rem);
  font-weight: var(--font-weight-brand);
  line-height: 1.05;
  letter-spacing: -0.03em;
  background: linear-gradient(100deg, var(--auth-text) 30%, var(--auth-gold-strong) 75%, var(--auth-gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.emi-hero__lead {
  max-width: 44em;
  color: var(--auth-muted);
  font-size: clamp(1rem, 0.92rem + 0.35vw, 1.2rem);
  line-height: 1.65;
}

.emi-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.emi-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--radius-pill);
  background-color: var(--emi-surface-raised);
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
}

.emi-chip__icon {
  width: 1rem;
  height: 1rem;
  color: var(--auth-gold);
}

/* Decorative motif: a falling repayment curve in the hero's corner. */
.emi-motif {
  position: absolute;
  right: -4%;
  bottom: -6%;
  z-index: -1;
  width: clamp(16rem, 38vw, 34rem);
  height: auto;
  opacity: 0.55;
  pointer-events: none;
}

@media (max-width: 719.98px) {
  .emi-motif {
    opacity: 0.3;
  }
}

.emi-motif__curve {
  fill: none;
  stroke: rgba(235, 196, 42, 0.45);
  stroke-width: 2;
  stroke-dasharray: 6 8;
}

.emi-motif__coin {
  fill: var(--auth-gold);
  transform-box: fill-box;
  transform-origin: center;
}

.emi-motif__coin--2 { fill: #f7d35a; }
.emi-motif__coin--3 { fill: var(--emi-interest); }

/* ----------------------------------------------------------- Calculator */

.emi-calc {
  position: relative;
}

.emi-calc__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--emi-gap);
  align-items: start;
}

/* The partial's wrapper: its sections join this grid. */
.emi-results {
  display: contents;
}

@media (min-width: 1024px) {
  .emi-calc__grid {
    grid-template-columns: minmax(0, clamp(22rem, 18rem + 10vw, 30rem)) minmax(0, 1fr);
  }

  .emi-form {
    grid-column: 1;
    grid-row: 1;
  }

  .emi-summary {
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: calc(var(--site-header-height) + 1rem);
  }

  .emi-compare,
  .emi-schedule {
    grid-column: 1 / -1;
  }
}

.emi-panel {
  position: relative;
  min-width: 0;
  padding: clamp(1.1rem, 0.8rem + 1.4vw, 2.25rem);
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius);
  background-color: var(--emi-surface);
  box-shadow: 0 40px 80px -48px rgba(0, 0, 0, 0.95);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .emi-panel {
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    backdrop-filter: blur(18px) saturate(140%);
  }
}

.emi-panel__header {
  display: grid;
  gap: 0.35rem;
  margin-bottom: var(--auth-gap);
}

.emi-panel__badge {
  display: inline-grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  margin-bottom: 0.25rem;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--auth-gold-strong), var(--auth-gold));
  color: var(--color-brand-contrast);
  font-size: 1.25rem;
  font-weight: var(--font-weight-bold);
  box-shadow: 0 10px 30px -10px var(--auth-gold-glow);
}

.emi-panel__title {
  font-family: var(--font-brand);
  font-size: clamp(1.3rem, 1.05rem + 0.8vw, 1.75rem);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.02em;
}

.emi-panel__subtitle {
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
  line-height: 1.55;
}

.emi-panel__subtitle strong {
  color: var(--auth-text);
}

/* ---------------------------------------------------------------- Form */

.emi-form {
  display: grid;
  gap: clamp(1rem, 0.8rem + 0.6vw, 1.4rem);
}

.emi-form .emi-panel__header {
  margin-bottom: 0;
}

.emi-form__alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(255, 138, 138, 0.4);
  border-radius: var(--auth-radius-sm);
  background-color: var(--auth-error-soft);
  color: var(--auth-text);
  font-size: var(--auth-fs-small);
}

.emi-form__alert[hidden],
.emi-form__retry[hidden] {
  display: none;
}

.emi-form__alert > span {
  flex: 1 1 12rem;
}

.emi-form__alert-icon {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--auth-error);
}

.emi-field {
  display: grid;
  align-content: start;
  gap: 0.45rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.emi-field__label {
  padding: 0;
  color: var(--auth-text);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-semibold);
}

.emi-field__control-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.emi-field__control {
  width: 100%;
  min-height: var(--emi-touch);
  height: calc(var(--auth-control) - 4px);
  padding: 0 0.9rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--auth-field);
  color: var(--auth-text);
  font: inherit;
  font-size: var(--auth-fs-body);
  font-variant-numeric: tabular-nums;
  transition: border-color var(--transition-normal), background-color var(--transition-normal),
    box-shadow var(--transition-normal);
}

.emi-field__control:hover {
  border-color: var(--auth-line-strong);
  background-color: var(--auth-field-hover);
}

.emi-field__control:focus {
  outline: none;
  border-color: var(--auth-gold);
  background-color: rgba(235, 196, 42, 0.05);
  box-shadow: 0 0 0 4px var(--auth-gold-soft);
}

.emi-field__select {
  padding-inline-end: 0.6rem;
  cursor: pointer;
}

.emi-field__select option {
  background-color: #15161c;
  color: var(--auth-text);
}

.emi-field__control-wrap--prefix .emi-field__control {
  padding-inline-start: 2.4rem;
}

.emi-field__control-wrap--suffix .emi-field__control {
  padding-inline-end: 4.4rem;
}

.emi-field__affix {
  position: absolute;
  color: var(--auth-gold);
  font-weight: var(--font-weight-bold);
  pointer-events: none;
}

.emi-field__affix--prefix {
  left: 0.95rem;
}

.emi-field__affix--suffix {
  right: 0.95rem;
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-semibold);
}

.emi-field__hint {
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
  line-height: 1.5;
}

.emi-field__error {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  color: var(--auth-error);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1.45;
}

.emi-field__error[hidden] {
  display: none;
}

.emi-field__error-icon {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  margin-top: 0.05rem;
}

.emi-field--invalid .emi-field__control[aria-invalid="true"],
.emi-field--invalid > .emi-field__control-wrap .emi-field__control,
.emi-field--invalid .emi-field__pair .emi-field__control {
  border-color: var(--auth-error);
  background-color: var(--auth-error-soft);
}

.emi-field__pair {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 0.6rem;
}

.emi-field__pair--yearly {
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 420px) {
  .emi-field__pair--yearly {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    align-items: start;
  }
}

/* Range sliders: a gold track with a round thumb (shown by the script). */
.emi-slider[hidden] {
  display: none;
}

.emi-slider {
  display: grid;
  gap: 0.15rem;
}

.emi-slider__input {
  width: 100%;
  height: var(--emi-touch);
  margin: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.emi-slider__input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--auth-gold), rgba(235, 196, 42, 0.25));
}

.emi-slider__input::-moz-range-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--auth-gold), rgba(235, 196, 42, 0.25));
}

.emi-slider__input::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border: 3px solid var(--auth-card-solid);
  border-radius: 50%;
  background: var(--auth-gold-strong);
  box-shadow: 0 0 0 4px var(--auth-gold-soft), 0 6px 16px -4px var(--auth-gold-glow);
  -webkit-appearance: none;
  transition: transform var(--transition-fast);
}

.emi-slider__input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid var(--auth-card-solid);
  border-radius: 50%;
  background: var(--auth-gold-strong);
  box-shadow: 0 0 0 4px var(--auth-gold-soft);
}

.emi-slider__input:focus-visible {
  outline: 2px solid var(--auth-gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.emi-slider__input:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

.emi-slider__ends {
  display: flex;
  justify-content: space-between;
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
}

/* Years / Months toggle. */
.emi-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.3rem;
  margin: 0;
  padding: 0.25rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--radius-pill);
  background-color: var(--auth-field);
  justify-self: start;
}

.emi-toggle__option {
  position: relative;
}

.emi-toggle__input {
  position: absolute;
  opacity: 0;
}

.emi-toggle__label {
  display: grid;
  place-items: center;
  min-width: 5.5rem;
  min-height: 38px;
  padding: 0 1rem;
  border-radius: var(--radius-pill);
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

.emi-toggle__input:checked + .emi-toggle__label {
  background-color: var(--auth-gold);
  color: var(--color-brand-contrast);
}

.emi-toggle__input:focus-visible + .emi-toggle__label {
  outline: 2px solid var(--auth-gold);
  outline-offset: 2px;
}

/* Prepayment section (a native <details>, so it works without JavaScript). */
.emi-prepay {
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--emi-surface-raised);
}

.emi-prepay__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 52px;
  padding: 0 1rem;
  border-radius: var(--auth-radius-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  list-style: none;
}

.emi-prepay__summary::-webkit-details-marker {
  display: none;
}

.emi-prepay__summary:focus-visible {
  outline: 2px solid var(--auth-gold);
  outline-offset: 2px;
}

.emi-prepay__optional {
  color: var(--auth-subtle);
  font-weight: var(--font-weight-normal);
}

.emi-prepay__chevron,
.emi-year__chevron {
  flex: 0 0 auto;
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--auth-muted);
  transition: transform var(--transition-normal);
}

.emi-prepay[open] .emi-prepay__chevron {
  transform: rotate(180deg);
}

.emi-prepay__body {
  display: grid;
  gap: 1.1rem;
  padding: 0.25rem 1rem 1.1rem;
}

.emi-prepay__intro {
  color: var(--auth-muted);
  font-size: var(--font-size-xs);
}

.emi-lumps {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.emi-lumps__list {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: lump;
}

.emi-lump {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  padding: 0.6rem;
  border: 1px dashed var(--auth-line-strong);
  border-radius: var(--auth-radius-sm);
}

.emi-lump__when {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 0.45rem;
  grid-column: 1 / -1;
}

.emi-lump__amount {
  grid-column: 1;
}

.emi-lump__remove {
  display: inline-grid;
  place-items: center;
  width: var(--emi-touch);
  height: var(--emi-touch);
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background: transparent;
  color: var(--auth-muted);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.emi-lump__remove[hidden],
.emi-lumps__add[hidden] {
  display: none;
}

.emi-lump__remove:hover {
  border-color: var(--auth-error);
  color: var(--auth-error);
}

.emi-lump__remove svg {
  width: 1.1rem;
  height: 1.1rem;
}

.emi-lump__error {
  grid-column: 1 / -1;
}

.emi-lumps__add {
  justify-self: start;
}

/* Reduce tenure / Reduce EMI choice cards. */
.emi-effect {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  border: 0;
}

@media (min-width: 420px) {
  .emi-effect {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .emi-effect legend {
    grid-column: 1 / -1;
  }
}

.emi-effect__option {
  position: relative;
  display: flex;
}

.emi-effect__input {
  position: absolute;
  opacity: 0;
}

.emi-effect__card {
  display: grid;
  gap: 0.25rem;
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--auth-field);
  cursor: pointer;
  transition: border-color var(--transition-normal), background-color var(--transition-normal);
}

.emi-effect__name {
  font-weight: var(--font-weight-semibold);
}

.emi-effect__text {
  color: var(--auth-muted);
  font-size: var(--font-size-xs);
  line-height: 1.45;
}

.emi-effect__input:checked + .emi-effect__card {
  border-color: var(--auth-gold);
  background-color: var(--auth-gold-soft);
  box-shadow: inset 0 0 0 1px var(--auth-gold);
}

.emi-effect__input:focus-visible + .emi-effect__card {
  outline: 2px solid var(--auth-gold);
  outline-offset: 2px;
}

/* Buttons. */
.emi-actions {
  display: grid;
  gap: 0.7rem;
}

.emi-actions__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.emi-actions__button {
  flex: 1 1 9rem;
  justify-content: center;
  text-decoration: none;
}

.emi-actions__button[hidden] {
  display: none;
}

.emi-actions__note {
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
  text-align: center;
}

/* ------------------------------------------------------------- Results */

/* While a new result is calculated, the old one stays visible but dimmed. */
.emi-summary,
.emi-compare,
.emi-schedule {
  transition: opacity var(--transition-normal);
}

.emi-calc.is-busy .emi-summary,
.emi-calc.is-busy .emi-compare,
.emi-calc.is-busy .emi-schedule {
  opacity: 0.45;
}

.emi-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

@media (max-width: 639.98px) {
  .emi-card:last-child {
    grid-column: 1 / -1;
  }
}

@media (min-width: 640px) {
  .emi-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .emi-card--hero {
    grid-column: 1 / -1;
  }
}

.emi-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 0.3rem;
  min-width: 0;
  padding: clamp(0.85rem, 0.7rem + 0.5vw, 1.2rem);
  overflow: hidden;
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--emi-surface-raised);
}

.emi-card--hero {
  grid-column: 1 / -1;
  padding: clamp(1.1rem, 0.9rem + 1vw, 1.75rem);
  border-color: rgba(235, 196, 42, 0.4);
  background: linear-gradient(140deg, rgba(235, 196, 42, 0.16), rgba(124, 156, 255, 0.08) 70%);
}

/* A soft light that slowly turns behind the EMI (decorative). */
.emi-card__glow {
  position: absolute;
  inset: -80%;
  z-index: -1;
  /* Two soft lights; turning the layer makes them drift around the card. */
  background:
    radial-gradient(circle at 35% 35%, rgba(235, 196, 42, 0.22), transparent 30%),
    radial-gradient(circle at 65% 65%, rgba(124, 156, 255, 0.2), transparent 30%);
  pointer-events: none;
}

.emi-card--hero > :not(.emi-card__glow) {
  position: relative;
}

.emi-card--hero {
  isolation: isolate;
}

.emi-card__label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--auth-muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.emi-card__value {
  overflow-wrap: anywhere;
  font-family: var(--font-brand);
  font-size: clamp(1.1rem, 0.95rem + 0.7vw, 1.55rem);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.emi-card--hero .emi-card__value {
  color: var(--auth-gold-strong);
  font-size: clamp(2rem, 1.4rem + 2.6vw, 3.4rem);
  line-height: 1.05;
}

.emi-card__note {
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
}

.emi-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
}

.emi-dot--principal { background-color: var(--emi-principal); }
.emi-dot--interest { background-color: var(--emi-interest); }

.emi-charts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
  margin-top: 0.9rem;
}

@media (min-width: 640px) {
  .emi-charts {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  }
}

.emi-chart {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  min-width: 0;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--emi-surface-raised);
}

.emi-chart__caption {
  display: grid;
  gap: 0.15rem;
}

.emi-chart__title {
  font-weight: var(--font-weight-semibold);
}

.emi-chart__context {
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
}

/* Donut: principal vs interest. */
.emi-donut {
  justify-items: center;
  text-align: center;
}

.emi-donut__ring {
  position: relative;
  width: min(100%, 12rem);
  aspect-ratio: 1;
}

.emi-donut__svg {
  width: 100%;
  height: 100%;
  /* Start the arcs at 12 o'clock. */
  transform: rotate(-90deg);
}

.emi-donut__track,
.emi-donut__arc {
  fill: none;
  stroke-width: 6;
}

.emi-donut__track {
  stroke: rgba(255, 255, 255, 0.06);
}

.emi-donut__arc {
  transform-box: view-box;
  transform-origin: center;
}

.emi-donut__arc--principal { stroke: var(--emi-principal); }
.emi-donut__arc--interest { stroke: var(--emi-interest); }

.emi-donut__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.1rem;
}

.emi-donut__pct {
  font-family: var(--font-brand);
  font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.9rem);
  font-weight: var(--font-weight-bold);
  color: var(--emi-interest);
}

.emi-donut__caption {
  color: var(--auth-muted);
  font-size: var(--font-size-xs);
}

.emi-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
}

.emi-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.emi-legend b {
  color: var(--auth-text);
}

/* Balance bars (geometry in SVG attributes, stretched to the box). */
.emi-bars__plot {
  position: relative;
  height: clamp(8rem, 6rem + 6vw, 11rem);
  padding-top: 1.2rem;
  border-bottom: 1px solid var(--auth-line-strong);
}

.emi-bars__svg {
  display: block;
  width: 100%;
  height: 100%;
}

.emi-bars__grid {
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 0.5;
  vector-effect: non-scaling-stroke;
}

.emi-bars__bar {
  fill: var(--emi-interest);
  transform-box: fill-box;
  transform-origin: bottom;
}

.emi-bars__axis {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
}

.emi-bars__labels {
  display: flex;
  justify-content: space-between;
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
}

.emi-bars__table summary {
  min-height: var(--emi-touch);
  display: flex;
  align-items: center;
  color: var(--auth-gold);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}

.emi-bars__table summary:focus-visible {
  outline: 2px solid var(--auth-gold);
  outline-offset: 2px;
}

.emi-empty {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding: clamp(2rem, 1.5rem + 3vw, 4rem) 1rem;
  border: 1px dashed var(--auth-line-strong);
  border-radius: var(--auth-radius-sm);
  text-align: center;
}

.emi-empty__icon {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background-color: var(--auth-gold-soft);
  color: var(--auth-gold);
  font-size: 1.5rem;
  font-weight: var(--font-weight-bold);
}

.emi-empty__text {
  max-width: 28em;
  color: var(--auth-muted);
}

/* Tables: scroll sideways inside their own box on narrow screens. */
.emi-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  -webkit-overflow-scrolling: touch;
}

.emi-table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: var(--auth-fs-small);
  font-variant-numeric: tabular-nums;
}

.emi-table--compact {
  min-width: 18rem;
}

.emi-table th,
.emi-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--auth-line);
  text-align: right;
  white-space: nowrap;
}

.emi-table th:first-child {
  text-align: left;
}

.emi-table thead th {
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--auth-muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.emi-table tbody th {
  color: var(--auth-text);
  font-weight: var(--font-weight-medium);
}

.emi-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.025);
}

.emi-table tfoot th,
.emi-table tfoot td {
  border-bottom: 0;
  background-color: var(--auth-gold-soft);
  color: var(--auth-text);
  font-weight: var(--font-weight-bold);
}

/* ----------------------------------------------------------- Comparison */

.emi-savings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.emi-saving {
  display: grid;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(94, 224, 160, 0.35);
  border-radius: var(--auth-radius-sm);
  background-color: rgba(94, 224, 160, 0.08);
}

.emi-saving__label {
  color: var(--auth-muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.emi-saving__value {
  color: var(--emi-good);
  font-family: var(--font-brand);
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.8rem);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
}

.emi-compare__table {
  min-width: 30rem;
}

.emi-better {
  color: var(--emi-good);
  font-weight: var(--font-weight-semibold);
}

/* ------------------------------------------------- Amortization schedule */

.emi-schedule__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
}

.emi-schedule__toggle[hidden] {
  display: none;
}

.emi-years {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.emi-year {
  min-width: 0;
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--emi-surface-raised);
}

.emi-year.is-open {
  border-color: rgba(235, 196, 42, 0.35);
}

.emi-year__heading {
  margin: 0;
  font-size: inherit;
}

.emi-year__button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem 1rem;
  width: 100%;
  min-height: 56px;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: var(--auth-radius-sm);
  background: transparent;
  color: var(--auth-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.emi-year__button:focus-visible {
  outline: 2px solid var(--auth-gold);
  outline-offset: 2px;
}

.emi-year__year {
  font-family: var(--font-brand);
  font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.3rem);
  font-weight: var(--font-weight-bold);
  color: var(--auth-gold-strong);
}

.emi-year__figures {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem 1.1rem;
  color: var(--auth-text);
  font-size: var(--auth-fs-small);
  font-variant-numeric: tabular-nums;
}

.emi-year__figure-label {
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
}

.emi-year[data-collapsed] .emi-year__chevron {
  transform: rotate(-90deg);
}

.emi-year__panel {
  padding: 0 0.75rem 0.75rem;
}

/* Collapsed years are hidden only once the script runs (and never in print). */
.emi-js .emi-year[data-collapsed] .emi-year__panel {
  display: none;
}

@media (max-width: 559.98px) {
  .emi-year__figures {
    justify-content: flex-start;
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* -------------------------------------------------------------- Content */

.emi-content {
  display: grid;
  gap: clamp(1rem, 0.8rem + 1vw, 1.75rem);
  margin-top: clamp(2.5rem, 2rem + 3vw, 5rem);
}

.emi-article {
  max-width: 56rem;
  color: var(--auth-muted);
  line-height: 1.7;
}

.emi-article p + p,
.emi-article p + .emi-formula,
.emi-article .emi-formula + p {
  margin-top: 0.75rem;
}

.emi-article__title {
  margin-bottom: 0.6rem;
  color: var(--auth-text);
  font-family: var(--font-brand);
  font-size: clamp(1.35rem, 1.1rem + 1vw, 2rem);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.emi-article__subtitle {
  margin: 1rem 0 0.3rem;
  color: var(--auth-text);
  font-size: clamp(1.02rem, 0.97rem + 0.25vw, 1.15rem);
  font-weight: var(--font-weight-semibold);
}

.emi-article strong {
  color: var(--auth-gold-strong);
}

.emi-formula {
  max-width: 100%;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  border: 1px solid rgba(235, 196, 42, 0.35);
  border-radius: var(--auth-radius-sm);
  background-color: var(--auth-gold-soft);
  color: var(--auth-text);
  font-family: var(--font-mono);
  font-size: clamp(0.9rem, 0.8rem + 0.5vw, 1.15rem);
  white-space: nowrap;
}

.emi-terms {
  display: grid;
  gap: 0.35rem;
  margin: 0.9rem 0 0;
}

.emi-terms div {
  display: flex;
  gap: 0.75rem;
}

.emi-terms dt {
  flex: 0 0 1.5rem;
  color: var(--auth-gold);
  font-family: var(--font-mono);
  font-weight: var(--font-weight-bold);
}

.emi-terms dd {
  margin: 0;
}

.emi-steps {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.emi-steps li {
  position: relative;
  padding-left: 2.6rem;
  counter-increment: step;
}

.emi-steps li::before {
  content: counter(step);
  position: absolute;
  top: 0.1rem;
  left: 0;
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background-color: var(--auth-gold-soft);
  color: var(--auth-gold);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  line-height: 1;
}

.emi-faq {
  max-width: none;
}

.emi-faq__list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.8rem;
}

@media (min-width: 900px) {
  .emi-faq__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.emi-faq__item {
  padding: clamp(1rem, 0.85rem + 0.6vw, 1.5rem);
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--emi-surface);
}

.emi-faq__question {
  margin-bottom: 0.4rem;
  color: var(--auth-text);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
  font-weight: var(--font-weight-semibold);
}

.emi-faq__answer {
  font-size: var(--auth-fs-small);
}

.emi-disclaimer {
  max-width: 56rem;
  padding: 1rem 1.2rem;
  border-left: 3px solid var(--auth-line-strong);
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
  line-height: 1.6;
}

.emi-disclaimer a {
  color: var(--auth-gold);
}

.emi-print-only {
  display: none;
}

/* --------------------------------------------------------------- Motion */

@media (prefers-reduced-motion: no-preference) {
  .emi-kicker__pulse::after {
    animation: emi-ping 2.4s var(--auth-ease) infinite;
  }

  .emi-motif__coin {
    animation: emi-roll 7s var(--auth-ease) infinite;
  }

  .emi-motif__coin--2 { animation-delay: -2.3s; }
  .emi-motif__coin--3 { animation-delay: -4.6s; }

  .emi-card__glow {
    animation: emi-spin 14s linear infinite;
  }

  /* The decorative loops wait while the hero is off screen (loan-emi-page.js). */
  .emi-hero.is-offscreen .emi-motif__coin {
    animation-play-state: paused;
  }

  .emi-card,
  .emi-year,
  .emi-faq__item {
    transition: transform var(--transition-normal), border-color var(--transition-normal);
  }

  .emi-card:hover,
  .emi-faq__item:hover {
    transform: translateY(-2px);
  }

  /* A fresh result (the script marks it .is-fresh) grows its charts in. */
  .emi-js .is-fresh .emi-donut__svg {
    animation: emi-donut-in 900ms var(--auth-ease) both;
  }

  .emi-js .is-fresh .emi-bars__bar {
    animation: emi-bar-in 800ms var(--auth-ease) both;
  }

  .emi-js .is-fresh .emi-card {
    animation: emi-rise 600ms var(--auth-ease) both;
  }

  .emi-js .is-fresh .emi-card:nth-child(2) { animation-delay: 60ms; }
  .emi-js .is-fresh .emi-card:nth-child(3) { animation-delay: 120ms; }
  .emi-js .is-fresh .emi-card:nth-child(4) { animation-delay: 180ms; }

  /* Scroll reveal: only once loan-emi-page.js has marked <html>. */
  .emi-reveal [data-reveal] {
    transition: opacity 650ms var(--auth-ease), transform 650ms var(--auth-ease);
  }

  .emi-reveal [data-reveal]:not(.is-revealed) {
    opacity: 0;
    transform: translate3d(0, 18px, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-aurora,
  .auth-card__glow {
    animation: none;
  }
}

@keyframes emi-ping {
  0% { opacity: 0.7; transform: scale(1); }
  80%, 100% { opacity: 0; transform: scale(2.6); }
}

/* A coin eases down the curve and fades, then starts again. */
@keyframes emi-roll {
  0% { opacity: 0; transform: translate(-40px, -12px) scale(0.6); }
  15% { opacity: 1; }
  70% { opacity: 1; transform: translate(30px, 26px) scale(1); }
  100% { opacity: 0; transform: translate(60px, 50px) scale(0.8); }
}

@keyframes emi-spin {
  to { transform: rotate(1turn); }
}

@keyframes emi-donut-in {
  from { opacity: 0; transform: rotate(-200deg) scale(0.85); }
  to { opacity: 1; transform: rotate(-90deg) scale(1); }
}

@keyframes emi-bar-in {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

@keyframes emi-rise {
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
  to { opacity: 1; transform: none; }
}
