/* ==========================================================================
   SyncRelay dashboard — Enhanced Edition
   A dark instrument panel: glass surfaces over a deep field, neon only where
   it carries meaning. Colour is load-bearing — cyan is neutral data,
   magenta is a hot lead, amber is caution, red is a failing score.

   Enhanced with:
   - Particle constellation background
   - Animated info-tip system on every control
   - 3D card hover effects with glow borders
   - Neon priority score glows
   - Magnetic button interactions
   - Aurora gradient overlays
   - Smooth view transitions with parallax
   - Animated data loading states
   ========================================================================== */

:root {
  --bg:          #04060d;
  --bg-2:        #070b16;
  --panel-bg-a:  rgba(20, 28, 50, 0.66);
  --panel-bg-b:  rgba(9, 13, 25, 0.72);
  --line:        rgba(122, 162, 255, 0.14);
  --line-soft:   rgba(122, 162, 255, 0.07);

  --text:        #e7ecff;
  --muted:       #8794bb;
  --dim:         #5a6688;

  --cyan:        #34e6ff;
  --violet:      #a684ff;
  --magenta:     #ff5ce1;
  --lime:        #5ef7a4;
  --amber:       #ffc44d;
  --red:         #ff5470;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
          "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, "SF Mono",
          Consolas, "Liberation Mono", monospace;

  --r-sm: 8px;
  --r:    13px;
  --r-lg: 18px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --rail-w: 232px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
p  { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sprite { display: none; }

svg:not(.sprite) {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

/* ------------------------------------------------------------------ */
/* ambient background — enhanced with particles and aurora              */
/* ------------------------------------------------------------------ */
.bg-grid, .bg-glow, .bg-noise, .bg-particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

.bg-grid {
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 78%);
  animation: drift 34s linear infinite;
}
@keyframes drift { to { background-position: 56px 56px, 56px 56px; } }

.bg-glow { filter: blur(90px); opacity: 0.5; }
.bg-glow-a {
  background: radial-gradient(38rem 28rem at 12% -6%, rgba(52,230,255,0.22), transparent 70%);
  animation: float-a 24s ease-in-out infinite;
}
.bg-glow-b {
  background: radial-gradient(34rem 26rem at 88% 8%, rgba(166,132,255,0.20), transparent 70%);
  animation: float-b 30s ease-in-out infinite;
}
.bg-glow-c {
  background: radial-gradient(30rem 24rem at 50% 100%, rgba(255,92,225,0.10), transparent 70%);
  animation: float-c 28s ease-in-out infinite;
}
@keyframes float-a { 50% { transform: translate3d(4%, 3%, 0) scale(1.1); } }
@keyframes float-b { 50% { transform: translate3d(-5%, 4%, 0) scale(1.08); } }
@keyframes float-c { 50% { transform: translate3d(2%, -3%, 0) scale(1.05); } }

.bg-noise {
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.bg-particles {
  opacity: 0.35;
  z-index: 0;
}

/* ------------------------------------------------------------------ */
/* info-tip — reusable tooltip component                                */
/* ------------------------------------------------------------------ */
.info-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 5px;
  vertical-align: middle;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 15, 28, 0.7);
  color: var(--dim);
  cursor: help;
  transition: color 0.18s, border-color 0.18s, background 0.18s, transform 0.18s var(--ease-bounce);
  flex: none;
}
.info-tip svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.info-tip:hover,
.info-tip:focus-visible {
  color: var(--cyan);
  border-color: rgba(52, 230, 255, 0.5);
  background: rgba(52, 230, 255, 0.1);
  transform: scale(1.15);
  outline: none;
}
.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(6px);
  width: min(300px, 80vw);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(52, 230, 255, 0.25);
  background: rgba(6, 9, 18, 0.97);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 400;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.8), 0 0 30px -10px rgba(52,230,255,0.15);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s var(--ease), visibility 0.22s;
  z-index: 100;
  text-align: left;
  white-space: normal;
}
.info-tip:hover::after,
.info-tip:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
/* For info-tips near right edge, flip to left */
.info-tip[data-tip-align="left"]::after {
  left: auto;
  right: 0;
  transform: translateY(6px);
}
.info-tip[data-tip-align="left"]:hover::after,
.info-tip[data-tip-align="left"]:focus-visible::after {
  transform: translateY(0);
}
/* For info-tips in table headers, show below */
th .info-tip::after,
.h2 .info-tip::after,
h2 .info-tip::after {
  bottom: auto;
  top: calc(100% + 10px);
  transform: translateX(-50%) translateY(-6px);
}
th .info-tip:hover::after,
th .info-tip:focus-visible::after,
h2 .info-tip:hover::after,
h2 .info-tip:focus-visible::after {
  transform: translateX(-50%) translateY(0);
}

/* ------------------------------------------------------------------ */
/* shell                                                                */
/* ------------------------------------------------------------------ */
.shell {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
}

/* ---- left rail ---- */
.rail {
  /* position + z-index lift the whole rail (and its info-tip tooltips) above
     the main column's positioned cards; without it backdrop-filter confines
     tooltips to a stacking context that paints under the content.            */
  position: relative; z-index: 20;
  display: flex; flex-direction: column;
  padding: 22px 16px 16px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10,15,28,0.72), rgba(5,8,16,0.55));
  backdrop-filter: blur(14px);
}

.brand { display: flex; gap: 11px; align-items: center; padding: 0 6px 22px; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-mark svg { width: 38px; height: 38px; overflow: visible; }
.brand-mark .ring { fill: none; stroke: var(--cyan); stroke-width: 1.4; opacity: 0.5; }
.brand-mark .ring-2 { stroke: var(--violet); opacity: 0.65; }
.brand-mark .dot { fill: var(--magenta); stroke: none; filter: drop-shadow(0 0 6px var(--magenta)); }
.brand-mark .sweep {
  fill: url(#none); fill: rgba(52,230,255,0.16); stroke: none;
  transform-origin: 20px 20px; animation: sweep 4.5s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }

.brand-text b {
  display: block; font-size: 13px; font-weight: 700;
  letter-spacing: 0.16em; color: var(--text);
}
.brand-text b span { color: var(--cyan); }
.brand-text small { font-family: var(--mono); font-size: 10px; color: var(--dim); letter-spacing: 0.08em; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--muted);
  cursor: pointer; text-align: left;
  transition: color 0.22s, background 0.22s, transform 0.18s var(--ease), box-shadow 0.22s;
  position: relative;
}
.nav-item:hover {
  color: var(--text);
  background: rgba(122,162,255,0.06);
  transform: translateX(3px);
}
.nav-item.is-active {
  color: var(--text);
  background: rgba(52,230,255,0.09);
  box-shadow: 0 0 20px -8px rgba(52,230,255,0.2), inset 2px 0 0 0 var(--cyan);
}
.nav-item.is-active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 2px; border-radius: 2px;
  background: var(--cyan); box-shadow: 0 0 10px var(--cyan);
  animation: nav-glow 2s ease-in-out infinite;
}
@keyframes nav-glow { 50% { box-shadow: 0 0 18px var(--cyan); } }
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item .info-tip {
  margin-left: auto;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s, transform 0.2s var(--ease-bounce);
}
.nav-item:hover .info-tip,
.nav-item:focus-visible .info-tip {
  opacity: 1;
  transform: scale(1);
}

.rail-foot { margin-top: auto; display: grid; gap: 12px; }

.statusline {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: rgba(8,12,22,0.6);
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.12em; color: var(--muted);
}
.led {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--dim); box-shadow: 0 0 8px currentColor;
}
.led[data-state="idle"] { background: var(--lime); color: var(--lime); }
.led[data-state="run"]  {
  background: var(--cyan); color: var(--cyan);
  animation: pulse-led 1.1s ease-in-out infinite;
}
.led[data-state="err"]  { background: var(--red);  color: var(--red); }
@keyframes pulse-led {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px currentColor; }
  50% { opacity: 0.3; box-shadow: 0 0 20px currentColor; }
}

.rail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rail-meta > div {
  padding: 9px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: rgba(8,12,22,0.5);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.rail-meta > div:hover {
  border-color: rgba(52,230,255,0.2);
  box-shadow: 0 0 16px -6px rgba(52,230,255,0.15);
}
.rail-meta label { display: block; font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--dim); }
.rail-meta b { font-family: var(--mono); font-size: 16px; }

/* ---- main ---- */
.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(6,9,18,0.5);
  backdrop-filter: blur(12px);
}

