:root {
  --bg: oklch(97.8% 0.004 250);
  --surface: oklch(100% 0 0);
  --fg: oklch(20% 0.018 252);
  --muted: oklch(49% 0.018 252);
  --border: oklch(89.5% 0.009 252);
  --accent: oklch(54% 0.19 256);
  --accent-soft: oklch(95% 0.025 256);
  --success: oklch(55% 0.15 150);
  --success-soft: oklch(96% 0.028 150);
  --warn: oklch(68% 0.15 72);
  --warn-soft: oklch(97% 0.035 78);
  --danger: oklch(56% 0.19 28);
  --danger-soft: oklch(96% 0.035 28);
  --nav: oklch(17% 0.015 252);
  --nav-muted: oklch(72% 0.016 252);
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; color-scheme: light; }
body { margin: 0; color: var(--fg); background: var(--bg); font: 14px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(330px, .82fr) minmax(560px, 1.18fr); }
.auth-context { position: relative; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; padding: 38px clamp(32px, 4vw, 68px); color: white; background: var(--nav); }
.auth-context::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(color-mix(in oklch, white 4%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in oklch, white 4%, transparent) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, black, transparent 82%); }
.auth-context::after { content: ""; position: absolute; width: 420px; height: 420px; right: -210px; top: -210px; border: 1px solid color-mix(in oklch, var(--accent) 50%, transparent); border-radius: 50%; box-shadow: 0 0 0 70px color-mix(in oklch, var(--accent) 5%, transparent), 0 0 0 140px color-mix(in oklch, var(--accent) 3%, transparent); }
.auth-context > * { position: relative; z-index: 1; }
.auth-brand { width: max-content; display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.auth-brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid color-mix(in oklch, white 22%, transparent); border-radius: 7px; background: color-mix(in oklch, var(--accent) 78%, var(--nav)); font: 650 11px/1 var(--font-mono); }
.auth-brand strong { display: block; font-size: 14px; font-weight: 640; }
.auth-brand span span { display: block; margin-top: 2px; color: var(--nav-muted); font: 9px/1.25 var(--font-mono); letter-spacing: .09em; text-transform: uppercase; }
.context-copy { max-width: 510px; margin: auto 0; padding: 84px 0 54px; }
.context-eyebrow { display: flex; align-items: center; gap: 8px; color: color-mix(in oklch, white 72%, var(--accent)); font: 10px/1 var(--font-mono); letter-spacing: .11em; text-transform: uppercase; }
.context-eyebrow::before { content: ""; width: 22px; border-top: 1px solid currentColor; }
.context-copy h2 { max-width: 470px; margin: 20px 0 0; font: 620 clamp(32px, 3.2vw, 52px)/1.05 var(--font-display); letter-spacing: -.035em; text-wrap: balance; }
.context-copy > p { max-width: 480px; margin: 20px 0 0; color: var(--nav-muted); font-size: 15px; line-height: 1.65; }
.trust-path { display: grid; gap: 0; margin-top: 42px; }
.trust-step { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 13px; min-height: 56px; color: var(--nav-muted); }
.trust-step:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; border-left: 1px solid color-mix(in oklch, white 14%, transparent); }
.trust-number { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid color-mix(in oklch, white 16%, transparent); border-radius: 50%; color: white; background: var(--nav); font: 9px/1 var(--font-mono); }
.trust-step strong { display: block; color: white; font-size: 12px; font-weight: 590; }
.trust-step span:last-child span { display: block; margin-top: 3px; font-size: 11px; }
.context-foot { display: flex; align-items: center; gap: 8px; color: var(--nav-muted); font-size: 11px; }
.context-foot-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px color-mix(in oklch, var(--success) 16%, transparent); }

