:root {
  --auth-bg: #f9fafb;
  --auth-card-bg: #ffffff;
  --auth-text: #030712;
  --auth-muted: #6b7280;
  --auth-border: #d1d5db;
  --auth-border-focus: #017aa9;
  --auth-accent: #017aa9;
  --auth-accent-hover: #015f86;
  --auth-error: #dc2626;
  --auth-error-bg: #fef2f2;
  --auth-success: #047857;
  --auth-success-bg: #ecfdf5;
  --auth-info-bg: #eff6ff;
  --auth-rule-ok: #047857;
  --auth-rule-pending: #6b7280;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--auth-bg);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--auth-text);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.auth-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  text-align: left;
}

.auth-logo {
  display: block;
  height: 48px;
  width: auto;
  margin: 0 0 40px;
}

.auth-step {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 400;
  color: var(--auth-muted);
}

.auth-heading {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  color: #030712;
}

.auth-subheading {
  margin: 0 0 32px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--auth-muted);
}

.auth-subheading .auth-email {
  font-weight: 600;
  color: var(--auth-text);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-row { display: flex; gap: 12px; }
.auth-row > .auth-field { flex: 1; }

.auth-field { display: flex; flex-direction: column; }

.auth-label {
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: #030712;
  margin-bottom: 6px;
}

.auth-input::placeholder {
  color: #9ca3af;
}

/* Password field with reveal toggle */
.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.auth-input--password {
  padding-right: 44px;
}
.auth-pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  border-radius: 4px;
}
.auth-pw-toggle:hover { color: rgba(0, 0, 0, 0.75); }
.auth-pw-toggle .pw-icon-hide { display: none; }
.auth-pw-toggle.is-revealed .pw-icon-show { display: none; }
.auth-pw-toggle.is-revealed .pw-icon-hide { display: inline-flex; }

/* Remember me checkbox */
.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.auth-checkbox input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
}
.auth-checkbox-box {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 1px solid var(--auth-border);
  border-radius: 4px;
  background: var(--auth-card-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.auth-checkbox-box::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
  opacity: 0;
}
.auth-checkbox input:checked + .auth-checkbox-box {
  background: var(--auth-accent);
  border-color: var(--auth-accent);
}
.auth-checkbox input:checked + .auth-checkbox-box::after { opacity: 1; }
.auth-checkbox input:focus-visible + .auth-checkbox-box {
  box-shadow: 0 0 0 3px rgba(1, 122, 169, 0.15);
}
.auth-checkbox-label {
  font-size: 14px;
  color: var(--auth-muted);
}

/* Privacy / terms notice */
.auth-terms {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--auth-muted);
}
.auth-terms-link {
  color: #030712;
  font-weight: 400;
  text-decoration: underline;
  text-decoration-style: solid;
  cursor: pointer;
}

/* Page footer legal links */
.auth-page-footer {
  display: flex;
  gap: 24px;
  padding: 12px 32px;
  border-top: 1px solid var(--auth-border);
}
.auth-page-footer a {
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  color: #030712;
  text-decoration: underline;
  text-decoration-style: solid;
}

.auth-forgot {
  margin: 18px 0 0;
  font-size: 14px;
}

.auth-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--auth-text);
  background: var(--auth-card-bg);
  border: 1px solid var(--auth-border);
  border-radius: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-input:focus {
  outline: none;
  border-color: var(--auth-border-focus);
  box-shadow: 0 0 0 3px rgba(1, 122, 169, 0.15);
}

.auth-input.is-invalid {
  border-color: var(--auth-error);
}

.auth-field-error {
  margin-top: 6px;
  font-size: 13px;
  color: var(--auth-error);
  min-height: 0;
}
.auth-field-error:empty {
  margin-top: 0;
}

.auth-button {
  display: block;
  width: 100%;
  padding: 14px 24px;
  background: var(--auth-accent);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.auth-button:hover:not(:disabled), .auth-button:focus:not(:disabled) {
  background: var(--auth-accent-hover);
}

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

/* Submit button loading state (shown while authentication is in progress) */
.auth-button.is-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.auth-button__spinner {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  animation: auth-spin 0.9s steps(8) infinite;
}
@keyframes auth-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  /* Keep feedback but ease the motion for reduced-motion users. */
  .auth-button__spinner { animation-duration: 1.5s; }
}

/* Visually-hidden live region for announcing busy/loading state to AT. */
.auth-sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.auth-link {
  color: #017aa9;
  text-decoration: none;
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
}
.auth-link:hover, .auth-link:focus { text-decoration: underline; }

.auth-footer {
  margin-top: 24px;
  font-size: 14px;
  color: var(--auth-muted);
  text-align: left;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.auth-aside {
  margin-top: 12px;
  font-size: 13px;
  color: var(--auth-muted);
  text-align: right;
}

.auth-alert {
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 16px;
}
.auth-alert-error, .auth-alert-danger {
  background: var(--auth-error-bg);
  color: var(--auth-error);
}
.auth-alert-success {
  background: var(--auth-success-bg);
  color: var(--auth-success);
}
.auth-alert-info, .auth-alert-message {
  background: var(--auth-info-bg);
  color: var(--auth-accent);
}

/* Password rule indicators */
.auth-rules {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.auth-rule {
  font-size: 13px;
  color: var(--auth-rule-pending);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.15s ease;
}
.auth-rule::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
}
.auth-rule.is-met {
  color: var(--auth-rule-ok);
}

/* intl-tel-input integration */
.iti { width: 100%; }
.iti__tel-input.auth-input {
  padding-left: 96px; /* room for separate dial code */
}

/* OTP input (single-field legacy) */
.auth-otp {
  letter-spacing: 0.5em;
  font-size: 22px;
  text-align: center;
  font-weight: 600;
}

/* Reset password — each step is one block; header keeps Sign In spacing */
.reset-step[hidden] { display: none; }
.reset-step .auth-field { margin-bottom: 16px; }
.reset-step .auth-button { margin-top: 8px; }

/* 6-box verification code — connected segmented group */
.auth-otp-group {
  display: inline-flex;
  gap: 0;
  margin: 0 0 6px;
}
.auth-otp-box {
  width: 44px;
  height: 44px;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  font-family: inherit;
  color: var(--auth-text);
  background: var(--auth-bg);
  border: 1px solid var(--auth-border);
  border-right: none;
  border-radius: 0;
  transition: border-color 0.15s ease;
}
.auth-otp-box:first-child {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}
.auth-otp-box:last-child {
  border-right: 1px solid var(--auth-border);
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}
.auth-otp-box:focus {
  outline: none;
  position: relative;
  z-index: 1;
  border-color: var(--auth-border-focus);
  box-shadow: 0 0 0 1px var(--auth-border-focus);
}

.auth-resend {
  margin: 16px 0 0;
  font-size: 14px;
  color: var(--auth-muted);
}
.auth-resend .auth-link { margin-left: 4px; }

@media (max-width: 480px) {
  .auth-logo { margin-bottom: 32px; }
  .auth-heading { font-size: 24px; }
  .auth-row { flex-direction: column; gap: 18px; }
}
