/* ==========================================================================
   AGENCY COMMAND — 2026 ENTERPRISE WORKSPACE DESIGN SYSTEM
   Visual Language inspired by Linear, Stripe Dashboard, Vercel & Apple HIG
   ========================================================================== */

/* ---------- CSS Custom Properties & Design Tokens ---------- */
:root {
  /* Surface & Background Palette (Deep Space Void) */
  --bg-deep: #04070d;
  --bg-app: #070b14;
  --surface-1: #080e1a;
  --surface-2: #0e1627;
  --surface-3: #141f36;
  --surface-overlay: rgba(14, 22, 39, 0.85);

  /* Glassmorphism & Elevation */
  --glass-bg: rgba(8, 14, 26, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: blur(20px);

  /* Lines & Borders */
  --line: #1c2a44;
  --line-soft: #121c30;
  --line-bright: rgba(255, 255, 255, 0.14);

  /* Typography Scale */
  --f-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --f-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;

  /* Type scale — four roles, nothing in between. The previous build had 13
     sizes, five of them (10.5/11/11.5/12/12.5) doing the same job. */
  --t-display: 24px;
  --t-heading: 15px;
  --t-body: 13px;
  --t-caption: 11px;
  /* One border + one elevation, applied to every card without exception. */
  --border: 1px solid var(--line-soft);
  --elev: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-faint: #475569;

  /* Brand Accents */
  --cc: #f43f5e;
  --cc-grad: linear-gradient(135deg, #f43f5e, #9f1239);
  --cc-soft: rgba(244, 63, 94, 0.14);
  --cc-glow: rgba(244, 63, 94, 0.25);

  --jl: #14b8a6;
  --jl-grad: linear-gradient(135deg, #14b8a6, #0f766e);
  --jl-soft: rgba(20, 184, 166, 0.14);
  --jl-glow: rgba(20, 184, 166, 0.25);

  /* Status Colors */
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.14);
  --pending: #f59e0b;
  --pending-soft: rgba(245, 158, 11, 0.14);
  --warn: #f97316;
  --err: #ef4444;
  --err-soft: rgba(239, 68, 68, 0.14);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.14);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.14);

  /* Spacing Scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Border Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-full: 9999px;

  /* Elevation Shadows */
  --sh-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --sh-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --sh-lg: 0 16px 48px rgba(0, 0, 0, 0.7);

  /* Transitions & Animation Duration */
  --dur-fast: 150ms;
  --dur-base: 220ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Global Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

body.app-body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--f-sans);
  font-size: var(--t-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Accessible Focus Ring */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--info) !important;
  outline-offset: 2px !important;
}

/* ---------- Login Screen ---------- */
.login {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-4);
}
.login.hidden { display: none; }

.login-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-8);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--sh-lg);
  text-align: center;
  animation: fadeIn var(--dur-base) var(--ease);
}

.logo-mark {
  display: inline-flex;
  margin-bottom: var(--sp-4);
}
.logo-dot {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--cc-grad);
  color: #fff;
  font-weight: 800;
  font-size: var(--t-display);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px var(--cc-glow);
}

.login-card h1 {
  font-size: var(--t-display);
  font-weight: 800;
  margin: 0 0 var(--sp-1) 0;
  letter-spacing: -0.02em;
}
.login-card h1 span { color: var(--cc); }
.login-card p {
  color: var(--text-secondary);
  font-size: var(--t-body);
  margin: 0 0 var(--sp-6) 0;
}

.input-wrap {
  position: relative;
  margin-bottom: var(--sp-4);
}
.input-ico {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.input-wrap input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px 12px 42px;
  color: var(--text-primary);
  font-family: var(--f-sans);
  font-size: var(--t-heading);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease);
}
.input-wrap input:focus { border-color: var(--info); }

