.q-auth-root {
  --q-auth-bg: #f4f7fb;
  --q-auth-panel: #ffffff;
  --q-auth-text: #172033;
  --q-auth-muted: #5b687b;
  --q-auth-border: #c6cfdb;
  --q-auth-primary: #1558b0;
  --q-auth-primary-hover: #10498f;
  --q-auth-primary-soft: #eaf2ff;
  --q-auth-success: #087a42;
  --q-auth-success-soft: #e9f8f0;
  --q-auth-warning: #805200;
  --q-auth-warning-soft: #fff4df;
  --q-auth-danger: #a92d28;
  --q-auth-danger-soft: #ffeceb;
  --q-auth-shadow: 0 24px 70px rgba(18, 31, 53, 0.12);
  box-sizing: border-box;
  min-height: 100vh;
  padding: 32px 18px;
  display: grid;
  place-items: center;
  overflow: auto;
  background:
    radial-gradient(circle at 12% 16%, rgba(61, 126, 218, 0.13), transparent 28rem),
    radial-gradient(circle at 88% 86%, rgba(111, 66, 193, 0.09), transparent 25rem),
    var(--q-auth-bg);
  color: var(--q-auth-text);
  font-family: 'Tajawal', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.q-auth-root *,
.q-auth-root *::before,
.q-auth-root *::after {
  box-sizing: border-box;
}

.q-auth-root button,
.q-auth-root input {
  font: inherit;
}

.q-auth-root button {
  color: inherit;
  cursor: pointer;
}

.q-auth-root button:disabled,
.q-auth-root input:disabled {
  cursor: not-allowed;
}

.q-auth-card {
  width: min(100%, 500px);
  padding: 30px;
  border: 1px solid var(--q-auth-border);
  border-radius: 24px;
  background: var(--q-auth-panel);
  box-shadow: var(--q-auth-shadow);
}

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

.q-auth-card[aria-busy='true'] {
  cursor: wait;
}

.q-auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 26px;
}

.q-auth-brand > span {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 14px;
  background: linear-gradient(135deg, #2878df, #6f42c1);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(36, 102, 196, 0.22);
}

.q-auth-brand strong,
.q-auth-brand small {
  display: block;
}

.q-auth-brand strong {
  font-size: 20px;
  line-height: 1.25;
}

.q-auth-brand small {
  margin-top: 2px;
  color: var(--q-auth-muted);
  font-size: 11px;
}

.q-auth-heading {
  position: relative;
  margin-bottom: 22px;
}

.q-auth-heading-center {
  text-align: center;
}

.q-auth-heading h1 {
  margin: 0;
  font-size: clamp(24px, 5vw, 30px);
  line-height: 1.3;
}

.q-auth-heading p {
  margin: 8px 0 0;
  color: var(--q-auth-muted);
  font-size: 14px;
}

.q-auth-heading p strong {
  color: var(--q-auth-text);
  unicode-bidi: plaintext;
}

/* ملاحظة هادئة داخل ترويسة البطاقة: البريد المهمل ونحوه. */
.q-auth-root .q-auth-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--q-auth-border);
  border-radius: 12px;
  background: var(--q-auth-primary-soft);
  color: var(--q-auth-muted);
  font-size: 13px;
  line-height: 1.6;
}

/* تمهيد لزر المخرج أسفل شاشة الانتظار. */
.q-auth-root .q-auth-hint {
  margin: 18px 0 6px;
  color: var(--q-auth-muted);
  font-size: 13px;
  text-align: center;
}

.q-auth-step,
.q-auth-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--q-auth-primary-soft);
  color: var(--q-auth-primary);
  font-size: 12px;
  font-weight: 800;
}

.q-auth-status-pill {
  background: var(--q-auth-warning-soft);
  color: var(--q-auth-warning);
}

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

.q-auth-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
}

.q-auth-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.q-auth-field label,
.q-auth-photo-field label {
  color: var(--q-auth-text);
  font-size: 13px;
  font-weight: 800;
}

.q-auth-photo-field label small {
  color: var(--q-auth-muted);
  font-weight: 500;
}

.q-auth-field > small,
.q-auth-photo-field > div > small {
  color: var(--q-auth-muted);
  font-size: 11px;
}

.q-auth-field input,
.q-auth-photo-field input[type='file'] {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--q-auth-border);
  border-radius: 12px;
  outline: 0;
  background: var(--q-auth-panel);
  color: var(--q-auth-text);
  font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.q-auth-photo-field input[type='file'] {
  height: auto;
  padding: 8px;
  font-size: 12px;
}

.q-auth-photo-field input[type='file']::file-selector-button {
  min-height: 34px;
  margin-inline-end: 8px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  background: var(--q-auth-primary-soft);
  color: var(--q-auth-primary);
  font-weight: 800;
  cursor: pointer;
}

