/* =====================================================================
   Okto Nexus · read-only product surface (dark)
   An original build in Nexus's real information architecture (agent
   roster / handoffs / event log), in the same dark slate register as
   the Pulse embed alongside it, with Nexus's own violet accent.
   ===================================================================== */

.nx-app {
  --nx-bg: #0b0f1a;
  --nx-surface: #10162578;
  --nx-surface-1: #131a2b;
  --nx-surface-2: #182034;
  --nx-line: rgba(255, 255, 255, 0.08);
  --nx-line-strong: rgba(255, 255, 255, 0.14);
  --nx-ink: #f1f4fa;
  --nx-copy: #b6c0d6;
  --nx-muted: #7c87a3;
  --nx-accent: #a78bfa;
  --nx-accent-ink: #c4b5fd;
  --nx-accent-soft: rgba(167, 139, 250, 0.14);
  --nx-green: #34d399;
  --nx-amber: #fbbf24;
  --nx-red: #fb7185;
  --nx-ease: cubic-bezier(0.22, 1, 0.36, 1);

  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background:
    radial-gradient(720px 320px at 15% 0%, rgba(167, 139, 250, 0.08), transparent 65%),
    var(--nx-bg);
  color: var(--nx-copy);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}

.nx-app *, .nx-app *::before, .nx-app *::after { box-sizing: border-box; }
.nx-app button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

.nx-topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: var(--nx-surface-1);
  border-bottom: 1px solid var(--nx-line);
  flex-shrink: 0;
}

.nx-topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--nx-accent), transparent 55%);
  opacity: 0.6;
}

.nx-topbar__wordmark { height: 18px; width: auto; filter: brightness(0) invert(1); }

.nx-topbar__crumb { font-size: 12.5px; color: var(--nx-muted); }

.nx-topbar__live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--nx-muted);
}

.nx-live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--nx-accent);
  box-shadow: 0 0 6px rgba(167, 139, 250, 0.8);
  animation: nx-pulse 2.4s var(--nx-ease) infinite;
}

@keyframes nx-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(167, 139, 250, 0.8); }
  50% { opacity: 0.5; box-shadow: 0 0 2px rgba(167, 139, 250, 0.4); }
}

.nx-shell {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.nx-sidebar {
  width: 208px;
  flex-shrink: 0;
  border-right: 1px solid var(--nx-line);
  background: var(--nx-surface-1);
  padding: 16px 12px;
  overflow-y: auto;
}

.nx-nav { display: flex; flex-direction: column; gap: 3px; }

.nx-nav__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--nx-copy);
  text-align: left;
  transition: background 200ms var(--nx-ease), color 200ms var(--nx-ease), padding-left 200ms var(--nx-ease);
}

.nx-nav__item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--nx-accent);
  transform: scaleY(0);
  transition: transform 220ms var(--nx-ease);
}

.nx-nav__item:hover { background: var(--nx-surface-2); color: var(--nx-ink); }

.nx-nav__item.is-active {
  background: var(--nx-accent-soft);
  color: var(--nx-ink);
  padding-left: 14px;
}

.nx-nav__item.is-active::before { transform: scaleY(1); }

.nx-nav__item.is-active .nx-icon { color: var(--nx-accent-ink); opacity: 1; }

.nx-icon {
  width: 16px; height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 200ms var(--nx-ease), color 200ms var(--nx-ease);
}

.nx-nav__item em {
  margin-left: auto;
  font-style: normal;
  font-size: 10.5px;
  color: var(--nx-muted);
  background: var(--nx-surface-2);
  border-radius: 999px;
  padding: 1px 7px;
  transition: color 200ms var(--nx-ease), background 200ms var(--nx-ease);
}

.nx-nav__item.is-active em { color: var(--nx-accent-ink); background: rgba(167, 139, 250, 0.18); }

.nx-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  padding: 24px 28px 42px;
}

/* Page transition: replays on every render since a fresh .nx-page element
   is inserted each time (see nexus-app.js renderPage). */
.nx-page { animation: nx-page-in 340ms var(--nx-ease); }

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

.nx-page__title {
  font-family: var(--font-display, inherit);
  font-weight: 600;
  font-size: 19px;
  color: var(--nx-ink);
  margin: 0 0 4px;
}

.nx-page__sub {
  font-size: 12.5px;
  color: var(--nx-muted);
  margin: 0 0 22px;
}

/* ---------- overview ---------- */
.nx-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.nx-stat {
  padding: 15px 14px;
  border-radius: 10px;
  background: var(--nx-surface-1);
  border: 1px solid var(--nx-line);
  text-align: center;
  transform: translateY(0);
  transition: transform 200ms var(--nx-ease), border-color 200ms var(--nx-ease);
}

