:root {
  --portal-bg: #f5f7fb;
  --portal-surface: #ffffff;
  --portal-border: #d9e2ef;
  --portal-text: #1a2b42;
  --portal-muted: #5b6f86;
  --portal-accent: #4f6df5;
  --portal-accent-hover: #3f5ce0;
  --portal-radius: 14px;
  --portal-font: "Inter", system-ui, sans-serif;
  --portal-display: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body.portal-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--portal-font);
  color: var(--portal-text);
  background: var(--portal-bg);
}

/* —— Auth gate layout (centered card on ambient background) —— */

.auth-gate-page {
  position: relative;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

.auth-gate-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(79, 109, 245, 0.18), transparent 38%),
    radial-gradient(circle at 85% 10%, rgba(14, 165, 233, 0.14), transparent 32%),
    radial-gradient(circle at 50% 95%, rgba(79, 109, 245, 0.1), transparent 42%),
    linear-gradient(165deg, #fafbff 0%, #eef2f9 48%, #e8eef8 100%);
}

.auth-gate-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(30, 58, 95, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 20%, transparent 100%);
}

.auth-gate-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  pointer-events: none;
}

.auth-gate-orb--a {
  width: 22rem;
  height: 22rem;
  top: 8%;
  right: -4rem;
  background: rgba(79, 109, 245, 0.35);
}

.auth-gate-orb--b {
  width: 18rem;
  height: 18rem;
  bottom: 10%;
  left: -5rem;
  background: rgba(14, 165, 233, 0.28);
}

.auth-gate-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem clamp(1.25rem, 4vw, 2rem);
}

.auth-gate-signout {
  margin-left: auto;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--portal-muted);
  cursor: pointer;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.auth-gate-signout:hover {
  color: var(--portal-accent);
  background: rgba(255, 255, 255, 0.55);
}

.auth-gate-stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.auth-gate-home {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  padding: 0.4rem 0.65rem 0.4rem 0.4rem;
  margin: -0.4rem;
  border-radius: 0.85rem;
  transition: background 0.15s ease;
}

.auth-gate-home:hover {
  background: rgba(255, 255, 255, 0.55);
}

.auth-gate-home-copy {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  line-height: 1.2;
}

.auth-gate-home-brand {
  font-family: var(--portal-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--portal-text);
}

.auth-gate-home-back {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--portal-muted);
  transition: color 0.15s ease;
}

.auth-gate-home:hover .auth-gate-home-back {
  color: var(--portal-accent);
}

.auth-gate-main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 clamp(1.25rem, 4vw, 2rem) 3rem;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-gate-main.is-visible {
  opacity: 1;
}

.auth-gate-main.is-exiting {
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .auth-gate-main {
    opacity: 1;
    transition: none;
  }
}

.auth-gate-intro {
  width: 100%;
  max-width: 420px;
  text-align: center;
  margin-bottom: 1.35rem;
}

