:root {
  color-scheme: dark;
  --auth-bg: #080c12;
  --auth-panel: #0e141d;
  --auth-surface: #121a25;
  --auth-surface-strong: #172130;
  --auth-border: #263244;
  --auth-border-soft: rgba(148, 163, 184, 0.14);
  --auth-text: #edf3fb;
  --auth-muted: #93a1b4;
  --auth-faint: #657287;
  --auth-primary: #4f7cff;
  --auth-primary-strong: #3163f5;
  --auth-teal: #29c7a5;
  --auth-amber: #f5a524;
  --auth-danger: #ff6b68;
  --auth-success: #33d29f;
  --auth-input: #0a1018;
  --auth-shadow: 0 32px 90px rgba(0, 0, 0, 0.42);
  --auth-grid: rgba(148, 163, 184, 0.045);
  --auth-focus: 0 0 0 4px rgba(79, 124, 255, 0.2);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

:root[data-theme="light"] {
  color-scheme: light;
  --auth-bg: #f2f5fa;
  --auth-panel: #f8faff;
  --auth-surface: #ffffff;
  --auth-surface-strong: #f5f8fd;
  --auth-border: #d4ddea;
  --auth-border-soft: rgba(71, 85, 105, 0.13);
  --auth-text: #172236;
  --auth-muted: #617087;
  --auth-faint: #8490a2;
  --auth-primary: #3567ed;
  --auth-primary-strong: #2958d7;
  --auth-teal: #109777;
  --auth-amber: #b76d00;
  --auth-danger: #c9363d;
  --auth-success: #0c8564;
  --auth-input: #ffffff;
  --auth-shadow: 0 30px 80px rgba(44, 61, 89, 0.16);
  --auth-grid: rgba(71, 85, 105, 0.055);
  --auth-focus: 0 0 0 4px rgba(53, 103, 237, 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--auth-bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--auth-text);
  background:
    radial-gradient(circle at 8% -8%, rgba(79, 124, 255, 0.2), transparent 34rem),
    radial-gradient(circle at 98% 100%, rgba(41, 199, 165, 0.1), transparent 30rem),
    var(--auth-bg);
  font-size: 14px;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

a {
  color: var(--auth-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 9px 13px;
  border-radius: 8px;
  color: #fff;
  background: var(--auth-primary-strong);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.auth-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(390px, 0.9fr) minmax(520px, 1.1fr);
  isolation: isolate;
}

.auth-shell::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(var(--auth-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--auth-grid) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(90deg, #000, transparent 65%);
}

.auth-context {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
  padding: clamp(30px, 5vw, 72px);
  border-right: 1px solid var(--auth-border-soft);
  background: linear-gradient(145deg, rgba(79, 124, 255, 0.075), transparent 50%);
}

.brand {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--auth-text);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(79, 124, 255, 0.62);
  border-radius: 11px;
  background:
    linear-gradient(145deg, rgba(79, 124, 255, 0.3), rgba(41, 199, 165, 0.08)),
    var(--auth-surface);
  box-shadow: inset 0 0 22px rgba(79, 124, 255, 0.16);
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  left: 8px;
  width: 21px;
  height: 2px;
  border-radius: 999px;
  content: "";
  transform-origin: left center;
}

.brand-mark::before {
  top: 23px;
  background: var(--auth-primary);
  transform: rotate(-25deg);
}

.brand-mark::after {
  top: 14px;
  background: var(--auth-teal);
  transform: rotate(22deg);
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 760;
  letter-spacing: 0.025em;
}

.brand-copy small {
  color: var(--auth-muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.context-copy {
  width: min(520px, 100%);
  margin: auto 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  color: var(--auth-primary);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  content: "";
  background: var(--auth-teal);
  box-shadow: 0 0 0 5px rgba(41, 199, 165, 0.1);
}

.context-copy h1 {
  max-width: 12em;
  margin: 0;
  font-size: clamp(34px, 4.4vw, 62px);
  font-weight: 760;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.context-copy > p {
  max-width: 39em;
  margin: 24px 0 0;
  color: var(--auth-muted);
  font-size: 15px;
  line-height: 1.8;
}

.context-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 34px;
}

.context-point {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--auth-border-soft);
  border-radius: 11px;
  background: color-mix(in srgb, var(--auth-surface) 76%, transparent);
}

.context-point strong,
.context-point span {
  display: block;
}

.context-point strong {
  margin-bottom: 4px;
  font-size: 12px;
}

.context-point span {
  color: var(--auth-muted);
  font-size: 10px;
  line-height: 1.5;
}

.context-footer {
  color: var(--auth-faint);
  font-size: 11px;
}

.auth-workspace {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 76px clamp(24px, 7vw, 104px);
}

.theme-button {
  position: absolute;
  top: 24px;
  right: 28px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--auth-border);
  border-radius: 10px;
  color: var(--auth-muted);
  background: var(--auth-surface);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.theme-button::before {
  content: "☀";
  font-size: 17px;
  line-height: 1;
}

.theme-button[data-theme-state="light"]::before {
  content: "☾";
}

.theme-button:hover {
  color: var(--auth-text);
  border-color: var(--auth-primary);
}

.auth-card {
  width: min(450px, 100%);
  padding: clamp(26px, 4vw, 42px);
  border: 1px solid var(--auth-border);
  border-radius: 18px;
  background: color-mix(in srgb, var(--auth-surface) 96%, transparent);
  box-shadow: var(--auth-shadow);
  backdrop-filter: blur(20px);
}

.auth-card.wide {
  width: min(520px, 100%);
}

.card-header {
  margin-bottom: 28px;
}

.card-header h2 {
  margin: 0;
  font-size: clamp(25px, 3vw, 31px);
  font-weight: 760;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.card-header p {
  margin: 10px 0 0;
  color: var(--auth-muted);
  font-size: 13px;
  line-height: 1.7;
}

.environment-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px;
  padding: 9px 11px;
  border: 1px solid rgba(245, 165, 36, 0.22);
  border-radius: 9px;
  color: var(--auth-amber);
  background: rgba(245, 165, 36, 0.065);
  font-size: 11px;
  font-weight: 650;
}

.environment-line::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  content: "";
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(245, 165, 36, 0.1);
}

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

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

.field-label,
.field-label-row label,
.field > label {
  color: var(--auth-text);
  font-size: 12px;
  font-weight: 680;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.field-label-row a,
.field-label-row button {
  color: var(--auth-primary);
  font-size: 11px;
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--auth-border);
  border-radius: 9px;
  outline: none;
  color: var(--auth-text);
  background: var(--auth-input);
  caret-color: var(--auth-primary);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.field input::placeholder {
  color: var(--auth-faint);
}

.field input:hover {
  border-color: color-mix(in srgb, var(--auth-primary) 42%, var(--auth-border));
}

.field input:focus {
  border-color: var(--auth-primary);
  box-shadow: var(--auth-focus);
}

.field input[aria-invalid="true"] {
  border-color: var(--auth-danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 104, 0.12);
}

.field input:disabled,
.field input[readonly] {
  color: var(--auth-muted);
  background: var(--auth-surface-strong);
  cursor: not-allowed;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 62px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  padding: 6px 7px;
  border-radius: 6px;
  color: var(--auth-muted);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover {
  color: var(--auth-text);
  background: var(--auth-border-soft);
}

.field-help,
.field-error {
  min-height: 1em;
  margin: 0;
  font-size: 10px;
  line-height: 1.45;
}

.field-help {
  color: var(--auth-faint);
}

.field-error {
  color: var(--auth-danger);
}

.password-strength {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.password-strength i {
  height: 3px;
  border-radius: 999px;
  background: var(--auth-border);
}

.password-strength span {
  min-width: 28px;
  margin-left: 4px;
  color: var(--auth-faint);
  font-size: 9px;
  text-align: right;
}

.password-strength[data-score="1"] i:nth-child(-n+1) {
  background: var(--auth-danger);
}

.password-strength[data-score="2"] i:nth-child(-n+2) {
  background: var(--auth-amber);
}

.password-strength[data-score="3"] i:nth-child(-n+3) {
  background: var(--auth-primary);
}

.password-strength[data-score="4"] i:nth-child(-n+4) {
  background: var(--auth-success);
}

.checkbox-field {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: start;
  gap: 10px;
  color: var(--auth-muted);
  font-size: 11px;
  line-height: 1.65;
  cursor: pointer;
}

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

.checkbox-field:has(input[aria-invalid="true"]) {
  color: var(--auth-danger);
}

.primary-button,
.secondary-button,
.link-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.primary-button {
  width: 100%;
  padding: 0 18px;
  color: #fff;
  background: var(--auth-primary-strong);
  box-shadow: 0 12px 26px rgba(49, 99, 245, 0.25);
}

.primary-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--auth-primary-strong) 86%, #fff);
  transform: translateY(-1px);
}

.secondary-button {
  padding: 0 16px;
  border: 1px solid var(--auth-border);
  color: var(--auth-text);
  background: var(--auth-surface-strong);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--auth-primary);
  text-decoration: none;
}

.link-button {
  min-height: 32px;
  padding: 0;
  color: var(--auth-primary);
  background: transparent;
  font-size: 11px;
}

.link-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  transform: none !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--auth-primary);
  outline-offset: 2px;
}

.form-message {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--auth-border);
  border-radius: 8px;
  color: var(--auth-muted);
  background: var(--auth-surface-strong);
  font-size: 11px;
  line-height: 1.55;
}

