/* ============================================================
   Apply wizard — multi-step loan application
   ============================================================ */

.modal__panel--apply {
  max-width: 32rem;
  max-height: min(92vh, 920px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Inline wizard card embedded in the dashboard (below the motivation). */
.apply-inline {
  max-width: 40rem;
  margin: 0 auto 2rem;
  background: var(--surface);
  border-radius: 1.75rem;
  padding: 1.75rem 1.75rem;
  box-shadow: var(--shadow);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}
.apply-inline.hidden { display: none; }

.apply-inline__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0 0 1rem;
  color: var(--text);
}

.apply-inline__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  align-items: center;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ---- Progress: labelled tab-stepper with status icons ---- */
.wiz-progress { margin: 0.5rem 0 1.5rem; }

/* Thin progress line across the top (red fill = how far along). */
.wiz-progress__line {
  height: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 20%, transparent);
  overflow: hidden;
}
.wiz-progress__fill {
  display: block;
  height: 100%;
  width: 25%;
  border-radius: 999px;
  background: var(--accent-strong);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.wiz-progress__steps {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.wiz-progress__step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

/* Status icon: empty ring → half (current) → filled check (done) */
.wiz-progress__icon {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--muted) 32%, transparent);
  background: var(--surface);
  transition: background 0.3s, border-color 0.3s;
}
.wiz-progress__check {
  width: 0.8rem;
  height: 0.8rem;
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s;
}

.wiz-progress__label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.3s;
}

/* Current step — half-filled icon */
.wiz-progress__step.is-active .wiz-progress__icon {
  border-color: var(--accent-strong);
  background: linear-gradient(90deg, var(--accent-strong) 50%, var(--surface) 50%);
}
.wiz-progress__step.is-active .wiz-progress__label {
  color: var(--text);
  font-weight: 700;
}

/* Completed step — solid icon + white check */
.wiz-progress__step.is-done .wiz-progress__icon {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}
.wiz-progress__step.is-done .wiz-progress__check { opacity: 1; }
.wiz-progress__step.is-done .wiz-progress__label { color: var(--text); }

/* ---- Steps ---- */
.wiz-step { animation: wiz-step-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both; }
.wiz-step[hidden] { display: none; }

@keyframes wiz-step-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

.wiz-step__title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0 0 0.25rem;
  color: var(--text);
}

.wiz-step__sub {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
  line-height: 1.5;
}

.wiz-step__error {
  min-height: 1.1rem;
  font-size: 0.82rem;
  color: #c0392b;
  margin: 0.6rem 0 0;
}
.wiz-step__error:empty { min-height: 0; }

.wiz-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

/* ---- Step 1: amount ---- */
.wiz-amount-label {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.wiz-amount-chips {
  display: flex;
  gap: 0.75rem;
  margin: 0;
}

.wiz-amount-chip {
  flex: 1;
  padding: 1rem 0.5rem;
  border: 2px solid color-mix(in srgb, var(--muted) 25%, transparent);
  border-radius: 0.9rem;
  background: var(--surface);
  font-family: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.wiz-amount-chip:hover { border-color: var(--accent); }
.wiz-amount-chip.is-active {
  border-color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent-strong);
}

.wiz-repay-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.1rem;
  padding: 1rem 1.15rem;
  border-radius: 1rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.wiz-repay-card__info { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.wiz-repay-card__label { font-size: 0.85rem; color: var(--text); font-weight: 600; }
.wiz-repay-card__date { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.wiz-repay-card__value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-strong);
  white-space: nowrap;
}

/* ---- Step 3: document slots ---- */
.doc-slots { display: flex; flex-direction: column; gap: 0.75rem; }

.doc-slot { position: relative; }
.doc-slot__input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
}

