:root {
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-soft: rgba(37, 99, 235, 0.14);
  --bg: #f4f7fc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dfe5ef;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(37, 99, 235, 0.08), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid #eaeef5;
  border-radius: 20px;
  padding: 40px 36px 36px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.06);
  text-align: center;
}

.logo {
  display: block;
  margin: 0 auto 28px;
  border-radius: 50%;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

/* Логотип с надписью справа — вход в админку */
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 28px;
}
.login-brand .logo { margin: 0; }
.brand-tag {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 6px 0 28px;
  font-size: 14px;
  color: var(--muted);
}

form { text-align: left; }

.field { margin-bottom: 16px; }

label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
}

input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder { color: #a3adbd; }

input:hover { border-color: #c9d2e0; }

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}

.invalid input { border-color: var(--error); }
.invalid input:focus { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12); }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 46px; }

.eye {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.eye:hover { color: var(--blue); background: #f1f5fd; }
.eye:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

.eye svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eye .icon-hide { display: none; }
.eye[aria-pressed="true"] .icon-show { display: none; }
.eye[aria-pressed="true"] .icon-hide { display: block; }

.error {
  margin: 0 0 16px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--error);
  background: var(--error-bg);
  border-radius: 10px;
}

/* Спокойное сообщение об успехе — например, «Пароль изменён» */
.notice {
  margin: 0 0 16px;
  padding: 10px 12px;
  font-size: 13px;
  color: #1d4ed8;
  background: #eff5ff;
  border-radius: 10px;
}

.submit {
  position: relative;
  width: 100%;
  height: 46px;
  margin-top: 8px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
}

.submit:hover { background: var(--blue-hover); }
.submit:active { transform: translateY(1px); }
.submit:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--blue-soft); }
.submit:disabled { cursor: default; opacity: 0.85; }

