* {
  box-sizing: border-box;
}

:root {
  --auth-page-bg: #eef2f6;
  --auth-page-ink: #0f172a;
  --auth-card-bg: #ffffff;
  --auth-card-border: #d8e0ea;
  --auth-muted: #64748b;
  --auth-soft: #f4f7fa;
  --auth-soft-strong: #e8eef5;
  --auth-brand-panel: #101820;
  --auth-brand-panel-ink: #ffffff;
  --auth-brand-panel-muted: rgba(255, 255, 255, 0.72);
  --auth-accent: #41b76c;
  --auth-accent-strong: #27834a;
  --auth-accent-soft: #e7f6ec;
  --auth-danger: #be123c;
  --auth-danger-bg: #fff1f2;
  --auth-danger-border: #fecdd3;
  --auth-focus: rgba(65, 183, 108, 0.28);
  --auth-shadow: 0 28px 72px rgba(4, 12, 22, 0.28);
  --auth-background-image: url("/assets/auth/midsure-auth-road-bg.webp");
  --auth-radius: 8px;
  --auth-radius-lg: 12px;
  --auth-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-auth-theme="midsure"] {
  --auth-page-bg: #edf2f6;
  --auth-page-ink: #0d1724;
  --auth-card-bg: #ffffff;
  --auth-card-border: #d8e1ea;
  --auth-muted: #66768a;
  --auth-soft: #f5f8fb;
  --auth-soft-strong: #e7edf4;
  --auth-brand-panel: #0e1a28;
  --auth-brand-panel-ink: #ffffff;
  --auth-brand-panel-muted: rgba(255, 255, 255, 0.74);
  --auth-accent: #45b96f;
  --auth-accent-strong: #2f8f55;
  --auth-accent-soft: #e9f7ee;
  --auth-focus: rgba(69, 185, 111, 0.28);
}

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

body {
  min-height: 100vh;
  background: #0d1724;
  color: var(--auth-page-ink);
  font-family: var(--auth-font);
  font-size: 15px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

.auth-intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 22px),
    linear-gradient(135deg, #0b1724 0%, #0e1a28 48%, #122236 100%);
  animation: auth-intro-out 3000ms linear forwards;
}

.auth-intro::before,
.auth-intro::after {
  content: "";
  position: absolute;
  inset: -18%;
  pointer-events: none;
}

.auth-intro::before {
  background:
    linear-gradient(118deg, transparent 0 28%, rgba(69, 185, 111, 0.16) 32%, transparent 42%),
    linear-gradient(152deg, transparent 0 52%, rgba(255, 255, 255, 0.08) 56%, transparent 64%);
  opacity: 0.72;
  transform: rotate(-4deg);
}

.auth-intro::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(14, 26, 40, 0.2));
  opacity: 0.58;
}

.auth-intro-mark {
  --auth-intro-check-size: min(67px, 19vw);
  --auth-intro-check-optical-offset: 8px;
  --auth-intro-blip-scale: 0.18;
  --auth-intro-logo-width: min(320px, 76vw);
  --auth-intro-logo-bounce-scale: 1.08;
  position: relative;
  z-index: 1;
  width: min(360px, 82vw);
  min-height: 132px;
  display: grid;
  place-items: center;
}

.auth-intro-check,
.auth-intro-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  height: auto;
  opacity: 0;
  transform-origin: center;
  will-change: opacity, filter, transform, clip-path;
}

.auth-intro-check {
  width: var(--auth-intro-check-size);
  filter: blur(5px);
  transform: translate(-50%, -50%) translateX(var(--auth-intro-check-optical-offset)) scale(0.78) rotate(-6deg);
  animation: auth-intro-check 3000ms linear forwards;
}

.auth-intro-logo {
  width: var(--auth-intro-logo-width);
  clip-path: inset(0 50% 0 50%);
  filter: blur(7px);
  transform: translate(-50%, -50%) scale(0.18);
  transform-origin: center;
  animation: auth-intro-logo 3000ms linear forwards;
}

html.auth-intro-seen .auth-intro {
  display: none;
}

.auth-shell {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: var(--auth-page-bg);
}

.auth-shell::before,
.auth-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.auth-shell::before {
  z-index: -2;
  background-image: var(--auth-background-image);
  background-position: center;
  background-size: cover;
  opacity: 1;
  transform: scale(1.01);
}

