/* Окно заявки: макеты 2–4 (десктоп), 7–9 (телефон). */

/* ---------- Оверлей и контейнер ---------- */
.apply-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(10px) saturate(.9);
  backdrop-filter: blur(10px) saturate(.9);
  animation: overlay-in .2s ease-out both;
}

.apply-dialog {
  position: relative;
  width: 600px;
  max-width: 100%;
  max-height: calc(100dvh - 48px);
  background: var(--surface);
  border-radius: 28px;
  overflow: hidden;
  /* clip, а не только hidden: окно нельзя прокрутить фокусом — прокручивается лишь область полей. */
  overflow: clip;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px rgba(0, 29, 36, .04), 0 2px 6px rgba(0, 29, 36, .05), 0 48px 96px -32px rgba(0, 29, 36, .42);
  animation: dialog-in .24s cubic-bezier(.2, .8, .2, 1) both;
}

.apply-overlay.is-compact {
  padding: 12px 0 0;
  align-items: stretch;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.apply-dialog.is-sheet {
  width: 100%;
  max-height: none;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -24px 48px -28px rgba(0, 29, 36, .4);
  animation-name: sheet-in;
}

.sheet-handle {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 3;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: var(--line2);
}

@keyframes overlay-in {
  from { opacity: 0; }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
}

@keyframes sheet-in {
  from { transform: translateY(24px); opacity: 0; }
}

.apply-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

/* ---------- Шапка ---------- */
.apply-head {
  flex-shrink: 0;
  padding: 28px 40px 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.apply-head__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.apply-head__titles {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.apply-title {
  font-family: var(--font-heading);
  font-size: 30px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -.028em;
  outline: none;
}

.apply-subtitle {
  font-size: 15px;
  line-height: 22px;
  color: var(--ink3);
}

.close-button {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 0;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--close-bg);
  color: var(--ink2);
}

.close-button:disabled {
  opacity: .4;
  cursor: default;
}

/* ---------- Индикатор шагов ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stepper__item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stepper__line {
  width: 28px;
  height: 1.5px;
  border-radius: 1px;
  background: var(--line2);
}

.stepper__line.is-done {
  background: var(--emerald);
}

.stepper__node {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper__dot {
  width: 24px;
  height: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.stepper__label {
  font-size: 14px;
  font-weight: 500;
}

.is-active .stepper__dot {
  background: var(--acc);
  color: var(--on-acc);
}

.is-done .stepper__dot {
  background: var(--emerald-soft);
  color: var(--acc);
}

.is-todo .stepper__dot {
  box-shadow: inset 0 0 0 1.5px var(--line2);
  color: var(--ink3);
}

.is-todo .stepper__label {
  color: var(--ink3);
}

/* ---------- Тело ---------- */
.apply-scroll {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.apply-body {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: opacity .2s, filter .2s;
}

.apply-body.is-dim {
  opacity: .5;
  filter: saturate(.6);
}

.apply-fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.apply-fields--details {
  gap: 24px;
}

.apply-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* ---------- Менеджер банка ---------- */
.manager {
  border-radius: 20px;
  background: var(--panel);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.manager__head {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.manager__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.manager__fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.manager__row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inline-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.inline-field {
  position: relative;
  height: 52px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  cursor: text;
  transition: box-shadow .15s;
}

/* Заполненное поле — тот же оттенок, что у обычных полей (--field-filled). */
.inline-field.is-filled {
  background: var(--field-filled);
  box-shadow: inset 0 0 0 1px var(--field-filled-line);
}

.inline-field:focus-within {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--emerald), var(--focus-ring);
}

.inline-field.is-invalid {
  box-shadow: inset 0 0 0 1px var(--err);
}

.inline-field.is-invalid:focus-within {
  box-shadow: inset 0 0 0 1px var(--err), var(--err-ring);
}

.inline-field__label {
  font-size: 11px;
  line-height: 14px;
  font-weight: 500;
  color: var(--ink3);
}

.inline-field:not(.is-filled) .inline-field__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.inline-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  outline: none;
  font-size: 15px;
  line-height: 20px;
  color: var(--ink);
}

.inline-field input::placeholder {
  color: var(--ink4);
  opacity: 1;
}

/* Автозаполнение внутри поля с подписью — без голубой заливки. */
.inline-field input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--field-filled) inset;
  -webkit-text-fill-color: var(--ink);
}

.inline-field input:autofill {
  box-shadow: 0 0 0 1000px var(--field-filled) inset;
}

.inline-field:focus-within input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
}

.inline-field:focus-within input:autofill {
  box-shadow: 0 0 0 1000px var(--surface) inset;
}