.btn-primary {
  width: 100%;
  background: var(--info);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 12px var(--sp-4);
  font-family: var(--f-sans);
  font-size: var(--t-heading);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  transition: background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn-primary:hover { background: #2563eb; }
.btn-primary:active { transform: scale(0.98); }

.err-line {
  color: var(--err);
  font-size: var(--t-body);
  margin-top: var(--sp-3);
  min-height: 18px;
}

/* ---------- 2026 Workspace App Shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg-app);
}
.app-shell.hidden { display: none; }

/* Collapsible Left Navigation Dock */
.app-dock {
  width: 260px;
  background: var(--surface-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
}

.dock-header {
  padding: var(--sp-5) var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
}
.dock-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.dock-brand-text {
  display: flex;
  flex-direction: column;
}
.dock-title {
  font-size: var(--t-body);
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}
.dock-sub {
  font-size: var(--t-caption);
  font-weight: 700;
  color: var(--cc);
  letter-spacing: 0.08em;
}

.dock-nav {
  padding: var(--sp-4) var(--sp-3);
  flex: 1;
  overflow-y: auto;

  /* Custom Scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.nav-section-label {
  font-size: var(--t-caption);
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-1);
}

.dock-item {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 10px 12px;
  color: var(--text-secondary);
  font-family: var(--f-sans);
  font-size: var(--t-body);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-1);
  text-align: left;
  transition: all var(--dur-fast) var(--ease);
}
.dock-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.dock-item.active {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--line-bright);
  box-shadow: var(--sh-sm);
}
.dock-item svg {
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease);
}
.dock-item:hover svg, .dock-item.active svg {
  color: var(--info);
}

.badge-count {
  margin-left: auto;
  background: var(--pending-soft);
  color: var(--pending);
  font-family: var(--f-mono);
  font-size: var(--t-caption);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-full);
}

.dock-footer {
  padding: var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.dock-cmd-btn {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px 12px;
  color: var(--text-secondary);
  font-family: var(--f-sans);
  font-size: var(--t-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  transition: all var(--dur-fast) var(--ease);
}
.dock-cmd-btn:hover {
  border-color: var(--line-bright);
  color: var(--text-primary);
}
.dock-cmd-btn kbd {
  margin-left: auto;
  background: var(--surface-3);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  font-family: var(--f-mono);
  font-size: var(--t-caption);
  color: var(--text-muted);
}

.dock-status {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--t-caption);
  color: var(--text-muted);
}
.live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse 2s infinite;
}

/* ---------- Main Layout Area & Top Header ---------- */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  height: 64px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--line);
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-left {
  display: flex;
  flex-direction: column;
}
.view-title {
  font-size: var(--t-heading);
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.01em;
}
.view-subtitle {
  font-size: var(--t-caption);
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.client-chips {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-caption);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--r-full);
}
.chip.cc { background: var(--cc-soft); color: var(--cc); border: 1px solid rgba(244, 63, 94, 0.3); }
.chip.jl { background: var(--jl-soft); color: var(--jl); border: 1px solid rgba(20, 184, 166, 0.3); }
.chip .swatch { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 6px 12px;
  color: var(--text-secondary);
  font-family: var(--f-sans);
  font-size: var(--t-body);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--dur-fast) var(--ease);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--line-bright);
}

/* ---------- Workspace View Container & Motion ---------- */
.app-stage {
  padding: var(--sp-6);
  flex: 1;
}

.workspace-view {
  display: none;
  opacity: 0;
  animation: viewFadeIn var(--dur-base) var(--ease) forwards;
}
.workspace-view.active {
  display: block;
}

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

/* ---------- General Cards & Layout Blocks ---------- */
.block { margin-bottom: var(--sp-6); }

.card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--sh-sm);
  transition: border-color var(--dur-fast) var(--ease);
}
.card:hover { border-color: var(--line-bright); }

.card-header {
  margin-bottom: var(--sp-4);
}
.card-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.card-title-group {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.card-title-group h2 {
  font-size: var(--t-heading);
  font-weight: 700;
  margin: 0;
}
.card-subtitle {
  font-size: var(--t-body);
  color: var(--text-muted);
  margin: var(--sp-1) 0 0 0;
}

.count-pill {
  background: var(--surface-3);
  color: var(--text-secondary);
  font-family: var(--f-mono);
  font-size: var(--t-caption);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-full);
}