.submit.secondary {
  color: var(--blue);
  background: #eef3fe;
  box-shadow: none;
}
.submit.secondary:hover { background: #e2eafd; }

.spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.submit.loading .submit-text { visibility: hidden; }
.submit.loading .spinner { display: block; }

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

.shake { animation: shake 0.35s ease; }

@keyframes shake {
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.footer {
  margin: 24px 0 0;
  font-size: 12px;
  color: #94a3b8;
}

@media (max-width: 440px) {
  .card { padding: 32px 22px 26px; border-radius: 18px; }
}

/* Регистрация и код для входа */
.card h1 { margin-bottom: 24px; }
.link-btn { padding: 0; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--blue); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
a.link-btn { text-decoration: none; }
a.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { color: #94a3b8; cursor: default; text-decoration: none; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; }
.field-top label { margin-bottom: 6px; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.hint.ok { color: #15803d; }
.auth-switch { margin: 20px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.auth-switch a { color: var(--blue); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.step-text { margin: 0 0 20px; font-size: 14px; line-height: 1.55; color: #475569; text-align: center; }
.tg-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 48px; border-radius: var(--radius);
  background: #229ed9; color: #fff; font-size: 15px; font-weight: 600; text-decoration: none; box-shadow: 0 4px 12px rgba(34, 158, 217, 0.25); transition: background 0.15s; }
.tg-btn:hover { background: #1c8cc2; }
.tg-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.wait { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 18px 0 0; font-size: 13px; color: var(--muted); }
.wait .dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: #229ed9; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.7); } }
.done-icon { width: 56px; height: 56px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 50%; background: #dcfce7; color: #15803d; }
.done-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.test-box { margin: 16px 0 0; padding: 10px 12px; border-radius: 10px; background: #fffbeb; color: #92400e; font-size: 13px; text-align: left; }
.test-box .link-btn { color: #b45309; }
.code-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.back-link { display: block; margin: 16px auto 0; }

/* Поле «Telegram» на регистрации: как обычное поле ввода, пустое; справа значок загрузки → синяя галочка */
.tg-field { position: relative; display: block; height: 46px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  cursor: pointer; transition: border-color 0.2s, background 0.25s, box-shadow 0.25s; }
.tg-field:hover { border-color: #c9d2e0; }
.tg-field:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.tg-label { position: absolute; top: 50%; left: 14px; transform: translateY(-50%); font-size: 15px; color: #a3adbd; transition: color 0.2s; }
.tg-field:hover .tg-label { color: #64748b; }
.tg-field[data-state="linked"] .tg-label { color: var(--blue); font-weight: 500; }
.tg-status { position: absolute; top: 50%; right: 14px; width: 20px; height: 20px; transform: translateY(-50%); }
.tg-status svg { position: absolute; inset: 0; width: 20px; height: 20px; fill: none; transition: opacity 0.25s, transform 0.3s; }
.tg-track { stroke: #e2e8f0; stroke-width: 2.4; }
.tg-arc { stroke: #94a3b8; stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 16 41; transform-origin: 12px 12px; transition: stroke 0.2s; }
.tg-check { opacity: 0; transform: scale(0.4) rotate(-20deg); stroke: var(--blue); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.tg-field:hover .tg-arc { stroke: var(--blue); }
.tg-field[data-state="waiting"] { cursor: default; border-color: #bcd0f7; }
.tg-field[data-state="waiting"] .tg-arc { stroke: var(--blue); animation: spin 0.9s linear infinite; }
.tg-field[data-state="linked"] { cursor: default; border-color: #93b4f5; background: #f2f6ff; box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08); }
.tg-field[data-state="linked"] .tg-loader { opacity: 0; transform: scale(0.4); }
.tg-field[data-state="linked"] .tg-check { opacity: 1; transform: none; }
.invalid .tg-field { border-color: var(--error); }

/* Полоса готовности над кнопкой «Зарегистрироваться»: логин, пароль, Telegram — по трети */
.progress { height: 6px; margin: 4px 0 18px; border-radius: 999px; background: #e8edf6; overflow: hidden; }
.progress span { display: block; width: 0; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #60a5fa, var(--blue)); transition: width 0.4s ease; }
.progress span.full { background: linear-gradient(90deg, #34d399, #16a34a); }
#register-form .submit:disabled:not(.loading) { background: #c9d6f2; box-shadow: none; cursor: not-allowed; opacity: 1; transform: none; }

/* «Для чего?» у поля Telegram: подсказка раскрывается вниз из надписи */
.why { position: relative; }
.why-tip { position: absolute; top: calc(100% + 8px); right: 0; z-index: 10; width: 280px; padding: 12px 14px; border-radius: 12px;
  background: #fff; border: 1px solid #e3e9f3; box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12); font-size: 13px; line-height: 1.55; color: #475569;
  text-align: left; opacity: 0; visibility: hidden; transform: translateY(-6px) scaleY(0.92); transform-origin: top right;
  transition: opacity 0.2s ease, transform 0.25s ease, visibility 0.2s; }
.why-tip::before { content: ''; position: absolute; top: -6px; right: 22px; width: 10px; height: 10px; background: #fff;
  border-left: 1px solid #e3e9f3; border-top: 1px solid #e3e9f3; transform: rotate(45deg); }
.why-tip b { color: var(--text); font-weight: 600; }
.why-note { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px solid #eef1f6; color: var(--blue); font-weight: 600; }
.why:hover .why-tip, .why:focus-within .why-tip, .why.open .why-tip { opacity: 1; visibility: visible; transform: none; }
@media (max-width: 380px) {
  .why-tip { width: 250px; }
}

/* Поле кода на странице входа: справа «Получить код» / отсчёт до повторной отправки */
.code-to { margin-bottom: 6px; font-size: 12px; color: var(--muted); max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-wrap { position: relative; }
.code-wrap input { padding-right: 150px; letter-spacing: 0.22em; font-weight: 600; }
.code-wrap input::placeholder { letter-spacing: normal; font-weight: 400; color: #a3adbd; }
.code-action { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); height: 34px; padding: 0 10px; border: 0; border-radius: 8px;
  background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--blue); cursor: pointer; transition: background 0.15s, color 0.15s; }
.code-action:hover { background: #f1f5fd; }
.code-action:disabled { color: #94a3b8; background: transparent; cursor: default; font-weight: 500; }
.code-action[hidden] { display: none; }

/* Вход в админку — острые углы, как во всей админке (кабинет клиента остаётся скруглённым) */
body.admin-auth *,
body.admin-auth *::before,
body.admin-auth *::after { border-radius: 0 !important; }
body.admin-auth .spinner { border-radius: 50% !important; }
body.admin-auth,
body.admin-auth :is(button, input, select, textarea) { font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
