/* ============================================================
   ===== НАПОМИНАНИЕ О СЛОЖНЫХ ЗАЯВКАХ (.cx-popup + .cx-tab) =====
   Вставить в конец основного CSS-файла
   (если прошлая версия блока уже вставлена — заменить её целиком).
   ============================================================ */
[data-theme="light"] {
  --cx-red: #d64532;
  --cx-red-bg: rgba(214, 69, 50, 0.10);
}

[data-theme="dark"] {
  --cx-red: #ff6b5b;
  --cx-red-bg: rgba(255, 107, 91, 0.14);
}

/* ================= КАРТОЧКА ================= */
.cx-popup {
  --cx-dur: 14s;
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 997; /* ниже FAB (998), меню (999/1000) и модалок (9999) */
  width: 384px;
  max-width: calc(100vw - 48px);
  padding: 22px 22px 20px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  box-shadow: var(--card-sh-h);
  font-family: 'Geologica', sans-serif;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(.97);
  transition: opacity .35s ease, transform .5s cubic-bezier(.22,1,.36,1), visibility 0s linear .5s;
}

/* Сворачивание в язычок (уезжает к левому краю) */
.cx-popup.is-collapsing {
  transform-origin: left center;
  transform: translateX(calc(-100% - 40px)) scale(.6);
}

/* Разворачивание из язычка (выезжает от левого края) */
.cx-popup.is-from-left {
  transform-origin: left center;
  transform: translateX(-60px) scale(.9);
}

.cx-popup.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .35s ease, transform .5s cubic-bezier(.22,1,.36,1), visibility 0s;
}

.cx-popup::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cx-red, #d64532), var(--accent-green, #1a8c4e));
}

.cx-popup::after {
  content: '';
  position: absolute;
  top: -70px;
  right: -70px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--accent-green-bg, rgba(26,140,78,.1));
  filter: blur(30px);
  pointer-events: none;
}

.cx-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text3);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s, color .18s;
}

.cx-close:hover {
  background: var(--accentbg);
  color: var(--accent);
}

/* ---- Графика «Отказ банка → Одобрено» ---- */
.cx-flow {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 40px 16px 0;
}

.cx-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px 6px 8px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.cx-chip svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cx-chip--reject {
  color: var(--cx-red, #d64532);
  background: var(--cx-red-bg, rgba(214,69,50,.10));
}

.cx-chip--ok {
  color: var(--accent-green, #1a8c4e);
  background: var(--accent-green-bg, rgba(26,140,78,.10));
  opacity: .35;
  transform: scale(.9);
  filter: grayscale(1);
}

.cx-strike {
  position: relative;
}

.cx-strike::after {
  content: '';
  position: absolute;
  left: -2px;
  right: -2px;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
}

.cx-path {
  position: relative;
  flex: 1;
  min-width: 24px;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--border2) 0 6px, transparent 6px 11px);
}

.cx-path i {
  position: absolute;
  top: 50%;
  left: 0;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accentbg2);
  opacity: 0;
}

.cx-popup.is-visible .cx-chip--reject { animation: cxShake .5s ease .25s both; }
.cx-popup.is-visible .cx-strike::after { animation: cxStrike .4s ease .55s forwards; }
.cx-popup.is-visible .cx-path i { animation: cxDot 2s ease-in-out .7s infinite; }
.cx-popup.is-visible .cx-chip--ok { animation: cxPop .5s cubic-bezier(.34,1.56,.64,1) 1.8s forwards; }

@keyframes cxShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

@keyframes cxStrike {
  to { transform: scaleX(1); }
}

@keyframes cxDot {
  0% { left: 0; opacity: 0; }
  12% { opacity: 1; }
  60% { left: 100%; opacity: 1; }
  72%, 100% { left: 100%; opacity: 0; }
}

@keyframes cxPop {
  to { opacity: 1; transform: scale(1); filter: none; }
}

/* ---- Текст ---- */
.cx-title {
  position: relative;
  z-index: 1;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 6px;
}

.cx-text {
  position: relative;
  z-index: 1;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text2);
  margin-bottom: 16px;
}

/* ---- Кнопки ---- */
.cx-actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.cx-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 18px var(--glow);
  transition: background .2s, transform .15s, box-shadow .2s, gap .2s;
}

.cx-btn:hover {
  background: var(--accent2);
  color: #fff;
  transform: translateY(-1px);
  gap: 11px;
  box-shadow: 0 8px 26px var(--glow);
}

.cx-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
}