.auth-gate-intro h1 {
  margin: 0 0 0.45rem;
  font-family: var(--portal-display);
  font-size: clamp(1.75rem, 4vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.auth-gate-intro p {
  margin: 0;
  color: var(--portal-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.auth-gate-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 1rem;
}

.auth-gate-pills span {
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--portal-accent);
  background: rgba(79, 109, 245, 0.09);
  border: 1px solid rgba(79, 109, 245, 0.16);
}

.auth-gate-card {
  width: 100%;
  max-width: 420px;
  padding: clamp(1.35rem, 4vw, 1.85rem);
  border-radius: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  box-shadow:
    0 0 0 1px rgba(30, 58, 95, 0.04),
    0 24px 60px rgba(30, 58, 95, 0.1);
}

.auth-gate-card .portal-sub {
  margin-bottom: 1.1rem;
}

.auth-tier-pill {
  display: inline-block;
  margin-bottom: 0.65rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(79, 109, 245, 0.1);
  border: 1px solid rgba(79, 109, 245, 0.22);
  color: var(--portal-accent);
  font-size: 0.74rem;
  font-weight: 600;
}

.auth-gate-switch {
  margin: 1.15rem 0 0;
  text-align: center;
  font-size: 0.88rem;
  color: var(--portal-muted);
}

.auth-gate-switch a {
  color: var(--portal-accent);
  font-weight: 600;
  text-decoration: none;
}

.auth-gate-switch a:hover {
  text-decoration: underline;
}

.auth-gate-demo {
  margin-top: 0.65rem;
  text-align: center;
  font-size: 0.82rem;
}

.auth-gate-demo a {
  color: var(--portal-muted);
  text-decoration: none;
}

.auth-gate-demo a:hover {
  color: var(--portal-accent);
}

.portal-wrap {
  max-width: 440px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.portal-card {
  background: var(--portal-surface);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  padding: 1.75rem;
  box-shadow: 0 18px 48px rgba(30, 58, 95, 0.08);
  width: 100%;
}

.portal-field input:focus,
.portal-field select:focus,
.portal-field textarea:focus {
  outline: none;
  border-color: rgba(79, 109, 245, 0.55);
  box-shadow: 0 0 0 3px rgba(79, 109, 245, 0.12);
}

.portal-btn:hover {
  transform: translateY(-1px);
}

.portal-btn:active {
  transform: translateY(0);
}

@media (max-width: 520px) {
  .auth-gate-main {
    justify-content: flex-start;
    padding-top: 0.5rem;
  }

  .auth-gate-pills span {
    font-size: 0.68rem;
  }
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.portal-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
  background: rgba(79, 109, 245, 0.12);
  color: var(--portal-accent);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-family: var(--portal-display);
  font-size: 0.8rem;
}

.portal-card h1 {
  margin: 0 0 0.35rem;
  font-family: var(--portal-display);
  font-size: 1.45rem;
}

.portal-sub {
  margin: 0 0 1.25rem;
  color: var(--portal-muted);
  font-size: 0.92rem;
}

.portal-field { margin-bottom: 0.85rem; }

.portal-field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  color: var(--portal-muted);
}

.portal-field input,
.portal-field select,
.portal-field textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--portal-border);
  border-radius: 0.65rem;
  font: inherit;
  background: #fff;
}

.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.portal-btn.primary {
  background: var(--portal-accent);
  color: #fff;
}

.portal-btn.primary:hover { background: var(--portal-accent-hover); }

.portal-btn.secondary {
  background: rgba(79, 109, 245, 0.1);
  color: var(--portal-text);
  border: 1px solid rgba(79, 109, 245, 0.25);
}

.portal-btn.ghost {
  background: transparent;
  color: var(--portal-muted);
  border: 1px solid var(--portal-border);
}

.portal-btn.is-loading {
  pointer-events: none;
  opacity: 0.92;
}

.portal-btn-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-right: 0.45rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: portal-btn-spin 0.7s linear infinite;
  vertical-align: -0.15em;
}

.portal-btn.secondary .portal-btn-spinner,
.portal-btn.ghost .portal-btn-spinner {
  border-color: rgba(79, 109, 245, 0.2);
  border-top-color: var(--portal-accent);
}

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

.portal-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  color: var(--portal-muted);
  font-size: 0.78rem;
}

.portal-divider::before,
.portal-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--portal-border);
}

.portal-error {
  color: #dc2626;
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.portal-success {
  color: #059669;
  font-size: 0.85rem;
}

.portal-foot {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--portal-muted);
}

.portal-foot a { color: var(--portal-accent); }

.hidden { display: none !important; }

/* Dashboard shell */
.dashboard-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.dashboard-sidebar {
  border-right: 1px solid var(--portal-border);
  background: var(--portal-surface);
  padding: 1.25rem 1rem;
}

.dashboard-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.dashboard-sidebar a {
  padding: 0.55rem 0.75rem;
  border-radius: 0.55rem;
  color: var(--portal-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.dashboard-sidebar a.active,
.dashboard-sidebar a:hover {
  background: rgba(79, 109, 245, 0.1);
  color: var(--portal-accent);
}

.dashboard-main {
  padding: 1.5rem;
}

.status-banner {
  padding: 0.85rem 1rem;
  border-radius: 0.65rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid var(--portal-border);
  background: #fffbeb;
}

.admin-frame {
  width: 100%;
  height: calc(100vh - 120px);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  background: #fff;
}

@media (max-width: 768px) {
  .dashboard-shell { grid-template-columns: 1fr; }
  .dashboard-sidebar { border-right: 0; border-bottom: 1px solid var(--portal-border); }
}
