/* Auth modals — стиль Figma НЕРИС ЛК (node вход / регистрация)
   Без глобального reset body/* — иначе ломает оболочку ЛК. */
@font-face {
  font-family: "OpenSans";
  src: url("../fonts/OpenSans.woff2") format("woff2");
  font-display: swap;
  font-weight: 400 800;
  font-style: normal;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter.woff2") format("woff2");
  font-display: swap;
  font-weight: 400 800;
  font-style: normal;
}

.auth-stage,
.auth-overlay,
dialog.auth-dialog,
.auth-modal {
  --green-bright: #4ead33;
  --green: #2f6b1c;
  --green-dark: #1f4d12;
  --green-soft: #eef6eb;
  --ink: #12250c;
  --ink-muted: #4a5c46;
  --ink-faint: #5c6e58;
  --bg: #ffffff;
  --border: #e3ebe0;
  --header: #0e1c0a;
  --mark: #ffe14d;
  --danger: #c62828;
  --radius: 16px;
  --font: "OpenSans", "Open Sans", system-ui, sans-serif;
  --font-ui: "Inter", system-ui, sans-serif;
  box-sizing: border-box;
}
.auth-stage *,
.auth-overlay *,
dialog.auth-dialog *,
.auth-modal * {
  box-sizing: border-box;
}

/* Native <dialog> как оверлей макета */
dialog.auth-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: none;
  max-height: none;
  color: inherit;
  margin: auto;
}
dialog.auth-dialog::backdrop {
  background: rgba(8, 18, 8, .62);
  backdrop-filter: blur(4px);
}
dialog.auth-dialog[open] {
  display: grid;
  place-items: center;
  width: min(100vw, 100%);
  height: min(100vh, 100dvh);
  padding: 20px;
}

/* —— Фон-лендинг (упрощённый, как в макете) —— */
.auth-stage {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 60% at 85% 20%, rgba(78,173,51,.22), transparent 55%),
    radial-gradient(ellipse 50% 40% at 10% 90%, rgba(47,107,28,.28), transparent 50%),
    linear-gradient(165deg, #152a12 0%, #0e1c0a 48%, #081208 100%);
  color: #fff;
}
.auth-stage::before {
  content: "";
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(-12deg, transparent, transparent 48px, rgba(255,255,255,.012) 48px, rgba(255,255,255,.012) 49px);
  pointer-events: none;
}
.auth-top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  color: #fff; text-decoration: none;
}
.auth-logo img { height: 40px; width: auto; }
.auth-nav {
  display: flex; gap: 22px; flex-wrap: wrap;
  font-size: 14px; font-weight: 600;
  color: rgba(255,255,255,.72);
}
.auth-nav a { color: inherit; text-decoration: none; }
.auth-nav a:hover { color: #fff; }
.auth-top-actions { display: flex; align-items: center; gap: 12px; }
.auth-top-actions .phone {
  color: rgba(255,255,255,.85); font-weight: 700; font-size: 14px; text-decoration: none;
}
.btn-ghost-light {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px; border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,.55);
  color: #fff; background: transparent;
  font: inherit; font-weight: 700; font-size: 14px;
  cursor: pointer; text-decoration: none;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.btn-ghost-light:hover {
  background: rgba(255,255,255,.08);
  border-color: #fff;
  transform: translateY(-1px);
}

.auth-hero {
  position: relative; z-index: 1;
  width: min(1120px, calc(100% - 40px));
  margin: 48px auto 0;
  padding-bottom: 120px;
}
.auth-hero h1 {
  font-family: var(--font);
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700; letter-spacing: -.03em;
  max-width: 14em; line-height: 1.15;
  color: rgba(255,255,255,.92);
}
.auth-hero p {
  margin-top: 14px; max-width: 36em;
  color: rgba(255,255,255,.62); font-size: 16px;
}
.auth-hero-cta {
  margin-top: 22px;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 22px; border-radius: 999px;
  background: var(--green-bright); color: #fff;
  font-weight: 800; font-size: 14px; border: 0; cursor: pointer;
  text-decoration: none;
}
.auth-hero-cta:hover { background: #45a02d; }

.demo-links {
  position: relative; z-index: 2;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto 40px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.demo-links button {
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.88);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.demo-links button:hover { background: rgba(78,173,51,.35); }

/* —— Overlay + modal —— */
.auth-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(8,18,8,.62);
  backdrop-filter: blur(4px);
}
.auth-overlay[hidden] { display: none; }

.auth-modal {
  position: relative;
  width: min(440px, 100%);
  background: #f7f8f6;
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  box-shadow: 0 28px 64px rgba(0,0,0,.35);
  animation: authIn .35s cubic-bezier(.22,.9,.3,1) both;
  max-height: min(92vh, 900px);
  overflow: auto;
}
.auth-dialog--wide .auth-modal,
.auth-dialog--wide .dialog__body {
  width: min(640px, 100%);
}

/* Код из 6 цифр */
.auth-code,
.auth-modal .code {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: space-between;
}
.auth-code input,
.auth-modal .code input.js_user_checkword_part,
.auth-modal .input-cabinet--square input {
  width: 44px;
  height: 48px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  border: 1px solid #d5ddd2;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 0;
}
.auth-modal .hidden { display: none !important; }

/* Старые классы регистрации внутри auth-modal */
.auth-modal .dialog__header { margin: 0 28px 8px 0; }
.auth-modal .dialog__title {
  font-family: var(--font);
  font-size: clamp(22px, 3vw, 26px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
  letter-spacing: -.02em;
  margin: 0 0 8px;
}
.auth-modal .dialog__subtitle {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--ink-muted);
  line-height: 1.45;
}
.auth-modal .dialog__main { margin: 0; }
.auth-modal .dialog__section { margin: 0; }
.auth-modal .form__block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}
.auth-modal .input-cabinet {
  display: block;
  position: relative;
}
.auth-modal .input-cabinet > input:not([type="checkbox"]):not([type="hidden"]),
.auth-modal .input-cabinet > textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid #d5ddd2;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.auth-modal .input-cabinet > input:focus {
  outline: none;
  border-color: var(--green-bright);
  box-shadow: 0 0 0 3px rgba(78,173,51,.18);
}
.auth-modal .button-main,
.auth-modal button.button-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 18px;
  border-radius: 999px;
  border: 0;
  background: var(--green-bright);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
}
.auth-modal .button-main:hover { background: #45a02d; }
.auth-modal .button-link,
.auth-modal .button-cabinet-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--green);
  background: #fff;
  color: var(--green-dark);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.auth-modal .checkbox {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.4;
}
.auth-modal .checkbox input { margin-top: 3px; accent-color: var(--green); flex-shrink: 0; }
.auth-modal .spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 600;
}
.auth-modal .reginfo {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.auth-modal .reginfo__card {
  background: #fff;
  border: 1px solid #e3ebe0;
  border-radius: 12px;
  padding: 14px;
}
.auth-modal .reginfo__card__title {
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 8px;
}
.auth-modal .reginfo__card__info__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--ink-muted);
}
.auth-modal .reginfo__card__info__item span:last-child {
  color: var(--ink);
  font-weight: 700;
}
.auth-ok[data-auth-error] {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
@keyframes authIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: #8a9586;
  cursor: pointer;
  display: grid; place-items: center;
}
.auth-close:hover { background: #e8eee6; color: var(--ink); }
.auth-close svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round;
}