/* Title Accents */
.title-ico { color: var(--info); }
.title-ico.accent-pending { color: var(--pending); }
.title-ico.accent-purple { color: var(--purple); }
.title-ico.accent-teal { color: var(--jl); }
.title-ico.accent-pink { color: var(--cc); }
.title-ico.accent-ok { color: var(--ok); }
.title-ico.accent-warn { color: var(--warn); }
.title-ico.accent-cc { color: var(--cc); }
.title-ico.accent-jl { color: var(--jl); }

/* Grid Utilities */
.grid { display: grid; gap: var(--sp-5); }
.grid.g-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* ---------- KPI Banner ---------- */
.kpi-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
}
.kpi-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  box-shadow: var(--sh-sm);
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--line-bright); }

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-icon.pending { background: var(--pending-soft); color: var(--pending); }
.kpi-icon.agents { background: var(--purple-soft); color: var(--purple); }
.kpi-icon.spend { background: var(--ok-soft); color: var(--ok); }
.kpi-icon.leads { background: var(--info-soft); color: var(--info); }

.kpi-data { display: flex; flex-direction: column; }
.kpi-label { font-size: var(--t-caption); color: var(--text-muted); font-weight: 600; }
.kpi-val { font-family: var(--f-mono); font-size: var(--t-display); font-weight: 700; color: var(--text-primary); }
.kpi-val.ok { color: var(--ok); }

/* ---------- Video Prompts Studio Workspace ---------- */
.prompt-controls-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.prompt-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 240px;
}
.prompt-search-wrap .search-ico {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}
.prompt-search-in {
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-full);
  padding: 6px 12px 6px 32px;
  font-family: var(--f-sans);
  font-size: var(--t-body);
  color: var(--text-primary);
  outline: none;
  transition: all var(--dur-fast) var(--ease);
}
.prompt-search-in:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-soft);
}

.prompt-filter-bar {
  display: flex;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--r-full);
  border: 1px solid var(--line-soft);
}
.filter-pill {
  background: transparent;
  border: none;
  border-radius: var(--r-full);
  padding: 4px 12px;
  font-family: var(--f-sans);
  font-size: var(--t-caption);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.filter-pill:hover { color: var(--text-primary); }
.filter-pill.active {
  background: var(--surface-3);
  color: var(--text-primary);
  box-shadow: var(--sh-sm);
}

.prompts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}

.prompt-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  box-shadow: var(--sh-sm);
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.prompt-card:hover { border-color: var(--line-bright); transform: translateY(-2px); }

.prompt-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.prompt-post-title { font-size: var(--t-heading); font-weight: 700; color: var(--text-primary); }

.prompt-text {
  background: var(--surface-3);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  font-family: var(--f-mono);
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  user-select: text;
}

.prompt-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--t-caption);
  color: var(--text-muted);
}