.cx-later {
  background: none;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: 'Geologica', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  transition: background .18s, color .18s;
}

.cx-later:hover {
  color: var(--text2);
  background: var(--accentbg);
}

.cx-btn:focus-visible,
.cx-later:focus-visible,
.cx-close:focus-visible,
.cx-tab-open:focus-visible,
.cx-tab-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Таймер автоскрытия ---- */
.cx-timer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--accent);
  opacity: .35;
  transform: scaleX(0);
  transform-origin: left;
}

.cx-popup.is-visible .cx-timer {
  animation: cxTimer var(--cx-dur) linear forwards;
}

.cx-popup:hover .cx-timer,
.cx-popup:focus-within .cx-timer {
  animation-play-state: paused;
}

/* Открыта вручную из язычка — не исчезает сама */
.cx-popup.is-manual .cx-timer {
  display: none;
}

@keyframes cxTimer {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* ================= ЯЗЫЧОК У ЛЕВОГО КРАЯ ================= */
.cx-tab {
  position: fixed;
  left: 0;
  top: 50%;
  z-index: 997;
  font-family: 'Geologica', sans-serif;
  transform: translate(-110%, -50%);
  transition: transform .45s cubic-bezier(.22,1,.36,1);
}

.cx-tab.is-visible {
  transform: translate(0, -50%);
}

.cx-tab-open {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 9px 16px 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 0 12px 12px 0;
  box-shadow: 0 6px 24px var(--glow);
  cursor: pointer;
  transition: background .2s, padding .2s;
}

.cx-tab-open:hover {
  background: var(--accent2);
  padding-left: 12px;
}

.cx-tab-open svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cx-tab-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1;
  white-space: nowrap;
}

.cx-tab-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text3);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-sh);
  opacity: 0;
  transition: opacity .2s, color .2s;
}

.cx-tab:hover .cx-tab-close,
.cx-tab:focus-within .cx-tab-close {
  opacity: 1;
}

.cx-tab-close:hover {
  color: var(--accent);
}

/* На сенсорных экранах наведения нет — крестик виден всегда */
@media (hover: none) {
  .cx-tab-close { opacity: 1; }
}

/* «Подмигивание» язычка раз в N секунд */
.cx-tab.is-nudge .cx-tab-open {
  animation: cxNudge 1.2s ease;
}

@keyframes cxNudge {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(6px); }
  40% { transform: translateX(0); }
  60% { transform: translateX(4px); }
  80% { transform: translateX(0); }
}

/* ================= МОБИЛЬНЫЕ ================= */
@media (max-width: 600px) {
  .cx-popup {
    left: 12px;
    right: 12px;
    top: 80px;
    bottom: auto;
    width: auto;
    max-width: none;
    padding: 16px;
    border-radius: 16px;
    transform: translateY(-16px) scale(.98);
  }
  .cx-flow { margin-bottom: 12px; }
  .cx-title { font-size: 16px; }
  .cx-text { font-size: 13px; margin-bottom: 12px; }
  .cx-btn { flex: 1; justify-content: center; padding: 11px 14px; }

  /* Язычок выше — на уровне подзаголовка, подальше от кнопки «Оставить заявку» */
  .cx-tab {
    top: 38%;
    bottom: auto;
    transform: translate(-110%, 0);
  }
  .cx-tab.is-visible { transform: translate(0, 0); }
  .cx-tab-open { padding: 12px 5px 14px 6px; gap: 8px; }
  .cx-tab-open svg { width: 16px; height: 16px; }
  .cx-tab-text { font-size: 12px; }
}

/* ================= БЕЗ АНИМАЦИЙ ================= */
@media (prefers-reduced-motion: reduce) {
  .cx-popup,
  .cx-popup.is-collapsing,
  .cx-popup.is-from-left {
    transform: none;
    transition: opacity .2s ease, visibility 0s linear .2s;
  }
  .cx-popup.is-visible {
    transition: opacity .2s ease, visibility 0s;
  }
  .cx-popup.is-visible .cx-chip--reject,
  .cx-popup.is-visible .cx-path i,
  .cx-tab.is-nudge .cx-tab-open { animation: none; }
  .cx-popup.is-visible .cx-strike::after { animation: none; transform: scaleX(1); }
  .cx-popup.is-visible .cx-chip--ok { animation: none; opacity: 1; transform: none; filter: none; }
  .cx-tab { transition: none; }
}

@media print {
  .cx-popup, .cx-tab { display: none !important; }
}