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

html,
body.auth-body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body.auth-body {
  font-family: 'Dana', system-ui, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f0f3f6;
}

.auth-page {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
}

/* ── Brand panel ── */
.auth-brand {
  display: none;
  width: 44%;
  max-width: 520px;
  background: linear-gradient(160deg, var(--color-brand) 0%, var(--color-gradient-mid) 50%, var(--color-gradient-end) 100%);
  padding: 48px 40px;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

@media (min-width: 900px) {
  .auth-brand {
    display: flex;
  }
}

.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.08) 0%, transparent 40%);
}

.auth-brand::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 24px 24px;
}

.auth-brand-content {
  position: relative;
  z-index: 1;
}

.auth-brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 48px;
}

.auth-brand-logo img {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.auth-brand-logo span {
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
}

.auth-brand h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.5;
  margin-bottom: 16px;
}

.auth-brand p {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.85);
  line-height: 1.8;
  max-width: 320px;
}

.auth-features {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.9);
  font-size: 0.85rem;
  font-weight: 500;
}

.auth-feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-feature-icon svg {
  width: 18px;
  height: 18px;
}

.auth-brand-contact {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.auth-brand-contact__item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.6;
}

.auth-brand-contact__item svg {
  flex-shrink: 0;
  margin-top: 2px;
  opacity: 0.9;
}

/* ── Form panel ── */
.auth-form-wrap {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}

.auth-card {
  width: 100%;
  max-width: 420px;
  min-width: 0;
  background: #ffffff;
  border: 1px solid #e8edf2;
  border-radius: 20px;
  box-shadow: 0 8px 40px -12px rgba(15, 23, 42, 0.1);
  overflow: hidden;
  animation: auth-in 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes auth-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-card-head {
  padding: 28px 28px 0;
  text-align: center;
}

.auth-mobile-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  min-width: 0;
  max-width: 100%;
}

.auth-mobile-logo span {
  font-size: 1.25rem;
  font-weight: 800;
  color: #1a1a2e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

@media (min-width: 900px) {
  .auth-mobile-logo { display: none; }
}

.auth-mobile-logo img {
  width: 44px;
  height: 44px;
}

.auth-card-head h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: #1a1a2e;
  margin-bottom: 6px;
}

.auth-card-head p {
  font-size: 0.85rem;
  color: #64748b;
}

.auth-register-panel {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eef2f6;
  animation: step-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-register-panel.hidden {
  display: none !important;
}

.hidden {
  display: none !important;
}

.auth-register-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: rgba(var(--color-brand-rgb), 0.08);
  border: 1px solid rgba(var(--color-brand-rgb), 0.18);
  color: var(--color-brand-dark);
  font-size: 0.82rem;
  line-height: 1.6;
}

.auth-register-notice svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.auth-card-body {
  padding: 24px 28px 28px;
  margin-top: 8px;
}

/* ── Steps ── */
.auth-step {
  display: none;
  animation: step-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-step.active {
  display: block;
}

@keyframes step-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

.auth-input-group {
  display: flex;
  align-items: stretch;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #ffffff;
  min-width: 0;
  max-width: 100%;
}

.auth-input-group:focus-within {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(var(--color-brand-rgb), 0.12);
}

.auth-input-prefix {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  background: #f8fafb;
  border-left: 1px solid #e8edf2;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  direction: ltr;
  flex-shrink: 0;
}

.auth-input-prefix svg {
  width: 18px;
  height: 18px;
  color: var(--color-brand);
}

.auth-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  color: #1a1a2e;
  background: transparent;
  direction: ltr;
  text-align: left;
  letter-spacing: 0.05em;
}

.auth-input::placeholder {
  color: #cbd5e1;
  letter-spacing: 0;
}

.auth-field {
  margin-bottom: 18px;
}

.auth-field-hint {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 6px;
  transition: color 0.2s;
}

.auth-field-hint.is-error {
  color: #ef4444;
}

.auth-field-hint.is-success {
  color: var(--color-brand-dark);
}

.auth-input-group.is-valid {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(var(--color-brand-rgb), 0.12);
}

.auth-input-group.is-invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.auth-input-group.is-checking {
  border-color: #94a3b8;
}