.btn-copy {
  background: var(--purple-soft);
  color: var(--purple);
  border: 1px solid rgba(168, 85, 247, 0.3);
  font-size: var(--t-body);
  font-weight: 700;
  padding: 9px 14px;
  border-radius: var(--r-sm);
  width: 100%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--dur-fast) var(--ease);
}
.btn-copy:hover {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.3);
}
.btn-copy:active { transform: scale(0.98); }
.btn-copy.copied { background: var(--ok); color: #042f2e; border-color: var(--ok); }

/* ---------- Neural Graph & Chat Desk ---------- */
.flow-stage-wrap {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  overflow: hidden;
  height: 480px;
}
.nmap { width: 100%; height: 100%; }

.chat-card { display: flex; flex-direction: column; }
.chat-tabs { display: flex; gap: var(--sp-2); overflow-x: auto; margin-bottom: var(--sp-3); }
.chat-tab {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-full);
  padding: 4px 10px;
  font-size: var(--t-caption);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.chat-tab.active { background: var(--purple-soft); color: var(--purple); border-color: rgba(168, 85, 247, 0.3); }

.chat-log {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  height: 280px;
  overflow-y: auto;
  margin-bottom: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.chat-msg { max-width: 85%; padding: 8px 12px; border-radius: var(--r-md); font-size: var(--t-body); }
.chat-msg.me { align-self: flex-end; background: var(--info); color: #fff; }
.chat-msg.ai { align-self: flex-start; background: var(--surface-3); color: var(--text-primary); border: 1px solid var(--line-soft); }

.composer { display: flex; gap: var(--sp-2); }
.composer-in-wrap { position: relative; flex: 1; display: flex; align-items: center; }
.composer-in-wrap input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 9px 60px 9px 12px;
  color: var(--text-primary);
  font-family: var(--f-sans);
  font-size: var(--t-body);
  outline: none;
}
.composer-in-wrap input:focus { border-color: var(--info); }
.char-count { position: absolute; right: 12px; font-family: var(--f-mono); font-size: var(--t-caption); color: var(--text-muted); pointer-events: none; }

.btn-sm { padding: 8px 14px; font-size: var(--t-body); }

/* ---------- Pipelines & Lead Analytics ---------- */
.tiles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--sp-3); }
.tile {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
}
.tile b { font-family: var(--f-mono); font-size: var(--t-display); color: var(--text-primary); }
.tile span { font-size: var(--t-caption); color: var(--text-muted); }

.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.col { background: var(--surface-2); border-radius: var(--r-md); padding: var(--sp-2); }
.col-h { font-size: var(--t-caption); font-weight: 700; color: var(--text-muted); padding: var(--sp-2); display: flex; justify-content: space-between; }
.post { background: var(--surface-3); border-radius: var(--r-sm); padding: var(--sp-2); margin-bottom: var(--sp-2); font-size: var(--t-caption); }

/* ---------- Command Palette Dialog ---------- */
.palette-modal {
  background: transparent;
  border: none;
  padding: 0;
}
.palette-modal::backdrop { background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(8px); }

.palette-card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 540px;
  box-shadow: var(--sh-lg);
  overflow: hidden;
}
.palette-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
}
.palette-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--f-sans);
  font-size: var(--t-heading);
  outline: none;
}
.palette-results { max-height: 320px; overflow-y: auto; padding: var(--sp-2); }
.palette-item {
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.palette-item:hover, .palette-item.active { background: var(--surface-3); color: var(--text-primary); }

/* ---------- Keyframes ---------- */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ==========================================================================
   3D NEURAL ENGINE — stage, labels, inspector
   These rules were absent after the 26 Jul rewrite, which is why the canvas
   rendered at its intrinsic buffer size (2752px) inside a ~1290px card and we
   were looking at a magnified crop. Absolute-fill restores the real framing.
   ========================================================================== */
.flow-stage-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;   /* Mac-first: use the width */
  gap: var(--sp-4);
  align-items: stretch;
}
.flow-stage {
  position: relative;
  min-width: 0;
  height: clamp(460px, 72vh, 860px);             /* the scene gets real room */
  border-radius: var(--r-md);
  border: var(--border);
  overflow: hidden;
  background: #05070c;
}
#flowMap.nmap.has3d { position: absolute; inset: 0; padding: 0; }
.n3d-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.n3d-canvas:active { cursor: grabbing; }
.n3d-labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.n3d-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap;
  font-size: var(--t-caption); font-weight: 600; letter-spacing: .01em;
  color: var(--text-secondary);
  padding: 3px 8px 3px 7px; border-radius: var(--r-sm);
  background: rgba(5, 8, 14, .55);
  border: 1px solid transparent; border-left: 2px solid var(--nc, var(--text-faint));
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
  will-change: transform, opacity;
}
.n3d-label.is-hot { color: var(--text-primary); background: rgba(10, 16, 28, .92); border-color: var(--line-bright); }
.n3d-label.is-gate { color: var(--text-primary); }
.n3d-label.is-off { color: var(--text-faint); }