.q-auth-field input:hover,
.q-auth-photo-field input[type='file']:hover {
  border-color: #94a3b8;
}

.q-auth-field input:focus,
.q-auth-photo-field input[type='file']:focus {
  border-color: var(--q-auth-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--q-auth-primary) 18%, transparent);
}

.q-auth-field input[aria-invalid='true'],
.q-auth-photo-field input[aria-invalid='true'] {
  border-color: var(--q-auth-danger);
}

.q-auth-field-error {
  min-height: 0;
  color: var(--q-auth-danger);
  font-size: 11px;
  font-weight: 700;
}

.q-auth-field-error:empty {
  display: none;
}

.q-auth-password-wrap {
  display: flex;
  direction: rtl;
  align-items: stretch;
  gap: 8px;
}

.q-auth-password-wrap input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  direction: ltr;
}

.q-auth-password-wrap button {
  position: static;
  flex: 0 0 68px;
  min-width: 68px;
  min-height: 48px;
  border: 1px solid var(--q-auth-border);
  border-radius: 12px;
  background: var(--q-auth-bg);
  color: var(--q-auth-muted);
  font-size: 12px;
  font-weight: 800;
}

.q-auth-password-wrap button:hover {
  background: var(--q-auth-primary-soft);
  color: var(--q-auth-primary);
}

.q-auth-code {
  direction: ltr;
  text-align: center;
  font-size: 24px !important;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.48em;
}

.q-auth-ltr {
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}

.q-auth-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.q-auth-inline-between {
  justify-content: flex-end;
}

.q-auth-primary,
.q-auth-secondary {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 12px;
  font-weight: 800;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.q-auth-primary {
  border: 1px solid var(--q-auth-primary);
  background: var(--q-auth-primary);
  color: #fff !important;
}

.q-auth-primary:hover:not(:disabled) {
  border-color: var(--q-auth-primary-hover);
  background: var(--q-auth-primary-hover);
}

.q-auth-secondary {
  border: 1px solid var(--q-auth-border);
  background: var(--q-auth-panel);
  color: var(--q-auth-text);
}

.q-auth-secondary:hover:not(:disabled) {
  border-color: var(--q-auth-primary);
  background: var(--q-auth-primary-soft);
  color: var(--q-auth-primary);
}

.q-auth-primary:active:not(:disabled),
.q-auth-secondary:active:not(:disabled) {
  transform: scale(0.99);
}

.q-auth-primary:disabled,
.q-auth-secondary:disabled {
  opacity: 0.58;
}

.q-auth-link,
.q-auth-switch button,
.q-auth-back {
  min-height: 44px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--q-auth-primary);
  font-weight: 800;
}

.q-auth-link:hover,
.q-auth-switch button:hover {
  text-decoration: underline;
}

.q-auth-switch {
  margin: 20px 0 0;
  text-align: center;
  color: var(--q-auth-muted);
  font-size: 13px;
}

.q-auth-switch button {
  margin-inline-start: 3px;
}

.q-auth-back {
  position: absolute;
  inset-inline-start: 0;
  top: -9px;
  width: 44px;
  padding: 0;
  border-radius: 10px;
  font-size: 22px;
}

.q-auth-back:hover {
  background: var(--q-auth-primary-soft);
}

.q-auth-alert {
  margin: 0 0 16px;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 700;
}

.q-auth-alert-error {
  border-color: color-mix(in srgb, var(--q-auth-danger) 30%, transparent);
  background: var(--q-auth-danger-soft);
  color: var(--q-auth-danger);
}

.q-auth-alert-warning {
  border-color: color-mix(in srgb, var(--q-auth-warning) 30%, transparent);
  background: var(--q-auth-warning-soft);
  color: var(--q-auth-warning);
}

.q-auth-alert-success {
  border-color: color-mix(in srgb, var(--q-auth-success) 30%, transparent);
  background: var(--q-auth-success-soft);
  color: var(--q-auth-success);
}

.q-auth-alert-info {
  border-color: color-mix(in srgb, var(--q-auth-primary) 30%, transparent);
  background: var(--q-auth-primary-soft);
  color: var(--q-auth-primary);
}

.q-auth-photo-field {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 13px;
  border: 1px dashed var(--q-auth-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--q-auth-bg) 65%, var(--q-auth-panel));
}

.q-auth-photo-field > div:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.q-auth-photo-preview {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--q-auth-border);
  border-radius: 20px;
  background: var(--q-auth-primary-soft);
  color: var(--q-auth-primary);
  font-size: 30px;
}

.q-auth-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.q-auth-resend {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  color: var(--q-auth-muted);
  font-size: 12px;
}

.q-auth-resend small {
  width: 100%;
  text-align: center;
}

.q-auth-resend button:disabled {
  color: var(--q-auth-muted);
  text-decoration: none;
  opacity: 0.7;
}