.auth-title {
  font-family: var(--font);
  font-size: clamp(22px, 3vw, 26px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
  letter-spacing: -.02em;
  margin: 0 28px 8px 0;
}
.auth-title .mark {
  background: var(--mark);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  padding: 0 .12em;
  border-radius: 2px;
}
.auth-sub {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--ink-muted);
}

.auth-panel[hidden] { display: none; }

.auth-field { margin-bottom: 12px; }
.auth-field label {
  display: block;
  font-size: 12px; font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.auth-field input,
.auth-field select {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid #d5ddd2;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit; font-size: 15px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.auth-field input:focus,
.auth-field select:focus {
  outline: none;
  border-color: var(--green-bright);
  box-shadow: 0 0 0 3px rgba(78,173,51,.18);
}
.auth-field input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(198,40,40,.12);
}
.auth-field .hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-faint);
}
.auth-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdeceb;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.auth-error__text { flex: 1; min-width: 0; }
.auth-error__close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: -4px -4px 0 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--danger);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.auth-error__close:hover { background: rgba(198, 40, 40, .1); }
.auth-error[hidden] { display: none; }

/* Если бэкенд всё же отдаст info-bar — стилизуем и даём кликабельный крестик */
.auth-modal .info-bar.info-bar--error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdeceb;
  color: var(--danger);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}
.auth-modal .info-bar__content { flex: 1; }
.auth-modal .info-bar__closer button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--danger);
  font-size: 18px;
}
.auth-ok {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.auth-warn {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff4e5;
  color: #7a4a10;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.auth-warn[hidden] { display: none; }

.auth-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin: 4px 0 16px;
}
.auth-check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-muted); cursor: pointer;
}
.auth-check input { accent-color: var(--green); width: 16px; height: 16px; }

.btn-auth {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%;
  padding: 14px 18px;
  border-radius: 999px;
  border: 0;
  background: var(--green-bright);
  color: #fff;
  font: inherit; font-weight: 800; font-size: 15px;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
  text-decoration: none;
}
.btn-auth:hover {
  background: #45a02d;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(78,173,51,.28);
}
.btn-auth-outline {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%;
  padding: 13px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--green-bright);
  background: #fff;
  color: var(--green);
  font: inherit; font-weight: 800; font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s ease, transform .2s ease;
}
.btn-auth-outline:hover {
  background: var(--green-soft);
  transform: translateY(-1px);
}