/* Hover inspector — fixed corner panel, never occludes the node being read. */
.node-inspect {
  position: absolute; left: var(--sp-4); bottom: var(--sp-4); width: 268px;
  background: rgba(8, 13, 24, .92); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: var(--border); border-radius: var(--r-md); padding: var(--sp-4);
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.node-inspect.is-on { opacity: 1; transform: none; }
.ni-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-1); }
.ni-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.ni-name { font-size: var(--t-heading); font-weight: 700; color: var(--text-primary); }
.ni-state { margin-left: auto; font-size: var(--t-caption); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.ni-state.live { color: var(--ok); } .ni-state.idle { color: var(--text-muted); } .ni-state.off { color: var(--text-faint); }
.ni-role { font-size: var(--t-caption); color: var(--text-secondary); line-height: 1.5; margin-bottom: var(--sp-3); }
.ni-stats { display: flex; flex-direction: column; gap: 5px; padding-top: var(--sp-3); border-top: var(--border); }
.ni-stat { display: flex; align-items: baseline; justify-content: space-between; }
.ni-k { font-size: var(--t-caption); color: var(--text-muted); }
.ni-v { font-size: var(--t-body); font-weight: 700; color: var(--text-primary);
        font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.ni-hint { margin-top: var(--sp-3); font-size: var(--t-caption); color: var(--text-faint); }

/* Signal-path list beside the scene */
.flow-side { display: flex; flex-direction: column; min-width: 0; }
.flow-side-h {
  font-size: var(--t-caption); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); padding-bottom: var(--sp-3);
}
.flow-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: clamp(420px, 68vh, 820px);
             scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.flow-list .nlink {
  text-align: left; width: 100%; cursor: pointer;
  background: var(--surface-2); border: var(--border); border-left: 2px solid var(--line);
  border-radius: var(--r-sm); padding: var(--sp-3);
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.flow-list .nlink:hover { background: var(--surface-3); border-left-color: var(--info); }
.flow-list .nlink.live { border-left-color: var(--info); }
.flow-list .nlink.dormant { opacity: .55; }
.flow-list .nlink.sel { background: var(--surface-3); border-color: var(--line-bright); border-left-color: var(--info); }
.flow-list .nl-path { font-size: var(--t-body); font-weight: 600; color: var(--text-primary); }
.flow-list .nl-sig { font-size: var(--t-caption); color: var(--text-secondary); margin-top: 3px; line-height: 1.45; }

@media (max-width: 1180px) { .flow-stage-wrap { grid-template-columns: 1fr; } .flow-list { max-height: 260px; } }
@media (max-width: 720px) { .flow-stage { height: 380px; } .node-inspect { display: none; } }
@media (prefers-reduced-motion: reduce) { .n3d-label, .node-inspect { transition: none; } }

/* Data numerals line up everywhere they are compared. */
.ni-v, .kpi-val, .tile b, .mono, .nl-count { font-variant-numeric: tabular-nums; }

/* ---------------- control room: action log ---------------- */
.audit-list { display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow-y: auto; scrollbar-width: thin; }
.audit-row { display: grid; grid-template-columns: 110px 170px 130px 1fr 120px; gap: var(--sp-3); align-items: baseline;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 8px 12px; }
.au-ts { font-family: var(--f-mono); font-size: var(--t-caption); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.au-action { font-size: var(--t-body); font-weight: 700; color: var(--text-primary); }
.au-target { font-family: var(--f-mono); font-size: var(--t-caption); color: var(--text-secondary); }
.au-detail { font-size: var(--t-caption); color: var(--text-secondary); line-height: 1.45; }
.au-actor { font-size: var(--t-caption); color: var(--text-faint); text-align: right; }
@media (max-width: 900px) { .audit-row { grid-template-columns: 1fr 1fr; } .au-detail { grid-column: 1 / -1; } }