.doc-slot__zone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border: 2px dashed color-mix(in srgb, var(--muted) 30%, transparent);
  border-radius: 1rem;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.doc-slot__zone:focus-visible {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.doc-slot[data-drag="true"] .doc-slot__zone {
  border-color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
}
.doc-slot[data-state="ready"] .doc-slot__zone {
  border-style: solid;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.doc-slot[data-disabled="true"] .doc-slot__zone {
  opacity: 0.6;
  cursor: not-allowed;
}

.doc-slot__icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent-strong);
}
.doc-slot__icon svg { width: 1.25rem; height: 1.25rem; }

.doc-slot__text { flex: 1; min-width: 0; }
.doc-slot__title { margin: 0; font-weight: 700; font-size: 0.92rem; color: var(--text); }
.doc-slot__hint { margin: 0.1rem 0 0; font-size: 0.75rem; color: var(--muted); }
.doc-slot__name {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-slot__meta { margin: 0; font-size: 0.72rem; color: var(--muted); }

/* In ready state, swap hint for filename */
.doc-slot[data-state="empty"] .doc-slot__name,
.doc-slot[data-state="empty"] .doc-slot__meta { display: none; }
.doc-slot[data-state="ready"] .doc-slot__hint { display: none; }

.doc-slot__status {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
}
.doc-slot__status svg { width: 1.25rem; height: 1.25rem; }
.doc-slot__check { color: var(--accent-strong); display: none; }
.doc-slot__up { color: var(--muted); }
.doc-slot[data-state="ready"] .doc-slot__check { display: block; }
.doc-slot[data-state="ready"] .doc-slot__up { display: none; }

.doc-slot__clear {
  display: none;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.5rem;
  flex-shrink: 0;
}
.doc-slot__clear svg { width: 1.05rem; height: 1.05rem; }
.doc-slot__clear:hover { color: #c0392b; background: color-mix(in srgb, #c0392b 10%, transparent); }
.doc-slot[data-state="ready"] .doc-slot__clear { display: inline-flex; }
.doc-slot[data-state="ready"] .doc-slot__status { display: none; }

.doc-slot__error {
  min-height: 0;
  margin: 0.25rem 0 0 0.5rem;
  font-size: 0.75rem;
  color: #c0392b;
}
.doc-slot__error:empty { display: none; }

/* ---- Step 4: review ---- */
.wiz-review {
  margin: 0;
  border-radius: 1rem;
  border: 1px solid color-mix(in srgb, var(--muted) 20%, transparent);
  overflow: hidden;
}
.wiz-review__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1rem;
  font-size: 0.88rem;
}
.wiz-review__row:nth-child(even) { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.wiz-review__key { color: var(--muted); }
.wiz-review__val {
  font-weight: 700;
  color: var(--text);
  text-align: right;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.wiz-review__val--ok { color: var(--accent-strong); }

/* ---- Reading state during submit ---- */
.wiz-scan {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem 1.15rem;
  border-radius: 1.1rem;
  background:
    linear-gradient(
      145deg,
      color-mix(in srgb, var(--accent) 14%, var(--surface)),
      color-mix(in srgb, var(--bg) 70%, var(--surface))
    );
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 65%, transparent);
}
.wiz-scan.hidden { display: none; }

.wiz-scan__visual {
  flex-shrink: 0;
}

.wiz-scan__docs {
  position: relative;
  width: 3.4rem;
  height: 4rem;
}

.wiz-scan__page {
  position: absolute;
  inset: 0;
  border-radius: 0.45rem;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--muted) 22%, transparent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--text) 10%, transparent);
}

.wiz-scan__page--back {
  transform: translate(0.35rem, -0.2rem) rotate(6deg);
  opacity: 0.55;
}

.wiz-scan__page--mid {
  transform: translate(0.18rem, -0.08rem) rotate(2.5deg);
  opacity: 0.8;
}

.wiz-scan__page--front {
  overflow: hidden;
  animation: wiz-page-bob 2.4s ease-in-out infinite;
}

.wiz-scan__lines {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.7rem 0.55rem;
}

