:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f5f8f7;
  --text: #13282d;
  --text-muted: #5c7076;
  --border: #dfe5e2;
  --accent: #00756f;
  --accent-dark: #064f4c;
  --accent-soft: #d8f2ec;
  --warning: #a66f00;
  --night: #123232;
  --surface-rgb: 255 255 255;
  --text-rgb: 19 40 45;
  --accent-rgb: 0 117 111;
  --shadow-rgb: 36 44 42;
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --page-width: min(1720px, calc(100vw - 144px));
  --section-x: 40px;
  --shadow-sm: 0 16px 44px rgb(var(--shadow-rgb) / 0.08);
  --shadow-md: 0 24px 64px rgb(var(--shadow-rgb) / 0.12);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

svg {
  display: block;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.page {
  min-height: 100vh;
  background: #f8f9fa;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(440px, 500px);
  gap: 54px;
  width: min(1180px, calc(100% - 48px));
  min-height: 680px;
  margin: 0 auto;
  padding: 48px 0 72px;
  align-items: center;
}

.back-link {
  display: inline-flex;
  margin-bottom: 26px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 800;
}

.back-link:hover {
  color: var(--accent-dark);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.eyebrow::before {
  content: "";
  width: 44px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--accent);
}

h1 {
  max-width: 820px;
  margin-bottom: 16px;
  font-size: 48px;
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: 0;
}

.auth-intro > p {
  max-width: 760px;
  margin-bottom: 32px;
  color: var(--text-muted);
  font-size: 19px;
}

[data-auth-icon] {
  color: var(--accent);
}

[data-auth-icon] svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.auth-card {
  align-self: center;
  padding: 24px;
  border: 1px solid rgb(var(--text-rgb) / 0.12);
  border-radius: var(--radius-sm);
  background: #ffffff;
  box-shadow: 0 10px 28px rgb(var(--shadow-rgb) / 0.06);
}

.continuation-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 13px;
  align-items: start;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgb(var(--accent-rgb) / 0.24);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.continuation-strip.hidden {
  display: none;
}

.continuation-strip strong {
  display: block;
  margin-bottom: 3px;
  color: var(--accent-dark);
  font-size: 15px;
}

.continuation-strip p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.role-system-note {
  margin: 0 0 14px;
  padding: 9px 11px;
  border: 1px solid rgb(var(--accent-rgb) / 0.16);
  border-radius: var(--radius-xs);
  background: rgb(var(--accent-rgb) / 0.055);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 22px;
  padding: 5px;
  border: 1px solid rgb(var(--text-rgb) / 0.1);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.auth-tabs button {
  min-height: 42px;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-weight: 800;
}

.auth-tabs button.active {
  background: white;
  color: var(--accent-dark);
  box-shadow: 0 8px 22px rgb(var(--shadow-rgb) / 0.08);
}

.auth-form {
  display: none;
  gap: 15px;
}

.auth-form.active {
  display: grid;
}

.workspace-picker {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgb(var(--accent-rgb) / 0.22);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.workspace-picker .form-head strong,
.workspace-picker .form-head h2,
.workspace-picker .form-head h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.workspace-options {
  display: grid;
  gap: 8px;
}

.workspace-option {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid rgb(var(--accent-rgb) / 0.2);
  border-radius: var(--radius-xs);
  background: white;
  color: var(--text);
  text-align: left;
}

[dir="rtl"] .workspace-option {
  text-align: right;
}

.workspace-option:hover,
.workspace-option:focus-visible {
  border-color: rgb(var(--accent-rgb) / 0.45);
  box-shadow: 0 0 0 4px rgb(var(--accent-rgb) / 0.08);
}

.workspace-option strong {
  font-size: 14px;
}

.workspace-option span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-role-panel {
  display: none;
  gap: 15px;
}

.auth-role-panel.active {
  display: grid;
}

.form-head h2 {
  margin-bottom: 6px;
  font-size: 30px;
  line-height: 1.05;
}

.form-head p {
  margin-bottom: 4px;
  color: var(--text-muted);
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.auth-form [hidden] {
  display: none !important;
}

.auth-form input,
.auth-form select {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid rgb(var(--text-rgb) / 0.14);
  border-radius: var(--radius-xs);
  background: white;
  color: var(--text);
  outline: 0;
}

.auth-form input:focus,
.auth-form select:focus {
  border-color: rgb(var(--accent-rgb) / 0.35);
  box-shadow: 0 0 0 4px rgb(var(--accent-rgb) / 0.08);
}

.split-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.form-row-end {
  justify-content: flex-end;
}

.check {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
  color: var(--text-muted) !important;
  font-size: 13px !important;
  font-weight: 700 !important;
}

.check.hidden {
  display: none;
}

.role-note {
  margin: 0;
  padding: 12px 13px;
  border: 1px solid rgb(var(--accent-rgb) / 0.18);
  border-radius: var(--radius-xs);
  background: rgb(var(--accent-rgb) / 0.07);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.role-note.strong {
  border-color: rgb(166 111 0 / 0.22);
  background: #fff8e2;
  color: var(--warning);
}

.check input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.form-row a {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.text-link {
  justify-self: start;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: white;
  font-weight: 800;
  box-shadow: 0 14px 28px rgb(var(--accent-rgb) / 0.2);
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.form-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.mfa-setup,
.mfa-recovery-codes {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
}

.mfa-secret,
.mfa-recovery-codes pre {
  display: block;
  padding: 12px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font: 700 0.88rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #13233a;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.auth-runtime-status {
  min-height: 20px;
  margin: 16px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-runtime-status[data-state="error"] {
  color: #9f2d27;
}

.auth-runtime-status[data-state="success"] {
  color: var(--accent-dark);
}

.recovery-form .form-head {
  display: grid;
  gap: 8px;
}

.verification-note {
  display: grid;
  gap: 4px;
  padding: 13px;
  border: 1px solid rgb(var(--accent-rgb) / 0.16);
  border-radius: var(--radius-xs);
  background: #f0fbf8;
}

.verification-note strong {
  color: var(--accent-dark);
  font-size: 14px;
}

.verification-note span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.separator {
  position: relative;
  display: grid;
  place-items: center;
  margin: 24px 0 16px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.separator::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.separator span {
  position: relative;
  padding: 0 12px;
  background: white;
}

.social-auth {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.social-auth button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid rgb(var(--text-rgb) / 0.14);
  border-radius: var(--radius-xs);
  background: white;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.social-auth button:hover {
  border-color: rgb(var(--accent-rgb) / 0.3);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.social-auth [data-auth-icon] svg {
  width: 18px;
  height: 18px;
}

.next-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgb(var(--accent-rgb) / 0.18);
  border-radius: var(--radius-sm);
  background: #f0fbf8;
}

.next-panel strong {
  display: block;
  margin-bottom: 3px;
}

.next-panel p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.next-panel a {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 220ms cubic-bezier(.2, .8, .2, 1), transform 220ms cubic-bezier(.2, .8, .2, 1);
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

@media (max-width: 1080px) {
  :root {
    --page-width: min(100%, calc(100vw - 56px));
    --section-x: 24px;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    gap: 34px;
    width: min(760px, calc(100% - 48px));
    min-height: 0;
  }

  .auth-card {
    max-width: 680px;
    width: 100%;
  }
}

@media (max-width: 760px) {
  :root {
    --page-width: 100%;
    --section-x: 18px;
  }

  .auth-shell {
    width: calc(100% - 36px);
    padding-top: 28px;
    padding-bottom: 48px;
  }

  h1 {
    font-size: 40px;
  }

  .auth-intro > p {
    font-size: 17px;
  }

  .split-fields,
  .social-auth,
  .next-panel {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 18px;
  }

  .form-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
  }
}