.auth-link {
  display: block;
  text-align: center;
  margin: 12px 0 0;
  color: var(--green);
  font-size: 13px; font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none; border: 0; cursor: pointer; font-family: inherit;
}
.auth-link:hover { color: var(--green-dark); }

.auth-divider {
  margin: 18px 0 14px;
  font-size: 13px;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.4;
}

.auth-card-info {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--ink);
}
.auth-card-info dt {
  font-size: 11px; font-weight: 700;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 8px;
}
.auth-card-info dt:first-child { margin-top: 0; }
.auth-card-info dd { margin: 2px 0 0; font-weight: 700; }

.auth-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.45;
}

/* —— Адаптив (Figma: 1440 / 1024 / 834 / 360) —— */
@media (max-width: 1100px) {
  .auth-top,
  .auth-hero,
  .demo-links {
    width: calc(100% - 32px);
  }
  .auth-nav { gap: 14px; font-size: 13px; }
}

@media (max-width: 900px) {
  .auth-nav { display: none; }
  .auth-top {
    padding: 14px 0;
    gap: 10px;
  }
  .auth-logo img { height: 34px; }
  .auth-top-actions .phone { font-size: 13px; }
  .btn-ghost-light { padding: 9px 14px; font-size: 13px; }
  .auth-hero {
    margin-top: 28px;
    padding-bottom: 72px;
  }
  .auth-hero h1 { font-size: clamp(26px, 6vw, 36px); max-width: none; }
  .auth-hero p { font-size: 14.5px; }
  .auth-modal {
    width: min(420px, 100%);
    padding: 24px 22px 20px;
  }
}

@media (max-width: 720px) {
  .auth-stage { overflow-x: clip; }
  .auth-top,
  .auth-hero,
  .demo-links {
    width: calc(100% - 24px);
  }
  .auth-top-actions .phone { display: none; }
  .auth-hero { margin-top: 20px; padding-bottom: 48px; }
  .auth-hero-cta { width: 100%; justify-content: center; min-height: 48px; }
  .auth-top { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }

  .auth-overlay {
    padding: 0;
    align-items: end;
    align-content: end;
    overflow: hidden;
  }
  dialog.auth-dialog[open] {
    place-items: end center;
    align-content: end;
    padding: 0;
  }
  .auth-modal {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 12px);
    max-height: calc(100svh - 12px);
    border-radius: 20px 20px 0 0;
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    animation: authSheetIn .38s cubic-bezier(.22,.9,.3,1) both;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .auth-close {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
  }
  .auth-title {
    font-size: 22px;
    margin-right: 36px;
  }
  .auth-sub { font-size: 13.5px; margin-bottom: 16px; }
  .auth-field input,
  .auth-field select {
    font-size: 16px; /* без автозума iOS */
    padding: 14px 14px;
    min-height: 48px;
  }
  .btn-auth,
  .btn-auth-outline {
    min-height: 48px;
    font-size: 15px;
  }
  .demo-links {
    margin-bottom: 24px;
    gap: 6px;
  }
  .demo-links button {
    padding: 8px 10px;
    font-size: 11.5px;
  }
}

@media (max-width: 480px) {
  .auth-logo img { height: 30px; }
  .btn-ghost-light { padding: 8px 12px; font-size: 12.5px; }
  .auth-hero h1 { font-size: 24px; letter-spacing: -.02em; }
  .auth-hero p { font-size: 13.5px; }
  .auth-modal {
    border-radius: 16px 16px 0 0;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .auth-title { font-size: 20px; }
  .auth-divider { font-size: 12.5px; }
  .auth-card-info { font-size: 13px; }
  .auth-check { font-size: 12.5px; align-items: flex-start; }
  .auth-check input { margin-top: 2px; }
}

@media (max-width: 360px) {
  .auth-top,
  .auth-hero,
  .demo-links { width: calc(100% - 16px); }
  .auth-modal { padding-inline: 14px; }
  .auth-title { font-size: 18px; }
}

@keyframes authSheetIn {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-modal { animation: none; }
  .btn-auth:hover, .btn-auth-outline:hover, .btn-ghost-light:hover { transform: none; }
}

/* Landscape phone: modal centered, not bottom sheet */
@media (max-height: 500px) and (orientation: landscape) {
  .auth-overlay {
    align-items: center;
    padding: 12px;
  }
  .auth-modal {
    border-radius: 14px;
    max-height: calc(100dvh - 24px);
    width: min(440px, 100%);
    animation: authIn .3s ease both;
  }
  .auth-hero { display: none; }
  .demo-links { display: none; }
}