.wiz-scan__lines i {
  display: block;
  height: 0.22rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 28%, transparent);
}

.wiz-scan__lines i:nth-child(1) { width: 78%; }
.wiz-scan__lines i:nth-child(2) { width: 92%; }
.wiz-scan__lines i:nth-child(3) { width: 64%; }
.wiz-scan__lines i:nth-child(4) { width: 84%; }

.wiz-scan__beam {
  position: absolute;
  left: 8%;
  right: 8%;
  height: 0.18rem;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--accent),
    color-mix(in srgb, #fff 75%, var(--accent-strong)),
    var(--accent-strong),
    transparent
  );
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent-strong) 45%, transparent);
  animation: wiz-scan-beam 2s ease-in-out infinite;
}

.wiz-scan__copy {
  min-width: 0;
  flex: 1;
}

.wiz-scan__label {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  transition: opacity 0.25s ease;
}

.wiz-scan__label.is-fading {
  opacity: 0.35;
}

.wiz-scan__hint {
  margin: 0.3rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

@keyframes wiz-scan-beam {
  0% { top: 12%; opacity: 0.35; }
  45% { opacity: 1; }
  100% { top: 82%; opacity: 0.35; }
}

@keyframes wiz-page-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-0.12rem); }
}

@media (prefers-reduced-motion: reduce) {
  .wiz-scan__beam,
  .wiz-scan__page--front {
    animation: none;
  }
  .wiz-scan__beam { top: 45%; opacity: 0.85; }
}

/* ---- Actions ---- */
.wiz-actions { flex-wrap: wrap; align-items: center; }
/* Cancel anchors left; Back sits beside it; primary stays right. */
.wiz-actions #apply-close-btn { margin-right: auto; }

/* ============================================================
   Journey "what you'll need" block
   ============================================================ */
.dash-needs {
  margin: 1.25rem 0 0;
  padding: 0.4rem 1.25rem;
  border-radius: 1rem;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.dash-needs__summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.dash-needs__summary::-webkit-details-marker { display: none; }
.dash-needs__summary svg { width: 1.1rem; height: 1.1rem; color: var(--accent-strong); }
.dash-needs__chevron {
  margin-left: auto;
  transition: transform 0.25s ease;
}
.dash-needs[open] .dash-needs__chevron { transform: rotate(180deg); }
.dash-needs__cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 0 0 0.85rem;
  animation: wiz-step-in 0.3s ease both;
}
.dash-needs__heading {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--accent-strong);
}
.dash-needs__list { margin: 0; padding-left: 1.1rem; }
.dash-needs__list li { font-size: 0.85rem; color: var(--text); margin-bottom: 0.2rem; }

/* ---- Responsive ---- */

/* Narrow modal widths: stack each step's icon above its label so all four
   stay visible and legible (no clipping). */
@media (max-width: 560px) {
  .wiz-progress__steps { gap: 0.35rem; }
  .wiz-progress__step {
    flex: 1 1 0;
    flex-direction: column;
    gap: 0.35rem;
    text-align: center;
  }
  .wiz-progress__label {
    font-size: 0.66rem;
    line-height: 1.15;
    white-space: normal;
  }
}

@media (max-width: 479px) {
  .wiz-field-row { grid-template-columns: 1fr; }
  .wiz-step__title { font-size: 1.15rem; }
  .dash-needs__cols { grid-template-columns: 1fr; }
  .wiz-repay-card__value { font-size: 1.25rem; }
  .modal__panel--apply { padding: 1.5rem 1.25rem; }
  .apply-inline { padding: 1.4rem 1.15rem; border-radius: 1.25rem; }

  /* Stack actions — primary action sits full-width on top. */
  .wiz-actions {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 0.6rem;
  }
  .wiz-actions .btn { width: 100%; }
  .wiz-actions #apply-close-btn { margin-right: 0; }
}
