/* ============================================================================
   NEX auth gate — ports the SCC full-page access gate to the NEX surface.
   Default-VISIBLE (fail-closed): if nex-auth.js or this stylesheet fails to
   load, the gate stays up rather than flashing the NEX stage. nex-auth.js
   removes it only after the ZITADEL OIDC PKCE flow returns a valid bearer.
   Mirrors zenna-ops-dashboard/commerce/gpu-farm/sovereign-control-center.css
   (CCD-B-v2-FE) — re-skinned for NEX's ice-blue/charcoal aesthetic.
   ========================================================================== */

#nex-gate {
  /* critical coverage is ALSO inline on the element (fail-closed); this only beautifies */
  background:
    radial-gradient(900px 380px at 50% 16%, rgba(127,195,255,0.16), transparent 60%),
    radial-gradient(760px 340px at 50% 102%, rgba(127,195,255,0.08), transparent 60%),
    #0b0d10;
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  padding: 1.5rem;
  color: #e9eef5;
}
body.nex-authed #nex-gate { display: none !important; }
body:not(.nex-authed) { overflow: hidden; }

.nex-gate-card { width: 100%; max-width: 480px; text-align: center; }
.nex-gate-logo {
  width: 58px; height: 58px; margin: 0 auto 1.5rem; border-radius: 1rem;
  background: rgba(127,195,255,0.08); border: 1px solid rgba(127,195,255,0.28);
  display: flex; align-items: center; justify-content: center;
}
.nex-gate-brand {
  font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: #7fc3ff; margin-bottom: 0.55rem; font-weight: 600;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.nex-gate-title {
  font-size: 2.1rem; font-weight: 600; letter-spacing: 0.18em;
  color: #e9eef5; margin: 0 0 0.55rem; line-height: 1.1;
}
.nex-gate-sub { font-size: 0.7rem; color: #6b7683; margin-bottom: 1.5rem; font-family: "JetBrains Mono", ui-monospace, monospace; }
.nex-gate-msg { font-size: 0.85rem; color: #aab4c2; line-height: 1.6; margin: 0 auto 1.6rem; max-width: 400px; font-weight: 300; }

.nex-gate-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.78rem 1.8rem; border-radius: 0.6rem; border: 1px solid rgba(127,195,255,0.45);
  cursor: pointer; font-size: 0.78rem; font-weight: 500; letter-spacing: 0.18em;
  text-transform: uppercase; color: #0b0d10;
  background: linear-gradient(135deg, #7fc3ff, #4a9be0);
  box-shadow: 0 8px 28px -8px rgba(127,195,255,0.55), 0 0 0 1px rgba(127,195,255,0.45) inset;
  transition: transform .12s, box-shadow .15s, opacity .15s;
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
}
.nex-gate-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 32px -8px rgba(127,195,255,0.65), 0 0 0 1px rgba(127,195,255,0.6) inset; }
.nex-gate-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.nex-gate-btn-soft {
  background: rgba(127,195,255,0.10); color: #7fc3ff;
  box-shadow: none; border: 1px solid rgba(127,195,255,0.32);
}
.nex-gate-btn-soft:hover:not(:disabled) { background: rgba(127,195,255,0.18); }
.nex-gate-btn-danger {
  background: rgba(240,179,107,0.10); color: #f0b36b;
  box-shadow: none; border: 1px solid rgba(240,179,107,0.32);
}

.nex-gate-spinner {
  width: 30px; height: 30px; margin: 0 auto 1.2rem;
  border: 2px solid rgba(170,180,194,0.25); border-top-color: #7fc3ff;
  border-radius: 50%; animation: nex-spin 0.8s linear infinite;
}
@keyframes nex-spin { to { transform: rotate(360deg); } }

.nex-gate-extra { margin-top: 1.3rem; }
.nex-gate-note {
  font-size: 0.68rem; color: #f0b36b; line-height: 1.55;
  background: rgba(240,179,107,0.06); border: 1px solid rgba(240,179,107,0.28);
  border-radius: 0.5rem; padding: 0.65rem 0.8rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.nex-gate-err { font-size: 0.72rem; color: #f08484; margin-top: 1rem; min-height: 1em; line-height: 1.5; font-family: "JetBrains Mono", ui-monospace, monospace; }

.nex-gate-diag { margin-top: 1.1rem; text-align: left; }
.nex-gate-diag label { font-size: 0.62rem; color: #6b7683; display: block; margin-bottom: 0.3rem; text-transform: uppercase; letter-spacing: 0.12em; font-family: "JetBrains Mono", ui-monospace, monospace; }
.nex-gate-diag input {
  width: 100%; background: rgba(11,15,25,0.85);
  border: 1px solid rgba(170,180,194,0.22); border-radius: 0.4rem;
  color: #e9eef5; font-size: 0.7rem; padding: 0.42rem 0.55rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

/* ============================================================================
   Header user menu — appears top-right once authed, mirrors SCC's avatar+menu
   but skinned for NEX. Default-hidden, revealed by nex-auth.js after sign-in.
   ========================================================================== */
.nex-user {
  position: fixed; top: 14px; right: 14px; z-index: 5000;
  display: none;
}
body.nex-authed .nex-user { display: block; }
.nex-user-btn {
  display: inline-flex; align-items: center; gap: 0.55rem;
  background: rgba(11,13,16,0.72); backdrop-filter: blur(10px);
  border: 1px solid rgba(127,195,255,0.32); border-radius: 0.75rem;
  padding: 0.35rem 0.65rem 0.35rem 0.4rem; cursor: pointer;
  color: #e9eef5; transition: background .15s, border-color .15s;
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
}
.nex-user-btn:hover { background: rgba(127,195,255,0.10); border-color: rgba(127,195,255,0.5); }
.nex-user-avatar {
  position: relative; width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #7fc3ff, #4a9be0);
  color: #0b0d10; font-weight: 700; font-size: 0.78rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px rgba(127,195,255,0.25);
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
}
.nex-user-avatar::after {
  content: ''; position: absolute; right: -1px; bottom: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #7fc3ff; border: 2px solid #0b0d10;
}
.nex-user-meta { text-align: left; line-height: 1.1; }
.nex-user-meta .nex-user-l1 {
  display: block; font-size: 0.55rem; text-transform: uppercase;
  letter-spacing: 0.18em; color: #6b7683;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.nex-user-meta .nex-user-l2 {
  display: block; font-size: 0.78rem; font-weight: 500; color: #e9eef5;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nex-user-chev { opacity: 0.7; font-size: 0.7rem; color: #aab4c2; transition: transform .15s; }
.nex-user.open .nex-user-chev { transform: rotate(180deg); }

.nex-user-menu {
  position: absolute; right: 0; top: calc(100% + 0.4rem); min-width: 240px;
  background: rgba(11,13,16,0.92); backdrop-filter: blur(14px);
  border: 1px solid rgba(127,195,255,0.32); border-radius: 0.7rem;
  box-shadow: 0 16px 48px -12px rgba(0,0,0,0.7);
  padding: 0.5rem; z-index: 500; display: none;
}
.nex-user.open .nex-user-menu { display: block; }
.nex-user-head {
  padding: 0.55rem 0.6rem 0.7rem;
  border-bottom: 1px solid rgba(170,180,194,0.12); margin-bottom: 0.4rem;
}
.nex-user-head .nm { font-size: 0.82rem; font-weight: 500; color: #e9eef5; }
.nex-user-head .em {
  font-size: 0.62rem; color: #6b7683;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  word-break: break-all; margin-top: 0.18rem;
}
.nex-user-item {
  width: 100%; text-align: left; background: transparent; border: none;
  color: #f08484; font-size: 0.8rem; font-weight: 500;
  padding: 0.55rem 0.6rem; border-radius: 0.45rem;
  cursor: pointer; transition: background .12s; letter-spacing: 0.04em;
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
}
.nex-user-item:hover { background: rgba(240,132,132,0.10); }
