:root {
  --bg: #f4f5f8;
  --text: #080b12;
  --muted: #747988;
  --line: #d9dde7;
  --field: #edeff5;
  --field-hover: #e9ecf3;
  --button: #dfe2ea;
  --button-text: #7d8492;
  --blue: #2f6af7;
  --error: #b91c1c;
  --success: #15803d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.35;
}
button, input { font: inherit; }
button { appearance: none; -webkit-appearance: none; }
a { color: inherit; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-shell {
  width: 100%;
  max-width: 382px;
  transform: translateY(-5px);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-brand--code { margin-bottom: 22px; }
.login-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
}
.login-brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.login-card {
  width: 100%;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.step-panel { display: none; }
.step-panel.is-active { display: block; }

.login-card h1 {
  margin: 0 0 15px;
  font-size: 21px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.login-subtitle {
  width: 340px;
  max-width: 100%;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.28;
}

.login-form,
.otp-form {
  display: grid;
  gap: 10px;
}

.field-group { display: grid; gap: 7px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.field-group input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--field);
  color: var(--text);
  padding: 0 15px;
  outline: none;
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.field-group input::placeholder { color: #9aa0ac; }
.field-group input:focus {
  background: #fff;
  border-color: #c6cad5;
  box-shadow: 0 0 0 3px rgba(47,106,247,.10);
}
.field-error {
  display: none;
  margin: 0;
  color: var(--error);
  font-size: 12px;
}
.field-group.is-error .field-error { display: block; }
.field-group.is-error input {
  background: #fff7f7;
  border-color: #fecaca;
}

.action-btn,
.resend-btn {
  width: 100%;
  min-height: 44px;
  border-radius: 13px;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  transition: transform .12s ease, background .12s ease, opacity .12s ease;
}
.action-btn {
  background: var(--button);
  color: var(--button-text);
}
.action-btn:hover { background: #d6dae5; }
.action-btn:active,
.resend-btn:active,
.inline-back:active { transform: translateY(1px); }
.action-btn:disabled,
.resend-btn:disabled { cursor: not-allowed; opacity: .72; }
.action-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }

.legal-note {
  width: 330px;
  max-width: 100%;
  margin: 18px auto 0;
  color: #858a97;
  text-align: center;
  font-size: 11px;
  line-height: 1.35;
}
.legal-note a {
  color: #707684;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.status-box {
  margin-bottom: 12px;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.35;
  border: 1px solid #dbe1ee;
  background: #fff;
  color: #303744;
}
.status-box.is-success { background: #f0fdf4; border-color: #bbf7d0; color: var(--success); }
.status-box.is-error { background: #fef2f2; border-color: #fecaca; color: var(--error); }
.status-box.is-info { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
[hidden] { display: none !important; }

.otp-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 8px 0 2px;
}
.otp-input {
  height: 48px;
  min-width: 0;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--field);
  color: var(--text);
  font-weight: 800;
  font-size: 18px;
  outline: none;
}
.otp-input:focus,
.otp-input.has-value {
  background: #fff;
  border-color: #c6cad5;
  box-shadow: 0 0 0 3px rgba(47,106,247,.10);
}
.verify-caption {
  min-height: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.resend-btn {
  background: var(--button);
  color: var(--button-text);
}
.resend-btn.is-ready { background: #111827; color: #fff; }
.inline-back {
  margin: 14px auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #737987;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
}
.inline-back svg { width: 17px; height: 17px; }
.hint-box { display: none; }

@media (max-width: 520px) {
  .login-page { align-items: flex-start; padding: 118px 22px 32px; }
  .login-shell { max-width: 100%; transform: none; }
}

/* FIX: Telegram login button must keep the original premium button look. */
.tg-login-btn {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #27a9ea;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 12px 26px rgba(39, 169, 234, .24);
  transition: transform .12s ease, background .12s ease, opacity .12s ease, box-shadow .12s ease;
}
.tg-login-btn:hover { background: #1997d8; box-shadow: 0 14px 30px rgba(39, 169, 234, .30); }
.tg-login-btn:active { transform: translateY(1px); }
.tg-login-btn:disabled { cursor: not-allowed; opacity: .72; box-shadow: none; }
.hint-box .tg-login-btn { margin-top: 0; }

/* FIX v4: кнопка входа должна быть светлой по умолчанию, а серой только при нажатии/загрузке */
.action-btn {
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #d9dde7;
  box-shadow: 0 10px 24px rgba(48, 76, 133, .08);
}
.action-btn:hover { background: #f7f8fb; }
.action-btn:active { background: #e3e6ee; transform: translateY(1px); }
.action-btn:disabled {
  background: #eef1f7;
  color: #8a91a0;
  box-shadow: none;
  opacity: 1;
}
