:root {
  --login-bg: #f7fafc;
  --login-surface: rgba(255, 255, 255, 0.94);
  --login-ink: #17293f;
  --login-muted: #738398;
  --login-gold: #c68f38;
  --login-gold-deep: #a87327;
  --login-steel: #a9bed6;
  --login-line: #cbd8e5;
  --login-error: #a53b36;
  --login-warn: #8a641f;
  --login-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html,
body { min-height: 100%; }

html {
  background: var(--login-bg);
  color-scheme: light;
}

body.login-space-page {
  display: flex;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background: var(--login-bg);
  color: var(--login-ink);
  font-family: var(--login-font);
  font-size: 15px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  flex-direction: column;
}

[hidden] { display: none !important; }

.login-skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  min-height: 44px;
  padding: 11px 16px;
  border: 1px solid var(--login-ink);
  border-radius: 10px;
  background: #fff;
  color: var(--login-ink);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.18s ease;
}

.login-skip-link:focus { transform: translateY(0); }

.login-fx,
.login-glow,
.login-fade {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.login-fx {
  z-index: 1;
  display: block;
}

.login-glow {
  z-index: 0;
  background:
    radial-gradient(56rem 42rem at 50% 42%, rgba(255, 255, 255, 0.98), rgba(247, 250, 252, 0.66) 58%, transparent 78%),
    radial-gradient(44rem 34rem at 10% 12%, rgba(169, 190, 214, 0.23), transparent 68%),
    radial-gradient(36rem 30rem at 88% 86%, rgba(198, 143, 56, 0.09), transparent 70%);
  transform-origin: 50% 48%;
  animation: login-glow-breathe 24s ease-in-out infinite alternate;
}

.login-fade {
  z-index: 0;
  background: radial-gradient(34rem 28rem at 50% 48%, rgba(255, 255, 255, 0.92) 0%, rgba(247, 250, 252, 0.68) 44%, transparent 76%);
}

@keyframes login-glow-breathe {
  from { transform: translate3d(0, 0, 0) scale(1); opacity: 0.92; }
  to { transform: translate3d(0.8%, -0.7%, 0) scale(1.035); opacity: 1; }
}

.login-top,
.login-stage,
.login-footer {
  position: relative;
  z-index: 2;
}

.login-top {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px 0;
}

.login-language {
  display: flex;
  gap: 2px;
}

.login-language__button {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--login-muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  transition: color 0.18s ease, background 0.18s ease;
}

.login-language__button:hover {
  background: rgba(23, 41, 63, 0.05);
  color: var(--login-ink);
}

.login-language__button.is-active,
.login-language__button[aria-pressed="true"] {
  color: var(--login-gold);
  font-weight: 700;
}

.login-stage {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 22px 24px 30px;
}

.login-panel {
  width: 100%;
  max-width: 376px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
}

.login-logo-link {
  display: block;
  width: 204px;
  margin: 0 auto 22px;
  border-radius: 14px;
}

.login-logo {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.login-panel h1 {
  margin: 0 0 26px;
  color: var(--login-ink);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.login-form {
  margin: 0;
  text-align: left;
}

.login-field label {
  display: block;
  margin: 0 0 8px 2px;
  color: var(--login-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-input {
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--login-line);
  border-radius: 12px;
  background: var(--login-surface);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.login-input:hover { border-color: #b5c8dc; }

.login-input:focus-within {
  border-color: var(--login-gold);
  box-shadow: 0 0 0 3px rgba(198, 143, 56, 0.14);
}

.login-input input {
  flex: 1;
  min-width: 0;
  /* Автозаполнение и восстановление формы из bfcache заливают поле сплошным
     прямоугольником: без собственного радиуса он срезает углы рамки. */
  border-radius: 12px 0 0 12px;
  min-height: 50px;
  padding: 13px 4px 13px 15px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--login-ink);
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.login-input input::placeholder {
  color: #aab5c2;
  letter-spacing: 0.06em;
  opacity: 1;
}

.login-input input:-webkit-autofill,
.login-input input:-webkit-autofill:hover,
.login-input input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--login-ink);
  box-shadow: 0 0 0 1000px #fff inset;
}

.login-token-toggle {
  display: grid;
  width: 44px;
  height: 44px;
  margin-right: 3px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--login-muted);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.login-token-toggle:hover {
  background: rgba(23, 41, 63, 0.05);
  color: var(--login-ink);
}

.login-token-toggle svg {
  width: 19px;
  height: 19px;
}

.login-token-toggle .login-eye-off { display: none; }

.login-token-toggle.is-visible .login-eye,
.login-token-toggle[aria-pressed="true"] .login-eye { display: none; }

.login-token-toggle.is-visible .login-eye-off,
.login-token-toggle[aria-pressed="true"] .login-eye-off { display: block; }

.auth-field--invalid .login-input,
.login-input:has(input[aria-invalid="true"]) {
  border-color: var(--login-error);
  box-shadow: 0 0 0 3px rgba(165, 59, 54, 0.12);
}

.auth-message {
  margin: 12px 2px 0;
  padding: 10px 12px;
  border: 1px solid currentColor;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}

.auth-message--warn {
  background: rgba(198, 143, 56, 0.08);
  color: var(--login-warn);
}

.auth-message--error {
  background: rgba(165, 59, 54, 0.07);
  color: var(--login-error);
}

.login-submit {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 18px;
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--login-gold);
  box-shadow: 0 12px 26px -14px rgba(168, 115, 39, 0.7);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.login-submit:hover:not(:disabled) {
  background: var(--login-gold-deep);
  box-shadow: 0 16px 30px -14px rgba(168, 115, 39, 0.78);
}

.login-submit:active:not(:disabled) { transform: translateY(1px); }

.login-submit:disabled {
  cursor: wait;
  opacity: 0.82;
}

.login-submit__arrow {
  width: 17px;
  height: 17px;
}

.auth-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: login-spin 0.7s linear infinite;
}

.login-submit.is-busy .auth-spinner { display: block; }
.login-submit.is-busy .login-submit__arrow { display: none; }

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

.login-secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 16px 0 0;
  color: var(--login-muted);
  font-size: 12.5px;
  text-align: center;
}

.login-secure svg {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--login-steel);
}

.login-alt {
  margin: 22px 0 0;
  color: var(--login-muted);
  font-size: 13px;
  text-align: center;
}

.login-alt__action {
  padding-bottom: 1px;
  border-bottom: 1px solid var(--login-line);
  color: var(--login-ink);
}

.login-footer {
  padding: 0 28px 22px;
  color: #8c98a6;
  font-size: 12px;
  text-align: center;
}

.login-language__button:focus-visible,
.login-logo-link:focus-visible,
.login-token-toggle:focus-visible,
.login-submit:focus-visible,
.login-input input:focus-visible,
.login-skip-link:focus-visible {
  outline: 3px solid rgba(198, 143, 56, 0.55);
  outline-offset: 3px;
}

@media (max-width: 520px) {
  .login-top { padding: 10px 12px 0; }
  .login-stage { padding: 10px 18px 28px; }
  .login-panel { max-width: 390px; }
  .login-logo-link { width: 176px; margin-bottom: 18px; }
  .login-panel h1 { margin-bottom: 24px; }
  .login-footer { padding-bottom: 18px; }
}

@media (max-width: 340px) {
  .login-stage { padding-inline: 14px; }
  .login-logo-link { width: 158px; margin-bottom: 14px; }
  .login-panel h1 { margin-bottom: 20px; }
  .login-secure { font-size: 12px; }
}

@media (max-height: 720px) and (min-width: 521px) {
  .login-top { padding-top: 8px; }
  .login-stage { padding-block: 8px 14px; }
  .login-logo-link { width: 166px; margin-bottom: 12px; }
  .login-panel h1 { margin-bottom: 18px; }
  .login-alt { margin-top: 14px; }
  .login-footer { padding-bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .login-input,
  .auth-message,
  .login-submit { border: 1px solid CanvasText; }
  .login-language__button.is-active,
  .login-language__button[aria-pressed="true"] { outline: 2px solid Highlight; }
}
