.login-portal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex; /* matches the original inline default — JS still
                     overrides with style.display="none"/"flex" as before */
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: var(--space-6);
  box-sizing: border-box;
  background: radial-gradient(circle at 20% 20%, #1e293b, #0b1120 60%);
  transition: var(--theme-transition);
}

[data-theme="dark"] .login-portal {
  background: radial-gradient(circle at 20% 20%, #0f172a, #04070d 60%);
}

/* ---------- decorative blurred blobs (pure CSS, no external assets) ---------- */
.login-portal-bg-shapes {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.login-portal-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  animation: loginBlobDrift 16s ease-in-out infinite alternate;
}

.login-portal-blob-1 {
  width: 420px;
  height: 420px;
  top: -120px;
  left: -100px;
  background: var(--color-accent);
}

.login-portal-blob-2 {
  width: 360px;
  height: 360px;
  bottom: -140px;
  right: -80px;
  background: #7c3aed;
  animation-delay: -8s;
}

.login-portal-blob-3 {
  width: 280px;
  height: 280px;
  bottom: 10%;
  left: 8%;
  background: #22c55e;
  opacity: 0.18;
  animation-delay: -4s;
}

@keyframes loginBlobDrift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, 30px) scale(1.12); }
}

/* ---------- glass card ---------- */
.login-portal-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: color-mix(in srgb, var(--color-surface) 72%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
  border-radius: var(--radius-xl);
  padding: var(--space-7) var(--space-6);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: loginCardRise 0.5s ease;
  transition: var(--theme-transition);
}

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


.login-portal-toggle-mount {
  display: flex;
  align-items: center;
}

/* ---------- branding ---------- */
.login-portal-brand {
  margin-bottom: var(--space-6);
}

.login-portal-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-heavy);
  overflow: hidden;
}

/* Moti Group logo image — shown on its own now, no badge/box behind it.
   object-fit:contain so a non-square logo file doesn't get
   cropped/stretched. */
.login-portal-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: filter 0.3s ease;
}

/* UI FIX (Shakir — logo disappears in dark mode): the logo PNG is pure
   black line-art on a transparent background, so on the dark-theme
   gradient card it blends straight into the background and vanishes.
   invert(1) flips black -> white (alpha/transparency is untouched by
   invert, so the transparent parts stay transparent) — same trick as
   flipping a black-on-white icon for a dark UI without needing a
   second logo asset. */
[data-theme="dark"] .login-portal-logo img {
  filter: invert(1);
}

/* Fallback "M" monogram — only shown if the logo image at
   assets/moti-group-logo.png fails to load (see onerror in index.html).
   It keeps the old gradient badge look so it still reads as a logo mark
   even without an image. */
#loginPortalLogoFallback {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-accent), #7c3aed);
  color: var(--color-text-inverse);
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.login-portal-title {
  font-family: var(--font-family-base);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-heavy);
  color: var(--color-text-primary);
  margin: 0;
  letter-spacing: -0.02em;
}

.login-portal-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin: var(--space-1) 0 0;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Per-app icon next to "You are accessing the portal of <App>" on the
   password step — see js/core/auth.js's loginLookupEmail(). */
.login-app-scope-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ---------- steps (inherits the existing .login-step display toggle) ---------- */
.login-step {
  text-align: left;
  animation: loginStepFadeIn 0.3s ease;
}

@keyframes loginStepFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-step-hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-3);
}

.login-field-label {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}

.login-input {
  width: 100%;
  box-sizing: border-box;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  color: var(--color-text-primary);
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  transition: var(--transition-base);
}

.login-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 20%, transparent);
}

/* ---------- password show/hide toggle ---------- */
.login-password-wrap {
  position: relative;
}
.login-password-wrap .login-input {
  padding-right: calc(var(--space-4) + 28px);
}
.login-password-toggle {
  position: absolute;
  top: 0;
  bottom: var(--space-4); /* matches .login-input's margin-bottom so it centers on the input, not the wrapper */
  right: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0;
}
.login-password-toggle:hover {
  color: var(--color-text-primary);
}
.login-password-toggle-active {
  color: var(--color-accent);
}

.login-btn {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: var(--transition-base);
}

.login-btn-primary {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-strong));
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-sm);
}

.login-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.login-btn-secondary {
  background: var(--color-text-secondary);
  color: var(--color-text-inverse);
}

.login-legacy-link {
  display: block;
  margin-top: var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  cursor: pointer;
  text-decoration: underline;
  text-align: center;
}

@media (max-width: 480px) {
  .login-portal-card {
    padding: var(--space-6) var(--space-4);
  }
}