/* ── OTP ── */
.otp-boxes {
  display: flex;
  gap: clamp(4px, 1.5vw, 10px);
  justify-content: center;
  direction: ltr;
  margin: 20px 0;
  position: relative;
  max-width: 100%;
}

.otp-sms-capture {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.otp-box {
  width: clamp(36px, 11vw, 48px);
  height: 52px;
  flex: 0 1 clamp(36px, 11vw, 48px);
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: inherit;
  color: #1a1a2e;
  background: #ffffff;
  transition: all 0.2s;
  caret-color: var(--color-brand);
}

.otp-box:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(var(--color-brand-rgb), 0.12);
}

.otp-box.filled {
  border-color: var(--color-brand);
  background: rgba(var(--color-brand-rgb), 0.04);
}

.otp-phone-display {
  text-align: center;
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 4px;
}

.otp-phone-display strong {
  color: #1a1a2e;
  direction: ltr;
  display: inline-block;
}

.otp-resend {
  text-align: center;
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 16px;
}

.otp-resend button {
  background: none;
  border: none;
  color: var(--color-brand-dark);
  font-weight: 600;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0 4px;
}

.otp-resend button:disabled {
  color: #94a3b8;
  cursor: not-allowed;
}

/* ── Buttons ── */
.auth-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: all 0.25s;
}

.auth-btn-primary {
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-hover));
  color: #ffffff;
  box-shadow: 0 4px 16px -4px rgba(var(--color-brand-rgb), 0.45);
}

.auth-btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px -4px rgba(var(--color-brand-rgb), 0.5);
}

.auth-btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.auth-btn-ghost {
  background: transparent;
  color: #64748b;
  margin-top: 12px;
  padding: 10px;
  font-weight: 600;
  font-size: 0.82rem;
}

.auth-btn-ghost:hover {
  color: var(--color-brand-dark);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  font-size: 0.75rem;
  color: #94a3b8;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #eef2f6;
}

.auth-footer {
  text-align: center;
  padding: 0 28px 24px;
  font-size: 0.75rem;
  color: #94a3b8;
  overflow-wrap: anywhere;
}

.auth-footer a {
  color: var(--color-brand-dark);
  font-weight: 600;
}

.auth-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 16px;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  padding: 0;
  transition: color 0.2s;
}

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

.auth-input--rtl {
  direction: rtl;
  text-align: right;
  letter-spacing: 0;
}

.auth-account-type {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
}

.auth-type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  color: #64748b;
  cursor: pointer;
  transition: all 0.25s;
}

.auth-type-btn svg {
  width: 16px;
  height: 16px;
}

.auth-type-btn.active {
  background: #ffffff;
  color: var(--color-brand-dark);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.auth-fields-group {
  display: none;
  animation: fields-switch 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-fields-group.active {
  display: block;
}

@keyframes fields-switch {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.6;
  margin-bottom: 18px;
  overflow-wrap: anywhere;
}

.auth-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-brand);
  margin-top: 2px;
  flex-shrink: 0;
}

.auth-checkbox a {
  color: var(--color-brand-dark);
  font-weight: 600;
}

.auth-home-link {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0));
  inset-inline-end: 16px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.9);
  border: 1px solid #e8edf2;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  backdrop-filter: blur(8px);
  transition: all 0.2s;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  text-decoration: none;
}

.auth-home-link:hover {
  border-color: rgba(var(--color-brand-rgb), 0.3);
  color: var(--color-brand-dark);
}

@media (min-width: 900px) {
  .auth-home-link {
    top: calc(24px + env(safe-area-inset-top, 0));
    inset-inline-end: 24px;
  }
}

@media (max-width: 479px) {
  .auth-form-wrap {
    padding: calc(56px + env(safe-area-inset-top, 0)) 12px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    align-items: flex-start;
  }

  .auth-card-head {
    padding: 20px 16px 0;
  }

  .auth-card-body {
    padding: 20px 16px 24px;
  }

  .auth-footer {
    padding: 0 16px 20px;
  }

  .auth-home-link {
    inset-inline-end: 12px;
    font-size: 0.72rem;
    padding: 7px 10px;
  }

  .otp-box {
    height: 48px;
    font-size: 1.1rem;
  }
}

.auth-loading {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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