:root {
  --auth-accent: #2563eb;
  --auth-accent-strong: #1d4ed8;
  --auth-ink: #172033;
  --auth-muted: #64748b;
  --auth-line: #dbe3ee;
  --auth-panel: #ffffff;
  --auth-field: #ffffff;
  --auth-shell: #edf2f7;
  --auth-intro-scrim: rgba(237, 242, 247, .88);
}

[data-bs-theme="dark"] {
  --auth-accent: #60a5fa;
  --auth-accent-strong: #93c5fd;
  --auth-ink: #f8fafc;
  --auth-muted: #a7b4c8;
  --auth-line: #273244;
  --auth-panel: #111827;
  --auth-field: #0f172a;
  --auth-shell: #07111f;
  --auth-intro-scrim: rgba(7, 17, 31, .9);
}

body {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, .14), transparent 34%),
    linear-gradient(315deg, rgba(16, 185, 129, .12), transparent 30%),
    var(--auth-shell);
  background-size: 130% 130%, 120% 120%, auto;
  animation: authBackgroundDrift 10s ease-in-out infinite alternate;
  color: var(--auth-ink);
  overflow-x: hidden;
}

.auth-intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, .18), transparent 38%),
    linear-gradient(315deg, rgba(16, 185, 129, .14), transparent 34%),
    var(--auth-intro-scrim);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .42s ease, visibility .42s ease;
}

.auth-intro-mark {
  will-change: transform, opacity;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: center;
  transition: opacity .42s ease, filter .42s ease;
}

.auth-intro-logo {
  max-width: min(280px, 70vw);
  max-height: 150px;
  object-fit: contain;
  filter: drop-shadow(0 22px 34px rgba(15, 23, 42, .22));
}

.auth-intro-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 132px;
  height: 132px;
  border-radius: 24px;
  background: #0f766e;
  color: #fff;
  font-size: 4rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
}

.auth-intro-active {
  overflow: hidden;
}

.auth-intro-active .auth-intro-overlay {
  opacity: 1;
  visibility: visible;
}

.auth-intro-active [data-auth-intro-target] {
  animation-play-state: paused;
  opacity: 0 !important;
}

.auth-intro-active .auth-card,
.auth-intro-active .auth-brand-panel {
  animation: none;
  opacity: 1;
  transform: none;
}

.auth-intro-flying .auth-intro-mark {
  animation: none;
  filter: drop-shadow(0 14px 22px rgba(15, 23, 42, .14));
}

.auth-intro-done .auth-intro-overlay {
  opacity: 0;
  visibility: hidden;
}

.auth-intro-done [data-auth-intro-target] {
  transition: opacity .32s ease;
  opacity: 1 !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
}

.auth-brand-panel,
.auth-form-panel {
  min-width: 0;
}

.auth-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2rem;
  padding: clamp(2rem, 6vw, 5rem);
  animation: authFadeInLeft .85s cubic-bezier(.16, 1, .3, 1) both;
}

.auth-brand-top {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.auth-brand-logo {
  max-width: 180px;
  max-height: 70px;
  object-fit: contain;
  animation: authSettle .9s cubic-bezier(.16, 1, .3, 1) .08s both;
}

.auth-brand-mark,
.auth-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0f766e;
  color: #fff;
}

.auth-brand-mark {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  font-size: 2rem;
  flex: 0 0 auto;
  animation:
    authSettle .9s cubic-bezier(.16, 1, .3, 1) .08s both,
    authMarkPulse 4s ease-in-out 1.2s infinite;
}

.auth-eyebrow {
  color: var(--auth-muted);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.auth-brand-panel h1 {
  margin: .2rem 0 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0;
  animation: authFadeUp .7s cubic-bezier(.16, 1, .3, 1) .12s both;
}

.auth-brand-copy {
  max-width: 700px;
  color: var(--auth-muted);
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  line-height: 1.7;
  margin: 0;
  animation: authFadeUp .7s cubic-bezier(.16, 1, .3, 1) .22s both;
}

.auth-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
  max-width: 760px;
}

.auth-metrics div {
  border: 1px solid var(--auth-line);
  background: color-mix(in srgb, var(--auth-panel) 72%, transparent);
  border-radius: 8px;
  padding: .9rem;
  animation: authMetricArrive .72s cubic-bezier(.16, 1, .3, 1) both;
  transition: border-color .2s ease, transform .2s ease, background .2s ease, box-shadow .2s ease;
}

.auth-metrics div:nth-child(1) {
  animation-delay: .12s;
}

.auth-metrics div:nth-child(2) {
  animation-delay: .2s;
}