.auth-stage { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.auth-topbar { min-height: 72px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 0 clamp(24px, 4vw, 56px); border-bottom: 1px solid var(--border); background: color-mix(in oklch, var(--surface) 92%, transparent); }
.invite-only { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font: 10px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.invite-only svg { width: 15px; height: 15px; fill: none; stroke: var(--success); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.auth-main { flex: 1; display: grid; place-items: center; padding: 48px clamp(24px, 5vw, 72px); }
.auth-frame { width: min(100%, 500px); }
.auth-back { min-height: 38px; display: inline-flex; align-items: center; gap: 7px; margin-bottom: 18px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 560; }
.auth-back:hover { color: var(--accent); }
.auth-card { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 18px 50px color-mix(in oklch, var(--fg) 6%, transparent); overflow: hidden; }
.auth-card-head { padding: 28px 30px 22px; border-bottom: 1px solid var(--border); }
.auth-kicker { color: var(--accent); font: 10px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; }
.auth-card h1 { margin: 12px 0 0; font: 630 clamp(26px, 2.2vw, 34px)/1.12 var(--font-display); letter-spacing: -.028em; text-wrap: balance; }
.auth-intro { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-card-body { padding: 26px 30px 30px; }
.identity-summary { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-bottom: 24px; padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); }
.identity-avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; color: var(--accent); background: var(--accent-soft); font: 650 11px/1 var(--font-mono); }
.identity-summary strong { display: block; font-size: 12px; }
.identity-summary small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.role-chip { padding: 4px 7px; border-radius: 999px; color: var(--muted); background: var(--surface); font: 9px/1 var(--font-mono); text-transform: uppercase; letter-spacing: .05em; }
.field + .field { margin-top: 17px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.field label { display: block; color: var(--fg); font-size: 12px; font-weight: 520; }
.field-link { min-height: 28px; display: inline-flex; align-items: center; color: var(--accent); font-size: 11px; font-weight: 570; text-decoration: none; }
.field input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--fg); }
.field input:hover { border-color: color-mix(in oklch, var(--fg) 24%, var(--border)); }
.field input:focus { border-color: var(--accent); outline: 2px solid color-mix(in oklch, var(--accent) 18%, transparent); outline-offset: 0; }
.field input[readonly] { color: var(--muted); background: var(--bg); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.secret-control { position: relative; }
.secret-control input { padding-right: 64px; }
.secret-toggle { position: absolute; top: 5px; right: 5px; min-width: 50px; min-height: 34px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; font-weight: 570; }
.secret-toggle:hover { color: var(--fg); background: var(--bg); }
.field-help { margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.field-error { margin-top: 6px; color: var(--danger); font-size: 11px; }
.password-strength { margin-top: 10px; }
.strength-track { height: 4px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.strength-track span { border-radius: 999px; background: var(--border); transition: background .16s ease; }
.password-strength[data-level="1"] .strength-track span:nth-child(-n+1) { background: var(--danger); }
.password-strength[data-level="2"] .strength-track span:nth-child(-n+2) { background: var(--warn); }
.password-strength[data-level="3"] .strength-track span:nth-child(-n+3) { background: var(--accent); }
.password-strength[data-level="4"] .strength-track span { background: var(--success); }
.strength-label { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; color: var(--muted); font-size: 10px; }
.password-rules { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 14px 0 0; padding: 0; list-style: none; }
.password-rules li { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.password-rules li::before { content: ""; width: 6px; height: 6px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 50%; }
.password-rules li.pass { color: color-mix(in oklch, var(--success) 75%, var(--fg)); }
.password-rules li.pass::before { border-color: var(--success); background: var(--success); }
.auth-error-module, .auth-status-module { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; margin: 20px 0 0; padding: 13px; border: 1px solid color-mix(in oklch, var(--danger) 30%, var(--border)); border-radius: 7px; background: var(--danger-soft); }
.auth-status-module { border-color: color-mix(in oklch, var(--success) 30%, var(--border)); background: var(--success-soft); }
.auth-error-module > span, .auth-status-module > span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--danger); background: color-mix(in oklch, var(--danger) 10%, white); font-weight: 700; }
.auth-status-module > span { color: var(--success); background: color-mix(in oklch, var(--success) 10%, white); }
.auth-error-module strong, .auth-status-module strong { display: block; font-size: 12px; }
.auth-error-module p, .auth-status-module p { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.auth-submit { width: 100%; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; margin-top: 22px; border: 1px solid var(--accent); border-radius: 6px; color: white; background: var(--accent); cursor: pointer; font-weight: 600; text-decoration: none; }
.auth-submit:hover { background: color-mix(in oklch, var(--accent) 88%, black); }
.auth-submit:disabled { opacity: .58; cursor: wait; }
.auth-secondary { width: 100%; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; margin-top: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--fg); text-decoration: none; font-weight: 580; }
.auth-secondary:hover { background: var(--bg); }
.auth-fineprint { margin: 18px 0 0; color: var(--muted); text-align: center; font-size: 10px; line-height: 1.5; }
.auth-fineprint a { color: var(--accent); font-weight: 570; }
.auth-support { margin: 18px 0 0; color: var(--muted); text-align: center; font-size: 11px; }
.auth-support a { color: var(--fg); font-weight: 590; text-decoration: none; }
.auth-support a:hover { color: var(--accent); }
.state-panel { padding: 32px 30px; text-align: center; }
.state-icon { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto; border: 1px solid color-mix(in oklch, var(--warn) 28%, var(--border)); border-radius: 50%; color: var(--warn); background: var(--warn-soft); font: 650 18px/1 var(--font-mono); }
.state-panel.success .state-icon { color: var(--success); border-color: color-mix(in oklch, var(--success) 28%, var(--border)); background: var(--success-soft); }
.state-panel h1 { margin-top: 18px; }
.state-panel p { margin: 10px auto 0; max-width: 390px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.state-meta { display: grid; gap: 0; margin-top: 22px; border: 1px solid var(--border); border-radius: 7px; text-align: left; overflow: hidden; }
.state-meta-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 18px; padding: 11px 13px; }
.state-meta-row + .state-meta-row { border-top: 1px solid var(--border); }
.state-meta-row span { color: var(--muted); font-size: 10px; }
.state-meta-row strong { font: 570 10px/1.45 var(--font-mono); overflow-wrap: anywhere; }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-context { min-height: auto; padding: 24px; }
  .context-copy { margin: 46px 0 0; padding: 0; }
  .context-copy h2 { max-width: 620px; font-size: clamp(28px, 7vw, 42px); }
  .context-copy > p { max-width: 640px; }
  .trust-path { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 30px; }
  .trust-step { grid-template-columns: 28px minmax(0, 1fr); min-height: auto; }
  .trust-step::after { display: none; }
  .context-foot { margin-top: 28px; }
  .auth-stage { min-height: auto; }
  .auth-main { min-height: 720px; }
}

@media (max-width: 680px) {
  .auth-context { padding: 20px 18px; }
  .context-copy { margin-top: 36px; }
  .context-copy > p { font-size: 13px; }
  .trust-path { grid-template-columns: 1fr 1fr; }
  .trust-step span:last-child span { display: none; }
  .auth-topbar { min-height: 60px; justify-content: flex-start; padding: 0 18px; }
  .auth-main { min-height: 0; place-items: start center; padding: 28px 14px 54px; }
  .auth-card-head, .auth-card-body, .state-panel { padding-right: 20px; padding-left: 20px; }
  .identity-summary { grid-template-columns: 36px minmax(0, 1fr); }
  .role-chip { grid-column: 2; width: max-content; }
  .password-rules { grid-template-columns: 1fr; }
  .state-meta-row { grid-template-columns: 1fr; gap: 4px; }
  .auth-submit, .auth-secondary, .field input { min-height: 44px; }
}

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