.auth-shell::after {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(9, 18, 30, 0.72), rgba(9, 18, 30, 0.28) 42%, rgba(255, 255, 255, 0.2)),
    linear-gradient(180deg, rgba(237, 242, 246, 0.25), rgba(9, 18, 30, 0.38));
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(100%, 940px);
  min-height: 560px;
  display: grid;
  grid-template-columns: 0.94fr 1.06fr;
  overflow: hidden;
  border: 0;
  border-radius: var(--auth-radius-lg);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--auth-shadow);
  animation: auth-card-in 520ms cubic-bezier(.22, 1, .36, 1) 2680ms both;
  backdrop-filter: blur(14px);
}

html.auth-shell-ready .auth-card {
  animation-delay: 0ms;
}

.auth-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 28px;
  padding: 34px;
  overflow: hidden;
  background: rgb(9 22 34 / 95%);
  color: var(--auth-brand-panel-ink);
}

.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 18px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 46%);
  pointer-events: none;
}

.auth-visual > * {
  position: relative;
  z-index: 1;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  animation: auth-content-in 460ms cubic-bezier(.22, 1, .36, 1) 2760ms both;
}

.auth-logo {
  display: block;
  width: min(230px, 56vw);
  height: auto;
}

.auth-slogan {
  max-width: 280px;
  margin: 0;
  color: var(--auth-brand-panel-muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  text-align: center;
  animation: auth-content-in 460ms cubic-bezier(.22, 1, .36, 1) 2840ms both;
}

.auth-visual-copy {
  display: grid;
  gap: 14px;
  max-width: 440px;
  animation: auth-content-in 460ms cubic-bezier(.22, 1, .36, 1) 2840ms both;
}

.auth-kicker {
  margin: 0;
  color: var(--auth-brand-panel-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.auth-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0;
}

.auth-copy {
  margin: 0;
  color: var(--auth-brand-panel-muted);
  font-size: 15px;
  line-height: 1.65;
}

.auth-mini-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  animation: auth-content-in 460ms cubic-bezier(.22, 1, .36, 1) 2920ms both;
}

.auth-mini-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  line-height: 1.35;
}

.auth-mini-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--auth-radius);
  background: rgba(255, 255, 255, 0.08);
  color: #79d79a;
}

.auth-panel {
  min-width: 0;
  display: grid;
  align-content: center;
  padding: 44px 56px;
  background: var(--auth-card-bg);
}

.auth-panel-inner {
  width: min(100%, 430px);
  margin: 0 auto;
  animation: auth-content-in 460ms cubic-bezier(.22, 1, .36, 1) 2800ms both;
}

html.auth-shell-ready .auth-brand,
html.auth-shell-ready .auth-slogan,
html.auth-shell-ready .auth-visual-copy,
html.auth-shell-ready .auth-mini-list,
html.auth-shell-ready .auth-panel-inner {
  animation-delay: 0ms;
}

.auth-panel-logo {
  display: none;
  width: 150px;
  height: auto;
  margin: 0 0 26px;
}

.auth-panel-header {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.auth-panel-title {
  margin: 0;
  color: var(--auth-page-ink);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0;
}

.auth-panel-copy {
  margin: 0;
  color: var(--auth-muted);
  font-size: 14px;
  line-height: 1.55;
}

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

.auth-field {
  display: grid;
  gap: 7px;
}

.auth-label {
  color: #344257;
  font-size: 13px;
  font-weight: 600;
}

.auth-input {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--auth-card-border);
  border-radius: var(--auth-radius);
  outline: none;
  background: #ffffff;
  color: var(--auth-page-ink);
  font-size: 15px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.auth-input:hover {
  background: #fbfdff;
}

.auth-input:focus {
  border-color: var(--auth-accent);
  box-shadow: 0 0 0 4px var(--auth-focus);
}

.auth-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--auth-radius);
  padding: 0 16px;
  cursor: pointer;
  color: #ffffff;
  background: var(--auth-brand-panel);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 140ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.auth-button:hover {
  background: #152334;
}

.auth-button:active {
  transform: translateY(1px);
}

.auth-button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.auth-button-secondary {
  color: var(--auth-page-ink);
  border-color: var(--auth-card-border);
  background: #ffffff;
}

.auth-button-secondary:hover {
  color: var(--auth-page-ink);
  background: var(--auth-soft);
}

.auth-actions {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.auth-status {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 9px;
  align-items: start;
  margin: 18px 0 0;
  padding: 12px;
  border: 1px solid var(--auth-card-border);
  border-radius: var(--auth-radius);
  background: var(--auth-soft);
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-status svg {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--auth-accent-strong);
}

.auth-error {
  display: none;
  margin: 0 0 16px;
  padding: 11px 12px;
  border: 1px solid var(--auth-danger-border);
  border-radius: var(--auth-radius);
  background: var(--auth-danger-bg);
  color: var(--auth-danger);
  font-size: 14px;
  line-height: 1.45;
}

.auth-error.is-visible {
  display: block;
}

.auth-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: auth-spin 800ms linear infinite;
}