.form-message[data-type="error"] {
  border-color: rgba(255, 107, 104, 0.28);
  color: var(--auth-danger);
  background: rgba(255, 107, 104, 0.07);
}

.form-message[data-type="success"] {
  border-color: rgba(51, 210, 159, 0.26);
  color: var(--auth-success);
  background: rgba(51, 210, 159, 0.07);
}

.form-message[data-type="info"] {
  border-color: rgba(79, 124, 255, 0.28);
  color: var(--auth-primary);
  background: rgba(79, 124, 255, 0.07);
}

.card-footer {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--auth-border-soft);
  color: var(--auth-muted);
  font-size: 11px;
  text-align: center;
}

.security-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 20px 0 0;
  color: var(--auth-faint);
  font-size: 10px;
  line-height: 1.55;
}

.security-note::before {
  width: 9px;
  height: 11px;
  flex: 0 0 auto;
  margin-top: 2px;
  border: 1px solid var(--auth-teal);
  border-radius: 2px 2px 4px 4px;
  content: "";
  box-shadow: inset 0 4px transparent;
}

.invite-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  padding: 14px;
  border: 1px solid rgba(79, 124, 255, 0.22);
  border-radius: 10px;
  background: rgba(79, 124, 255, 0.055);
}

.invite-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.invite-summary-row span:first-child {
  color: var(--auth-faint);
  font-size: 10px;
}