.auth-metrics div:nth-child(3) {
  animation-delay: .28s;
}

.auth-metrics div:nth-child(4) {
  animation-delay: .36s;
}

.auth-metrics div:hover {
  border-color: color-mix(in srgb, var(--auth-accent) 45%, var(--auth-line));
  box-shadow: 0 16px 34px rgba(15, 23, 42, .12);
  transform: translateY(-5px) scale(1.015);
}

.auth-metrics span {
  display: block;
  color: var(--auth-muted);
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-metrics strong {
  display: block;
  margin-top: .2rem;
  font-size: .98rem;
}

.auth-security-note {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--auth-muted);
  font-size: .9rem;
  max-width: 620px;
  animation: authFadeUp .7s cubic-bezier(.16, 1, .3, 1) .48s both;
}

.auth-security-note i {
  color: #0f766e;
  font-size: 1.2rem;
}

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 3rem);
}

.auth-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 430px;
  border: 1px solid var(--auth-line);
  border-radius: 10px;
  background: var(--auth-panel);
  box-shadow: 0 20px 60px rgba(15, 23, 42, .12);
  padding: clamp(1.35rem, 4vw, 2rem);
  animation: authCardArrive .9s cubic-bezier(.16, 1, .3, 1) .08s both;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 0%, color-mix(in srgb, var(--auth-accent) 16%, transparent) 42%, transparent 70%);
  opacity: .75;
  transform: translateX(-130%);
  animation: authCardSheen 6s ease-in-out 1.2s infinite;
}

.auth-card-wide {
  max-width: 500px;
}

.auth-card-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: 1.5rem;
}

.auth-card-logo {
  max-width: 150px;
  max-height: 52px;
  object-fit: contain;
  animation: authSettle .8s cubic-bezier(.16, 1, .3, 1) .18s both;
}

.auth-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  font-size: 1.45rem;
  flex: 0 0 auto;
  animation:
    authSettle .8s cubic-bezier(.16, 1, .3, 1) .18s both,
    authMarkPulse 4.5s ease-in-out 1.35s infinite;
}

.auth-card h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: 0;
}

.auth-card p {
  color: var(--auth-muted);
}

.auth-card form,
.auth-public-actions,
.auth-footer-link,
.auth-card > .alert,
.auth-card > .text-center,
.auth-secret-key {
  position: relative;
  z-index: 1;
}

.auth-subtitle {
  margin: .2rem 0 0;
  font-size: .92rem;
}

.form-label {
  color: var(--auth-ink);
  font-size: .84rem;
  font-weight: 700;
}

.form-control,
.input-group-text {
  border-color: var(--auth-line);
  background-color: var(--auth-field);
}

.form-control {
  min-height: 44px;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background-color .18s ease;
}

.form-control:focus {
  box-shadow: 0 0 0 .22rem color-mix(in srgb, var(--auth-accent) 20%, transparent);
  transform: translateY(-2px);
}

.input-group-text {
  color: var(--auth-muted);
}

.btn-primary {
  --bs-btn-bg: var(--auth-accent);
  --bs-btn-border-color: var(--auth-accent);
  --bs-btn-hover-bg: var(--auth-accent-strong);
  --bs-btn-hover-border-color: var(--auth-accent-strong);
  position: relative;
  overflow: hidden;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background-color .18s ease;
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, .28) 45%, transparent 68%);
  transform: translateX(-120%);
  transition: transform .45s ease;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  box-shadow: 0 16px 36px color-mix(in srgb, var(--auth-accent) 30%, transparent);
  transform: translateY(-3px);
}

.btn-primary:hover::after,
.btn-primary:focus-visible::after {
  transform: translateX(120%);
}

.btn-primary:active {
  transform: translateY(-1px) scale(.99);
}

.auth-password-toggle {
  border-color: var(--auth-line);
  color: var(--auth-muted);
  min-width: 44px;
  transition: border-color .18s ease, color .18s ease, transform .18s ease;
}

.auth-password-toggle:hover {
  border-color: var(--auth-accent);
  color: var(--auth-accent);
  transform: translateY(-2px);
}

.auth-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.auth-public-actions {
  border-top: 1px solid var(--auth-line);
  margin-top: 1.35rem;
  padding-top: 1.35rem;
}

.auth-public-title {
  color: var(--auth-muted);
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: .65rem;
  text-transform: uppercase;
}

.auth-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .9rem;
  border: 1px solid var(--auth-line);
  border-radius: 8px;
  padding: .85rem .95rem;
  text-decoration: none;
  color: var(--auth-ink);
  background: color-mix(in srgb, var(--auth-panel) 92%, var(--auth-shell));
  transition: border-color .18s ease, color .18s ease, transform .18s ease, background .18s ease;
}

