/* ==========================================================================
   Sign-in page: the stage (the agent at the center of your contour, as on optortech.ru)
   and the form. Over style.css: tokens, fonts, icons.
   ========================================================================== */
body.login {
  --navy: #070b18;
  --navy-2: #0b1226;
  --glass: rgba(16, 22, 42, 0.72);
  --glass-line: rgba(124, 150, 230, 0.16);
  min-height: 100%;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(400px, 0.9fr);
  background: var(--navy);
}

/* -- The stage ---------------------------------------------------------- */
.stage { position: relative; overflow: hidden; min-height: 100vh; isolation: isolate; }
.stage .glow { position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; z-index: -1; }
.stage .g1 { width: 620px; height: 620px; left: 50%; top: 50%; transform: translate(-50%, -50%); background: radial-gradient(circle, rgba(36, 74, 184, 0.55), transparent 65%); }
.stage .g2 { width: 380px; height: 380px; right: -120px; bottom: -120px; background: radial-gradient(circle, rgba(56, 101, 206, 0.35), transparent 70%); }
.stage .grid {
  position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(rgba(124, 150, 230, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(124, 150, 230, 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 50%, #000 0, transparent 70%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0, transparent 70%);
}
.orbits { position: absolute; left: 50%; top: 50%; width: min(620px, 92%); aspect-ratio: 1; transform: translate(-50%, -50%); overflow: visible; }
.orbits .ring { fill: none; stroke: url(#ring); stroke-width: 1; }
.orbits .r2 { stroke-dasharray: 2 7; }
.orbits .r3 { stroke-dasharray: 1 10; opacity: 0.7; }
.orbits .node { fill: #8fb0ff; filter: drop-shadow(0 0 6px rgba(107, 140, 240, 0.9)); }
.orbits .node.dim { fill: #6b8cf0; opacity: 0.6; filter: none; }
.orbits .spin { transform-origin: 0 0; animation: orbit 38s linear infinite; }
.orbits .s2 { animation-duration: 64s; animation-direction: reverse; }
.orbits .s3 { animation-duration: 96s; }
@keyframes orbit { to { transform: rotate(360deg); } }

.core {
  position: absolute; left: 50%; top: 50%; width: 112px; height: 112px; transform: translate(-50%, -50%);
  display: grid; place-items: center; border-radius: 30px;
  background: linear-gradient(160deg, #ffffff, #e9eefb);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 0 10px rgba(56, 101, 206, 0.12), 0 0 0 22px rgba(56, 101, 206, 0.06), 0 30px 80px -10px rgba(36, 74, 184, 0.8);
  animation: breathe 5s var(--ease) infinite alternate;
}
.core img { width: 64px; height: 64px; }
@keyframes breathe { to { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 0 14px rgba(56, 101, 206, 0.16), 0 0 0 30px rgba(56, 101, 206, 0.07), 0 30px 90px -6px rgba(36, 74, 184, 0.95); } }

.chips { position: absolute; inset: 0; pointer-events: none; }
.chip {
  position: absolute; display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px;
  background: rgba(14, 20, 40, 0.78); border: 1px solid var(--glass-line); color: #d9e1f7;
  font-size: 13.5px; font-weight: 550; letter-spacing: -0.005em; white-space: nowrap;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.7);
  animation: float 7s var(--ease) infinite alternate;
}
.chip .ic { width: 16px; height: 16px; color: #8fb0ff; }
.chip.c1 { left: 14%; top: 24%; }
.chip.c2 { right: 12%; top: 36%; animation-delay: -2.5s; }
.chip.c3 { left: 22%; bottom: 20%; animation-delay: -4.5s; }
@keyframes float { from { transform: translateY(-6px); } to { transform: translateY(6px); } }

/* -- The form side ------------------------------------------------------- */
.auth {
  position: relative; display: flex; flex-direction: column; justify-content: center; gap: 26px;
  padding: max(40px, env(safe-area-inset-top)) clamp(24px, 5vw, 64px) max(28px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  border-left: 1px solid var(--glass-line);
  min-height: 100vh;
}
.auth-brand .wordmark { width: min(300px, 100%); height: auto; display: block; }
.auth-brand .pitch { margin: 14px 0 0; max-width: 380px; color: #9aa6c4; font-size: 14.5px; line-height: 1.55; }

.auth-card {
  width: 100%; max-width: 400px; padding: 28px; border-radius: 22px;
  background: var(--glass); border: 1px solid var(--glass-line);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  display: grid; gap: 16px;
  animation: rise 0.5s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.step { display: grid; gap: 14px; }
.step:not([hidden]) { animation: step-in 0.32s var(--ease) both; }
@keyframes step-in { from { opacity: 0; transform: translateX(14px); } }
.auth-card h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.025em; color: #f3f5fb; }
.auth-card .sub { margin: -8px 0 4px; color: #9aa6c4; font-size: 14px; line-height: 1.5; }

/* Passkey: the big, first way in */
.passkey {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; text-align: left;
  border: 1px solid rgba(124, 150, 230, 0.35); border-radius: 16px; cursor: pointer;
  background: linear-gradient(135deg, rgba(56, 101, 206, 0.28), rgba(36, 74, 184, 0.12));
  color: #f3f5fb; font: inherit;
  transition: transform 0.15s var(--ease), border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.passkey:hover { border-color: rgba(143, 176, 255, 0.7); box-shadow: 0 10px 30px -12px rgba(56, 101, 206, 0.8); }
.passkey:active { transform: scale(0.985); }
.passkey:focus-visible { outline: 2px solid #8fb0ff; outline-offset: 2px; }
.passkey[aria-busy="true"] { pointer-events: none; opacity: 0.75; }
.passkey .pk-ic {
  flex: none; width: 44px; height: 44px; padding: 10px; border-radius: 12px;
  background: linear-gradient(160deg, #3865CE, #244AB8); fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  box-shadow: 0 6px 16px -6px rgba(56, 101, 206, 0.9);
}
.passkey span { display: grid; gap: 2px; }
.passkey b { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.passkey small { color: #9aa6c4; font-size: 12.5px; }

.or { display: flex; align-items: center; gap: 12px; color: #6f7a96; font-size: 12.5px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--glass-line); }

.field { display: grid; gap: 7px; }
.field > span:first-child { color: #9aa6c4; font-size: 13px; font-weight: 550; }
.field input {
  width: 100%; padding: 13px 14px; border-radius: 12px; outline: none;
  background: rgba(7, 11, 24, 0.7); border: 1px solid rgba(124, 150, 230, 0.18); color: #f3f5fb;
  font: 500 15px/1.3 var(--sans);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.field input:hover { border-color: rgba(124, 150, 230, 0.32); }
.field input:focus { border-color: #6b8cf0; box-shadow: 0 0 0 4px rgba(107, 140, 240, 0.18); background: rgba(7, 11, 24, 0.9); }
.field input:-webkit-autofill { -webkit-text-fill-color: #f3f5fb; -webkit-box-shadow: 0 0 0 40px #0d1430 inset; caret-color: #f3f5fb; }
.pw { position: relative; display: block; }
.pw input { padding-right: 48px; }
.eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 9px; background: none; color: #7d89a8; cursor: pointer; }
.eye:hover { color: #f3f5fb; background: rgba(124, 150, 230, 0.12); }
.eye .ic { width: 18px; height: 18px; }
.caps { margin: -6px 0 0; color: var(--warn); font-size: 12.5px; }

/* The code: one wide, spaced field; six digits send themselves */
.field input.code { text-align: center; font: 600 28px/1.2 var(--mono); letter-spacing: 0.28em; padding: 16px 12px; }
.field input.code.recovery { font-size: 18px; letter-spacing: 0.08em; }
.field input.code::placeholder { color: #3a4566; }
.back { justify-self: start; display: inline-flex; align-items: center; gap: 6px; margin: -6px 0 -4px -6px; padding: 4px 8px; border: 0; border-radius: 8px; background: none; color: #9aa6c4; font: 500 13px var(--sans); cursor: pointer; }
.back:hover { color: #f3f5fb; background: rgba(124, 150, 230, 0.1); }
.back .ic { width: 15px; height: 15px; }
.auth-card .link { justify-self: center; border: 0; background: none; color: #8fb0ff; font: 500 13px var(--sans); cursor: pointer; padding: 4px; }
.auth-card .link:hover { text-decoration: underline; }
/* Sign in with the phone */
.phone-link { display: inline-flex; align-items: center; gap: 7px; margin-top: 2px; }
.phone-link .ic { width: 16px; height: 16px; }
.qr-box { position: relative; justify-self: center; padding: 12px; border-radius: 18px; background: #fff; box-shadow: 0 20px 50px -18px rgba(56, 101, 206, 0.8), 0 0 0 6px rgba(56, 101, 206, 0.12); line-height: 0; }
.qr-box img { width: 216px; height: 216px; display: block; image-rendering: pixelated; }
.qr-shade { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; border-radius: 18px; background: rgba(11, 18, 38, 0.88); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); line-height: 1.4; text-align: center; }
.qr-number { display: flex; align-items: center; justify-content: center; gap: 14px; color: #9aa6c4; font-size: 14px; }
.qr-number b { min-width: 72px; padding: 6px 14px; border-radius: 12px; background: rgba(56, 101, 206, 0.18); border: 1px solid rgba(124, 150, 230, 0.35); color: #f3f5fb; font: 700 30px/1.1 var(--mono); letter-spacing: 0.06em; text-align: center; }
.qr-wait { display: flex; align-items: center; justify-content: center; gap: 9px; margin: 0; color: #7d89a8; font-size: 13px; }
.qr-wait .dot { width: 8px; height: 8px; border-radius: 50%; background: #6b8cf0; animation: pulse 1s var(--ease) infinite alternate; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.go {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; margin-top: 2px;
  border: 0; border-radius: 13px; cursor: pointer; color: #fff; font: 650 15.5px var(--sans); letter-spacing: -0.01em;
  background: linear-gradient(180deg, #3a63d8, #2343c8);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 12px 28px -12px rgba(35, 67, 200, 0.9);
  transition: transform 0.15s var(--ease), filter 0.15s, box-shadow 0.15s;
}
.go:hover { filter: brightness(1.08); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 16px 34px -12px rgba(35, 67, 200, 1); }
.go:active { transform: scale(0.985); }
.go .ic { width: 18px; height: 18px; transition: transform 0.2s var(--ease); }
.go:hover .ic { transform: translateX(3px); }
.go[aria-busy="true"] { pointer-events: none; }
.go[aria-busy="true"] .ic { display: none; }
.go[aria-busy="true"]::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-card .login-error { margin: 0; padding: 10px 12px; border-radius: 11px; font-size: 13.5px; border: 1px solid rgba(242, 109, 101, 0.3); }
.auth-card.shake { animation: shake 0.4s var(--ease); }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }

.auth-foot { display: flex; align-items: center; gap: 8px; color: #5f6a87; font-size: 12.5px; }
.auth-foot .ic { width: 14px; height: 14px; }

/* -- Narrow screens: the stage becomes a band above the form ---------------- */
@media (max-width: 960px) {
  body.login { grid-template-columns: 1fr; }
  .stage { min-height: 0; height: calc(210px + env(safe-area-inset-top)); }
  /* the band fades into the form's background: no edge between them */
  .stage::after { content: ""; position: absolute; inset: auto 0 0 0; height: 90px; background: linear-gradient(transparent, var(--navy-2)); }
  .auth { background: var(--navy-2); }
  .orbits { width: 520px; }
  .core { width: 76px; height: 76px; border-radius: 22px; }
  .core img { width: 44px; height: 44px; }
  .chips { display: none; }
  .auth { min-height: 0; border-left: 0; padding-top: 4px; gap: 20px; align-items: stretch; }
  .auth-card, .auth-brand .pitch { max-width: none; }
  .auth-brand { text-align: center; }
  .auth-brand .wordmark { margin: 0 auto; width: min(260px, 80%); }
  .auth-brand .pitch { margin-inline: auto; max-width: 420px; }
  .auth-card { margin: 0 auto; max-width: 440px; padding: 22px; }
  .auth-foot { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .orbits .spin, .core, .chip, .auth-card, .step:not([hidden]) { animation: none; }
}