.search { position: relative; flex: 1; max-width: 480px; }
.search svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--dim); width: 16px; height: 16px;
}
.search input {
  width: 100%; padding: 10px 14px 10px 38px;
  border-radius: 10px; border: 1px solid var(--line);
  background: rgba(10,15,28,0.7); color: var(--text);
  outline: none; transition: border-color 0.22s, box-shadow 0.22s, transform 0.18s;
}
.search input::placeholder { color: var(--dim); }
.search input:focus {
  border-color: rgba(52,230,255,0.45);
  box-shadow: 0 0 0 3px rgba(52,230,255,0.10), 0 0 30px -10px rgba(52,230,255,0.15);
  transform: translateY(-1px);
}

.topbar-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; }

/* ---- buttons — enhanced with glow and magnetic hover ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(16,23,40,0.7); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: transform 0.16s var(--ease), border-color 0.22s, background 0.22s, box-shadow 0.22s;
  position: relative;
  overflow: hidden;
}
.btn svg { width: 15px; height: 15px; flex: none; }
.btn:hover {
  border-color: rgba(122,162,255,0.3);
  background: rgba(24,33,56,0.8);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px -12px rgba(52,230,255,0.2);
}
.btn:active { transform: translateY(1px) scale(0.98); }
.btn-sm { padding: 7px 11px; font-size: 12px; }
.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--cyan), #4aa8ff 55%, var(--violet));
  color: #04121b; font-weight: 600;
  box-shadow: 0 6px 22px -8px rgba(52,230,255,0.7);
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 10px 30px -8px rgba(52,230,255,0.9), 0 0 20px -6px rgba(52,230,255,0.3);
  transform: translateY(-2px);
}
.btn-ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Ripple effect on button click */
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), rgba(255,255,255,0.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.btn:active::after { opacity: 1; transition: opacity 0s; }

.icon-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line); background: transparent;
  color: var(--muted); cursor: pointer; transition: 0.18s;
}
.icon-btn:hover { color: var(--text); border-color: rgba(122,162,255,0.3); transform: rotate(90deg); }

/* ---- views ---- */
.view { display: none; padding: 22px 26px 34px; overflow-y: auto; flex: 1; }
.view.is-active { display: block; animation: rise-in 0.4s var(--ease); }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px) scale(0.995); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- panel — enhanced with animated border glow ---- */
.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: linear-gradient(160deg, var(--panel-bg-a), var(--panel-bg-b));
  backdrop-filter: blur(18px) saturate(135%);
  padding: 18px;
  margin-bottom: 18px;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s var(--ease);
}
.panel::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px;
  border-radius: var(--r) var(--r) 0 0;
  background: linear-gradient(90deg, transparent, rgba(52,230,255,0.5), rgba(166,132,255,0.35), transparent);
  opacity: 0.6;
}
.panel::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--r) + 1px);
  background: linear-gradient(135deg, rgba(52,230,255,0), rgba(166,132,255,0), rgba(255,92,225,0));
  z-index: -1;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}
.panel:hover {
  border-color: rgba(122,162,255,0.22);
  box-shadow: 0 12px 40px -16px rgba(0,0,0,0.5), 0 0 30px -12px rgba(52,230,255,0.08);
  transform: translateY(-1px);
}
.panel:hover::after {
  opacity: 1;
  background: linear-gradient(135deg, rgba(52,230,255,0.08), rgba(166,132,255,0.05), rgba(255,92,225,0.03));
}
.panel-note { color: var(--muted); font-size: 12.5px; margin: 6px 0 14px; max-width: 74ch; }
.panel-actions { margin-top: 14px; display: flex; gap: 9px; align-items: center; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1180px) { .grid-2 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ */
/* stat strip — enhanced with glow and animated sparklines              */
/* ------------------------------------------------------------------ */
.stat-strip {
  display: grid; gap: 14px; margin-bottom: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(240px, 1.4fr);
}
@media (max-width: 1380px) { .stat-strip { grid-template-columns: repeat(2, 1fr); } }

.stat {
  position: relative; overflow: hidden;
  padding: 15px 16px 14px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: linear-gradient(160deg, var(--panel-bg-a), var(--panel-bg-b));
  backdrop-filter: blur(16px);
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s var(--ease);
}
.stat:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px -16px rgba(0,0,0,0.5);
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--accent, var(--cyan));
  box-shadow: 0 0 14px var(--accent, var(--cyan));
  opacity: 0.8;
  animation: stat-glow 3s ease-in-out infinite;
}
@keyframes stat-glow {
  0%, 100% { box-shadow: 0 0 14px var(--accent, var(--cyan)); }
  50% { box-shadow: 0 0 24px var(--accent, var(--cyan)); }
}
.stat[data-accent="cyan"]    { --accent: var(--cyan); }
.stat[data-accent="magenta"] { --accent: var(--magenta); }
.stat[data-accent="violet"]  { --accent: var(--violet); }
.stat[data-accent="amber"]   { --accent: var(--amber); }

.stat label {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; letter-spacing: 0.11em;
  text-transform: uppercase; color: var(--dim);
}
.stat .num {
  display: block; font-family: var(--mono);
  font-size: 30px; line-height: 1.15; font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
  transition: text-shadow 0.3s;
}
.stat:hover .num {
  text-shadow: 0 0 20px var(--accent, var(--cyan));
}
.stat-sub { font-size: 11.5px; color: var(--muted); }
.stat-wide { grid-column: span 1; }

.stat-spark {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 28px;
  opacity: 0.15;
  background: linear-gradient(90deg, transparent, var(--accent, var(--cyan)), transparent);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 28'%3E%3Cpath d='M0 20 L8 18 L16 22 L24 8 L32 14 L40 6 L48 10' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
  animation: spark-drift 4s ease-in-out infinite;
}
@keyframes spark-drift {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50% { transform: translateY(-50%) translateX(4px); }
}

.bands { display: flex; align-items: flex-end; gap: 6px; height: 62px; margin-top: 10px; }
.band { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 5px; }
.band i {
  display: block; width: 100%; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--bc, var(--cyan)), rgba(52,230,255,0.16));
  min-height: 3px; transition: height 0.6s var(--ease), box-shadow 0.3s;
  box-shadow: 0 0 12px -2px var(--bc, var(--cyan));
}
.band:hover i {
  box-shadow: 0 0 20px 0px var(--bc, var(--cyan));
}
.band span { font-family: var(--mono); font-size: 9px; color: var(--dim); text-align: center; }