/* «Не знаю своего менеджера»: поля приглушены и неактивны. */
.inline-field.is-disabled {
  opacity: .5;
  cursor: default;
}

.inline-field.is-disabled input {
  cursor: default;
}

.manager__unknown {
  margin-top: 4px;
}

/* ---------- Галочки: согласие и «Не знаю своего менеджера» ---------- */
.checkbox-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkbox {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}

.checkbox__input {
  position: absolute;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  opacity: 0;
}

.checkbox__box {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line2);
  color: var(--on-acc);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color .15s, box-shadow .15s;
}

.checkbox__input:checked + .checkbox__box {
  background: var(--emerald);
  box-shadow: none;
}

.checkbox__input:focus-visible + .checkbox__box {
  box-shadow: inset 0 0 0 1.5px var(--emerald), 0 0 0 4px rgba(11, 171, 132, .18);
}

.checkbox.is-invalid .checkbox__input:not(:checked) + .checkbox__box {
  box-shadow: inset 0 0 0 1.5px var(--err);
}

.checkbox__text {
  font-size: 14px;
  line-height: 22px;
  color: var(--ink2);
}

.honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- Нижняя панель ---------- */
.apply-foot {
  position: relative;
  flex-shrink: 0;
  padding: 20px 40px;
  background: var(--foot);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

/* На шаге 1 в нижней панели только «Далее» — справа, как «Отправить заявку» на шаге 2. */
.btn-next {
  width: 148px;
  margin-left: auto;
}

.btn-submit {
  width: 224px;
}

.btn-submit.is-sending {
  background: var(--btn-sending);
}

.btn-back {
  padding: 0 12px 0 6px;
  margin-left: -6px;
}

.btn-back:disabled,
.btn-square:disabled {
  opacity: .35;
}

.btn-square {
  width: 56px;
  flex-shrink: 0;
  padding: 0;
}

.spinner {
  flex-shrink: 0;
  animation: spin .8s linear infinite;
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 2px;
  overflow: hidden;
}

.progress__bar {
  display: block;
  width: 30%;
  height: 2px;
  background: var(--emerald);
  animation: slide 1.1s cubic-bezier(.4, 0, .2, 1) infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(340%); }
}

/* ---------- Телефонная раскладка формы ---------- */
.is-sheet .apply-head {
  padding: 28px 20px 0;
  gap: 20px;
}

.is-sheet .apply-head__titles {
  gap: 4px;
}

.is-sheet .apply-title {
  font-size: 26px;
  line-height: 32px;
}

.is-sheet .apply-body {
  padding: 24px 20px;
  gap: 18px;
}

.is-sheet .apply-fields {
  gap: 18px;
}

.is-sheet .apply-fields--details {
  gap: 20px;
}

.is-sheet .apply-row {
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.is-sheet .manager {
  padding: 16px;
}

.is-sheet .textarea {
  height: 104px;
}

.apply-foot.is-compact {
  padding: 14px 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface);
  justify-content: flex-start;
  gap: 10px;
}

.is-sheet .btn-submit {
  width: auto;
}

@media (prefers-reduced-motion: reduce) {
  .apply-overlay,
  .apply-dialog,
  .progress__bar {
    animation: none;
  }

  .spinner {
    animation-duration: 2.4s;
  }
}

/* ---------- Невысокий горизонтальный экран (телефон боком) ----------
   Окно почти во всю высоту, шапка и нижняя панель компактнее — полям остаётся место для прокрутки. */
@media (orientation: landscape) and (max-height: 500px) {
  .apply-overlay {
    padding: 8px 16px;
  }

  .apply-dialog {
    max-height: calc(100dvh - 16px);
    border-radius: 20px;
  }

  .apply-head {
    padding: 14px 24px 0;
    gap: 10px;
  }

  .apply-head__titles {
    gap: 2px;
  }

  .apply-title {
    font-size: 22px;
    line-height: 28px;
  }

  .apply-subtitle {
    font-size: 14px;
    line-height: 20px;
  }

  .close-button {
    width: 32px;
    height: 32px;
  }

  .apply-body {
    padding: 14px 24px;
    gap: 14px;
  }

  .apply-fields {
    gap: 12px;
  }

  .apply-fields--details {
    gap: 14px;
  }

  .apply-row {
    gap: 12px;
  }

  .manager {
    padding: 14px;
    gap: 10px;
  }

  .textarea {
    height: 72px;
  }

  .apply-foot {
    padding: 10px 24px;
  }

  .apply-foot .btn {
    height: 44px;
  }

  .btn-square {
    width: 44px;
  }
}
