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

.auth-page {
  margin: 0;
  background: var(--bg-app);
  color: var(--ink);
}

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) var(--s-5) max(24px, env(safe-area-inset-bottom));
}

.auth__panel {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
}

.auth__panel[hidden] {
  display: none !important;
}

@media (min-width: 600px) {
  .auth__panel {
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-2xl);
    box-shadow: var(--sh-lg);
    padding: var(--s-10) var(--s-8);
  }
}

@media (max-width: 599px) {
  .auth {
    align-items: start;
    place-items: start center;
    padding: max(18px, env(safe-area-inset-top)) var(--s-4) max(18px, env(safe-area-inset-bottom));
  }

  .auth__panel {
    max-width: 420px;
  }

  .auth__brand {
    margin-bottom: var(--s-5);
  }

  .auth__logo {
    width: 46px;
    height: 46px;
    border-radius: var(--r-lg);
  }

  .auth__title {
    margin-top: var(--s-4);
    font-size: var(--fs-xl);
  }

  .auth__sub {
    font-size: var(--fs-sm);
  }
}

.auth__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: var(--s-7);
}

.auth__logo {
  width: 52px;
  height: 52px;
  border-radius: var(--r-xl);
  box-shadow: 0 6px 18px -8px rgba(197, 62, 45, 0.5);
}

.auth__title {
  margin: var(--s-5) 0 0;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}

.auth__sub {
  margin: var(--s-2) auto 0;
  max-width: 31ch;
  font-size: var(--fs-md);
  line-height: var(--lh-snug);
  color: var(--ink-secondary);
}

.auth__form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.auth__link-btn {
  appearance: none;
  background: none;
  border: none;
  padding: var(--s-1);
  color: var(--ink-secondary);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
}

.auth__link-btn:hover {
  color: var(--ink);
  text-decoration: underline;
}

.auth__center-error {
  min-height: 16px;
  margin: calc(-1 * var(--s-2)) 0 0;
  text-align: center;
}

.auth-test {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
  margin-top: var(--s-6);
}

.auth-test__head {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 0 2px;
}

.auth-test__head b {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--ink);
}

.auth-test__head span {
  font-family: var(--font-num);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--brand-active);
}

.auth-test button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.auth-test button:hover {
  border-color: var(--brand);
  box-shadow: var(--sh-sm);
}

.auth-test b,
.auth-test span {
  display: block;
}

.auth-test b {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--ink);
}

.auth-test span {
  margin-top: 2px;
  font-family: var(--font-num);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
}

.otp {
  display: flex;
  justify-content: center;
  gap: var(--s-2);
}

.otp__cell {
  width: 46px;
  height: 56px;
  padding: 0;
  text-align: center;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

.otp.is-error .otp__cell {
  border-color: var(--danger);
  color: var(--danger-ink);
}

@media (max-width: 360px) {
  .otp {
    gap: 6px;
  }

  .otp__cell {
    width: 42px;
    height: 52px;
  }

  .auth-test {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .auth-test {
    grid-template-columns: 1fr;
    margin-top: var(--s-5);
  }

  .auth-test__head {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .auth-test button {
    min-height: 58px;
  }
}

@media (max-width: 340px) {
  .otp {
    gap: 5px;
  }

  .otp__cell {
    width: 39px;
    height: 50px;
    font-size: var(--fs-xl);
  }
}

#trena-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: var(--bg-app);
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  opacity: 1;
  transition: opacity var(--t-slow) var(--ease), visibility 0s;
}

#trena-loader.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--t-slow) var(--ease), visibility 0s linear var(--t-slow);
}

.boot-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.boot-loader__logo {
  width: 72px;
  height: 72px;
  border-radius: var(--r-2xl);
  box-shadow: 0 8px 24px -10px rgba(197, 62, 45, 0.55), 0 2px 6px -2px rgba(20,20,18,0.08);
}

.boot-loader__word {
  margin-top: 20px;
  font-size: 26px;
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}

.boot-loader__spin {
  margin-top: 30px;
  min-height: 28px;
  display: grid;
  place-items: center;
}

.boot-loader__status {
  margin-top: 14px;
  min-height: 16px;
  font-size: 12px;
  color: var(--ink-muted);
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
  display: inline-block;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: auth-spin 1.6s steps(8, end) infinite;
  }
}
