:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #17324d;
  --muted: #65758a;
  --line: rgba(23, 50, 77, 0.14);
  --blue: #2467b2;
  --blue-dark: #173f73;
  --green: #1d7f5b;
  --red: #b43a3a;
  --shadow: 0 18px 44px rgba(25, 54, 90, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(36, 103, 178, 0.13), transparent 34%),
    linear-gradient(225deg, rgba(29, 127, 91, 0.12), transparent 32%),
    var(--bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth-panel {
  width: min(100%, 480px);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.auth-copy {
  margin: 30px 0 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

.auth-copy p:last-child,
.auth-note {
  color: var(--muted);
  line-height: 1.55;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: #eef3f9;
  border-radius: 8px;
}

.auth-tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.is-active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 3px rgba(25, 54, 90, 0.12);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form.is-hidden {
  display: none;
}

.field {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  outline: none;
}

.field input:focus,
.password-field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 103, 178, 0.14);
}

.field input.is-invalid,
.password-field.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(180, 58, 58, 0.12);
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.password-field input {
  min-height: 42px;
  border: 0;
  border-radius: 6px 0 0 6px;
  box-shadow: none !important;
}

.password-toggle {
  position: relative;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.password-toggle span {
  position: absolute;
  left: 9px;
  top: 13px;
  width: 20px;
  height: 12px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  transform: none;
}

.password-toggle span::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  transform: translate(-50%, -50%);
}

.password-toggle::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 18px;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: var(--muted);
  transform: rotate(-32deg);
  transform-origin: center;
}

.password-toggle.is-visible span {
  border-color: var(--blue);
}

.password-toggle.is-visible span::before {
  background: var(--blue);
}

.password-toggle.is-visible::after {
  opacity: 0;
}

.field-register {
  display: none;
}

.auth-form.is-register .field-register {
  display: grid;
}

.password-strength.field-register,
.auth-check.field-register {
  display: none;
}

.auth-form.is-register .password-strength.field-register,
.auth-form.is-register .auth-check.field-register {
  display: grid;
}

.password-strength {
  display: grid;
  gap: 6px;
}

.password-strength__bar {
  display: block;
  overflow: hidden;
  height: 6px;
  border-radius: 999px;
  background: #e6edf5;
}

.password-strength__bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--red);
  transition: width .16s ease, background .16s ease;
}

.password-strength small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.password-strength[data-score="1"] .password-strength__bar span {
  width: 25%;
  background: var(--red);
}

.password-strength[data-score="2"] .password-strength__bar span {
  width: 50%;
  background: #c78624;
}

.password-strength[data-score="3"] .password-strength__bar span {
  width: 75%;
  background: #3d8d6a;
}

.password-strength[data-score="4"] .password-strength__bar span {
  width: 100%;
  background: var(--green);
}

.password-strength[data-score="mismatch"] .password-strength__bar span {
  width: 100%;
  background: var(--red);
}

.password-strength[data-score="mismatch"] small {
  color: var(--red);
}

.auth-check {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.38;
}

.auth-check input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--blue);
}

.auth-check a {
  color: #0b63ff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-check input.is-invalid {
  outline: 2px solid rgba(180, 58, 58, 0.58);
  outline-offset: 2px;
}

.form-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-status.is-error {
  color: var(--red);
}

.form-status.is-success {
  color: var(--green);
}

.submit-button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.telegram-auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid rgba(36, 103, 178, 0.22);
  border-radius: 6px;
  color: var(--blue-dark);
  background: #f3f8ff;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
}

.telegram-auth-button:hover,
.telegram-auth-button:focus-visible {
  border-color: rgba(36, 103, 178, 0.42);
  background: #eaf3ff;
}

.auth-secondary-link {
  justify-self: center;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.auth-secondary-link:hover,
.auth-secondary-link:focus-visible {
  text-decoration: underline;
}

.auth-note {
  margin: 18px 0 0;
  font-size: 13px;
}

@media (max-width: 520px) {
  .auth-shell {
    align-items: stretch;
    padding: 12px;
  }

  .auth-panel {
    padding: 22px;
  }

  h1 {
    font-size: 25px;
  }
}