.auth-footnote {
  margin: 18px 0 0;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-footnote a {
  color: var(--auth-page-ink);
  font-weight: 600;
  text-decoration: none;
}

.auth-footnote a:hover {
  text-decoration: underline;
}

@keyframes auth-card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.992);
  }

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

@keyframes auth-content-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

@keyframes auth-intro-check {
  0% {
    opacity: 0;
    filter: blur(2px);
    transform: translate(-50%, -50%) translateX(var(--auth-intro-check-optical-offset)) scale(0.92) rotate(0deg);
  }

  16.667% {
    opacity: 1;
    filter: blur(0);
    transform: translate(-50%, -50%) translateX(var(--auth-intro-check-optical-offset)) scale(0.96) rotate(0deg);
  }

  58% {
    opacity: 1;
    filter: blur(0);
    transform: translate(-50%, -50%) translateX(var(--auth-intro-check-optical-offset)) scale(1.05) rotate(0deg);
  }

  63% {
    opacity: 1;
    filter: blur(0);
    transform: translate(-50%, -50%) translateX(var(--auth-intro-check-optical-offset)) scale(var(--auth-intro-blip-scale)) rotate(0deg);
  }

  70% {
    opacity: 0;
    filter: blur(2px);
    transform: translate(-50%, -50%) translateX(var(--auth-intro-check-optical-offset)) scale(0.1) rotate(0deg);
  }

  100% {
    opacity: 0;
    filter: blur(4px);
    transform: translate(-50%, -50%) translateX(var(--auth-intro-check-optical-offset)) scale(0.1) rotate(0deg);
  }
}

@keyframes auth-intro-logo {
  0%,
  62% {
    opacity: 0;
    clip-path: inset(0 50% 0 50%);
    filter: blur(4px);
    transform: translate(-50%, -50%) scale(0.18);
  }

  66% {
    opacity: 1;
    clip-path: inset(0 42% 0 42%);
    filter: blur(2px);
    transform: translate(-50%, -50%) scale(0.28);
  }

  70% {
    opacity: 1;
    clip-path: inset(0 8% 0 8%);
    filter: blur(0);
    transform: translate(-50%, -50%) scale(0.88);
  }

  73% {
    opacity: 1;
    clip-path: inset(0 0 0 0);
    filter: blur(0);
    transform: translate(-50%, -50%) scale(var(--auth-intro-logo-bounce-scale));
  }

  78% {
    opacity: 1;
    clip-path: inset(0 0 0 0);
    filter: blur(0);
    transform: translate(-50%, -50%) scale(1);
  }

  84% {
    opacity: 0.9;
    clip-path: inset(0 0 0 0);
    filter: blur(1px);
    transform: translate(-50%, -50%) scale(2.6);
  }

  92% {
    opacity: 0.42;
    clip-path: inset(0 0 0 0);
    filter: blur(4px);
    transform: translate(-50%, -50%) scale(9);
  }

  100% {
    opacity: 0;
    clip-path: inset(0 0 0 0);
    filter: blur(10px);
    transform: translate(-50%, -50%) scale(18);
  }
}

@keyframes auth-intro-out {
  0%,
  78% {
    opacity: 1;
  }

  92% {
    opacity: 0.36;
  }

  100% {
    opacity: 0;
  }
}

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

@media (max-width: 820px) {
  .auth-shell {
    align-items: stretch;
    padding: 14px;
    background: var(--auth-brand-panel);
  }

  .auth-card {
    min-height: calc(100vh - 28px);
    grid-template-columns: 1fr;
    border-radius: 12px;
    box-shadow: 0 18px 46px rgba(4, 12, 22, 0.3);
  }

  .auth-visual {
    min-height: auto;
    gap: 18px;
    padding: 24px 20px 20px;
  }

  .auth-visual-copy {
    gap: 9px;
  }

  .auth-slogan {
    font-size: 14px;
  }

  .auth-title {
    font-size: 22px;
  }

  .auth-copy {
    font-size: 14px;
  }

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

  .auth-panel {
    min-height: 0;
    align-content: start;
    padding: 26px 20px 30px;
    border-radius: 12px 12px 0 0;
  }
}

@media (max-width: 520px) {
  .auth-logo {
    width: min(190px, 62vw);
  }

  .auth-panel-title {
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .auth-brand,
  .auth-slogan,
  .auth-visual-copy,
  .auth-mini-list,
  .auth-panel-inner {
    opacity: 1 !important;
    transform: none !important;
  }

  .auth-intro {
    opacity: 0 !important;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