.q-auth-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.q-auth-choice {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--q-auth-border);
  border-radius: 17px;
  background: var(--q-auth-panel);
  text-align: start;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.q-auth-choice:hover {
  border-color: var(--q-auth-primary);
  background: var(--q-auth-primary-soft);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(30, 84, 161, 0.1);
}

.q-auth-choice-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--q-auth-primary-soft);
  font-size: 25px;
}

.q-auth-choice strong {
  font-size: 17px;
}

.q-auth-choice small {
  color: var(--q-auth-muted);
  font-size: 12px;
  line-height: 1.65;
}

.q-auth-icon {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  margin: 0 auto 15px;
  border-radius: 20px;
  background: var(--q-auth-primary-soft);
  font-size: 30px;
}

.q-auth-result-icon {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 50%;
  font-size: 32px;
  font-weight: 900;
}

.q-auth-result-success {
  background: var(--q-auth-success-soft);
  color: var(--q-auth-success);
}

.q-auth-waiting-art {
  position: relative;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 30px;
  background: var(--q-auth-warning-soft);
  color: var(--q-auth-warning);
  font-size: 42px;
}

.q-auth-waiting-art::after {
  content: '';
  position: absolute;
  inset: -7px;
  border: 1px dashed color-mix(in srgb, var(--q-auth-warning) 45%, transparent);
  border-radius: 36px;
  animation: q-auth-rotate 16s linear infinite;
}

.q-auth-company-code {
  display: inline-flex;
  margin-top: 13px;
  padding: 7px 12px;
  border: 1px solid var(--q-auth-border);
  border-radius: 9px;
  background: var(--q-auth-bg);
  font-size: 15px;
}

.q-auth-logout {
  width: 100%;
  margin-top: 12px;
  color: var(--q-auth-muted);
  text-align: center;
}

.q-auth-loading {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.q-auth-loading h1 {
  margin: 16px 0 0;
}

.q-auth-loading p {
  margin: 5px 0 0;
  color: var(--q-auth-muted);
}

.q-auth-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--q-auth-primary-soft);
  border-top-color: var(--q-auth-primary);
  border-radius: 50%;
  animation: q-auth-rotate 0.8s linear infinite;
}

.q-auth-root :is(button, input):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--q-auth-primary) 55%, transparent);
  outline-offset: 2px;
}

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

html[data-theme='dark'] .q-auth-root,
.q-auth-root[data-theme='dark'] {
  --q-auth-bg: #0b1220;
  --q-auth-panel: #111a2b;
  --q-auth-text: #edf2f7;
  --q-auth-muted: #a8b4c6;
  --q-auth-border: #53637d;
  --q-auth-primary: #75afff;
  --q-auth-primary-hover: #5799f7;
  --q-auth-primary-soft: #142d52;
  --q-auth-success: #62dda0;
  --q-auth-success-soft: #102d21;
  --q-auth-warning: #f4be62;
  --q-auth-warning-soft: #342612;
  --q-auth-danger: #ff827d;
  --q-auth-danger-soft: #351919;
  --q-auth-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

@media (prefers-color-scheme: dark) {
  .q-auth-root[data-theme='auto'] {
    --q-auth-bg: #0b1220;
    --q-auth-panel: #111a2b;
    --q-auth-text: #edf2f7;
    --q-auth-muted: #a8b4c6;
    --q-auth-border: #53637d;
    --q-auth-primary: #75afff;
    --q-auth-primary-hover: #5799f7;
    --q-auth-primary-soft: #142d52;
    --q-auth-success: #62dda0;
    --q-auth-success-soft: #102d21;
    --q-auth-warning: #f4be62;
    --q-auth-warning-soft: #342612;
    --q-auth-danger: #ff827d;
    --q-auth-danger-soft: #351919;
  }
}

@media (max-width: 700px) {
  .q-auth-root {
    min-height: 100dvh;
    display: block;
    padding: max(12px, env(safe-area-inset-top)) 12px max(24px, env(safe-area-inset-bottom));
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .q-auth-card {
    margin: 0 auto;
    padding: 23px 18px;
    border-radius: 19px;
  }

  .q-auth-root :is(button, input, select, textarea) {
    touch-action: manipulation;
  }

  .q-auth-form-grid,
  .q-auth-choice-grid {
    grid-template-columns: 1fr;
  }

  .q-auth-choice {
    min-height: 148px;
  }

  .q-auth-brand {
    margin-bottom: 21px;
  }
}

@media (max-width: 420px) {
  .q-auth-card {
    padding-inline: 15px;
  }

  .q-auth-photo-field {
    grid-template-columns: 1fr;
  }

  .q-auth-photo-preview {
    width: 64px;
    height: 64px;
  }

  .q-auth-code {
    letter-spacing: 0.34em;
  }
}

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