/* ------------------------------------------------------------------ */
/* filters                                                              */
/* ------------------------------------------------------------------ */
.filterbar {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end;
  padding: 14px 18px;
}
.field { display: grid; gap: 5px; min-width: 132px; }
.field label {
  display: flex; align-items: center; gap: 4px;
  font-size: 9.5px; letter-spacing: 0.11em; text-transform: uppercase; color: var(--dim);
}
.field select, .field input {
  padding: 8px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: rgba(10,15,28,0.75);
  color: var(--text); outline: none;
  transition: border-color 0.22s, box-shadow 0.22s, transform 0.18s;
}
.field select:focus, .field input:focus {
  border-color: rgba(52,230,255,0.45);
  box-shadow: 0 0 0 3px rgba(52,230,255,0.10), 0 0 20px -8px rgba(52,230,255,0.1);
  transform: translateY(-1px);
}
.field select option { background: #0a1120; }

.range-wrap { display: flex; align-items: center; gap: 10px; }
.range-wrap output {
  font-family: var(--mono); font-size: 13px; color: var(--cyan);
  min-width: 22px; text-align: right;
  text-shadow: 0 0 8px rgba(52,230,255,0.3);
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 118px; height: 3px; border-radius: 3px; outline: none;
  background: linear-gradient(90deg, var(--cyan) var(--pct, 0%), rgba(122,162,255,0.16) var(--pct, 0%));
  transition: box-shadow 0.2s;
}
input[type="range"]:hover {
  box-shadow: 0 0 10px -2px rgba(52,230,255,0.3);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--cyan); cursor: pointer;
  box-shadow: 0 0 10px var(--cyan), 0 0 20px -4px var(--cyan);
  transition: transform 0.15s var(--ease-bounce), box-shadow 0.2s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.3);
  box-shadow: 0 0 14px var(--cyan), 0 0 30px -4px var(--cyan);
}
.check { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.check input { accent-color: var(--cyan); width: 15px; height: 15px; }

/* ------------------------------------------------------------------ */
/* table — enhanced with glow row hover and slide-in                    */
/* ------------------------------------------------------------------ */
.table-panel { padding: 0; overflow: hidden; }
.table-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.table-head em { font-style: normal; color: var(--dim); font-size: 12px; font-family: var(--mono); }
.table-scroll { max-height: calc(100vh - 430px); overflow-y: auto; }

.grid { width: 100%; border-collapse: collapse; }
.grid thead th {
  position: sticky; top: 0; z-index: 2;
  padding: 10px 14px; text-align: left;
  font-size: 9.5px; letter-spacing: 0.11em; text-transform: uppercase;
  color: var(--dim); font-weight: 500;
  background: rgba(8,12,22,0.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  transition: color 0.2s;
}
.grid thead th:hover { color: var(--text); }
.grid tbody tr {
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s var(--ease);
  animation: row-enter 0.35s var(--ease) backwards;
}
@keyframes row-enter {
  from { opacity: 0; transform: translateX(-8px); }
}
.grid tbody tr:nth-child(1) { animation-delay: 0.02s; }
.grid tbody tr:nth-child(2) { animation-delay: 0.04s; }
.grid tbody tr:nth-child(3) { animation-delay: 0.06s; }
.grid tbody tr:nth-child(4) { animation-delay: 0.08s; }
.grid tbody tr:nth-child(5) { animation-delay: 0.10s; }
.grid tbody tr:nth-child(6) { animation-delay: 0.12s; }
.grid tbody tr:nth-child(7) { animation-delay: 0.14s; }
.grid tbody tr:nth-child(8) { animation-delay: 0.16s; }
.grid tbody tr:nth-child(9) { animation-delay: 0.18s; }
.grid tbody tr:nth-child(10) { animation-delay: 0.20s; }
.grid tbody tr:hover {
  background: rgba(52,230,255,0.045);
  transform: translateX(2px);
}
.grid tbody tr:hover .biz-name { color: var(--cyan); }
.grid td { padding: 12px 14px; vertical-align: middle; }

.c-rank { width: 46px; }
.rank { font-family: var(--mono); font-size: 11px; color: var(--dim); }

.c-pri { width: 118px; }
.pri { display: flex; align-items: center; gap: 10px; }
.pri b {
  font-family: var(--mono); font-size: 19px; font-weight: 600;
  min-width: 30px; color: var(--pc, var(--cyan));
  text-shadow: 0 0 16px var(--pc, transparent);
  transition: text-shadow 0.3s;
}
.pri:hover b {
  text-shadow: 0 0 24px var(--pc, transparent);
}
.pri-bar { flex: 1; height: 3px; border-radius: 3px; background: rgba(122,162,255,0.13); overflow: hidden; }
.pri-bar i {
  display: block; height: 100%; border-radius: 3px;
  background: var(--pc, var(--cyan));
  box-shadow: 0 0 8px var(--pc);
  transition: width 0.6s var(--ease), box-shadow 0.3s;
}
.pri:hover .pri-bar i {
  box-shadow: 0 0 14px var(--pc);
}

.biz-name { font-weight: 550; transition: color 0.15s; }
.biz-domain { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.biz-meta { font-size: 11px; color: var(--muted); }

.dualscore { display: flex; gap: 7px; align-items: center; font-family: var(--mono); font-size: 12px; }
.value-conf { margin-top: 4px; font-size: 10.5px; color: var(--dim); white-space: nowrap; }
.value-rows { display: grid; gap: 6px; margin: 8px 0 10px; }
.value-row { display: grid; grid-template-columns: minmax(110px, 0.9fr) 96px minmax(0, 2.4fr); gap: 8px; align-items: baseline;
  font-size: 12.5px; overflow-wrap: anywhere; }
.value-row small { color: var(--muted); }
.value-missing { color: var(--dim); }
@media (max-width: 760px) { .value-row { grid-template-columns: 1fr auto; } .value-row small { grid-column: 1 / -1; } }
.chip {
  padding: 3px 8px; border-radius: 6px; font-size: 11px;
  border: 1px solid var(--line); background: rgba(122,162,255,0.06); color: var(--muted);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.chip:hover { transform: translateY(-1px); }
.chip.hot { border-color: rgba(255,92,225,0.35); background: rgba(255,92,225,0.10); color: var(--magenta); }

.issue { font-size: 12.5px; color: var(--muted); }
.issue b { display: block; color: var(--text); font-weight: 500; font-size: 13px; }

.pillstat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px; font-size: 11px;
  border: 1px solid var(--line); background: rgba(122,162,255,0.05); color: var(--muted);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.pillstat:hover { transform: translateY(-1px); }
.pillstat::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pillstat[data-s="new"]         { color: var(--muted); }
.pillstat[data-s="shortlisted"] { color: var(--cyan);   border-color: rgba(52,230,255,0.3); }
.pillstat[data-s="contacted"]   { color: var(--violet); border-color: rgba(166,132,255,0.3); }
.pillstat[data-s="meeting"]     { color: var(--amber);  border-color: rgba(255,196,77,0.3); }
.pillstat[data-s="won"]         { color: var(--lime);   border-color: rgba(94,247,164,0.35); }
.pillstat[data-s="lost"],
.pillstat[data-s="rejected"]    { color: var(--dim); }

.empty { padding: 70px 20px; text-align: center; }
.empty-mark {
  width: 62px; height: 62px; margin: 0 auto 16px;
  display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--line); color: var(--cyan);
  box-shadow: 0 0 40px -12px var(--cyan);
  animation: empty-pulse 3s ease-in-out infinite;
}
@keyframes empty-pulse {
  0%, 100% { box-shadow: 0 0 40px -12px var(--cyan); }
  50% { box-shadow: 0 0 60px -8px var(--cyan); }
}
.empty-mark svg { width: 26px; height: 26px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); margin-bottom: 18px; }

/* ------------------------------------------------------------------ */
/* bar lists / catalog / weights                                        */
/* ------------------------------------------------------------------ */
.barlist { display: grid; gap: 10px; }
.barrow { display: grid; grid-template-columns: 1fr 46px; gap: 10px; align-items: center; }
.barrow span { font-size: 12.5px; color: var(--muted); }
.barrow .track { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: rgba(122,162,255,0.11); overflow: hidden; }
.barrow .track i {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  transition: width 0.6s var(--ease), box-shadow 0.3s;
  box-shadow: 0 0 8px -2px var(--cyan);
}
.barrow:hover .track i {
  box-shadow: 0 0 14px 0px var(--cyan);
}
.barrow b { font-family: var(--mono); font-size: 12px; text-align: right; color: var(--text); }
/* Rows whose right side is text, not a number (campaigns, schedules): let it take the room it needs. */
.barrow.wide { grid-template-columns: minmax(0, 1fr) auto; }
.barrow.wide b { overflow-wrap: anywhere; }

.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.cat-card {
  padding: 13px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: rgba(10,15,28,0.5);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s var(--ease);
}
.cat-card:hover {
  border-color: rgba(122,162,255,0.25);
  box-shadow: 0 8px 24px -12px rgba(0,0,0,0.4);
  transform: translateY(-2px);
}
.cat-card h4 { margin: 0 0 4px; font-size: 12.5px; font-weight: 600; }
.cat-card p { font-size: 11.5px; color: var(--muted); }
.cat-tag {
  display: inline-block; margin-bottom: 7px; padding: 2px 8px;
  border-radius: 5px; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--line); color: var(--cyan);
  transition: box-shadow 0.2s;
}
.cat-card:hover .cat-tag {
  box-shadow: 0 0 10px -3px var(--cyan);
}

.weights { display: grid; gap: 15px; }
.wrow { display: grid; grid-template-columns: 132px 1fr 48px; gap: 12px; align-items: center; }
.wrow label { font-size: 12.5px; color: var(--muted); }
.wrow input[type="range"] { width: 100%; }
.wrow output { font-family: var(--mono); font-size: 12.5px; color: var(--cyan); text-align: right; }

.keylist, .pathlist { display: grid; gap: 8px; }
.pathlist { margin-top: 14px; }
.kv {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: rgba(10,15,28,0.5);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.kv:hover {
  border-color: rgba(122,162,255,0.2);
  box-shadow: 0 4px 16px -8px rgba(52,230,255,0.1);
}
.kv span { font-size: 12.5px; color: var(--muted); }
.kv b { font-family: var(--mono); font-size: 11px; color: var(--text); overflow-wrap: anywhere; text-align: right; }
.kv .yes { color: var(--lime); text-shadow: 0 0 8px rgba(94,247,164,0.3); }
.kv .no  { color: var(--dim); }

/* ---- ops — stage cards with enhanced hover ---- */
.stage-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 900px) { .stage-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .stage-row { grid-template-columns: 1fr; } }
.stage-cell {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
}
.stage {
  flex: 1;
  display: grid; gap: 3px; text-align: left; cursor: pointer;
  padding: 15px 36px 15px 15px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: rgba(10,15,28,0.55);
  transition: 0.22s var(--ease);
  width: 100%;
  color: inherit;
  font: inherit;
}
.stage:hover {
  border-color: rgba(52,230,255,0.4);
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 14px 36px -16px var(--cyan), 0 0 20px -10px rgba(52,230,255,0.15);
}
.stage:active { transform: translateY(-1px) scale(0.99); }
.stage b { font-size: 13.5px; }
.stage > span { font-size: 11.5px; color: var(--muted); }

.stage-info {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 15, 28, 0.85);
  color: var(--muted);
  cursor: help;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.15s var(--ease-bounce);
}
.stage-info svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stage-info:hover,
.stage-info:focus-visible {
  color: var(--cyan);
  border-color: rgba(52, 230, 255, 0.45);
  background: rgba(52, 230, 255, 0.08);
  transform: scale(1.15);
  outline: none;
}
.stage-tip {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(280px, 70vw);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(52, 230, 255, 0.28);
  background: rgba(8, 12, 22, 0.96);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 14px 36px -12px rgba(0, 0, 0, 0.65);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
  z-index: 5;
  text-align: left;
  font-weight: 400;
}
.stage-info:hover .stage-tip,
.stage-info:focus-visible .stage-tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.runs { display: grid; gap: 8px; }
.run {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: rgba(10,15,28,0.5);
  font-size: 12.5px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.run:hover {
  border-color: rgba(122,162,255,0.2);
  box-shadow: 0 4px 16px -8px rgba(52,230,255,0.1);
  transform: translateX(2px);
}
.run .kind { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.run .meta { color: var(--muted); font-size: 11.5px; }
.run .state { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.run .state[data-s="done"]    { color: var(--lime); }
.run .state[data-s="running"] { color: var(--cyan); animation: blink 1.5s ease-in-out infinite; }
.run .state[data-s="failed"]  { color: var(--red); }
@keyframes blink { 50% { opacity: 0.4; } }

/* ------------------------------------------------------------------ */
/* drawer — enhanced with smoother entrance                             */
/* ------------------------------------------------------------------ */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(2, 4, 9, 0.66); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.drawer-scrim.is-open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(760px, 94vw);
  border-left: 1px solid var(--line);
  background: linear-gradient(200deg, rgba(13,19,35,0.97), rgba(5,8,16,0.98));
  backdrop-filter: blur(26px);
  transform: translateX(100%);
  transition: transform 0.5s var(--ease);
  overflow-y: auto;
  box-shadow: -30px 0 70px -30px rgba(0,0,0,0.9);
}
.drawer.is-open { transform: none; }
.drawer-inner { padding: 24px 26px 40px; }

.d-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.d-title h2 { font-size: 20px; letter-spacing: -0.02em; }
.d-title a {
  font-family: var(--mono); font-size: 12px; color: var(--cyan);
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
}
.d-title a:hover { text-decoration: underline; }
.d-title a svg { width: 12px; height: 12px; }
.d-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.d-head .icon-btn { margin-left: auto; flex: none; }

.d-hero { display: grid; grid-template-columns: 190px 1fr; gap: 22px; margin-bottom: 22px; }
@media (max-width: 640px) { .d-hero { grid-template-columns: 1fr; } }

.phone {
  position: relative; width: 100%; aspect-ratio: 9 / 17.5;
  border-radius: 24px; padding: 7px;
  background: linear-gradient(160deg, #232b42, #0b1020);
  border: 1px solid rgba(122,162,255,0.22);
  box-shadow: 0 24px 60px -26px rgba(0,0,0,0.95), 0 0 44px -22px var(--cyan);
  transition: box-shadow 0.3s, transform 0.3s var(--ease);
}
.phone:hover {
  box-shadow: 0 28px 70px -26px rgba(0,0,0,0.95), 0 0 60px -18px var(--cyan);
  transform: translateY(-2px) rotateY(-3deg);
}
.phone::before {
  content: ""; position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 42px; height: 4px; border-radius: 4px; background: rgba(255,255,255,0.16); z-index: 2;
}
.phone-screen {
  width: 100%; height: 100%; border-radius: 18px; overflow: hidden;
  background: #0a0e18; position: relative;
}
.phone-screen img { width: 100%; display: block; object-fit: cover; object-position: top; }
.phone-missing {
  display: grid; place-items: center; height: 100%;
  color: var(--dim); font-size: 11px; text-align: center; padding: 16px;
}

.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.gauge { text-align: center; }
.gauge svg { width: 100%; max-width: 96px; height: auto; stroke: none; }
.gauge-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.gauge-val { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.d-facts { display: grid; gap: 7px; }
.fact { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--muted); }
.fact svg { width: 14px; height: 14px; color: var(--dim); flex: none; }
.fact b { color: var(--text); font-weight: 500; }

.d-section { margin-bottom: 22px; }
.d-section > h3 {
  font-size: 10.5px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 11px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}

svg.radar {
  display: block; margin: 4px auto 0;
  width: 100%; max-width: 360px; height: auto; stroke: none;
}

.finding {
  padding: 13px 14px; margin-bottom: 9px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: rgba(10,15,28,0.55);
  border-left: 2px solid var(--fc, var(--cyan));
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.finding:hover {
  border-color: rgba(122,162,255,0.25);
  box-shadow: 0 6px 20px -10px rgba(0,0,0,0.4);
  transform: translateX(3px);
}
.finding-top { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.finding-top b { font-size: 13px; }
.sev {
  margin-left: auto; font-family: var(--mono); font-size: 10px;
  padding: 2px 7px; border-radius: 5px;
  border: 1px solid var(--line); color: var(--fc, var(--cyan));
}
.finding p { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.finding .evidence {
  font-family: var(--mono); font-size: 11px; color: var(--amber);
  background: rgba(255,196,77,0.07); border-radius: 6px;
  padding: 6px 9px; overflow-wrap: anywhere;
}
.finding .bench { font-size: 11px; color: var(--dim); margin-top: 6px; }

.cmp { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cmp th { text-align: left; font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--dim); font-weight: 500; padding: 6px 8px; }
.cmp td { padding: 9px 8px; border-top: 1px solid var(--line-soft); }
.cmp tr.self td { background: rgba(255,92,225,0.07); }
.cmp .n { font-family: var(--mono); }

.d-actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.d-actions select {
  padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(10,15,28,0.75); color: var(--text);
}
.notes {
  width: 100%; min-height: 74px; margin-top: 10px; resize: vertical;
  padding: 11px 13px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(10,15,28,0.7); color: var(--text);
  outline: none; font-size: 12.5px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.notes:focus { border-color: rgba(52,230,255,0.4); box-shadow: 0 0 0 3px rgba(52,230,255,0.09); }

.confbar { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--muted); }
.confbar .track { flex: 1; height: 3px; border-radius: 3px; background: rgba(122,162,255,0.13); }
.confbar .track i { display: block; height: 100%; border-radius: 3px; background: var(--lime); }

/* ------------------------------------------------------------------ */
/* modal — enhanced with backdrop blur and scale entrance               */
/* ------------------------------------------------------------------ */
.modal-scrim {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(2,4,9,0.72); backdrop-filter: blur(5px);
  opacity: 0; pointer-events: none; transition: opacity 0.26s;
}
.modal-scrim.is-open { opacity: 1; pointer-events: auto; }
.modal {
  width: min(560px, 94vw); margin: 0; padding: 0;
  max-height: 92dvh; display: flex; flex-direction: column;
  transform: translateY(14px) scale(0.985);
  transition: transform 0.4s var(--ease);
}
.modal-scrim.is-open .modal {
  transform: none;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 20px; border-bottom: 1px solid var(--line);
}
.modal-body { padding: 18px 20px; display: grid; gap: 15px; overflow-y: auto; min-height: 0; }
.modal-foot {
  flex-shrink: 0;
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 15px 20px; border-top: 1px solid var(--line);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row .field { min-width: 0; }

/* Optional research uses the existing visual language without replacing it. */
.research-options { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: rgba(122,162,255,.05); }
.research-options[hidden], .research-panel[hidden] { display: none; }
.research-options .check { margin-top: 14px; }
.research-warning { color: #ffc58a; }
.research-advanced { margin-top: 14px; }
.research-advanced summary, .research-card summary { cursor: pointer; padding: 8px 0; color: var(--cyan); }
.research-advanced .field-row { margin-top: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.research-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.research-heading h3 { margin: 0; overflow-wrap: anywhere; }
.research-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.research-filters [aria-pressed="true"] { border-color: var(--cyan); color: var(--cyan); }
/* Long lists that scroll inside their own panel (Web research candidates, Fact review,
   Possible matches): with the cursor over the list the wheel moves the list (and stops at
   the ends instead of moving the page); elsewhere it moves the page. */
.inner-scroll { align-content: start; max-height: min(70vh, 760px); overflow-y: auto;
  overscroll-behavior: contain; scrollbar-gutter: stable; padding-right: 6px; }
.inner-scroll:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 12px; }
.research-results { display: grid; gap: 12px; }
.research-card { border: 1px solid var(--line); border-radius: 12px; padding: 18px; overflow-wrap: anywhere; }
.research-card p { line-height: 1.6; }
.research-card blockquote { margin: 12px 0; padding: 8px 14px; border-left: 2px solid var(--cyan); color: var(--dim); }
.research-badge { white-space: nowrap; font-size: 12px; border: 1px solid var(--line); padding: 5px 8px; border-radius: 20px; color: #ffc58a; }
.research-badge[data-match="likely_match"] { color: var(--cyan); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.hud-bar .is-indeterminate { opacity: .4; }
@media (max-width: 600px) {
  .research-advanced .field-row { grid-template-columns: 1fr; }
  .research-heading { flex-wrap: wrap; }
  .research-card { padding: 12px; }
  .modal-body { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .modal, .modal-scrim { transition: none; }
}

/* ------------------------------------------------------------------ */
/* run hud — enhanced with cyberpunk scanline                           */
/* ------------------------------------------------------------------ */
.hud {
  position: fixed; right: 24px; bottom: 24px; z-index: 45;
  width: 330px; overflow: hidden;
  border: 1px solid rgba(52,230,255,0.3); border-radius: var(--r);
  background: linear-gradient(160deg, rgba(14,22,42,0.95), rgba(6,10,20,0.95));
  backdrop-filter: blur(18px);
  box-shadow: 0 22px 50px -22px rgba(0,0,0,0.9), 0 0 40px -22px var(--cyan);
  animation: hud-enter 0.4s var(--ease);
}
@keyframes hud-enter {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
}
.hud-scan {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(52,230,255,0.12), transparent);
  height: 40%; animation: scan 2.4s ease-in-out infinite;
}
@keyframes scan { 0% { transform: translateY(-100%); } 100% { transform: translateY(300%); } }

.hud-body { position: relative; padding: 14px 16px; }
.hud-top { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.hud-top b { font-size: 12.5px; }
.hud-top .mono { margin-left: auto; font-size: 11px; color: var(--muted); }
.hud-bar { height: 3px; border-radius: 3px; background: rgba(122,162,255,0.15); overflow: hidden; }
.hud-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 0 10px var(--cyan); transition: width 0.4s var(--ease);
}
.hud small { display: block; margin-top: 8px; font-family: var(--mono); font-size: 10px;
  color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ */
/* toasts — enhanced with glow entrance                                 */
/* ------------------------------------------------------------------ */
.toasts { position: fixed; top: 20px; right: 24px; z-index: 60; display: grid; gap: 9px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px; border-radius: 10px; max-width: 380px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(16,24,44,0.96), rgba(7,11,21,0.96));
  backdrop-filter: blur(14px); font-size: 12.5px;
  box-shadow: 0 16px 40px -20px rgba(0,0,0,0.9);
  animation: toast-in 0.4s var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(30px) scale(0.95); }
}
.toast.out { opacity: 0; transform: translateX(30px) scale(0.95); transition: 0.3s; }
.toast::before { content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 8px var(--cyan); flex: none; }
.toast[data-kind="ok"]::before  { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.toast[data-kind="err"]::before { background: var(--red);  box-shadow: 0 0 8px var(--red); }

/* ------------------------------------------------------------------ */
/* scrollbars + motion                                                  */
/* ------------------------------------------------------------------ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(122,162,255,0.18); border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: rgba(122,162,255,0.35); box-shadow: 0 0 8px rgba(122,162,255,0.2); }

.skeleton {
  background: linear-gradient(90deg, rgba(122,162,255,0.07), rgba(122,162,255,0.18), rgba(122,162,255,0.07));
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Staggered entrance for view sections */
.view.is-active .panel {
  animation: panel-rise 0.5s var(--ease) backwards;
}
.view.is-active .panel:nth-child(1) { animation-delay: 0.03s; }
.view.is-active .panel:nth-child(2) { animation-delay: 0.06s; }
.view.is-active .panel:nth-child(3) { animation-delay: 0.09s; }
.view.is-active .panel:nth-child(4) { animation-delay: 0.12s; }
.view.is-active .panel:nth-child(5) { animation-delay: 0.15s; }
@keyframes panel-rise {
  from { opacity: 0; transform: translateY(12px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 860px) {
  :root { --rail-w: 68px; }
  .brand-text, .nav-item span, .rail-meta, .statusline-text { display: none; }
  .nav-item { justify-content: center; }
  .nav-item .info-tip { display: none; }
  .view { padding: 16px; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
}

/* ------------------------------------------------------------------ */
/* floating tooltip layer (JS-rendered)                                 */
/* CSS ::after tooltips get trapped inside stacking contexts created    */
/* by backdrop-filter cards and clipped by overflow:hidden blocks, so   */
/* all info popups now render in a single fixed top layer above every   */
/* drawer, modal and panel.                                             */
/* ------------------------------------------------------------------ */
.info-tip::after { content: none; }
.stage-tip { display: none !important; }

.tip-pop {
  position: fixed;
  z-index: 300;
  max-width: min(300px, 80vw);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(52, 230, 255, 0.28);
  background: rgba(6, 9, 18, 0.97);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 400;
  text-align: left;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.8), 0 0 30px -10px rgba(52, 230, 255, 0.15);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.18s, transform 0.18s var(--ease), visibility 0.18s;
}
.tip-pop.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Readable, bounded activity tail; preserve the existing dashboard palette. */
.activity-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.activity-panel > select { width: 100%; max-width: 440px; margin: 8px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #0a1120; color: var(--text); }
.activity-panel > select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.modal .field { align-content: start; }
.modal .field select, .modal .field input { width: 100%; min-width: 0; }
.activity-panel > label { display: block; color: var(--muted); }
.activity-log { height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: rgba(4,8,16,0.65); }
.activity-log:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.activity-entry { display: grid; grid-template-columns: 90px 64px minmax(0,1fr); gap: 8px; font-family: var(--mono); font-size: 12px; line-height: 1.65; padding: 4px 0; }
.activity-entry time { color: var(--muted); }
.activity-entry b { color: var(--cyan); }
.activity-entry span { white-space: pre-wrap; overflow-wrap: anywhere; }
.activity-entry[data-level="WARNING"] b, .activity-wait, .run .state[data-s="interrupted"] { color: var(--amber, #ffd58a); }
.activity-entry[data-level="ERROR"] b { color: var(--red); }
.activity-wait { font-size: 13px; line-height: 1.6; margin: 8px 0; }
.activity-error { color: var(--red); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; margin: 8px 0; }
#hud-activity { margin-top: 10px; min-height: 36px; }
@media (max-width: 600px) {
  .activity-entry { grid-template-columns: 1fr auto; }
  .activity-entry span { grid-column: 1 / -1; }
}


/* fact review */
.review-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px);
  gap: 12px;
  margin: 18px 0;
}
.review-toolbar input, .review-toolbar select { width: 100%; }
.review-list { display: grid; gap: 12px; }
.review-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(10,15,28,0.55);
}
.review-card-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.review-card-head h3 { font-size: 14px; }
.review-card-head > b { font-family: var(--mono); overflow-wrap: anywhere; text-align: right; }
.review-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}
.review-meta div { min-width: 0; }
.review-meta dt { color: var(--dim); font-size: 11px; }
.review-meta dd { margin: 2px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.review-meta a { color: var(--cyan); }
.review-excerpt { margin-top: 12px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.review-actions { display: flex; gap: 8px; margin-top: 14px; }
@media (max-width: 640px) {
  .review-toolbar, .review-meta { grid-template-columns: 1fr; }
  .review-card-head { flex-direction: column; }
  .review-card-head > b { text-align: left; }
}


/* general research projects */
.rp-form { display: grid; gap: 14px; margin-top: 16px; }
.rp-form textarea { width: 100%; resize: vertical; }
.rp-budgets summary { cursor: pointer; color: var(--muted); }
.rp-budgets .field-row { margin-top: 12px; }
.rp-layout { display: grid; grid-template-columns: minmax(240px, 0.7fr) minmax(0, 1.6fr); gap: 14px; margin-top: 14px; }
.rp-projects { display: grid; gap: 8px; margin-top: 12px; }
.rp-project {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  width: 100%; padding: 12px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: rgba(10,15,28,0.5);
}
.rp-project:hover, .rp-project.is-active { border-color: rgba(52,230,255,0.45); }
.rp-project span:first-child { display: grid; gap: 4px; min-width: 0; }
.rp-project small { color: var(--muted); overflow-wrap: anywhere; }
.rp-detail-panel { min-width: 0; }
.rp-detail-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.rp-detail-head p { margin-top: 6px; overflow-wrap: anywhere; }
.rp-actions { display: flex; gap: 8px; flex-shrink: 0; }
.rp-statusline { display: flex; align-items: center; gap: 12px; margin: 14px 0; color: var(--muted); }
.rp-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rp-stats > div { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.rp-stats label, .rp-stats small { display: block; color: var(--muted); }
.rp-stats b { display: block; margin: 4px 0; font-family: var(--mono); color: var(--cyan); }
.rp-section-title { margin: 20px 0 10px; font-size: 13px; }
.rp-steps, .rp-evidence-list { display: grid; gap: 10px; }
.rp-step, .rp-evidence { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: rgba(10,15,28,0.45); }
.rp-step > div { display: flex; gap: 10px; align-items: center; }
.rp-step b { overflow-wrap: anywhere; }
.rp-step > span, .rp-evidence small { color: var(--muted); }
.rp-evidence-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rp-evidence-head b { margin-right: auto; overflow-wrap: anywhere; }
.rp-evidence p { margin: 10px 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.rp-evidence a { display: inline-block; margin-top: 8px; color: var(--cyan); }
@media (max-width: 1000px) { .rp-layout { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .rp-detail-head, .rp-statusline { flex-direction: column; }
  .rp-stats { grid-template-columns: 1fr; }
  .rp-actions { flex-wrap: wrap; }
}


/* company intelligence and comparison */
.ci-inline-form { display: flex; align-items: end; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.ci-inline-form .field { flex: 1; min-width: 180px; }
.ci-inline-form input, .ci-stack input { width: 100%; }
.ci-stack { display: grid; gap: 10px; margin-top: 12px; }
.ci-stack label { display: grid; gap: 4px; color: var(--muted); }
.ci-years { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ci-profile-head { margin-bottom: 14px; }
.ci-limitations { margin: 16px 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--muted); }
.ci-limitations ul { margin: 8px 0 0 18px; }
.ci-records { display: grid; gap: 10px; }
.ci-record, .ci-observation, .ci-comparison-row { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: rgba(10,15,28,0.45); }
.ci-record > div { display: flex; gap: 10px; align-items: center; }
.ci-record > strong, .ci-observation b { display: block; margin: 6px 0; overflow-wrap: anywhere; }
.ci-record small, .ci-record p, .ci-observation span { color: var(--muted); overflow-wrap: anywhere; }
.ci-record a, .ci-observation a { color: var(--cyan); }
.ci-sources { margin: 6px 0 0 18px; color: var(--muted); font-size: 0.92em; }
.ci-check-missing { opacity: 0.7; }
.ci-position-query { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; color: var(--muted); }
.ci-position-query input { flex: 1 1 220px; min-width: 0; }
#ci-positions { display: grid; gap: 8px; margin: 8px 0; }
.ci-observation small { display: block; margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.ci-profile-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.ci-metric { margin-bottom: 12px; }
.ci-metric h3 { margin-bottom: 8px; }
.ci-observation { display: grid; gap: 4px; margin-bottom: 8px; }
.ci-comparison-note { margin: 14px 0; color: var(--muted); }
.ci-comparison-row { margin-top: 12px; }
.ci-comparison-row > div:first-child { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ci-comparison-row > div:first-child span { color: var(--muted); }
.ci-compare-values { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 12px; }
.ci-compare-values > div { display: grid; gap: 5px; padding: 10px; border: 1px solid var(--line-soft); }
.ci-compare-values strong { overflow-wrap: anywhere; }
.ci-compare-values small { color: var(--muted); }
@media (max-width: 640px) {
  .ci-inline-form { display: grid; align-items: stretch; }
  .ci-years { grid-template-columns: 1fr; }
}


/* improvement planning */
.pl-recommendations { display: grid; gap: 12px; margin-top: 14px; }
.pl-recommendation { padding: 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: rgba(10,15,28,0.5); }
.pl-rec-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.pl-rec-head > div { display: flex; gap: 10px; align-items: center; }
.pl-rec-head b { overflow-wrap: anywhere; }
.pl-recommendation > p { margin: 10px 0; color: var(--muted); overflow-wrap: anywhere; }
.pl-estimates { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 12px; }
.pl-edit-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; margin-top: 12px; }
.pl-edit-grid label { display: grid; gap: 4px; color: var(--muted); }
.pl-edit-grid input { width: 100%; }
.pl-history { margin-top: 12px; color: var(--muted); }
.pl-history li { margin: 6px 0; }
.pl-actor-field { margin: 14px 0; }
.pl-ai-draft { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); margin-top: 10px; }
.pl-ai-draft p { color: var(--muted); margin: 8px 0; }
#pl-evidence-dialog { width: min(720px, 90vw); max-height: 85vh; padding: 20px; color: var(--text); background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); }
#pl-evidence-dialog::backdrop { background: rgba(0,0,0,0.65); }
.pl-evidence-content { display: grid; gap: 10px; margin-top: 14px; }
.pl-evidence-item { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.pl-evidence-item p { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.pl-evidence-item a { color: var(--cyan); display: block; margin-top: 8px; }
@media (max-width: 640px) { .pl-edit-grid { grid-template-columns: 1fr; } }


/* outcome verification */
.pl-outcomes { margin-top: 12px; }
.pl-outcome-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.pl-outcome-grid label { display: grid; gap: 4px; color: var(--muted); }
.pl-outcome-grid input { width: 100%; }
.pl-outcome-grid button { justify-self: start; }
.pl-outcome { display: grid; gap: 5px; padding: 10px; margin-top: 10px; border: 1px solid var(--line-soft); }
.pl-outcome span, .pl-outcome small { color: var(--muted); }
@media (max-width: 640px) { .pl-outcome-grid { grid-template-columns: 1fr; } }


/* supply-chain intelligence */
.sc-actor-field { max-width: 420px; margin-top: 12px; }
.sc-relationship, .sc-event { padding: 14px; margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: rgba(10,15,28,0.5); }
.sc-facts, .sc-assess-grid, .sc-review-grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-top: 12px; color: var(--muted); }
.sc-assess-grid label, .sc-review-grid label { display: grid; gap: 4px; min-width: 160px; }
.sc-risk { display: grid; gap: 5px; margin: 12px 0; padding: 12px; border: 1px solid var(--line-soft); }
.sc-risk span, .sc-risk small, .sc-event p, .sc-event small { color: var(--muted); overflow-wrap: anywhere; }
.sc-inventory-row { display: grid; gap: 5px; padding: 12px; margin-top: 8px; border: 1px solid var(--line-soft); }
.sc-inventory-row span, .sc-inventory-row small { color: var(--muted); }
.sc-inventory-row strong { color: var(--cyan); }
.sc-alternatives { margin-top: 10px; }
/* supply visibility: map levels, exposure, shipments, monitor results */
.sc-levels { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(180px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.sc-level h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.sc-node { display: grid; gap: 2px; padding: 8px 10px; margin-bottom: 6px; border: 1px solid var(--line-soft); border-radius: var(--r-sm); overflow-wrap: anywhere; }
.sc-node small { color: var(--muted); font-size: 11px; }
.sc-notes, .sc-signals { margin: 8px 0; padding-left: 18px; display: grid; gap: 4px; font-size: 12.5px; color: var(--text); }
.sc-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 10px 0; }
.sc-inline label { display: grid; gap: 3px; font-size: 11.5px; color: var(--muted); }
.sc-inline input, .sc-inline select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #0a1120; color: var(--text); min-width: 0; max-width: 100%; }
.sc-route { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.sc-route .btn { justify-self: start; }
.sc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sc-chip { display: inline-flex; gap: 5px; align-items: center; padding: 3px 8px; border: 1px solid var(--line-soft); border-radius: 999px; font-size: 11.5px; }
.sc-table-wrap { overflow-x: auto; }
.sc-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sc-table th, .sc-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.sc-table th { color: var(--muted); font-weight: 500; }
.sc-problem td { color: var(--amber); }
.sc-sev { font-size: 11px; color: var(--muted); }
.sc-sev[data-s="moderate"] { color: var(--amber); }
.sc-sev[data-s="high"], .sc-sev[data-s="critical"] { color: var(--red); }
.sc-credits { margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.sc-table a, .sc-signals a { color: var(--cyan); }
.sc-ai-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.sc-ai-title { margin: 12px 0 2px; font-size: 12.5px; color: var(--muted); }
.sc-signals ul { margin: 4px 0; padding-left: 16px; }
.sc-signals q { color: var(--text); font-style: italic; }
@media (max-width: 760px) { .sc-levels { grid-auto-flow: row; grid-auto-columns: auto; } }


/* finding cohorts: three-state chips with live counts */
.pill-count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  margin-left: 6px; padding: 0 5px; border-radius: 9px;
  font-family: var(--mono); font-size: 10.5px;
  background: rgba(255,92,225,0.16); color: var(--magenta);
}
.cohort-panel { padding: 16px 18px; }
.cohort-head { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: flex-start; }
.cohort-head h3 { font-size: 14px; display: flex; align-items: baseline; gap: 10px; }
.cohort-total { font-family: var(--mono); font-size: 12px; color: var(--cyan); font-weight: 500; }
.cohort-saved { color: var(--violet); }
.cohort-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cohort-actions input {
  padding: 7px 10px; border-radius: 9px; min-width: 190px;
  border: 1px solid var(--line); background: rgba(10,15,28,0.75); color: var(--text);
}
.cohort-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 6px; }
.cohort-group h4 {
  font-size: 9.5px; letter-spacing: 0.11em; text-transform: uppercase;
  color: var(--dim); margin: 0 0 7px;
}
.cohort-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sig-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 9px; border-radius: 8px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(122,162,255,0.05); color: var(--muted);
  font-family: var(--sans); text-align: left;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.15s;
}
.sig-chip:hover { transform: translateY(-1px); color: var(--text); }
.sig-chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.sig-chip .n { font-family: var(--mono); font-size: 10.5px; color: var(--dim); }
.sig-chip .mark { font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; }
.sig-chip[data-state="must"] { border-color: rgba(255,92,225,0.45); background: rgba(255,92,225,0.10); color: var(--magenta); }
.sig-chip[data-state="must_not"] { border-color: rgba(94,247,164,0.45); background: rgba(94,247,164,0.08); color: var(--lime); }
.sig-chip[data-state="saved"] { border-color: rgba(166,132,255,0.45); background: rgba(166,132,255,0.08); color: var(--violet); cursor: default; }
.sig-chip.is-empty { opacity: 0.55; }

/* drawer: what changed between the last two captures */
.d-when { float: right; text-transform: none; letter-spacing: 0; font-family: var(--mono); font-size: 10.5px; color: var(--dim); }
.chg { padding: 9px 12px; margin-bottom: 8px; border-radius: var(--r-sm); border: 1px solid var(--line); border-left: 2px solid var(--chg, var(--cyan)); background: rgba(10,15,28,0.5); }
.chg b { font-size: 12px; color: var(--chg, var(--cyan)); }
.chg ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }
.chg li { margin: 2px 0; }
.chg-bad { --chg: var(--red); }
.chg-good { --chg: var(--lime); }
.chg-info { --chg: var(--amber); }
.chg-metric { font-family: var(--mono); font-size: 11px; color: var(--dim); }


/* paid web search guard rails (settings panel + scan estimate) */
.search-panel { grid-column: 1 / -1; }
.search-paused { color: var(--amber); font-weight: 500; }
.search-list { display: grid; gap: 10px; margin-top: 8px; }
.search-row {
  display: grid; grid-template-columns: minmax(200px, 1.2fr) minmax(240px, 1.4fr) minmax(160px, 1fr);
  gap: 12px; align-items: center; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: rgba(10,15,28,0.5);
}
.search-name { display: grid; gap: 3px; }
.search-name small code { font-size: 10.5px; color: var(--dim); }
.key-state { font-size: 11px; color: var(--muted); }
.key-state[data-s="configured"] { color: var(--lime); }
.key-state[data-s="placeholder"] { color: var(--red); }
.search-usage { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text); }
.search-extra { display: grid; gap: 3px; font-size: 11.5px; color: var(--muted); }
.research-estimate { display: block; margin-top: 4px; }
.ai-models-row { grid-template-columns: minmax(200px, 1fr) minmax(0, 2.6fr); align-items: start; }
.ai-models-row .search-name { min-width: 0; }
.ai-models-row select {
  width: 100%; min-width: 0; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 9px; background: #0a1120; color: var(--text); font-size: 12px;
}
.ai-models-row select option { background: #0a1120; }
.ai-models-row .btn { justify-self: start; margin-top: 2px; }
.ai-model-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 12px; }
.ai-model {
  display: grid; grid-template-columns: 22px minmax(0, 2fr) minmax(0, 1.6fr) auto; gap: 8px; align-items: baseline;
  overflow-wrap: anywhere;
}
.ai-model-n { color: var(--dim); }
.ai-model-state { color: var(--lime); }
.ai-model[data-s="unreliable"] .ai-model-state { color: var(--amber); }
.ai-model[data-s="cooling"] .ai-model-state { color: var(--red); }
.ai-model small { color: var(--muted); }
@media (max-width: 760px) {
  .search-row, .ai-models-row { grid-template-columns: 1fr; }
  .ai-model { grid-template-columns: 22px minmax(0, 1fr); }
  .ai-model > :nth-child(n+3) { grid-column: 2; }
}

/* Background worker facts (Operations). */
.bg-worker-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; }
.bg-worker-facts dt { color: var(--muted, #8a93a6); }
.bg-worker-facts dd { margin: 0; overflow-wrap: anywhere; }

/* No website leads: name and facts on the left, the action on the right; stacked on narrow screens. */
.noweb-list { display: grid; gap: 8px; }
.noweb-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(122, 162, 255, 0.03); }
.noweb-row.is-live { border-color: rgba(122, 162, 255, 0.35); }
.noweb-main { min-width: 0; }
.noweb-name { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.noweb-name.is-placeholder { font-weight: 500; color: var(--dim); }
.noweb-meta { margin-top: 3px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.noweb-action { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.noweb-action small { font-size: 11.5px; color: var(--muted); }
.noweb-link { color: var(--cyan); }
.noweb-warn { color: #ffc58a; }
@media (max-width: 640px) {
  .noweb-row { grid-template-columns: minmax(0, 1fr); }
  .noweb-action { align-items: flex-start; text-align: left; }
}

/* Possible duplicates (Review) and Correct details (drawer). */
.dup-card { display: grid; gap: 12px; }
.dup-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; }
.dup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dup-side { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.dup-side dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 10px; margin: 6px 0 8px; font-size: 12.5px; }
.dup-side dt { color: var(--muted); }
.dup-side dd { margin: 0; overflow-wrap: anywhere; }
.dup-label { font-weight: 600; }
.dup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dup-merge { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.dup-keep { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.dup-field { display: grid; grid-template-columns: 90px minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: start; font-size: 12.5px; }
.dup-field > span { color: var(--muted); }
.dup-field label { overflow-wrap: anywhere; }
.dup-subtitle { margin: 6px 0 8px; font-size: 14px; }
.dup-history { margin-top: 12px; }
.dup-history summary { cursor: pointer; color: var(--cyan); padding: 6px 0; }
.badge-note { font-size: 11px; border: 1px solid var(--line); border-radius: 20px; padding: 2px 7px; color: #ffc58a; font-weight: 500; }
.fix-name { margin-top: 6px; width: 100%; max-width: 360px; }
.corr-grid { display: grid; gap: 6px; margin-bottom: 10px; }
.corr-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.corr-row > span { color: var(--muted); font-size: 12.5px; }
#d-corrections summary { cursor: pointer; }
@media (max-width: 640px) {
  .dup-grid { grid-template-columns: minmax(0, 1fr); }
  .dup-field { grid-template-columns: minmax(0, 1fr); }
  .corr-row { grid-template-columns: minmax(0, 1fr); }
}
/* Text boxes in Records to fix and Correct details: same look as the app's other fields. */
.fix-name, .corr-row input, #d-corr-reviewer {
  padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line); background: rgba(10,15,28,0.75);
  color: var(--text); outline: none; font: inherit; font-size: 13px; min-width: 0;
  transition: border-color 0.22s, box-shadow 0.22s;
}
.fix-name:focus, .corr-row input:focus, #d-corr-reviewer:focus {
  border-color: rgba(52,230,255,0.45); box-shadow: 0 0 0 3px rgba(52,230,255,0.10);
}
.dup-side a, #d-corrections a { color: var(--cyan); }

.dup-hint { margin: 0; padding: 8px 12px; border-left: 2px solid #ffc58a; background: rgba(255,197,138,0.06);
  border-radius: 6px; font-size: 12.5px; }
.dup-ai { padding: 8px 12px; border-left: 2px solid var(--cyan); background: rgba(52,230,255,0.05); border-radius: 6px;
  font-size: 12.5px; }
.dup-ai ul { margin: 6px 0; padding-left: 18px; }

/* Fact review: the Google place ID in small print (the Maps link carries the meaning). */
.review-id { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }

/* Campaigns page administration and the Jobs panel. */
.automation-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.automation-bar.is-paused { border-color: rgba(255,197,138,0.5); background: rgba(255,197,138,0.06); }
.admin-list { display: grid; gap: 10px; }
.admin-card { display: grid; gap: 8px; }
.admin-stats { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--muted); }
.admin-stats b { color: var(--text); }
.admin-schedule { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; }
.admin-schedule input { width: 72px; }
.admin-form { display: grid; gap: 10px; padding: 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(122,162,255,0.04); }
.admin-form .field input, .admin-form .field select { width: 100%; min-width: 0; }
.admin-sources { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.admin-runs { margin: 6px 0 0; padding-left: 0; list-style: none; display: grid; gap: 4px; font-size: 12.5px; }
.admin-schedule input, .admin-form input:not([type="checkbox"]), .admin-form select, #jobs-status {
  padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: rgba(10,15,28,0.75);
  color: var(--text); font: inherit; font-size: 13px; }
.cat-tag[data-status="paused"], .cat-tag[data-status="cancelled"], .cat-tag[data-status="interrupted"] { color: #ffc58a; }
.cat-tag[data-status="archived"] { color: var(--muted); }
.cat-tag[data-status="failed"] { color: #ff8a8a; }
.cat-tag[data-status="succeeded"], .cat-tag[data-status="active"] { color: var(--cyan); }

.automation-describe { display: grid; gap: 8px; }
.automation-describe #auto-describe { flex: 1; min-width: 240px; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line);
  background: rgba(10,15,28,0.75); color: var(--text); font: inherit; font-size: 13px; }
.auto-help { margin-top: 4px; padding: 6px 10px; border-left: 2px solid var(--cyan); background: rgba(52,230,255,0.05);
  border-radius: 6px; font-size: 12.5px; }
.admin-form .unclear, .admin-form input.unclear, .admin-form select.unclear { border-color: #ffc58a !important;
  box-shadow: 0 0 0 3px rgba(255,197,138,0.12); }

/* ---------- collaboration: bell, discussion, assignment, team ---------- */
.bell-wrap { position: relative; }
.bell { position: relative; padding: 9px 11px; }
.bell svg { width: 17px; height: 17px; }
.bell-count { position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--magenta); color: #0b1020; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; }
.bell-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, 92vw); max-height: 70vh; overflow-y: auto;
  z-index: 60; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(10,15,28,0.97);
  box-shadow: 0 18px 50px rgba(0,0,0,0.45); }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 8px; }
.bell-list { display: grid; gap: 4px; }
.bell-item { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 8px; border: 1px solid transparent;
  border-radius: 9px; background: transparent; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.bell-item:hover { border-color: var(--line); background: rgba(122,162,255,0.06); }
.bell-item.is-unread { background: rgba(52,230,255,0.06); border-color: rgba(52,230,255,0.18); }
.bell-kind { flex: none; padding: 2px 7px; border-radius: 6px; font-size: 10.5px; color: var(--cyan);
  border: 1px solid rgba(52,230,255,0.3); }
.bell-kind[data-kind="assigned"] { color: var(--amber); border-color: rgba(255,196,77,0.3); }
.bell-kind[data-kind="joined"] { color: var(--lime); border-color: rgba(94,247,164,0.3); }
.bell-text { display: grid; gap: 2px; min-width: 0; font-size: 12.5px; }
.bell-text small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; }
.bell-text em { color: var(--dim); font-style: normal; font-size: 11px; }

.disc { display: grid; gap: 10px; }
.disc-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.disc-head h3 { margin: 0; }
.disc-presence { color: var(--lime); }
.disc-threads { display: grid; gap: 10px; }
.disc-thread { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(8,12,22,0.45); }
.disc-thread.is-resolved { opacity: 0.72; }
.disc-resolved { margin-bottom: 6px; font-size: 11.5px; color: var(--lime); }
.disc-comment { display: grid; gap: 4px; }
.disc-comment.is-reply { margin: 8px 0 0 14px; padding-left: 10px; border-left: 2px solid var(--line); }
.disc-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; }
.disc-meta span { color: var(--dim); font-size: 11.5px; }
.disc-body { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.disc-body .mention { color: var(--cyan); font-weight: 600; }
.disc-actions { display: flex; gap: 12px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.link-btn:hover { color: var(--cyan); }
.disc-compose { position: relative; display: grid; gap: 6px; margin-top: 4px; }
.disc-compose textarea { width: 100%; min-height: 56px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(10,15,28,0.75); color: var(--text); font: inherit; font-size: 13px; resize: vertical; }
.disc-compose-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.disc-suggest { position: absolute; left: 8px; top: 100%; z-index: 40; display: grid; min-width: 200px; padding: 4px;
  border: 1px solid var(--line); border-radius: 8px; background: rgba(10,15,28,0.98); }
.disc-suggest button { padding: 6px 8px; border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left;
  font: inherit; font-size: 12.5px; cursor: pointer; }
.disc-suggest button:hover { background: rgba(52,230,255,0.08); }
.disc-suggest small { color: var(--dim); }
.disc-reply-slot:empty { display: none; }
.ci-discussion, .rp-discussion, .pl-discussion { margin-top: 18px; }
[data-campaign-discussion]:not(:empty) { margin-top: 10px; }

.assign-row { display: inline-flex; align-items: center; gap: 8px; margin: 10px 10px 4px 0; color: var(--muted); font-size: 12.5px; }
.assign-row select { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: rgba(10,15,28,0.75);
  color: var(--text); font: inherit; font-size: 12.5px; }
.assignee-chip { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 6px; font-size: 10.5px;
  color: var(--amber); border: 1px solid rgba(255,196,77,0.28); white-space: nowrap; }
.d-live:empty { display: none; }
.d-live p { margin: 8px 0 0; font-size: 12.5px; color: var(--amber); }
.collab-conflict { margin-top: 8px; padding: 9px 11px; border: 1px solid rgba(255,196,77,0.35); border-radius: 9px;
  background: rgba(255,196,77,0.06); font-size: 12.5px; }
.collab-conflict p { margin: 0 0 6px; }
.collab-conflict-actions { display: flex; gap: 8px; }

.team-body { display: grid; gap: 14px; }
.team-card h2 { display: flex; align-items: center; gap: 10px; }
.team-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.team-table th, .team-table td { padding: 8px 6px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.team-table th { color: var(--dim); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.team-table select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: rgba(10,15,28,0.75);
  color: var(--text); font: inherit; font-size: 12.5px; }
.team-invites { display: grid; gap: 6px; margin-top: 8px; }
.team-invite { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.team-link { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: rgba(10,15,28,0.75);
  color: var(--text); font: 12px ui-monospace, monospace; }
/* The topbar's blur makes it its own layer; lift it so the bell panel opens over the page (below the drawer). */
.topbar { position: relative; z-index: 30; }
.team-card .dup-actions { align-items: center; }
.team-card .dup-actions .btn { flex: none; }

/* ---------- evidence assistant, homepage tools, Ask, connections ---------- */
.assist { display: grid; gap: 8px; }
.assist-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.assist-head h3 { margin: 0 6px 0 0; }
.assist-summary { padding: 10px 12px; border: 1px solid rgba(52,230,255,0.25); border-radius: 10px; background: rgba(52,230,255,0.05); }
.assist-sentence { margin: 0 0 6px; font-size: 13px; line-height: 1.5; }
.assist-why ul { margin: 4px 0 0 18px; padding: 0; font-size: 13px; line-height: 1.5; }
.assist-facts summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.assist-facts ol { margin: 6px 0 0 18px; padding: 0; display: grid; gap: 4px; font-size: 12.5px; }
.assist-facts small { color: var(--dim); margin-left: 4px; }
.fact-chip { display: inline-block; margin-left: 3px; padding: 0 5px; border-radius: 5px; font-size: 10.5px; color: var(--cyan);
  border: 1px solid rgba(52,230,255,0.3); cursor: help; }
.ci-assist, .rp-assist, .pl-assist { margin-top: 18px; }
[data-campaign-explain]:not(:empty), [data-al-explain-slot]:not(:empty) { margin-top: 10px; }
.tool-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-chip { padding: 3px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; background: rgba(122,162,255,0.05); }
.tool-chip b { color: var(--muted); font-weight: 600; margin-right: 4px; }
.tool-gap { margin: 6px 0 0; font-size: 12.5px; color: var(--amber); }
.ask-panel { width: min(460px, 94vw); }
.ask-row { display: flex; gap: 8px; margin-bottom: 8px; }
.ask-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(10,15,28,0.75); color: var(--text); font: inherit; font-size: 13px; }
.ask-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ask-examples button, .ask-link { padding: 4px 9px; border: 1px solid var(--line); border-radius: 7px; background: transparent;
  color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.ask-examples button:hover, .ask-link:hover { color: var(--cyan); border-color: rgba(52,230,255,0.35); }
#ask-answer p { margin: 0 0 6px; font-size: 13px; line-height: 1.5; }
.ask-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.conn-list { display: grid; gap: 10px; margin: 8px 0; }
.conn-card code { font-size: 12px; }
.conn-ok { color: var(--lime); }
.conn-missing { color: var(--amber); }
.conn-card [data-conn-every] { width: 64px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px;
  background: rgba(10,15,28,0.75); color: var(--text); font: inherit; font-size: 12px; }
.conn-help summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.conn-help ul { margin: 6px 0 0 18px; padding: 0; font-size: 12.5px; display: grid; gap: 4px; }
/* The Ask panel opens to the right of its button, so it never slides under the side bar. */
.ask-panel { left: 0; right: auto; }