.auth-action-row + .auth-action-row {
  margin-top: .65rem;
}

.auth-action-row:hover {
  border-color: var(--auth-accent);
  color: var(--auth-accent);
  box-shadow: 0 12px 26px rgba(15, 23, 42, .1);
  transform: translateY(-3px);
}

.auth-action-row span {
  color: var(--auth-muted);
  display: block;
  font-size: .78rem;
}

.code-input {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: .32em;
  text-align: center;
  padding: .65rem 1rem;
}

.auth-qr-code {
  width: 180px;
  height: 180px;
  border: 1px solid var(--auth-line);
  border-radius: 8px;
  background: #fff;
  padding: .5rem;
}

.auth-secret-key {
  border: 1px solid var(--auth-line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--auth-panel) 88%, var(--auth-shell));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem;
  letter-spacing: .1em;
  padding: .75rem;
  text-align: center;
  word-break: break-all;
}

.auth-footer-link {
  border-top: 1px solid var(--auth-line);
  margin-top: 1.35rem;
  padding-top: 1.1rem;
  text-align: center;
}

@keyframes authBackgroundDrift {
  from {
    background-position: 0% 0%, 100% 100%, 0 0;
  }

  to {
    background-position: 24% 14%, 74% 84%, 0 0;
  }
}

@keyframes authFadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-34px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes authFadeInRight {
  from {
    opacity: 0;
    transform: translateX(34px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes authFadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes authMetricArrive {
  from {
    opacity: 0;
    transform: translateY(24px) scale(.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes authCardArrive {
  0% {
    opacity: 0;
    transform: translateX(44px) scale(.97);
  }

  70% {
    opacity: 1;
    transform: translateX(-3px) scale(1.006);
  }

  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes authCardSheen {
  0%, 58% {
    transform: translateX(-130%);
  }

  78%, 100% {
    transform: translateX(130%);
  }
}

@keyframes authMarkPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, #0f766e 28%, transparent);
  }

  45% {
    box-shadow: 0 0 0 8px color-mix(in srgb, #0f766e 0%, transparent);
  }
}

@keyframes authSettle {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(.96);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-brand-panel {
    min-height: auto;
    padding-bottom: 0;
  }

  .auth-brand-copy,
  .auth-metrics,
  .auth-security-note {
    display: none;
  }

  .auth-form-panel {
    align-items: flex-start;
  }
}

@media (max-width: 760px) {
  body {
    background: var(--auth-shell);
    animation: none;
  }

  .auth-shell {
    display: block;
    min-height: 100dvh;
  }

  .auth-brand-panel {
    display: none;
  }

  .auth-form-panel {
    min-height: 100dvh;
    padding: 1rem;
  }

  .auth-card {
    margin: 0 auto;
    max-width: 440px;
    border-radius: 12px;
    animation-name: authMobileCardArrive;
  }

  .auth-card-header {
    align-items: center;
    flex-direction: column;
    gap: .65rem;
    margin-bottom: 1.35rem;
    text-align: center;
  }

  .auth-card-header > div {
    width: 100%;
  }

  .auth-card-logo {
    max-height: 64px;
    max-width: 180px;
  }

  .auth-card-icon {
    width: 52px;
    height: 52px;
  }
}

@keyframes authMobileCardArrive {
  0% {
    opacity: 0;
    transform: translateY(28px) scale(.97);
  }

  72% {
    opacity: 1;
    transform: translateY(-2px) scale(1.004);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }

  .form-control:focus,
  .btn-primary:hover,
  .btn-primary:focus-visible,
  .auth-password-toggle:hover,
  .auth-action-row:hover,
  .auth-metrics div:hover {
    transform: none;
  }

  .auth-card::before,
  .btn-primary::after {
    display: none;
  }

  .auth-intro-overlay {
    display: none;
  }
}

@media (max-width: 560px) {
  .auth-form-panel {
    padding: .75rem;
  }

  .auth-card {
    border: 0;
    box-shadow: none;
    min-height: calc(100dvh - 1.5rem);
    padding: 1.35rem 1.15rem;
  }

  .auth-card h2 {
    font-size: 1.45rem;
  }

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

  .form-control {
    min-height: 46px;
  }

  .auth-link-row {
    align-items: center;
    flex-direction: row;
    gap: .75rem;
  }

  .auth-action-row {
    align-items: center;
    padding: .8rem .85rem;
  }

  .auth-action-row span {
    font-size: .75rem;
  }
}

@media (max-width: 380px) {
  .auth-link-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
