/* ============================================================
   NEXUS CONTROL — Institutional finance theme (modernised)
   Clean, trustworthy, slightly premium. Bootstrap 5 overrides.
   ============================================================ */

:root {
  --nx-navy: #0d1b2e;
  --nx-navy-2: #14263f;
  --nx-accent: #2f6fed;
  --nx-accent-soft: #eaf1fe;
  --nx-gold: #c9a227;
  --nx-bg: #f5f7fb;
  --nx-border: #e6eaf2;
  --nx-border-strong: #d7deea;
  --nx-text: #1c2a3a;
  --nx-muted: #64748b;
  --nx-radius: 14px;
  --nx-radius-sm: 9px;
  --nx-shadow-sm: 0 1px 2px rgba(13, 27, 46, 0.05);
  --nx-shadow: 0 8px 24px rgba(13, 27, 46, 0.08);
  --nx-font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

html, body { height: 100%; }

.nx-body {
  background:
    radial-gradient(1200px 400px at 80% -10%, rgba(47, 111, 237, 0.06), transparent 60%),
    var(--nx-bg);
  color: var(--nx-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: var(--nx-font);
  -webkit-font-smoothing: antialiased;
}

main { flex: 1 0 auto; }

h1, h2, h3, h4, h5, .card-header { letter-spacing: -0.01em; }

/* Consistent, accessible focus rings */
:focus-visible {
  outline: 2px solid var(--nx-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- Navbar ---- */
.nx-navbar {
  background: linear-gradient(90deg, var(--nx-navy) 0%, var(--nx-navy-2) 100%);
  border-bottom: 1px solid rgba(201, 162, 39, 0.55);
  box-shadow: 0 2px 14px rgba(13, 27, 46, 0.25);
  backdrop-filter: saturate(140%);
}
.nx-navbar .nav-link {
  color: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 0.42rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease, background 0.15s ease;
}
.nx-navbar .nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.nx-navbar .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  box-shadow: inset 0 -2px 0 var(--nx-gold);
}
.nx-logo { color: var(--nx-gold); font-size: 1.35rem; line-height: 1; }
.nx-tagline { color: rgba(255, 255, 255, 0.55); font-weight: 400; font-size: 0.75rem; transition: color 0.15s ease; }
a.nx-tagline:hover { color: var(--nx-gold); }

/* Navbar dropdowns */
.nx-navbar .dropdown-toggle::after { margin-left: 0.4rem; opacity: 0.7; }
.nx-dropdown {
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-sm);
  box-shadow: var(--nx-shadow);
  padding: 0.35rem;
  margin-top: 0.4rem;
  min-width: 12rem;
}
.nx-dropdown .dropdown-item {
  border-radius: 7px;
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--nx-text);
}
.nx-dropdown .dropdown-item:hover { background: var(--nx-accent-soft); color: var(--nx-accent); }
.nx-dropdown .dropdown-item.active { background: var(--nx-accent); color: #fff; }
.nx-dropdown .dropdown-item.text-danger:hover { background: #fdecee; color: #a02734 !important; }
.nx-dropdown .dropdown-item-text { padding: 0.35rem 0.7rem; line-height: 1.3; }

/* ---- Footer ---- */
.nx-footer {
  background: var(--nx-navy);
  color: rgba(255, 255, 255, 0.65);
  border-top: 2px solid var(--nx-gold);
}
.nx-footer .text-muted { color: rgba(255, 255, 255, 0.4) !important; }

/* ---- Auth screens ---- */
.nx-auth-wrap { min-height: calc(100vh - 120px); padding: 2rem 1rem; }
.nx-auth-card { width: 100%; max-width: 440px; border-radius: 14px; }
.nx-auth-logo {
  width: 64px; height: 64px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px; font-size: 2rem; color: #fff;
  background: linear-gradient(135deg, var(--nx-navy) 0%, var(--nx-accent) 100%);
}

/* ---- Cards / stats ---- */
.card {
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius);
  box-shadow: var(--nx-shadow-sm);
}
.card-header {
  background: #fff;
  font-weight: 600;
  border-bottom: 1px solid #eef1f6;
  border-radius: var(--nx-radius) var(--nx-radius) 0 0 !important;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}
.card-footer { background: #fbfcfe; border-top: 1px solid #eef1f6; }
.btn { border-radius: var(--nx-radius-sm); }
.form-control, .form-select { border-radius: var(--nx-radius-sm); border-color: var(--nx-border-strong); }
.form-control:focus, .form-select:focus {
  border-color: var(--nx-accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}
.nx-stat-card { transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; }
.nx-stat-card:hover { transform: translateY(-3px); box-shadow: var(--nx-shadow); border-color: var(--nx-border-strong); }
.nx-stat-icon {
  width: 46px; height: 46px; flex: 0 0 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 1.3rem;
}
.nx-stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.nx-stat-label { font-size: 0.74rem; color: var(--nx-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

.nx-badge-live { background: #e7f5ee; color: #157347; font-weight: 600; padding: 0.5rem 0.8rem; border-radius: 50rem; }
.nx-badge-live i { animation: nx-pulse 2s ease-in-out infinite; }
@keyframes nx-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---- Tables ---- */
.nx-table { font-size: 0.875rem; }
.nx-table thead th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600; color: var(--nx-muted); background: #f8fafd;
  border-bottom: 1px solid var(--nx-border);
  padding-top: 0.7rem; padding-bottom: 0.7rem;
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.nx-table thead th:first-child, .nx-table tbody td:first-child { padding-left: 1.25rem; }
.nx-table thead th:last-child,  .nx-table tbody td:last-child  { padding-right: 1.25rem; }
.nx-table tbody td { padding-top: 0.7rem; padding-bottom: 0.7rem; border-color: #eef1f6; }
.nx-table tbody tr { transition: background 0.12s ease; }
.nx-table tbody tr:hover { background: #f6f9ff; box-shadow: inset 3px 0 0 var(--nx-accent); }
.nx-table tbody tr:last-child td { border-bottom: 0; }
.nx-table .text-end, .nx-table td[data-num] { font-variant-numeric: tabular-nums; }

/* Sortable columns (enhanced by app.js) */
.nx-table th[data-sort] { cursor: pointer; user-select: none; transition: color 0.12s ease; }
.nx-table th[data-sort]:hover { color: var(--nx-accent); }
.nx-table th[data-sort]::after {
  content: "\2195"; /* ↕ */
  margin-left: 0.35rem; opacity: 0.35; font-size: 0.8em;
}
.nx-table th[data-sort].nx-sorted-asc::after  { content: "\2191"; opacity: 1; color: var(--nx-accent); }
.nx-table th[data-sort].nx-sorted-desc::after { content: "\2193"; opacity: 1; color: var(--nx-accent); }

/* Table toolbar (search + meta) */
.nx-table-toolbar { gap: 0.75rem; }
.nx-table-search { position: relative; }
.nx-table-search > i {
  position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%);
  color: var(--nx-muted); font-size: 0.85rem; pointer-events: none;
}
.nx-table-search > input {
  padding-left: 2.1rem; min-width: 220px;
  border-radius: 50rem; font-size: 0.85rem;
  background: #fbfcfe;
}
.nx-table-count { font-size: 0.78rem; color: var(--nx-muted); white-space: nowrap; }

.nx-reason { max-width: 340px; }
.nx-vol-bar { width: 70px; height: 6px; border-radius: 50rem; }

/* ---- Status / event badges (soft pills with status dot) ---- */
[class*="nx-status-"], [class*="nx-action-"], .nx-event-badge {
  border-radius: 50rem;
  font-weight: 600;
  padding: 0.32em 0.75em;
}
[class*="nx-status-"]::before {
  content: "";
  display: inline-block;
  width: 0.45em; height: 0.45em;
  border-radius: 50%;
  background: currentColor;
  margin-right: 0.45em;
  vertical-align: 0.08em;
}

.nx-status-pending       { background: #fff3cd; color: #8a6d1a; }
.nx-status-approved      { background: #d1e7dd; color: #146c43; }
.nx-status-auto_approved { background: #cfe2ff; color: #1f4fa8; }
.nx-status-rejected      { background: #f8d7da; color: #a02734; }
.nx-status-blocked       { background: #e2e3e5; color: #495057; }
.nx-status-active        { background: #d1e7dd; color: #146c43; }
.nx-status-paused        { background: #e2e3e5; color: #495057; }

/* Role badges (RBAC) */
.nx-role-badge { border-radius: 50rem; font-weight: 600; padding: 0.32em 0.75em; }
.nx-role-admin    { background: #f3e0d0; color: #8a4b1a; }
.nx-role-operator { background: #cfe2ff; color: #1f4fa8; }
.nx-role-viewer   { background: #e2e3e5; color: #495057; }

/* Read-only indicator in the app navbar (viewer / demo account) */
.nx-readonly-badge {
  display: inline-flex; align-items: center;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 0.3em 0.7em; border-radius: 50rem;
  color: var(--nx-gold);
  background: rgba(201, 162, 39, 0.14);
  border: 1px solid rgba(201, 162, 39, 0.4);
  white-space: nowrap;
}

.nx-action-buy       { background: #d1e7dd; color: #146c43; }
.nx-action-sell      { background: #f8d7da; color: #a02734; }
.nx-action-rebalance { background: #cfe2ff; color: #1f4fa8; }
.nx-action-transfer  { background: #e7dcf5; color: #5d3d92; }

.nx-event-badge { font-weight: 600; text-transform: capitalize; }
.nx-event-agent_run            { background: #cfe2ff; color: #1f4fa8; }
.nx-event-proposal_created     { background: #fff3cd; color: #8a6d1a; }
.nx-event-policy_check         { background: #e7f5ee; color: #157347; }
.nx-event-policy_block         { background: #f8d7da; color: #a02734; }
.nx-event-action_approved      { background: #d1e7dd; color: #146c43; }
.nx-event-action_auto_approved { background: #cfe2ff; color: #1f4fa8; }
.nx-event-action_rejected      { background: #f8d7da; color: #a02734; }
.nx-event-portfolio_update     { background: #e7dcf5; color: #5d3d92; }
.nx-event-settings_change      { background: #e2e3e5; color: #495057; }
.nx-event-simulation_reset     { background: #ffe5d0; color: #a05a1c; }
.nx-event-auth                 { background: #e2e3e5; color: #495057; }

/* ---- Audit reasoning callout ---- */
.nx-reasoning {
  background: linear-gradient(90deg, #fdfaf1 0%, #f8fafc 30%);
  border-left: 3px solid var(--nx-gold);
  padding: 0.55rem 0.8rem; border-radius: 0 var(--nx-radius-sm) var(--nx-radius-sm) 0;
  color: #4a5568;
}

/* ---- Policies ---- */
.nx-policy-global { border: 1px solid var(--nx-accent); box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.08); }

/* ---- Empty states ---- */
.nx-empty { color: #8b98ab; }
.nx-empty i { color: #c4cddb; }

/* ---- Run-agent inline results ---- */
.nx-run-result {
  font-size: 0.8rem; border-radius: var(--nx-radius-sm); padding: 0.6rem 0.75rem;
  animation: nx-fade-up 0.25s ease;
}
.nx-run-result.ok { background: #e7f5ee; color: #157347; }
.nx-run-result.warn { background: #fff3cd; color: #8a6d1a; }
.nx-run-result.err { background: #f8d7da; color: #a02734; }

@keyframes nx-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Pills ---- */
.nx-pills .nav-link {
  font-size: 0.85rem; padding: 0.35rem 0.9rem; border-radius: 50rem;
  color: var(--nx-muted); transition: background 0.15s ease, color 0.15s ease;
}
.nx-pills .nav-link:hover { background: var(--nx-accent-soft); color: var(--nx-accent); }
.nx-pills .nav-link.active { background: var(--nx-accent); }

/* ---- Relative timestamps ---- */
time[data-nx-time] { cursor: default; border-bottom: 1px dotted transparent; }
time[data-nx-time]:hover { border-bottom-color: currentColor; }

/* ---- Subtle custom scrollbars for table overflow ---- */
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--nx-border-strong); border-radius: 50rem; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }

/* ---- Respect reduced-motion preference ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================
   Landing page (product website)
   ============================================================ */
/* Solid dark base at the body level so the page never renders
   white behind the landing content (even mid-load). */
.nx-body.nx-landing-body { background: #0a1524; color: #dbe4f0; }

.nx-landing {
  background:
    radial-gradient(900px 500px at 15% -5%, rgba(47, 111, 237, 0.28), transparent 60%),
    radial-gradient(800px 480px at 90% 10%, rgba(201, 162, 39, 0.16), transparent 55%),
    radial-gradient(700px 500px at 50% 110%, rgba(47, 111, 237, 0.18), transparent 60%),
    linear-gradient(180deg, #0a1524 0%, #0d1b2e 55%, #0a1524 100%);
  color: #dbe4f0;
}

.nx-landing-nav { background: rgba(10, 21, 36, 0.75); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255,255,255,0.06); }
.nx-landing-nav .nav-link { color: rgba(255,255,255,0.7); font-size: 0.92rem; font-weight: 500; white-space: nowrap; }
.nx-landing-nav .nav-link:hover { color: #fff; }
.nx-landing-nav .btn { white-space: nowrap; }

/* Glowing primary CTA */
.nx-btn-glow {
  background: linear-gradient(135deg, var(--nx-accent) 0%, #6d9bff 100%);
  color: #fff;
  border: 0;
  font-weight: 600;
  box-shadow: 0 0 24px rgba(47, 111, 237, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.nx-btn-glow:hover { color: #fff; transform: translateY(-2px); box-shadow: 0 0 36px rgba(47, 111, 237, 0.65); }

/* Hero */
.nx-hero { padding: 6rem 1rem 5rem; }
.nx-hero-badge {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 50rem;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(201, 162, 39, 0.1);
  color: var(--nx-gold);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.nx-hero-title { font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 800; letter-spacing: -0.02em; color: #fff; line-height: 1.12; }
.nx-gradient-text {
  background: linear-gradient(90deg, #6d9bff 0%, #c9a227 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.nx-hero-sub { max-width: 640px; font-size: 1.08rem; color: rgba(219, 228, 240, 0.75); }
.nx-hero-note { color: rgba(219, 228, 240, 0.5); }
.nx-hero-note code { color: var(--nx-gold); background: rgba(201, 162, 39, 0.1); padding: 0.15em 0.45em; border-radius: 6px; }

.nx-hero-stat {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--nx-radius);
  padding: 1rem 0.75rem;
  backdrop-filter: blur(6px);
}
.nx-hero-stat-value { font-size: 1.6rem; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.nx-hero-stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: rgba(219, 228, 240, 0.55); font-weight: 600; }

/* Sections */
.nx-section { padding: 5rem 0; }
.nx-section-alt { background: rgba(255, 255, 255, 0.025); border-top: 1px solid rgba(255,255,255,0.05); border-bottom: 1px solid rgba(255,255,255,0.05); }
.nx-section h2 { color: #fff; letter-spacing: -0.02em; }
.nx-section-kicker {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--nx-gold);
  margin-bottom: 0.5rem;
}
.nx-section-sub { max-width: 560px; color: rgba(219, 228, 240, 0.65) !important; }

/* Pipeline step cards */
.nx-step-card {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--nx-radius);
  padding: 1.75rem 1.5rem 1.5rem;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.nx-step-card:hover { transform: translateY(-4px); border-color: rgba(109, 155, 255, 0.4); background: rgba(47, 111, 237, 0.07); }
.nx-step-card h5 { color: #fff; }
.nx-step-card p { color: rgba(219, 228, 240, 0.65); }
.nx-step-num {
  position: absolute; top: 1.1rem; right: 1.25rem;
  font-size: 0.8rem; font-weight: 700; color: rgba(219, 228, 240, 0.25);
  letter-spacing: 0.1em;
}
.nx-step-icon {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 1.3rem; margin-bottom: 1rem;
  background: rgba(47, 111, 237, 0.15); color: #6d9bff;
  border: 1px solid rgba(109, 155, 255, 0.25);
}

/* Feature cards */
.nx-feature-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(13, 27, 46, 0.5);
  border-radius: var(--nx-radius);
  padding: 1.5rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.nx-feature-card:hover { transform: translateY(-4px); border-color: rgba(201, 162, 39, 0.4); }
.nx-feature-card h6 { color: #fff; }
.nx-feature-card p { color: rgba(219, 228, 240, 0.65); }
.nx-feature-icon {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px; font-size: 1.15rem; margin-bottom: 0.9rem;
  background: rgba(201, 162, 39, 0.12); color: var(--nx-gold);
  border: 1px solid rgba(201, 162, 39, 0.25);
}

/* Agent cards */
.nx-agent-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--nx-radius);
  padding: 1.5rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.nx-agent-card:hover { transform: translateY(-4px); border-color: var(--nx-agent-c, #6d9bff); }
.nx-agent-card h5 { color: #fff; }
.nx-agent-card p { color: rgba(219, 228, 240, 0.65); }
.nx-agent-icon {
  width: 46px; height: 46px; flex: 0 0 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 1.3rem;
  color: var(--nx-agent-c, #6d9bff);
  background: color-mix(in srgb, var(--nx-agent-c, #6d9bff) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--nx-agent-c, #6d9bff) 30%, transparent);
}

/* CTA band */
.nx-cta {
  padding: 5rem 1rem 6rem;
  background: radial-gradient(700px 320px at 50% 20%, rgba(47, 111, 237, 0.22), transparent 65%);
}
.nx-cta h2 { color: #fff; }

/* Check list inside feature cards */
.nx-check-list { list-style: none; padding: 0; margin: 0; color: rgba(219, 228, 240, 0.7); }
.nx-check-list li { position: relative; padding-left: 1.4rem; margin-bottom: 0.35rem; }
.nx-check-list li:last-child { margin-bottom: 0; }
.nx-check-list li::before {
  content: "\F26E"; font-family: "bootstrap-icons";
  position: absolute; left: 0; top: 0; color: var(--nx-gold);
  font-size: 0.85rem;
}

/* Sign-up band */
.nx-signup-band {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--nx-radius);
  padding: 3rem 1.5rem;
  background:
    radial-gradient(600px 260px at 50% 0%, rgba(47, 111, 237, 0.2), transparent 65%),
    rgba(13, 27, 46, 0.55);
}
.nx-signup-band h3 { color: #fff; }