.invite-summary-row span:last-child {
  overflow: hidden;
  color: var(--auth-text);
  font-size: 11px;
  font-weight: 650;
  text-align: right;
  text-overflow: ellipsis;
}

.loading-block {
  display: grid;
  place-items: center;
  gap: 14px;
  min-height: 170px;
  color: var(--auth-muted);
  font-size: 12px;
}

.loading-block::before {
  width: 28px;
  height: 28px;
  border: 2px solid var(--auth-border);
  border-top-color: var(--auth-primary);
  border-radius: 50%;
  content: "";
  animation: auth-spin 700ms linear infinite;
}

.success-state {
  padding: 12px 0 0;
  text-align: center;
}

.success-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border: 1px solid rgba(51, 210, 159, 0.35);
  border-radius: 50%;
  color: var(--auth-success);
  background: rgba(51, 210, 159, 0.08);
  font-size: 22px;
  font-weight: 800;
}

.success-state h3 {
  margin: 0;
  font-size: 21px;
}

.success-state p {
  margin: 10px auto 22px;
  color: var(--auth-muted);
  font-size: 12px;
  line-height: 1.7;
}

.success-state .secondary-button {
  width: 100%;
}

.otp-input {
  height: 62px;
  padding: 0 16px !important;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace !important;
  font-size: 29px !important;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-align: center;
}

.otp-input.recovery-input {
  font-size: 17px !important;
  letter-spacing: 0.08em;
}

.mfa-device {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 22px;
  padding: 12px;
  border: 1px solid var(--auth-border-soft);
  border-radius: 10px;
  background: var(--auth-surface-strong);
}

.mfa-device-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(41, 199, 165, 0.26);
  border-radius: 8px;
  color: var(--auth-teal);
  background: rgba(41, 199, 165, 0.07);
  font-weight: 800;
}

.mfa-device div {
  display: grid;
  gap: 1px;
}

.mfa-device strong {
  font-size: 11px;
}

.mfa-device span {
  color: var(--auth-muted);
  font-size: 10px;
}

.mfa-alternate {
  margin-top: -5px;
  text-align: center;
}

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

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

  .auth-context {
    min-height: auto;
    padding: 26px clamp(22px, 6vw, 54px) 34px;
    border-right: 0;
    border-bottom: 1px solid var(--auth-border-soft);
  }

  .context-copy {
    margin: 32px 0 0;
  }

  .context-copy h1 {
    max-width: 18em;
    font-size: clamp(29px, 6vw, 46px);
  }

  .context-copy > p {
    margin-top: 15px;
  }

  .context-points,
  .context-footer {
    display: none;
  }

  .auth-workspace {
    min-height: auto;
    padding: 62px 20px 70px;
  }

  .theme-button {
    top: 14px;
    right: 18px;
  }
}

@media (max-width: 560px) {
  .auth-context {
    padding: 20px 18px 26px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-copy strong {
    font-size: 13px;
  }

  .context-copy {
    margin-top: 26px;
  }

  .context-copy h1 {
    font-size: 29px;
  }

  .context-copy > p {
    font-size: 13px;
    line-height: 1.65;
  }

  .auth-workspace {
    align-items: flex-start;
    padding: 58px 12px 42px;
  }

  .auth-card {
    padding: 24px 20px;
    border-radius: 14px;
  }

  .card-header {
    margin-bottom: 22px;
  }

  .card-header h2 {
    font-size: 24px;
  }

  .invite-summary-row {
    display: grid;
    gap: 2px;
  }

  .invite-summary-row span:last-child {
    text-align: left;
  }
}

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

@media print {
  .auth-context,
  .theme-button {
    display: none;
  }

  .auth-shell {
    display: block;
  }

  .auth-workspace {
    padding: 0;
  }

  .auth-card {
    box-shadow: none;
  }
}
