:root {
  --auth-bg: #111827;
  --auth-bg-soft: #1f2937;
  --auth-card: rgba(17, 24, 39, 0.72);
  --auth-border: rgba(148, 163, 184, 0.24);
  --auth-text: #e5e7eb;
  --auth-muted: #9ca3af;
  --auth-input: rgba(15, 23, 42, 0.55);
  --auth-input-border: rgba(148, 163, 184, 0.24);
  --auth-primary: #0ea5e9;
  --auth-primary-2: #2563eb;
  --auth-focus: rgba(14, 165, 233, 0.35);
}

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

body.auth-page {
  margin: 0;
  display: grid;
  place-items: center;
  align-content: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.25rem;
  color: var(--auth-text);
  background:
    radial-gradient(1200px 550px at 5% -10%, rgba(14, 165, 233, 0.24), transparent 56%),
    radial-gradient(1000px 540px at 95% 108%, rgba(37, 99, 235, 0.2), transparent 58%),
    linear-gradient(135deg, var(--auth-bg) 0%, var(--auth-bg-soft) 100%);
}

.form-signin {
  max-width: 420px;
  padding: 0;
}

.form-signin > form {
  width: 100%;
  padding: 2rem 1.5rem 1.4rem;
  border-radius: 22px;
  border: 1px solid var(--auth-border);
  background: var(--auth-card);
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 48px rgba(2, 6, 23, 0.45);
}

.form-signin h1 {
  letter-spacing: 0.01em;
}

.auth-subtitle {
  margin: 0 0 1.2rem;
  color: var(--auth-muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.form-floating > .form-control {
  min-height: 58px;
  height: 58px;
  background-color: var(--auth-input);
  border: 1px solid var(--auth-input-border);
  color: var(--auth-text);
}

.form-floating > .form-control:focus {
  border-color: var(--auth-primary);
  box-shadow: 0 0 0 0.22rem var(--auth-focus);
}

.form-floating > .form-control,
.form-floating > .form-control:focus {
  border-radius: 12px;
}

.form-floating > label {
  color: var(--auth-muted);
}

.remembered-account {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--auth-input-border);
  background: rgba(15, 23, 42, 0.5);
}

.remembered-avatar {
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-weight: 700;
  color: #dbeafe;
  background: linear-gradient(140deg, #0ea5e9 0%, #2563eb 100%);
}

.remembered-content {
  min-width: 0;
  flex: 1;
}

.remembered-label {
  font-size: 0.73rem;
  letter-spacing: 0.01em;
  color: var(--auth-muted);
}

.remembered-email {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.remembered-change {
  color: #7dd3fc;
  font-size: 0.86rem;
  text-decoration: none;
}

.remembered-change:hover {
  color: #bae6fd;
  text-decoration: underline;
}

.remember-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0;
}

.remember-switch .form-check-input {
  margin: 0 !important;
  margin-left: 0 !important;
  margin-top: 0 !important;
  float: none;
  flex: 0 0 auto;
  align-self: center;
}

.remember-switch .form-check-label {
  margin: 0;
  padding: 0;
  color: var(--auth-muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.twofa-cell {
  width: 100%;
  min-height: 56px;
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: 12px;
  background-color: var(--auth-input);
  border: 1px solid var(--auth-input-border);
  color: var(--auth-text);
}

.twofa-cell:focus {
  border-color: var(--auth-primary);
  box-shadow: 0 0 0 0.22rem var(--auth-focus);
}

.auth-submit {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: linear-gradient(92deg, var(--auth-primary) 0%, var(--auth-primary-2) 100%);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.auth-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.38);
}

.auth-submit .btn-loading {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.auth-submit.is-loading .btn-label {
  display: none;
}

.auth-submit.is-loading .btn-loading {
  display: inline-flex;
}

.auth-submit.auth-submit-icon-only.is-loading {
  width: 3rem;
  min-width: 3rem;
  min-height: 3rem;
  padding: 0 !important;
  border-radius: 999px;
  margin-left: auto;
  margin-right: auto;
}

.auth-submit.auth-submit-icon-only.is-loading .btn-loading {
  gap: 0;
}

.twofa-cancel {
  display: block;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  min-width: 6.5rem;
}

.csrf-refresh-btn {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.auth-submit:disabled {
  opacity: 0.88;
}

.btn-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.34);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}

.auth-tip,
.auth-copyright {
  color: var(--auth-muted) !important;
}

.auth-toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1080;
  width: min(92vw, 360px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  pointer-events: none;
}

.auth-toast-stack .toast {
  width: 100%;
  pointer-events: auto;
}

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

.twofa-shake {
  animation: twofa-shake 0.36s ease;
}

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

@media (max-width: 480px) {
  body.auth-page {
    padding: 0.85rem;
  }

  .form-signin > form {
    padding: 1.5rem 1rem 1.1rem;
    border-radius: 18px;
  }

  .auth-subtitle {
    font-size: 0.9rem;
  }
}