.nx-stat:hover { transform: translateY(-2px); border-color: rgba(167, 139, 250, 0.3); }

.nx-stat__v {
  display: block;
  font-family: var(--font-display, inherit);
  font-size: 23px;
  font-weight: 700;
  color: var(--nx-ink);
  font-variant-numeric: tabular-nums;
}
.nx-stat__l { display: block; font-size: 11px; color: var(--nx-muted); margin-top: 3px; }

.nx-panel {
  padding: 16px 18px;
  border-radius: 10px;
  background: var(--nx-surface-1);
  border: 1px solid var(--nx-line);
  margin-bottom: 16px;
  transition: border-color 200ms var(--nx-ease);
}

.nx-panel:hover { border-color: var(--nx-line-strong); }

.nx-panel h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--nx-muted);
}

.nx-panel p { margin: 0 0 8px; font-size: 13px; line-height: 1.6; color: var(--nx-copy); }
.nx-panel p:last-child { margin-bottom: 0; }
.nx-panel code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--nx-accent-ink);
  background: rgba(167, 139, 250, 0.12);
  padding: 1px 4px;
  border-radius: 3px;
}
.nx-panel strong { color: var(--nx-ink); }

/* ---------- agents ---------- */
.nx-agents {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.nx-agent-card {
  position: relative;
  padding: 14px;
  border-radius: 10px;
  background: var(--nx-surface-1);
  border: 1px solid var(--nx-line);
  overflow: hidden;
  transform: translateY(0);
  transition: transform 200ms var(--nx-ease), border-color 200ms var(--nx-ease);
}

.nx-agent-card:hover { transform: translateY(-3px); border-color: rgba(167, 139, 250, 0.32); }

.nx-agent-card.is-active {
  border-color: rgba(167, 139, 250, 0.4);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.16);
}

.nx-agent-card.is-active::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--nx-accent), transparent);
}

.nx-agent-card__id {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--nx-ink);
  display: block;
  margin-bottom: 4px;
}

.nx-agent-card__role { font-size: 11.5px; color: var(--nx-muted); display: block; margin-bottom: 8px; }

.nx-agent-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--nx-accent-soft);
  color: var(--nx-accent-ink);
}

.nx-agent-card__badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- handoffs ---------- */
.nx-handoff-card {
  padding: 18px 20px;
  border-radius: 10px;
  background: var(--nx-surface-1);
  border: 1px solid var(--nx-line);
}

.nx-handoff-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.nx-handoff-card__id { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--nx-muted); }

.nx-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.15);
  color: var(--nx-green);
}

.nx-status-pill::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.nx-handoff-card__route {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--nx-copy);
  margin-bottom: 18px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--nx-bg);
  border: 1px solid var(--nx-line);
}

.nx-handoff-card__route code {
  font-family: "IBM Plex Mono", monospace;
  color: var(--nx-ink);
  font-weight: 500;
}

/* ---------- activity timeline ---------- */
.nx-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--nx-line);
}

.nx-event {
  position: relative;
  padding: 0 0 18px 22px;
}

.nx-event__dot {
  position: absolute;
  left: -7px;
  top: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--nx-bg);
  border: 2px solid var(--nx-accent);
  transition: box-shadow 200ms var(--nx-ease);
}

.nx-event.is-final .nx-event__dot { background: var(--nx-accent); }

.nx-event__row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  cursor: pointer;
  padding: 6px 8px;
  margin: -6px -8px;
  border-radius: 6px;
  transition: background 160ms var(--nx-ease);
}

.nx-event__row:hover {
  background: var(--nx-surface-1);
}

.nx-event:has(.nx-event__row:hover) .nx-event__dot {
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.16);
}

.nx-event__type {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--nx-accent-ink);
}

.nx-event__actor { font-size: 12px; color: var(--nx-copy); }
.nx-event__actor code { font-family: "IBM Plex Mono", monospace; color: var(--nx-ink); }

.nx-event__time {
  margin-left: auto;
  font-size: 11px;
  color: var(--nx-muted);
  font-variant-numeric: tabular-nums;
}

.nx-event__toggle {
  font-size: 10px;
  color: var(--nx-muted);
  transition: transform 200ms var(--nx-ease);
}

.nx-event.is-open .nx-event__toggle { transform: rotate(90deg); color: var(--nx-accent-ink); }

.nx-event__payload {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 260ms var(--nx-ease), opacity 200ms var(--nx-ease);
  margin-top: 0;
}

.nx-event__payload > div { overflow: hidden; }

.nx-event.is-open .nx-event__payload {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-top: 10px;
}

.nx-event__payload pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--nx-bg);
  border: 1px solid var(--nx-line);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--nx-copy);
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 720px) {
  .nx-sidebar { width: 168px; }
  .nx-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
