/* =================================================================
   RADAR — design tokens
   Light is the canonical theme; dark is a mirror. Country and severity
   palettes are semantic and identical across themes.
   ================================================================= */

:root {
  /* surfaces */
  --bg:        #f5f3ed;
  --paper:    #faf8f2;
  --surface:  #ffffff;
  --surface-2:#f0ede4;
  --rule:     #e3ddcd;
  --rule-2:   #d6cfba;

  /* ink */
  --ink:       #18130a;
  --ink-2:     #2f2a20;
  --ink-3:     #4b4538;
  --muted:     #7a7363;
  --muted-2:   #9b9483;

  /* accent — slate-blue, chosen to not collide with CZ blue */
  --accent:       #355070;
  --accent-hover: #233a55;
  --accent-soft:  #e6ecf2;
  --accent-soft-2:#d7e0ea;
  --accent-ink:   #ffffff;

  /* semantic — country (UNCHANGED from the live app, intentional) */
  --c-cz: #2563eb;
  --c-de: #111827;
  --c-md: #10b981;
  --c-pl: #dc2626;
  --c-mx: #c2790a;       /* darker amber for AA on paper */
  --c-uk: #6b7280;

  /* semantic — selector */
  --s-phone:    #2563eb;
  --s-telegram: #c2790a;
  --s-email:    #0e8264;
  --s-whatsapp: #06849b;
  --s-tg_user:  #b03c2a;
  /* signal-category hues (Leads "By scripts" expansion) */
  --cat-sex: oklch(0.53 0.16 25);  --cat-mul: oklch(0.53 0.13 65);
  --cat-scam: oklch(0.53 0.15 300); --cat-doc: oklch(0.53 0.13 245);
  --cat-mlm: oklch(0.53 0.16 350); --cat-target: oklch(0.53 0.13 155);
  --cat-eva: oklch(0.53 0.10 110);

  /* semantic — severity */
  --sev-hi:  #b3361f;
  --sev-mid: #b0741b;
  --sev-lo:  #6b7280;

  /* radii (small set) */
  --r-1: 2px;
  --r-2: 4px;
  --r-3: 6px;

  /* shadows */
  --shadow-1: 0 1px 0 rgba(20, 18, 12, 0.04);
  --shadow-2: 0 1px 2px rgba(20, 18, 12, 0.06), 0 0 0 1px var(--rule);
  --shadow-pop: 0 8px 24px rgba(20, 18, 12, 0.12), 0 0 0 1px var(--rule-2);

  /* type scale — small/micro bumped a notch for more readable labels & body */
  --t-micro: 12px;
  --t-small: 13.5px;
  --t-body:  14px;
  --t-base:  15px;
  --t-lede:  17px;
  --t-h3:    18px;
  --t-h2:    22px;
  --t-h1:    28px;
  --lh:      1.5;

  /* fonts */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue",
               Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  /* layout */
  --nav-h: 52px;
  --side-w: 320px;
  --maxw: 1280px;

  /* container padding (canonical card paddings) */
  --pad-card: 16px 18px;
  --pad-tight: 14px 16px;
}

html[data-theme="dark"] {
  --bg:        #16140f;
  --paper:    #1c1a14;
  --surface:  #221f17;
  --surface-2:#2a2620;
  --rule:     #383228;
  --rule-2:   #4a4434;

  --ink:       #f3eee0;
  --ink-2:     #e0d9c5;
  --ink-3:     #c4bca5;
  --muted:     #8e8773;
  --muted-2:   #6f6957;

  --accent:       #93b3d5;
  --accent-hover: #b2cae5;
  --accent-soft:  #243446;
  --accent-soft-2:#2d4259;
  --accent-ink:   #0f1820;

  --c-cz: #6196ff;
  --c-de: #d1d5db;
  --c-md: #34d399;
  --c-pl: #f87171;
  --c-mx: #fbbf24;
  --c-uk: #9ca3af;

  --s-phone:    #6196ff;
  --s-telegram: #fbbf24;
  --s-email:    #34d399;
  --s-whatsapp: #38bdf8;
  --s-tg_user:  #f87171;
  /* signal-category hues (Leads "By scripts" expansion) */
  --cat-sex: oklch(0.74 0.15 25);  --cat-mul: oklch(0.74 0.12 70);
  --cat-scam: oklch(0.74 0.13 300); --cat-doc: oklch(0.74 0.12 245);
  --cat-mlm: oklch(0.74 0.14 350); --cat-target: oklch(0.74 0.12 155);
  --cat-eva: oklch(0.74 0.10 110);

  --sev-hi:  #f87171;
  --sev-mid: #fbbf24;
  --sev-lo:  #9ca3af;

  --shadow-1: 0 1px 0 rgba(0, 0, 0, 0.25);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--rule);
  --shadow-pop: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--rule-2);
}

/* ----- reset ----- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font: var(--t-base)/var(--lh) var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
::selection { background: var(--accent-soft-2); color: var(--ink); }

/* =================================================================
   APP CHROME — top nav, page wrapper
   ================================================================= */
.app {
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.nav {
  height: var(--nav-h);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: stretch;
  position: sticky; top: 0; z-index: 50;
}
.nav__inner {
  width: 100%;
  /* The centred cap on content pages is made with side PADDING (not max-width),
     so entering/leaving the map can ANIMATE between centred and full-width —
     max-width is not animatable, padding is. Off-map the content sits in a
     centred --maxw column (min 24px gutter); on the map the padding shrinks to a
     flush 24px gutter, so the bar smoothly EXPANDS to the screen edges and
     contracts back when you leave. */
  padding: 0 max(24px, calc((100% - var(--maxw)) / 2));
  display: flex; align-items: center; gap: 24px;
  transition: padding 400ms cubic-bezier(.4, 0, .2, 1);
}
/* the map is the only full-screen page, so its nav spans the full width (brand
   flush with the flush-left rail). Content pages keep the centred cap. */
body.map-page .nav__inner { padding-left: 24px; padding-right: 24px; }
/* respect reduced-motion: snap instead of sliding */
@media (prefers-reduced-motion: reduce) { .nav__inner { transition: none; } }
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink);
  font-size: 15px;
}
/* Slim logo-only header shown during the whole-app warmup lock (no nav links). */
.warmup-header {
  height: var(--nav-h);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
/* Brand logo - inlined as <RadarLogo/> (see primitives.jsx) so it
   inherits theme accent via currentColor. The /static/logo.svg file is
   the same geometry, hard-coded slate-blue, used as the favicon and on
   the Cloudflare Access login page. */
.brand svg { color: var(--accent); }

/* logo + section indicator as one tight unit (so the nav's 24px gap doesn't
   push them apart). */
.brand-wrap { display: flex; align-items: center; gap: 9px; }
/* (the "/ section" breadcrumb was removed — it duplicated the highlighted nav
   tab.) */

/* Refresh banner: full-width strip under the Nav while the pipeline
   runs. Subtle so it never blocks reading; dot + accent-tinted bg so
   it reads as informational, not error. Live-region for a11y. */
.refresh-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px; font-size: var(--t-small);
  background: var(--accent-soft, rgba(53, 80, 112, 0.10));
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
}
.refresh-banner__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: refresh-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes refresh-pulse {
  0%, 100% { opacity: 0.5; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1.15); }
}
.refresh-banner__link {
  margin-left: auto; color: var(--accent); font-size: var(--t-small);
}
.refresh-banner__close {
  margin-left: auto; background: transparent; border: 0;
  color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
  padding: 0 2px; flex-shrink: 0;
}
.refresh-banner__close:hover { color: var(--ink); }
.brand small {
  color: var(--muted); font-weight: 400; font-size: 11px;
  font-family: var(--font-mono); letter-spacing: 0.05em;
  margin-left: 2px;
}

.nav__links {
  display: flex; gap: 2px; align-items: center;
  flex: 1;
}
.nav__link {
  padding: 6px 12px;
  font-size: var(--t-body);
  color: var(--ink-3);
  border-radius: var(--r-2);
  cursor: pointer;
  user-select: none;
  border: 0; background: transparent;
}
.nav__link:hover { color: var(--ink); background: var(--surface-2); }
.nav__link[aria-current="page"] {
  color: var(--ink); background: var(--accent-soft);
  font-weight: 500;
}
.nav__right { display: flex; align-items: center; gap: 6px; }
.nav__btn {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 5px 10px;
  font-size: var(--t-small);
  font-family: var(--font-mono);
  color: var(--ink-3);
  cursor: pointer;
  border-radius: var(--r-2);
  display: inline-flex; align-items: center; gap: 6px;
}
.nav__btn:hover { color: var(--ink); border-color: var(--rule-2); }
.nav__btn--icon { padding: 5px; width: 30px; justify-content: center; }
.nav__btn--icon[aria-current="page"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft-2); }

.nav__status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--muted);
  margin-right: 4px;
  border-right: 1px solid var(--rule);
  white-space: nowrap;
}
.nav__status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-md);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--c-md) 22%, transparent);
}
.nav__status-sep { color: var(--rule-2); }

/* The headline stats strip was removed from the map nav; the right-side status
   pill still shows on every page, the map included. */

@media (max-width: 1024px) {
  .nav__btn-lbl { display: none; }
}
@media (max-width: 900px) {
  .nav__status { display: none; }
}

/* Pipeline status chip — shows in the navbar only while a run is in progress;
   click opens the live logs modal. */
.nav__pipeline {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; margin-right: 2px;
  font: 500 var(--t-small)/1 var(--font-sans);
  color: var(--accent);
  background: var(--accent-soft, rgba(53, 80, 112, 0.10));
  border: 1px solid var(--accent-soft-2, var(--rule));
  border-radius: var(--r-2);
  cursor: pointer; white-space: nowrap;
}
.nav__pipeline:hover { border-color: var(--accent); }
.nav__pipeline-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: refresh-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.nav__pipeline-label .mono { font-family: var(--font-mono); }
@media (max-width: 760px) {
  .nav__pipeline-label { display: none; }
}
/* Warming-caches indicator in the nav status slot (post-restart only). Clickable
   button that re-opens the full warmup page. */
.nav__status--warm {
  color: var(--accent); border: 0; border-right: 1px solid var(--rule);
  background: transparent; cursor: pointer; font: 500 var(--t-small)/1 var(--font-mono);
}
.nav__status--warm:hover { color: var(--accent-hover); }
@media (max-width: 900px) { .nav__status--warm { display: inline-flex; } }

/* Pipeline logs modal — live-tailing terminal-style view */
.ppl-logs { display: flex; flex-direction: column; gap: 12px; min-height: 320px; }
.ppl-logs__head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.ppl-logs__status {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: var(--t-small); color: var(--muted);
}
.ppl-logs__status.is-running { color: var(--accent); }
.ppl-logs__body {
  flex: 1; overflow-y: auto;
  max-height: min(60vh, 520px);
  background: var(--surface-2, #0d1117);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 12px 14px;
  font-size: var(--t-micro, 11px); line-height: 1.55;
}
.ppl-logs__line { color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }
.ppl-logs__line--hd { color: var(--accent); font-weight: 600; margin-top: 6px; }
.ppl-logs__line--err { color: var(--c-sex, #d2607a); font-weight: 600; }

/* PageHead — simple title + optional ? popover + right meta
   Reserve a top "preamble" zone so optional Back/Crumb on detail pages
   don't shift the title position relative to top-level pages. */
.phead {
  margin-bottom: 18px;
  padding-top: 0;
  min-height: 56px;
}
.phead__row {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  min-height: 36px;
}
.phead__title {
  font: 500 var(--t-h1)/1.15 var(--font-sans);
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ink);
}
.phead__info {
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--muted);
  width: 22px; height: 22px;
  border-radius: 50%;
  font: 500 12px/1 var(--font-sans);
  cursor: pointer;
  padding: 0;
  align-self: center;
}
.phead__info:hover { color: var(--ink); border-color: var(--rule-2); }
.phead__info[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft-2); }
/* Labeled, more-noticeable variant: a small "ⓘ What is this page?" chip
   instead of the bare "?" circle. Opt-in via PageHead's infoLabel prop. */
.phead__info--labeled {
  width: auto; height: auto;
  border-radius: 999px;
  padding: 4px 11px;
  gap: 5px;
  display: inline-flex; align-items: center;
  font: 500 var(--t-small)/1 var(--font-sans);
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-soft-2);
}
.phead__info--labeled:hover { color: var(--accent); background: var(--accent-soft-2); border-color: var(--accent); }

.phead__meta {
  margin-left: auto;
  font: 500 var(--t-small)/1.4 var(--font-mono);
  color: var(--muted);
  text-align: right;
  align-self: center;
}
.phead__sub {
  margin-top: 6px;
  color: var(--muted); font-size: var(--t-body);
  max-width: 64ch;
}

/* page */
.page {
  flex: 1;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}
.page__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.page__title {
  font: 500 var(--t-h1)/1.15 var(--font-sans);
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ink);
}
.page__title small {
  font: 400 var(--t-small)/1 var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.page__sub {
  color: var(--muted); font-size: var(--t-body);
  max-width: 64ch;
}
.page__meta {
  font: 400 var(--t-small)/1.4 var(--font-mono);
  color: var(--muted);
  text-align: right;
}

/* back affordance */
.back {
  display: flex; align-items: center; gap: 6px;
  width: max-content;
  font-size: var(--t-small);
  font-family: var(--font-mono);
  color: var(--accent);
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: var(--r-2);
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 12px;
  white-space: nowrap;
}
.back:hover { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.back svg { width: 12px; height: 12px; }

/* trail dropdown attached to the back button */
.back-wrap {
  display: inline-flex; align-items: stretch;
  position: relative;
  margin-bottom: 8px;
  height: 28px;
}
.back-wrap + .crumb { margin-top: -4px; }
.back-wrap .back { margin-bottom: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.back__more {
  border: 1px solid var(--rule);
  border-left: 0;
  background: var(--surface);
  color: var(--accent);
  padding: 0 8px;
  cursor: pointer;
  border-top-right-radius: var(--r-2);
  border-bottom-right-radius: var(--r-2);
  display: inline-flex; align-items: center;
}
.back__more:hover { background: var(--accent-soft); border-color: var(--accent-soft-2); }
.back__menu {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-pop);
  min-width: 280px;
  max-width: 360px;
  z-index: 40;
  padding: 6px;
}
.back__menu-h {
  font: 500 var(--t-micro)/1 var(--font-mono);
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;
  padding: 6px 8px 8px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.back__menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-1);
  font: 500 var(--t-small)/1.3 var(--font-mono);
  color: var(--ink-3);
  text-decoration: none;
  white-space: nowrap;
}
.back__menu-item:hover { background: var(--surface-2); color: var(--ink); }
.back__menu-item > span:first-of-type {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis;
}
.back__menu-i { font-size: var(--t-micro); }

.crumb {
  display: flex; gap: 6px; align-items: center;
  font-size: var(--t-small);
  color: var(--muted);
  font-family: var(--font-mono);
  margin-bottom: 12px;
  flex-wrap: wrap;
  min-height: 18px;
}

/* Back + Crumb on the same horizontal row. Pages wrap them in this div so
   they share a horizontal line instead of stacking two block-level elements
   with their own margin-bottom. Children are sized to MATCH the back
   button's height so their text-centers align to the same baseline. */
.page__hdrow {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.page__hdrow .back,
.page__hdrow .back-wrap,
.page__hdrow .crumb { margin: 0; }
/* Match the back pill's height so flex vertical-center puts the crumb's
   text-center on the same y as the back button's. */
.page__hdrow .crumb { min-height: 28px; align-items: center; }
.crumb__sep { opacity: 0.4; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--ink-3); }
.crumb__here { color: var(--ink); }

/* =================================================================
   FILTER BAR — inline chip toggles + popover for long lists
   ================================================================= */
.filterbar {
  /* Span the full page width on every page that uses it (Search, Leads,
     Network, Scripts, Entities). Settings keeps its own admin-grid layout
     and doesn't render a FilterBar. */
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}
/* When a text input sits inside the filterbar (e.g. Entities "Find by id"
   or Network "Find by..."), let it stretch to fill remaining horizontal
   space rather than sit at its fixed width. */
.filterbar > input.text {
  flex: 1 1 220px;
  min-width: 0;
}
.filterbar__group {
  display: flex; align-items: center; gap: 6px;
}
.filterbar__label {
  font: 500 var(--t-micro)/1 var(--font-mono);
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em;
  margin-right: 2px;
}

.filterbar__search {
  position: relative;
  flex: 1 1 320px;
  min-width: 220px;
  max-width: 480px;
}
/* Scripts page has no other right-side controls in the leading area
   (just the seg switch lives on the left). Let the search input
   stretch the full width here for easier scanning. */
.page[data-screen-label="04 Scripts"] .filterbar__search {
  max-width: none;
  flex: 1 1 auto;
  display: flex; align-items: center;
}
/* Search page: drop the cap and let the search input grow into the
   gap between it and the trailing Weights button. Otherwise the bar
   sat at 480px with a giant void between Sort and Weights. */
.page[data-screen-label="01 Search"] .filterbar__search {
  max-width: none;
}
.filterbar__search > svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; z-index: 1;
}
/* Higher-specificity selector + longhand props so the magnifier / clear
   icons don't get overlapped by the input text. The earlier
   `.filterbar__search > input` rule lost to the later `input.text {
   padding: 5px 8px }` shorthand and the placeholder/value collided
   with the icons. */
.filterbar__search > input.text {
  padding-left: 28px; padding-right: 28px;
}
.filterbar__clear {
  position: absolute; right: 6px;
  border: 0; background: transparent;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer;
  border-radius: var(--r-1);
}
.filterbar__clear:hover { color: var(--ink); background: var(--surface-2); }

.filterbar__inline {
  display: inline-flex; align-items: center; gap: 4px;
  flex-wrap: wrap;
}
.filterbar__inline--nowrap {
  flex-wrap: nowrap;
  min-width: 0;
}
@media (max-width: 1100px) {
  /* at narrow widths give each filter group its own row to avoid awkward
     half-wraps where "Multi" lands next to a date input */
  .filterbar__inline { flex-basis: 100%; }
}
input.text.filterbar__date {
  width: 130px;
  font-family: var(--font-mono);
  font-size: var(--t-small);
  padding: 4px 6px;
  flex-shrink: 0;
  flex-grow: 0;
}
.filterbar__date-sep {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--t-small);
  flex-shrink: 0;
}
@media (max-width: 1100px) {
  /* date row gets its own line so it doesn't fight other filter chips */
  .filterbar__inline--nowrap { flex-basis: 100%; }
}

.fchip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 3px 8px;
  font: 500 var(--t-small)/1.4 var(--font-mono);
  color: var(--ink-3);
  cursor: pointer;
  border-radius: var(--r-2);
  white-space: nowrap;
  transition: border-color 80ms ease, background 80ms ease;
}
.fchip:hover { border-color: var(--rule-2); color: var(--ink); }
.fchip--on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.fchip__lbl {
  font-family: var(--font-sans);
  color: inherit;
  font-weight: 400;
  opacity: 0.92;
}

/* Selected-filter chip tokens (country / contact) with an × remove button.
   Country variants get a subtle color-mix tint + country-coloured text inline
   (see chrome.jsx), matching the .pill--sev tag pattern so they read calmly
   in dark mode instead of a solid bright pastel fill. */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  font: 500 var(--t-small)/1.4 var(--font-mono);
  background: var(--surface);
  color: var(--ink-3);
  white-space: nowrap;
}
.chip__x {
  border: 0; background: transparent; color: inherit;
  cursor: pointer; opacity: 0.7; line-height: 1;
  font-size: 1.05em; padding: 0 1px;
}
.chip__x:hover { opacity: 1; }

/* on narrow viewports, country chips show codes only */
@media (max-width: 900px) {
  .filterbar__inline .fchip .fchip__lbl { display: none; }
}

.filter-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 5px 10px;
  font-size: var(--t-small);
  color: var(--ink-3);
  border-radius: var(--r-2);
  cursor: pointer;
  font-family: var(--font-mono);
}
.filter-btn:hover { border-color: var(--rule-2); color: var(--ink); }
.filter-btn[aria-expanded="true"],
.filter-btn--active { background: var(--accent-soft); color: var(--ink); border-color: var(--accent-soft-2); }

.popover {
  /* Was position: absolute; that broke when a Popover sat inside an
     ancestor that had a positioned context (the right edge would shift).
     Switched to fixed so the computed top/left/right are pure viewport
     coords, independent of any positioned ancestor. */
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--rule-2);
  box-shadow: var(--shadow-pop);
  padding: 14px 16px;
  border-radius: var(--r-3);
  z-index: 40;
  min-width: 240px;
  /* Cap the width so explainer text wraps into a compact box (never a
     full-width bar), and never exceed the viewport on narrow screens. */
  max-width: min(340px, calc(100vw - 24px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  box-sizing: border-box;
  /* Popovers (esp. InfoHint "?") are often DOM children of uppercased,
     nowrap table headers (text-transform: uppercase + white-space: nowrap on
     .tbl th), so the explainer text would inherit ALL CAPS and refuse to wrap.
     Force normal casing/spacing/wrapping — explainer copy is sentences. */
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
}
.popover__title {
  font: 500 var(--t-micro)/1 var(--font-mono);
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 8px;
}
/* Consistent popover body: one type size + colour for all PageHead "?" content. */
.popover__body {
  max-width: 320px;
  font-size: var(--t-small);
  line-height: 1.5;
  color: var(--ink-3);
}
.popover__row { margin-bottom: 12px; }
.popover__row:last-child { margin-bottom: 0; }
.popover__label {
  display: block;
  font: 500 var(--t-small)/1.4 var(--font-sans);
  color: var(--ink-3);
  margin-bottom: 4px;
}
.popover__opts {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.opt {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 3px 8px;
  font-size: var(--t-small);
  border-radius: var(--r-2);
  color: var(--ink-3);
  cursor: pointer;
}
.opt:hover { border-color: var(--rule-2); }
.opt[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

input.text, select.text {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 5px 8px;
  font-size: var(--t-body);
  border-radius: var(--r-2);
  width: 100%;
  color: var(--ink);
}
input.text:focus, select.text:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Native <select>: suppress the browser's chrome and draw our own caret so
   the closed control matches the app. NB: the OPEN option list is OS-drawn
   and can't be fully CSS-styled cross-browser - replacing <select> with a
   custom Popover-based listbox is the only way to theme the open menu. */
select.text {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  font-family: var(--font-sans);
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
/* best-effort theming of the options themselves (honoured on Win/Linux
   Chrome + Firefox; macOS draws them natively regardless) */
select.text option { background: var(--surface); color: var(--ink); font-family: var(--font-sans); }

/* =================================================================
   PRIMITIVES — card, pill, pager, empty, spinner
   ================================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 16px 18px;
  transition: border-color 80ms ease;
}
.card:hover { border-color: var(--rule-2); }
.card--flat { border-radius: 0; padding: 14px 16px; }
.card--graph {
  padding: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.card__hd {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; gap: 10px;
}
.card__bd { padding: 14px 16px; }

/* pill */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px;
  font: 500 var(--t-micro)/1.5 var(--font-mono);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--rule);
  white-space: nowrap;
}
.pill--lg { font-size: var(--t-small); padding: 2px 9px; }
.pill--meta { background: var(--surface-2); color: var(--muted); border-color: var(--rule); }
.pill--src { background: transparent; color: var(--muted); border-color: var(--rule); }

.pill--country {
  color: #fff;
  border: 0;
  padding: 2px 8px;
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
.pill--country[data-c="CZ"] { background: var(--c-cz); }
.pill--country[data-c="DE"] { background: var(--c-de); }
.pill--country[data-c="MD"] { background: var(--c-md); }
.pill--country[data-c="PL"] { background: var(--c-pl); }
.pill--country[data-c="MX"],
.pill--country[data-c="Multi"] { background: var(--c-mx); }
.pill--country[data-c="XX"],
.pill--country[data-c="Unknown"],
.pill--country[data-c="??"] { background: var(--c-uk); }
/* Dark mode: chip backgrounds are pastel, so a near-black foreground
   passes contrast where light-on-light previously failed. */
html[data-theme="dark"] .pill--country {
  color: #11161f;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

.pill--sev-hi  { background: color-mix(in oklab, var(--sev-hi) 16%, transparent); color: var(--sev-hi); border-color: color-mix(in oklab, var(--sev-hi) 30%, transparent); }
.pill--sev-mid { background: color-mix(in oklab, var(--sev-mid) 16%, transparent); color: var(--sev-mid); border-color: color-mix(in oklab, var(--sev-mid) 30%, transparent); }
.pill--sev-lo  { background: var(--surface-2); color: var(--muted); }

.pill--sel {
  color: #fff;
  border: 0;
  padding: 2px 8px;
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
.pill--sel[data-t="phone"]    { background: var(--s-phone); }
.pill--sel[data-t="telegram"] { background: var(--s-telegram); }
.pill--sel[data-t="email"]    { background: var(--s-email); }
.pill--sel[data-t="whatsapp"] { background: var(--s-whatsapp); }
.pill--sel[data-t="tg_user"]  { background: var(--s-tg_user); }
/* Identity (poster) node pill - uses the muted-slate token so it
   visually separates from the contact-type pills (which are vivid)
   while still being readable in light + dark themes. */
.pill--sel[data-t="_poster"]  { background: var(--c-md); }
html[data-theme="dark"] .pill--sel {
  color: #11161f;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* flag */
.flag {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  /* Keep the chip a clean square even inside a tight flex row: never let a
     long sibling (e.g. the "Ring #N · stats" line) squeeze it below its set
     width. flex-shrink:0 holds the box; aspect-ratio guards the square. */
  flex: 0 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 2px;
  /* Heavier weight + slightly larger letterforms so the 2-letter code
     reads cleanly against the colored background. */
  font: 700 11px/1 var(--font-mono);
  color: #fff;
  letter-spacing: 0.04em;
  /* Subtle text shadow lifts the white text off mid-saturation chip
     backgrounds (amber, green, light blue) without darkening the chip. */
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
.flag[data-c="CZ"] { background: var(--c-cz); }
.flag[data-c="DE"] { background: var(--c-de); }
.flag[data-c="MD"] { background: var(--c-md); }
.flag[data-c="PL"] { background: var(--c-pl); }
.flag[data-c="MX"],
.flag[data-c="Multi"] { background: var(--c-mx); }
.flag[data-c="XX"],
.flag[data-c="Unknown"],
.flag[data-c="??"] { background: var(--c-uk); }
/* Dark mode: chip backgrounds are pastel, so a near-black foreground
   passes WCAG AA where light-on-light previously failed. */
html[data-theme="dark"] .flag {
  color: #11161f;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
.flag--lg { width: 28px; height: 28px; font-size: 12px; }
/* Avatar-size flag: used in entity/source headers in place of a generic icon. */
.flag--xl { width: 44px; height: 44px; font-size: 15px; border-radius: 10px; letter-spacing: 0.06em; }

/* button */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--rule);
  padding: 5px 12px;
  font-size: var(--t-body);
  border-radius: var(--r-2);
  cursor: pointer;
  font-family: var(--font-sans);
}
.btn:hover { border-color: var(--rule-2); color: var(--ink); }
.btn--primary {
  background: var(--accent); color: var(--accent-ink);
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
/* Owner-locked action (e.g. Run now for members): reads as deliberately locked,
   not just transiently disabled. Flat/neutral with a dashed outline + lock cursor. */
.btn--locked, .btn--locked:disabled {
  background: transparent; color: var(--muted);
  border: 1px dashed var(--rule); cursor: not-allowed; opacity: 1;
}
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--rule); }
.btn--icon { padding: 5px; }
.btn svg { width: 14px; height: 14px; }
.btn--xs { font-size: var(--t-small); padding: 2px 8px; }

/* segmented */
.seg {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  background: var(--surface);
  padding: 2px;
  gap: 2px;
}
.seg__btn {
  background: transparent;
  border: 0;
  padding: 4px 12px;
  font-size: var(--t-small);
  color: var(--ink-3);
  cursor: pointer;
  border-radius: var(--r-1);
  font-family: var(--font-mono);
  white-space: nowrap;
}
.seg__btn:hover { color: var(--ink); }
.seg__btn[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink);
}

/* pager — single line, compact even in narrow rails */
.pager {
  display: inline-flex; align-items: center; gap: 2px;
  font-family: var(--font-mono);
  font-size: var(--t-small);
  flex-wrap: nowrap;
  max-width: 100%;
  min-width: 0;
}
.pager__btn {
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-3);
  padding: 3px 6px;
  cursor: pointer;
  border-radius: var(--r-1);
  font: inherit;
  min-width: 24px;
  flex: 0 0 auto;
}
.pager__btn:hover { color: var(--ink); border-color: var(--rule-2); }
.pager__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pager__cur {
  padding: 3px 6px;
  color: var(--muted);
  white-space: nowrap;
  font-size: var(--t-micro);
  min-width: 0;
  text-align: center;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Source page — Top posters list. The height-lock kicks in ONLY when the
   list is paginated (`--paged` modifier), so a source with only a few
   posters renders at its natural compact size instead of leaving a tall
   empty area. When paginated, every row is a strict 48px so pages with
   kw subtitles aren't taller than pages without, and the container
   reserves the full perPage rows so the section doesn't jump on swap. */
.src__poster-list {
  align-content: flex-start;
}
.src__poster-list--paged {
  min-height: calc(10 * 48px + 9 * 4px);  /* perPage=10 rows * row height + gaps */
}
.src__poster-list--paged .sub-row {
  box-sizing: border-box;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  overflow: hidden;
}

/* Source page — search input + square sort button on one row */
.src__filter { align-items: stretch; }
.src__sort-btn {
  flex: 0 0 auto;
  width: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.src__sort-btn--active {
  border-color: var(--accent);
  color: var(--accent);
}
.src__sort-opt {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: 0;
  border-radius: var(--r-1);
  color: var(--ink-2);
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.src__sort-opt:hover { background: var(--paper); color: var(--ink); }
.src__sort-opt--on { color: var(--accent); font-weight: 500; }

/* empty state */
.empty {
  background: var(--paper);
  border: 1px dashed var(--rule-2);
  padding: 36px 24px;
  text-align: center;
  border-radius: var(--r-3);
  color: var(--muted);
}
.empty__title {
  font: 500 var(--t-body)/1.3 var(--font-mono);
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.empty__msg { font-size: var(--t-body); max-width: 48ch; margin: 0 auto; }
.empty__action { margin-top: 14px; }
.empty--inline { padding: 18px; }

/* spinner & skeleton */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skel {
  background: linear-gradient(90deg, var(--surface-2), var(--rule), var(--surface-2));
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: var(--r-1);
}
@keyframes skel {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Apply to any element to make it pulse like a skeleton WHILE preserving
   its CSS-driven dimensions (font line-height, padding, etc.). Use on
   .ent__hd .name, .ent__hd .kw, etc. so the skeleton's size comes from
   the real CSS rather than a hardcoded h={32}. */
.skel-pulse {
  background: linear-gradient(90deg, var(--surface-2), var(--rule), var(--surface-2));
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: var(--r-1);
  color: transparent !important;
  user-select: none;
}
.skel-pulse * { color: transparent !important; }

/* Ring context banner (Phase 5.5.4) — single source of truth for the strip
   that sits under .ent__hd. Both the real banner and its skeleton render
   inside this class so they share the same dimensions. */
.ent__ring-banner {
  padding: 6px 12px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  /* Match the section rhythm (.ent__section margin-bottom: 18px) so the
     banner sits at the same pace as the cards below it. */
  margin: 0 0 18px;
  font-size: var(--t-small);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.ent__ring-banner--empty {
  background: transparent;
  border-left-color: var(--rule);
  border-left-style: dashed;
  color: var(--muted);
  padding: 4px 12px;
}

/* =================================================================
   MODAL — focus overlay (full-text ads, network-card detail)
   ================================================================= */
.modal {
  position: fixed; inset: 0;
  background: rgba(20, 18, 12, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 100;
  animation: modalFade 120ms ease-out;
}
html[data-theme="dark"] .modal { background: rgba(0, 0, 0, 0.7); }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal__box {
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-3);
  padding: 22px 26px;
  max-width: 720px;
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow: auto;
  position: relative;
  box-shadow: var(--shadow-pop);
  animation: modalPop 160ms ease-out;
}
.modal__box--wide { max-width: 1100px; }
@keyframes modalPop { from { opacity: 0; } to { opacity: 1; } }

/* ad detail modal header — two-column row.
   LEFT (.adm-head__main, flex:1 min-width:0): flag + title + identity/source/
   date sublines (unchanged content). RIGHT (.adm-head__signals, ~240px,
   top-aligned): the fired-signal pills in their own vertical column, NOT
   stacked below the title. Under 640px the signals column drops below the
   main block (flex-wrap + full-width). */
.adm-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px 20px;
  margin-bottom: 16px;
}
.adm-head__main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1 1 320px;
  min-width: 0;
}
.adm-head__signals {
  flex: 0 0 auto;
  width: 340px;          /* wide enough that pills sit side-by-side + wrap, not a vertical stack */
  max-width: 100%;
  padding-right: 30px;   /* keep the right-aligned pills clear of the modal's X close button */
  box-sizing: border-box;
  align-self: center; /* vertically center the pill stack against the whole header text block (title + identity + source) */
}
/* A hair more vertical padding for legibility — pills stay compact (font-size
   unchanged), matching the card .ad__pills treatment. */
.adm-head__signals .pill { padding-top: 2px; padding-bottom: 2px; }
/* Under 640px the pills column stacks below the left block (full width). */
@media (max-width: 640px) {
  .adm-head__signals { flex: 1 1 100%; width: 100%; }
}

/* ad detail modal body + sections */
.adm-body {
  font: 14px/1.5 var(--font-sans);
  color: var(--ink-2);
  white-space: pre-wrap;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 12px 14px;
  max-height: 280px;
  overflow: auto;
  margin-bottom: 16px;
}
/* Fired-signal pills in the modal header. The base `.sig-mark` is `display:
   inline` (built for in-body text); inside `.adm-fired` we override to small
   inline-flex chips that wrap onto multiple rows and never exceed the modal
   width (max-width:100% on the container). Visible pills are capped in JSX;
   the trailing `.adm-fired__more` "+N" chip absorbs the remainder. */
.adm-fired {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;   /* right-aligned Pills, identical to the card .ad__signals */
  gap: 6px;
  margin-top: 0;               /* heading removed — pills top-align with the title */
  max-width: 100%;
}
.adm-repost { display: flex; justify-content: flex-end; }
/* Signal category pills are RED (high-severity tone), matching the card pills. */
.adm-fired .pill {
  color: var(--sev-hi);
  background: color-mix(in oklab, var(--sev-hi) 16%, transparent);
  border-color: color-mix(in oklab, var(--sev-hi) 30%, transparent);
}
.adm-fired .sig-mark {
  display: inline-flex;
  align-items: center;
  line-height: 1.4;
  padding: 1px 6px;
  border-bottom-width: 1.5px;
  font-size: var(--t-micro);
  font-weight: 500;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.adm-fired__more {
  color: var(--muted);
  cursor: default;
}

.adm-grid {
  display: grid;
  /* minmax(0, 1fr) - without the explicit 0 min, grid columns expand
     to fit their widest unbreakable content, which lets a long
     posting-id + truncated title row push the column past the modal
     boundary. Clamping the min to 0 keeps each cell at exactly half. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}
@media (max-width: 720px) { .adm-grid { grid-template-columns: 1fr; } }
/* Sub-rows inside the modal grid (Same script / Similar wording) sit
   inside a flex container; the middle (title) cell needs min-width:0
   to actually clip with ellipsis instead of pushing the row wider. */
.adm-grid .sub-row { min-width: 0; max-width: 100%; }
.adm-grid .sub-row > * { min-width: 0; }
.adm-h4 {
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 4px;
  display: flex; align-items: baseline; gap: 8px;
}
.modal__close {
  position: absolute; top: 12px; right: 12px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--muted);
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: var(--r-2);
}
.modal__close:hover { color: var(--ink); border-color: var(--rule-2); }

/* =================================================================
   AD CARD & AD BODY (clamp pattern preserved from rules §5.1)
   ================================================================= */
.ad {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 14px 16px;
}
.ad--compact {
  padding: 10px 12px;
  border-radius: var(--r-2);
}
.ad--compact .ad__hd { margin-bottom: 4px; }

/* Poster line under the title - matches the AdDetailModal subline so
   the list and full view read the same way: display name + small mono
   #id suffix, all on one wrap-friendly row. */
.ad__poster {
  font-family: var(--font-sans);
  font-size: var(--t-small);
  color: var(--ink-3);
  margin: 0 0 8px;
  line-height: 1.4;
}
.ad--compact .ad__poster { margin: 2px 0 6px; font-size: var(--t-micro); }
.ad--compact .ad__foot { margin-top: 8px; padding-top: 8px; font-size: var(--t-micro); }
.ad--clickable { cursor: pointer; }
.ad--clickable:hover { border-color: var(--rule-2); box-shadow: 0 1px 0 rgba(20,18,12,0.06); }

/* Card top is two columns: content (title + identity) on the left, pills
   (signal tags + ×N repost) stacked on the right. Pills in their own column
   means they never sit between the title and the identity line. */
/* align-items:flex-start keeps the pill column TOP-aligned with the title row
   (.ad__hd), so the pills sit beside the headline rather than floating against
   the taller identity+source block below. The pills stay compact — we do NOT
   stretch them to the block height. */
.ad__top { display: flex; align-items: flex-start; gap: 12px; }
.ad__top-main { flex: 1 1 auto; min-width: 0; }
.ad__pills { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; max-width: 45%; align-self: center; }
.ad__signals { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
/* A hair more vertical padding than the base .pill for legibility beside the
   title — kept compact (font-size unchanged at --t-micro). */
.ad__pills .pill { padding-top: 2px; padding-bottom: 2px; }
/* On narrow screens drop the pills under the content so the title keeps room */
@media (max-width: 640px) {
  .ad__top { flex-direction: column; gap: 4px; }
  .ad__pills { max-width: 100%; align-items: flex-start; }
  .ad__signals { justify-content: flex-start; }
}

/* navigation trail — pills above page content */
.trail {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 24px;
  /* Single horizontal line — never wrap. Long trails scroll horizontally
     instead of stacking into multiple lines. */
  display: flex; align-items: center; gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  white-space: nowrap;
  /* Sans (not mono) so the breadcrumb reads like body text, not code. */
  font: 500 var(--t-small)/1.4 var(--font-sans);
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.trail > * { flex: 0 0 auto; }
.trail__lbl {
  text-transform: uppercase; letter-spacing: 0.08em;
  font-size: var(--t-micro);
  margin-right: 4px;
}
.trail__sep { color: var(--rule-2); }
.trail__step {
  border: 0; background: transparent;
  color: var(--ink-3);
  padding: 2px 6px;
  border-radius: var(--r-1);
  cursor: pointer;
  font: inherit;
}
.trail__step:hover { background: var(--surface-2); color: var(--ink); }
.trail__here {
  color: var(--ink);
  padding: 2px 6px;
  background: var(--accent-soft);
  border-radius: var(--r-1);
}
.trail__clear {
  margin-left: auto;
  border: 0; background: transparent;
  color: var(--muted-2); cursor: pointer;
  padding: 2px 6px;
  font: inherit;
}
.trail__clear:hover { color: var(--ink); }
.ad__hd {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.ad__title {
  font: 500 var(--t-base)/1.35 var(--font-sans);
  color: var(--ink);
  letter-spacing: -0.005em;
  flex: 1;
  min-width: 0;
  /* Truncate to one line — the full ad body is rendered right below the
     title, so the title doesn't need to wrap. Avoids long emoji-heavy
     titles eating two or three lines of vertical real estate per card. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ad__body {
  font-size: var(--t-body);
  color: var(--ink-3);
  line-height: 1.5;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad__body--full {
  display: block;
  -webkit-line-clamp: unset;
}
.ad__toggle {
  display: inline-flex;
  margin-top: 6px;
  border: 0; background: transparent; padding: 0;
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--accent); cursor: pointer;
}
.ad__toggle:hover { color: var(--accent-hover); }
.ad__foot {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  font-size: var(--t-small);
  color: var(--muted);
  font-family: var(--font-mono);
}
/* The trailing links (source/ring/profile/network) live in a single
   inline-flex span pushed flush-right (margin-left:auto). They must stay on
   ONE line — never stack — so they keep their own nowrap. The room they need
   is reclaimed from the SOURCE name on the left, which truncates instead. */
.ad__foot-links { flex-wrap: nowrap; flex: 0 0 auto; }
/* Keep each meta chunk (channel / date) on its own line — without this the
   date can break mid-token and steal width from the links, squeezing them
   into a tall one-per-line column. */
.ad__foot > span:not(.ad__foot-links) { white-space: nowrap; }

/* Single-line compact footer (the map detail sidebar `.ad--compact`).
   meta (source · date) on the LEFT, action links flush RIGHT, all on one
   row. The action links are the priority and must NEVER wrap or clip; the
   narrow sidebar can't fit a full source name beside them, so the meta on
   the left is the flexible zone that shrinks. The SOURCE name truncates with
   an ellipsis first; the date can ellipsize too if the sidebar is extremely
   narrow — either way the links keep their full width on the one line.
   Tighter gaps reclaim the last few px so all four links fit without clip. */
.ad--compact .ad__foot {
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 5px;
}
/* The source name link is the element that gives up width: it carries the
   ellipsis and shrinks (potentially to a few chars) so the links stay on one
   line. The date is short + a complete value, so we keep it whole and let the
   source absorb (almost) all of the shrink instead. */
.ad--compact .ad__foot a.src,
.ad--compact .ad__foot span.src {
  min-width: 0;
  flex: 1 1 auto;
  flex-shrink: 999;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The date is the LAST thing to collapse — it only ellipsizes if the source
   has already gone to its minimum, so the links never clip in any case. */
.ad--compact .ad__foot > span:not(.ad__foot-links) {
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ad--compact .ad__foot-links {
  margin-left: auto;
  flex: 0 0 auto;
  column-gap: 6px;
  font-size: var(--t-micro);
}

/* The map detail sidebar's map.css pins `.mdetail .ad__foot` to
   `flex-wrap: nowrap; overflow: hidden` — which is exactly what we want for
   the single-line compact footer, so we no longer override it. */
.ad__foot a.src { color: var(--muted); text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: currentColor; text-underline-offset: 2px; }
.ad__foot span.src { color: var(--muted); }
.ad__foot a.src:hover { color: var(--accent); }
.ad__foot a { color: var(--muted); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.ad__foot a:hover { color: var(--accent); }

/* Soft empty-state block used in places where a section would otherwise
   render nothing (e.g. unique-script left column of the ad modal). Hints
   at the meaning of the empty state instead of leaving dead space. */
.empty-soft {
  background: color-mix(in oklab, var(--paper) 60%, var(--rule));
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink-3);
}

/* Chip-link wrapper - anchors that wrap a <Pill> in the AdCard header
   so each chip is a deep link. Subtle outline ring on hover + cursor
   so the pill clearly reads as clickable, not just a visual badge. */
.ad__chip-link {
  display: inline-flex; align-items: center;
  text-decoration: none; color: inherit;
  border-radius: 3px;
  cursor: pointer;
  transition: filter 80ms ease, box-shadow 80ms ease;
}
.ad__chip-link:hover {
  filter: brightness(1.12);
  box-shadow: 0 0 0 1.5px var(--accent);
}

/* Signal tags: chip-style labels above the ad body showing every
   indicator that fired. Category-tinted background so a row of them
   visually maps to the same colour family as the inline highlights
   below in the body text. */
.sig-tag {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.6;
}
.sig-tag--sex    { background: color-mix(in oklab, var(--sev-hi)  18%, var(--paper)); border-color: color-mix(in oklab, var(--sev-hi)  35%, transparent); color: var(--ink-2); }
.sig-tag--scam   { background: color-mix(in oklab, var(--sev-mid) 18%, var(--paper)); border-color: color-mix(in oklab, var(--sev-mid) 35%, transparent); color: var(--ink-2); }
.sig-tag--mul    { background: color-mix(in oklab, var(--accent)  16%, var(--paper)); border-color: color-mix(in oklab, var(--accent)  35%, transparent); color: var(--ink-2); }
.sig-tag--doc    { background: color-mix(in oklab, var(--c-cz)    16%, var(--paper)); border-color: color-mix(in oklab, var(--c-cz)    35%, transparent); color: var(--ink-2); }
.sig-tag--mlm    { background: color-mix(in oklab, var(--c-de)    16%, var(--paper)); border-color: color-mix(in oklab, var(--c-de)    35%, transparent); color: var(--ink-2); }
.sig-tag--target { background: color-mix(in oklab, var(--c-md)    18%, var(--paper)); border-color: color-mix(in oklab, var(--c-md)    35%, transparent); color: var(--ink-2); }
.sig-tag--eva    { background: color-mix(in oklab, var(--muted)   16%, var(--paper)); border-color: color-mix(in oklab, var(--muted)   35%, transparent); color: var(--ink-2); }
.sig-tag--unk    { background: var(--paper); border-color: var(--rule); color: var(--muted); }

/* Inline signal highlights inside the ad body. Each match is the
   triggered phrase + a small attached label chip naming the indicator
   that fired - reads like a displaCy / NER annotation: the eye picks
   up which words mattered AND why without leaving the sentence. */
.sig-mark {
  display: inline;
  border-radius: 3px;
  padding: 1px 3px;
  color: inherit;
  background: color-mix(in oklab, var(--ink-3) 14%, transparent);
  border-bottom: 1.5px solid color-mix(in oklab, var(--ink-3) 50%, transparent);
  line-height: 1.85;
}
.sig-mark__tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: 1px;
  background: rgba(0,0,0,.18);
  color: var(--ink-2);
  white-space: nowrap;
}
.sig-mark--sex    { background: color-mix(in oklab, var(--sev-hi)  22%, transparent); border-bottom-color: var(--sev-hi); }
.sig-mark--sex    .sig-mark__tag { background: color-mix(in oklab, var(--sev-hi)  55%, transparent); color: #fff; }
.sig-mark--scam   { background: color-mix(in oklab, var(--sev-mid) 22%, transparent); border-bottom-color: var(--sev-mid); }
.sig-mark--scam   .sig-mark__tag { background: color-mix(in oklab, var(--sev-mid) 55%, transparent); color: #fff; }
.sig-mark--mul    { background: color-mix(in oklab, var(--accent)  20%, transparent); border-bottom-color: var(--accent); }
.sig-mark--mul    .sig-mark__tag { background: color-mix(in oklab, var(--accent)  55%, transparent); color: #fff; }
.sig-mark--doc    { background: color-mix(in oklab, var(--c-cz)    22%, transparent); border-bottom-color: var(--c-cz); }
.sig-mark--doc    .sig-mark__tag { background: color-mix(in oklab, var(--c-cz)    55%, transparent); color: #fff; }
.sig-mark--mlm    { background: color-mix(in oklab, var(--c-de)    22%, transparent); border-bottom-color: var(--c-de); }
.sig-mark--mlm    .sig-mark__tag { background: color-mix(in oklab, var(--c-de)    55%, transparent); color: #fff; }
.sig-mark--target { background: color-mix(in oklab, var(--c-md)    24%, transparent); border-bottom-color: var(--c-md); }
.sig-mark--target .sig-mark__tag { background: color-mix(in oklab, var(--c-md)    55%, transparent); color: #fff; }
.sig-mark--eva    { background: color-mix(in oklab, var(--muted)   24%, transparent); border-bottom-color: var(--muted); }
.sig-mark--eva    .sig-mark__tag { background: color-mix(in oklab, var(--muted)   55%, transparent); color: #fff; }
/* Worksite LOCATION tag — geographic blue, distinct from the red signal chips. */
/* Location is a tag, but NOT a signal — a neutral GREY chip labelled "location"
   (no signal category uses --c-uk), so it's clearly a place reference and never
   reads as a fired sex/scam/doc/... indicator. */
.sig-mark--loc    { background: color-mix(in oklab, var(--c-uk) 20%, transparent); border-bottom-color: var(--c-uk); }
.sig-mark--loc    .sig-mark__tag { background: color-mix(in oklab, var(--c-uk) 55%, transparent); color: #fff; }

/* Text-style hyperlink used in ad meta lines (#posting-id, identity #N).
   Always-visible accent underline so it reads as a link at first glance,
   not as muted metadata. Inherits the mono / muted color of its parent
   so it sits naturally inside the meta line. */
.xref-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
}
.xref-link:hover {
  color: var(--accent);
  text-decoration-thickness: 1.5px;
}

/* =================================================================
   LEADS TABLE
   ================================================================= */
.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-3);
}
/* Leads-specific: tighter padding so 13 columns fit inside the page width.
   Indicator columns are narrow & centered to read like a heatmap row. */
.tbl-wrap--leads .tbl thead th,
.tbl-wrap--leads .tbl tbody td {
  padding: 8px 8px;
}
.tbl-wrap--leads .tbl thead th.ind-col,
.tbl-wrap--leads .tbl tbody td.ind-col {
  padding: 8px 4px;
  text-align: center;
  font-size: var(--t-small);
}
.tbl-wrap--leads .tbl thead th.ind-col {
  font-size: var(--t-micro);
}
.tbl-wrap--leads .tbl thead th.col-score,
.tbl-wrap--leads .tbl tbody td.col-score {
  white-space: nowrap;
}
.tbl-wrap--leads .indicator-bar { width: 36px !important; }
/* Brief highlight when arriving via deep-link (Entity → Leads). The
   `.leads__row--focus` class is set for ~2.4s; the transition fades the
   accent tint back to the default row colour. */
.tbl tbody tr.leads__row--focus > td {
  background: color-mix(in oklab, var(--accent) 18%, var(--surface));
  transition: background 1.6s ease-out;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-body);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  overflow: hidden;
}
.tbl thead th {
  background: var(--paper);
  text-align: left;
  font: 500 var(--t-micro)/1 var(--font-mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
/* Active-sort coloring standard (app-wide): inactive = var(--muted),
   active = var(--accent). Matches the Source page sort control
   (.src__sort-btn--active / .src__sort-opt--on). */
.tbl thead th .sort {
  display: inline-block; margin-left: 4px; color: var(--muted);
}
.tbl thead th[aria-sort] { color: var(--accent); }
.tbl thead th[aria-sort] .sort { color: var(--accent); }
/* small clickable info chip — reuse anywhere we want a clear "hint here" */
.th-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  margin-left: 6px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--muted);
  font: 500 10px/1 var(--font-sans);
  border-radius: 50%;
  cursor: pointer;
  vertical-align: middle;
  transition: color 80ms, border-color 80ms, background 80ms;
  padding: 0;
}
.th-info:hover,
.th-info[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent-soft-2);
  background: var(--accent-soft);
}
.th-info:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tbl tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  color: var(--ink-2);
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr {
  cursor: pointer;
}
.tbl tbody tr:hover td { background: var(--paper); }
.tbl tbody tr[aria-expanded="true"] td { background: var(--accent-soft); }
/* Numeric columns: right-align header AND body cell so the digits sit
   under the column label. Was only td.num — meant the header word read
   left-aligned while the digits sat right, looking misaligned. */
.tbl th.num,
.tbl td.num { font-variant-numeric: tabular-nums; text-align: right; }
/* Padding consistency across `.tbl` instances — Leads uses its own
   .tbl-wrap--leads modifier; the default rule already handles other
   tables uniformly via .tbl thead th / .tbl tbody td. */
.tbl td.k { font-family: var(--font-mono); font-size: var(--t-small); white-space: nowrap; }
/* Score cell: number + indicator bar on ONE line. nowrap keeps the cell a
   real table-cell (so columns stay aligned) while letting it auto-widen to
   fit both; the bar gets a small gap and sits centred against the digits. */
.tbl td.score-cell { white-space: nowrap; }
.tbl td.score-cell .indicator-bar { margin-left: 6px; vertical-align: middle; }

.indicator-bar {
  display: inline-block;
  height: 6px;
  background: var(--accent-soft);
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 8px;
}
.indicator-bar > i {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.indicator-bar.sev-hi  > i { background: var(--sev-hi); }
.indicator-bar.sev-mid > i { background: var(--sev-mid); }
.indicator-bar.sev-lo  > i { background: var(--sev-lo); }

/* Indicator legend strip — shown on Leads under the page head to demystify
   the column abbreviations (SEX / MUL / SCAM / DOC / MLM / TGT / EVA). */
.ind-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  font: 500 var(--t-small)/1.4 var(--font-mono);
  color: var(--muted);
}
.ind-legend__item { white-space: nowrap; }
.ind-legend__item b {
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}

/* expanded row */
.tbl__expand {
  background: var(--paper);
  padding: 16px 18px;
}
.tbl__expand-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

/* =================================================================
   WEIGHTS POPOVER & SLIDERS
   ================================================================= */
/* Two-row slider: label + value chip share a top row, slider track
   gets the full width on a second row. Was a single flex row where
   the tag (56px) collided with the value chip (28px) at the right —
   small viewports clipped one or the other. */
.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 10px;
  align-items: center;
  min-width: 0;
}
.slider__lbl {
  font: 500 var(--t-small)/1 var(--font-sans);
  color: var(--ink-2);
  letter-spacing: 0;
  text-transform: none;
  grid-row: 1;
  grid-column: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slider__val {
  font: 500 var(--t-small)/1 var(--font-sans);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  grid-row: 1;
  grid-column: 2;
  justify-self: end;
}
.slider input[type="range"] {
  grid-row: 2;
  grid-column: 1 / -1;
  width: 100%;
  height: 4px;
  -webkit-appearance: none; appearance: none;
  background: var(--rule); border-radius: 2px;
  outline: 0;
}
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
}
.slider input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
}

/* =================================================================
   NETWORK PAGE
   ================================================================= */
.ngrid {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  gap: 18px;
  align-items: start;
}
.ngrid--no-side {
  grid-template-columns: 1fr;
}
.ncards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 1200px) {
  .ncards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* "big" mode — one card per row at narrow widths, 2 at wide. Used as default
   so each sub-graph is large enough to scan. */
.ncards--big { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
  .ncards--big { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.ncard {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 320px;
  transition: border-color 120ms, box-shadow 120ms;
}
.ncard--clickable { cursor: pointer; }
.ncard--clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}
.ncard--clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ncards--big .ncard { min-height: 380px; }
/* Loading-state card. Reuses every .ncard dimension (min-height, border,
   radius, header band, graph area) so the skeleton occupies the exact box
   the real NCard will land in — no layout shift on swap. Just drops the
   interactive affordances (pointer cursor / hover lift) since it's inert. */
.ncard--skel { cursor: default; }
.ncard--skel:hover {
  border-color: var(--rule);
  box-shadow: none;
}
.ncard__hd {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  /* Grid: title on top-left, meta on bottom-left, focus button on the
     right centered between the two text lines. row-gap: 0 so the button
     doesn't push the lines apart; the title + meta sit at their natural
     line heights only. */
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  /* Small breathing room between the keyword title and the id/stats line
     so they read as two distinct pieces of info, not stacked text. */
  row-gap: 7px;
  align-items: center;
  background: var(--paper);
}
.ncard__hd .label { grid-column: 1; grid-row: 1; }
.ncard__focus    {
  grid-column: 2; grid-row: 1 / span 2;
  align-self: center;
  padding: 2px 6px;
  min-width: 0;
}
.ncard__hd-row   {
  grid-column: 1; grid-row: 2;
  display: flex; align-items: center; gap: 8px;
  /* Let the row's own width be the shrink target (not its children), so the
     long stats string truncates inside .stats rather than squeezing the
     square flag chip and the "Ring #N" id out of shape. */
  min-width: 0;
}
/* "Ring #N" id — sits between the flag chip and the stats. Pin it so it never
   shrinks; the stats line is the only flexible element on the row. */
.ncard__hd .ncard__rid {
  flex: 0 0 auto;
  white-space: nowrap;
}
.ncard__hd .label {
  /* Keyword title — clamped to one line via -webkit-line-clamp so the
     cut happens at a WORD boundary (not mid-word like text-overflow:
     ellipsis does). At least the first whole word always shows; the
     full text rides in the .tt hover tooltip. */
  font: 600 var(--t-base)/1.25 var(--font-sans);
  letter-spacing: -0.01em;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: normal;
  overflow-wrap: anywhere;
}
.ncard__hd .stats {
  font: 500 var(--t-micro)/1 var(--font-mono);
  color: var(--muted);
  /* Stats is the flexible element: it takes the remaining row width and
     truncates with an ellipsis when there isn't room, instead of forcing the
     whole nowrap string to overflow and crush the flag + "Ring #N" siblings. */
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ncard__graph {
  flex: 1;
  position: relative;
  background:
    radial-gradient(circle at 20% 20%, var(--paper), var(--surface));
  min-height: 200px;
}
.ncard__graph .cy-host { position: absolute; inset: 0; }

.cy-hint {
  position: absolute;
  bottom: 8px; left: 8px;
  font: 500 var(--t-micro)/1 var(--font-mono);
  color: var(--muted);
  background: color-mix(in oklab, var(--surface) 80%, transparent);
  border: 1px solid var(--rule);
  padding: 4px 8px;
  border-radius: var(--r-2);
  pointer-events: none;
  letter-spacing: 0.02em;
}

/* network sidebar */
.nside {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 14px 16px;
  position: sticky;
  top: calc(var(--nav-h) + 12px);
  max-height: calc(100vh - var(--nav-h) - 24px);
  overflow: auto;
}
.nside__head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 12px;
}
.nside h4 {
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em;
  margin: 14px 0 6px;
}
.legend {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px;
  font: 500 var(--t-small)/1.4 var(--font-mono);
}
.legend__row { display: flex; align-items: center; gap: 6px; color: var(--ink-3); }
.legend__dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.nbar {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* progressive-disclosure section (collapsible) */
.dsec {
  border-top: 1px solid var(--rule);
  padding: 8px 0 6px;
}
.dsec:first-child { border-top: 0; }
.dsec__hd {
  width: 100%;
  border: 0; background: transparent;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0;
  cursor: pointer;
  color: var(--ink-2);
  font: 500 var(--t-small)/1 var(--font-mono);
}
.dsec__hd:hover { color: var(--ink); }
.dsec__lbl {
  text-transform: uppercase; letter-spacing: 0.06em;
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--muted);
}
.dsec__hd:hover .dsec__lbl { color: var(--ink-3); }
.dsec__count {
  margin-left: auto;
  font: 500 var(--t-micro)/1 var(--font-mono);
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 8px;
}
.dsec__count--hi { background: color-mix(in oklab, var(--sev-hi) 16%, transparent); color: var(--sev-hi); }
.dsec__bd { padding: 8px 0 4px; }

/* the collision summary block — the high-value, always-on row */
.collision {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.collision--hit {
  background: color-mix(in oklab, var(--sev-mid) 14%, var(--surface));
  border-color: color-mix(in oklab, var(--sev-mid) 30%, var(--rule));
}
.collision__num {
  font: 600 22px/1 var(--font-mono);
  color: var(--ink);
}
.collision--hit .collision__num { color: var(--sev-mid); }
.collision__lbl {
  font-size: var(--t-small);
  color: var(--ink-3);
}

/* idle summary stats — calm rhythm: no per-row rules, spacing comes from the
   parent column gap; tabular numerals keep the figures aligned. */
.sum-stat {
  display: flex; align-items: baseline; gap: 12px;
  padding: 0;
}
.sum-stat__num {
  font: 500 var(--t-h3)/1 var(--font-mono);
  color: var(--ink);
  min-width: 44px;
  font-variant-numeric: tabular-nums;
}
.sum-stat__lbl {
  flex: 1;
  font-size: var(--t-small);
  color: var(--ink-3);
  line-height: 1.4;
}

/* selector value display with copy */
.sel-value {
  display: flex; align-items: center; gap: 4px;
  margin-top: 4px;
  padding: 6px 6px 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  font: 500 var(--t-small)/1.4 var(--font-mono);
  word-break: break-all;
}
.sel-value > span:first-child { flex: 1; }

/* sub-row used in collision lists & co-occur lists */
.sub-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  border-radius: var(--r-2);
  text-decoration: none;
  color: var(--ink-2);
}
.sub-row:hover { background: var(--surface-2); color: var(--ink); }
/* Fixed-width leading #id column so the flag / title / date columns line up
   across rows (ids vary #15…#2401745). 8ch covers a 7-digit id; mono digits
   are already tabular. Used by the modal neighbour lists + selector rails. */
.sub-row__id { flex: 0 0 auto; min-width: 8ch; }

/* Shared-script card in the network Connection panel - full body preview
   in a small card, distinct from the dense one-line .sub-row. */
.shared-script {
  display: block;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  transition: border-color 120ms, background 120ms;
}
.shared-script:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.sub-row--btn {
  border: 0; background: transparent;
  font: inherit;
  width: 100%;
  cursor: pointer;
  color: var(--ink-2);
}
.sub-row--btn:hover { background: var(--surface-2); color: var(--ink); }

/* =================================================================
   ENTITY PAGE
   ================================================================= */
.ent {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  /* 18px in both directions — matches the Source page (.src-grid) rail
     spacing AND the section-to-section rhythm (.ent__section
     margin-bottom: 18px) so Entity / Ring / Source all sit on the same
     visual cadence. */
  gap: 18px;
}
.ent__hd {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
  /* No bottom margin — the grid row-gap handles header → content spacing. */
  margin-bottom: 0;
  grid-column: 1 / -1;
}
.ent__hd .ent__role { margin-bottom: 4px; }

/* ===== Expanded "By scripts" Leads row ===== */
.tbl__expand--script { padding: 0; background: transparent; }
.scriptexp { width: 100%; box-sizing: border-box; display: flex; justify-content: center; padding: 10px 0 14px; }
.scriptexp__card {
  width: 100%; max-width: 920px; box-sizing: border-box; padding: 18px 22px;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-3);
  box-shadow: var(--shadow-2); display: grid;
  grid-template-columns: minmax(0, 560px) minmax(240px, 1fr); gap: 24px; align-items: start;
}
.scriptexp__h { font: 500 var(--t-micro)/1 var(--font-mono); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 8px; }
.scriptexp__main { display: flex; flex-direction: column; min-width: 0; max-width: 560px; }
/* sample is a fixed-height scrollable box so long scripts don't blow up the row */
.scriptexp__main .tpl__sample { display: block; -webkit-line-clamp: unset; max-height: 240px; overflow-y: auto; overflow-x: hidden; overflow-wrap: anywhere; }
.scriptexp__main .ad__toggle { display: none; }
.scriptexp__sub-h { margin-top: 18px; }
.siglist { display: flex; flex-direction: column; gap: 7px; }
.sigline { display: grid; grid-template-columns: 1fr 72px 40px; align-items: center; gap: 12px; }
.sigline__lbl { font: var(--t-small)/1.3 var(--font-sans); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; }
.sigline__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cat, var(--muted)); margin-right: 8px; flex-shrink: 0; }
.sigline__val { font-size: var(--t-small); color: var(--ink); text-align: right; }
.sigbar { display: block; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.sigbar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.sigbar.sev-hi > i { background: var(--sev-hi); } .sigbar.sev-mid > i { background: var(--sev-mid); } .sigbar.sev-lo > i { background: var(--sev-lo); }
.sigline[data-cat="sex"] { --cat: var(--cat-sex); } .sigline[data-cat="mul"] { --cat: var(--cat-mul); }
.sigline[data-cat="scam"] { --cat: var(--cat-scam); } .sigline[data-cat="doc"] { --cat: var(--cat-doc); }
.sigline[data-cat="mlm"] { --cat: var(--cat-mlm); } .sigline[data-cat="target"] { --cat: var(--cat-target); }
.sigline[data-cat="eva"] { --cat: var(--cat-eva); }
.scriptexp__side { border-left: 1px solid var(--rule); padding-left: 24px; display: flex; flex-direction: column; min-width: 0; }
.scriptexp__kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0 0 4px; }
.scriptexp__kv dt { font: var(--t-small)/1.3 var(--font-mono); color: var(--muted); }
.scriptexp__kv dd { margin: 0; text-align: right; font: 500 var(--t-small)/1.3 var(--font-mono); color: var(--ink); }
.scriptexp__sec { margin-top: 16px; padding-top: 16px; margin-left: -24px; padding-left: 24px; border-top: 1px solid var(--rule); }
.scriptexp__contacts { display: flex; flex-direction: column; gap: 5px; }
.scriptexp__contact { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.scriptexp__contact:hover .scriptexp__cval { color: var(--accent); }
.scriptexp__ctype { font: 600 var(--t-micro)/1 var(--font-mono); letter-spacing: .05em; padding: 3px 5px; border-radius: var(--r-1); flex-shrink: 0; min-width: 30px; text-align: center; }
.scriptexp__ctype--tg { color: var(--cat-doc); background: color-mix(in oklab, var(--cat-doc) 15%, transparent); }
.scriptexp__ctype--phone { color: var(--muted); background: var(--surface-2); }
.scriptexp__cval { font-size: var(--t-small); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scriptexp__poster-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.scriptexp__poster-head .scriptexp__h { line-height: 1.3; }
.scriptexp__pager { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.scriptexp__pginfo { font-size: var(--t-micro); color: var(--muted); white-space: nowrap; }
.scriptexp__pgbtn { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--rule); background: var(--surface); color: var(--ink-3); border-radius: var(--r-1); cursor: pointer; font-size: 13px; line-height: 1; padding: 0; }
.scriptexp__pgbtn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.scriptexp__pgbtn:disabled { opacity: .35; cursor: default; }
.scriptexp__posters { display: flex; flex-direction: column; gap: 1px; margin: 0 -8px; }
.scriptexp__poster { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px; border-radius: var(--r-2); text-decoration: none; }
.scriptexp__poster:hover { background: color-mix(in oklab, var(--accent) 9%, transparent); }
.scriptexp__poster-name { font: 500 var(--t-small)/1.3 var(--font-sans); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.scriptexp__poster-meta { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.scriptexp__poster-meta .mono { font-size: var(--t-micro); white-space: nowrap; }
.scriptexp__cta { margin-top: 14px; align-self: flex-start; }
@media (max-width: 880px) {
  .scriptexp__card { grid-template-columns: 1fr; gap: 16px; }
  .scriptexp__side { border-left: 0; padding-left: 0; border-top: 1px solid var(--rule); padding-top: 14px; }
  .scriptexp__poster-head, .scriptexp__sec { margin-left: 0; padding-left: 0; }
}
.ent__hd .name {
  font: 500 var(--t-h1)/1.2 var(--font-sans);
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ink);
}
.ent__hd .kw {
  font: 500 var(--t-small)/1.3 var(--font-mono);
  color: var(--muted);
  margin-top: 2px;
}
.ent__hd .actions {
  margin-left: auto;
  display: flex; gap: 4px;
}

.ent__section {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 18px 20px;
  margin-bottom: 18px;
}
/* ===========================================================
   Truncate-with-tooltip pattern.

   Goal: long keywords / titles / source names truncate cleanly
   instead of overflowing their container, and the full text is
   revealed via a custom hover tooltip (NOT the browser default
   title-attribute tooltip).

   Usage:
     <span className="trunc tt" data-tt={fullText} style={{maxWidth: 240}}>
       {fullText}
     </span>

   `.trunc` clamps to one line with ellipsis; `.tt` + data-tt
   shows the full string on hover. They're separate classes so
   `.tt` can also tooltip non-truncated content.
   =========================================================== */
.trunc {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.tt {
  position: relative;
  /* Used on inline spans most of the time — but block hosts work too. */
}
.tt[data-tt]:hover::after,
.tt[data-tt]:focus-visible::after {
  content: attr(data-tt);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  max-width: 320px;
  width: max-content;
  white-space: normal;
  word-break: break-word;
  background: var(--ink);
  color: var(--surface);
  padding: 6px 10px;
  border-radius: var(--r-2);
  font: 400 var(--t-small)/1.35 var(--font-sans);
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 0 4px 12px color-mix(in oklab, var(--ink) 35%, transparent);
  z-index: 90;
  pointer-events: none;
}
.tt[data-tt]:hover::before,
.tt[data-tt]:focus-visible::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 10px;
  border: 4px solid transparent;
  border-top-color: var(--ink);
  margin-bottom: -2px;
  pointer-events: none;
  z-index: 90;
}
.ent__script-card {
  transition: border-color .12s, background-color .12s;
}
.ent__script-card:hover {
  border-color: var(--accent) !important;
  background: color-mix(in oklab, var(--accent) 4%, var(--paper)) !important;
}
.ent__section--accent {
  background: color-mix(in oklab, var(--accent) 5%, var(--surface));
  border-color: color-mix(in oklab, var(--accent) 20%, var(--rule));
}
.ent__section h3 {
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em;
  margin: 0 0 14px;
  display: flex; align-items: baseline; gap: 10px;
}
.ent__section h3 .ct { color: var(--ink); }

.ent__rail .ent__section { padding: 14px 16px; margin-bottom: 14px; }
.ent__rail .ent__section h3 { margin-bottom: 8px; }

/* Rail follows scroll on tall pages so the Overview / context cards don't
   stop being visible halfway through a long main column. align-self:start
   keeps the rail from stretching to match the main column's height (which
   is what kept it short but empty in the original layout). */
.ent__rail {
  position: sticky;
  /* nav-h offset so the rail doesn't slide under the sticky top nav */
  top: calc(var(--nav-h) + 12px);
  align-self: start;
  max-height: calc(100vh - var(--nav-h) - 24px);
  overflow-y: auto;
}

/* identity selectors */
.sel-group { margin-bottom: 12px; }
.sel-group:last-child { margin-bottom: 0; }
.sel-group__hd {
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.sel-list {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.sel {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 4px 3px 10px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  font: 500 var(--t-small)/1.4 var(--font-mono);
  color: var(--ink);
}
.sel__n { color: var(--muted); font-size: 11px; }
.sel__copy {
  border: 0; background: transparent;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer;
  border-radius: var(--r-1);
}
.sel__copy:hover { background: var(--rule); color: var(--ink); }
.sel__copy svg { width: 12px; height: 12px; }

/* indicators viz */
.indicators {
  display: flex; flex-direction: column; gap: 10px;
}
.indicator {
  display: grid;
  grid-template-columns: 100px 1fr 50px;
  gap: 12px;
  align-items: center;
}
.indicator__lbl {
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.indicator__bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.indicator__bar > i {
  display: block; height: 100%;
  background: var(--accent);
}
.indicator__val {
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* =================================================================
   TEMPLATES PAGE
   ================================================================= */
.tpl {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.tpl__list {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  overflow: hidden;
  /* Sticky list: the short list pins to the top of the viewport while
     the (much taller) detail panel on the right scrolls naturally. */
  position: sticky;
  top: calc(var(--nav-h) + 12px);
  max-height: calc(100vh - var(--nav-h) - 32px);
  overflow-y: auto;
}
.tpl__row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
}
.tpl__row:last-child { border-bottom: 0; }
.tpl__row:hover { background: var(--paper); }
.tpl__row[aria-pressed="true"] {
  background: var(--accent-soft);
}
.tpl__row .label {
  font: 500 var(--t-small)/1.3 var(--font-sans);
  color: var(--ink-2);
  /* Clamp to one line — the row also shows hash + label + count + date
     metadata below, so a two-line preview was overflow noise. Full
     preview lives on the row's title attribute and on the detail panel. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tpl__row .meta {
  font: 500 var(--t-micro)/1.6 var(--font-mono);
  color: var(--muted);
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.tpl__row .meta > * { white-space: nowrap; }

.tpl__detail {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 20px 22px;
  /* Detail scrolls naturally with the page now; the list on the left
     is sticky instead so the user can scan posters/scripts metadata
     while the list stays anchored. */
}
.tpl__sample {
  /* The ad sample is prose, not code — sans reads cleaner and less "terminal".
     Raised surface sets it apart from the expand panel. */
  font-family: var(--font-sans);
  font-size: var(--t-body);
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 14px 16px;
  border-radius: var(--r-3);
  white-space: pre-wrap;
  color: var(--ink-2);
  line-height: 1.6;
  /* Keep it a compact, readable box — not a full-width band across the table. */
  max-width: 680px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tpl__sample--full {
  display: block;
  -webkit-line-clamp: unset;
}

/* contact slot inline chip in template sample */
.cslot {
  display: inline-flex; align-items: center;
  padding: 0 6px;
  margin: 0 2px;
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  border: 1px dashed var(--accent);
  border-radius: var(--r-2);
  font: 500 var(--t-micro)/1.4 var(--font-mono);
  color: var(--accent);
  white-space: nowrap;
}

/* inline-explainer (under page sub-heads) */
.explainer {
  font-size: var(--t-small);
  color: var(--ink-3);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: var(--r-2);
  margin: 8px 0 16px;
  line-height: 1.5;
}

/* contact rotation timeline rows */
.rota {
  display: flex; flex-direction: column;
  gap: 2px;
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  background: var(--paper);
  padding: 4px;
  /* Contain children — was overflowing its card in narrow columns. */
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.rota__row {
  display: grid;
  grid-template-columns: 200px 1fr 200px;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--r-2);
}
.rota__row:hover { background: var(--surface); }
.rota__contact {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--t-small);
}
.rota__contact .mono {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rota__span {
  position: relative;
  height: 14px;
  background: var(--surface-2);
  border-radius: 7px;
  overflow: hidden;
}
.rota__bar {
  position: absolute;
  top: 3px; bottom: 3px;
  background: var(--accent);
  border-radius: 4px;
  min-width: 12px;
}
.rota__meta {
  font-size: var(--t-micro);
  text-align: right;
  white-space: nowrap;
}
@media (max-width: 720px) {
  .rota__row { grid-template-columns: 1fr; gap: 4px; }
  .rota__meta { text-align: left; }
}
.timeline {
  font-family: var(--font-mono);
  font-size: var(--t-small);
  color: var(--ink-3);
}
.timeline__row {
  display: grid;
  grid-template-columns: 76px 1fr 100px;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--rule);
}
.timeline__row:last-child { border-bottom: 0; }
.timeline__date { color: var(--muted); }
.timeline__n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Pipeline step rows can carry a live status message under the step
   name when running. The message wraps full-width on a second grid
   row so long Telethon log lines like "+joined Moldovahelp" stay
   readable without truncation. */
.timeline__row--stacked .timeline__msg {
  grid-column: 2 / -1;
  margin-top: 4px;
  color: var(--accent);
  font-size: var(--t-xsmall, 11px);
  word-break: break-word;
  white-space: normal;
}

/* =================================================================
   SELECTOR PAGE — pivot to "who else uses this selector"
   ================================================================= */
.sel-head {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 14px 18px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.sel-head__value {
  font: 500 var(--t-h3)/1.3 var(--font-mono);
  color: var(--ink);
  word-break: break-all;
}
.sel-head__count {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  font-size: var(--t-small);
  color: var(--ink-3);
}
.sel-head__count--hit {
  background: color-mix(in oklab, var(--sev-mid) 14%, var(--surface));
  border-color: color-mix(in oklab, var(--sev-mid) 30%, var(--rule));
  color: var(--ink);
}
.sel-head__count .num {
  font: 500 22px/1 var(--font-mono);
  color: var(--ink);
}
.sel-head__count--hit .num { color: var(--sev-mid); }

.sel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 1024px) {
  .sel-grid { grid-template-columns: 1fr; }
}
.sel-graph {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  min-height: 480px;
  overflow: hidden;
}
.sel-graph__hint {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px;
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  color: var(--ink-2);
  font-size: var(--t-small);
  font-family: var(--font-mono);
  pointer-events: none;
  max-width: calc(100% - 200px);
}
.sel-graph__controls {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  display: inline-flex; gap: 4px;
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 3px;
}
.sel-graph__controls .btn { min-width: 28px; }
.sel-graph__legend {
  position: absolute; bottom: 10px; left: 10px; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 6px 10px;
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  font-size: var(--t-micro);
  font-family: var(--font-mono);
  color: var(--ink-2);
  max-width: calc(100% - 20px);
}
.sel-graph__legend-item { display: inline-flex; align-items: center; gap: 5px; }
.sel-graph__dot {
  display: inline-block; width: 9px; height: 9px;
  border-radius: 50%; border: 1px solid var(--ink);
}
.sel-graph__dot--poster   { background: var(--accent); }
.sel-graph__dot--phone    { background: var(--s-phone, var(--muted)); }
.sel-graph__dot--telegram { background: var(--s-telegram, var(--muted)); }
.sel-graph__dot--tg_user  { background: var(--s-tg_user, var(--muted)); }
.sel-graph__dot--email    { background: var(--s-email, var(--muted)); }
.sel-graph__dot--whatsapp { background: var(--s-whatsapp, var(--muted)); }
.sel-graph__detail {
  position: absolute; bottom: 10px; right: 10px; z-index: 3;
  width: min(340px, calc(100% - 20px));
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 10px 12px;
  box-shadow: 0 8px 24px color-mix(in oklab, var(--ink) 12%, transparent);
}
.sel-graph__detail-hd {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.sel-graph__detail-hd .btn { margin-left: auto; }
.sel-graph__detail-value {
  font-family: var(--font-mono);
  font-size: var(--t-small);
  word-break: break-all;
  color: var(--ink);
  line-height: 1.4;
}
.sel-list {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  overflow: hidden;
}
.sel-list__row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: var(--ink-2);
}
.sel-list__row:last-child { border-bottom: 0; }
.sel-list__row:hover { background: var(--paper); color: var(--ink); }

/* =================================================================
   ONBOARDING TOUR
   ================================================================= */
.onboard {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 200;
  pointer-events: none;
  animation: modalFade 200ms ease-out;
  max-width: 420px;
  width: calc(100vw - 48px);
}
.onboard__box {
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-3);
  padding: 22px 26px 18px;
  position: relative;
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  /* Longer steps (the terminology glossary + recap) can get tall — cap to the
     viewport and scroll instead of overflowing off-screen. */
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.onboard-target {
  position: relative;
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--r-2);
  animation: onboardPulse 1.6s ease-in-out infinite;
  z-index: 10;
}
@keyframes onboardPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 30%, transparent); }
  50%      { box-shadow: 0 0 0 8px color-mix(in oklab, var(--accent) 15%, transparent); }
}
.onboard__skip {
  position: absolute; top: 14px; right: 16px;
  border: 0; background: transparent;
  color: var(--muted); cursor: pointer;
  font: 500 var(--t-small)/1 var(--font-mono);
  letter-spacing: 0.04em;
}
.onboard__skip:hover { color: var(--ink); }
/* Progress dots — moved out of the top row (where they collided with the
   absolute-positioned Skip button at narrow widths) and into the footer
   between Back and Next. Compact dots instead of flex-stretched bars. */
.onboard__progress {
  display: flex; gap: 6px; align-items: center;
  flex: 1 1 auto;
  justify-content: center;
}
.onboard__dot {
  width: 6px; height: 6px;
  background: var(--rule);
  border-radius: 50%;
  transition: background 200ms;
}
.onboard__dot.on { background: var(--accent); }
.onboard__title {
  margin: 0 0 12px;
  /* reserve space for the absolute "Skip tour" button so long titles don't
     run underneath it */
  padding-right: 72px;
  font: 500 var(--t-h2)/1.2 var(--font-sans);
  letter-spacing: -0.01em;
}
.onboard__body {
  color: var(--ink-2);
  font-size: var(--t-base);
  line-height: 1.55;
}
.onboard__body p { margin: 0 0 10px; }
.onboard__body p:last-child { margin-bottom: 0; }
.onboard__foot {
  display: flex; align-items: center; gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}
.onboard__counter {
  margin-left: auto;
  font-size: var(--t-small);
}
.signin {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.signin__box {
  width: 100%; max-width: 420px;
}
.signin__brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
}
.signin__chrome {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 26px 28px;
}
.signin__provider {
  display: flex; align-items: center; gap: 8px;
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--muted);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.signin__provider-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-mx);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--c-mx) 25%, transparent);
}
.signin__label {
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;
  display: block;
  margin-bottom: 6px;
}
.signin__input { width: 100%; margin-bottom: 8px; font-size: var(--t-base); padding: 8px 10px; }
.signin__input--pin {
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 0.5em;
  text-align: center;
}
.signin__note {
  font-size: var(--t-small); color: var(--muted); line-height: 1.5;
  margin: 6px 0 14px;
}
.signin__hint {
  text-align: center;
  font: 400 var(--t-micro)/1.5 var(--font-mono);
  color: var(--muted-2);
  margin-top: 12px;
}
.signin__error {
  font-size: var(--t-small); color: var(--sev-hi);
  margin: 4px 0 10px;
  padding: 6px 10px;
  background: color-mix(in oklab, var(--sev-hi) 12%, transparent);
  border-left: 2px solid var(--sev-hi);
  border-radius: 2px;
}
.signin__email {
  font-family: var(--font-mono); font-size: var(--t-small);
  color: var(--ink-2);
  margin-bottom: 12px;
}
.signin__back {
  border: 0; background: transparent;
  color: var(--accent); cursor: pointer;
  font: inherit; padding: 0 0 0 8px;
}
.signin__back:hover { text-decoration: underline; }
.signin__granted {
  text-align: center; padding: 14px 0;
}
.signin__check {
  font-size: 36px; line-height: 1;
  color: var(--good); margin-bottom: 10px;
}
.signin__foot {
  display: flex; justify-content: space-between;
  font: 400 var(--t-micro)/1.4 var(--font-mono);
  color: var(--muted-2);
  margin-top: 14px;
  padding: 0 4px;
}
.src-head {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 18px 22px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.src-head__icon {
  width: 48px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--r-3);
}
.src-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
}
@media (max-width: 1024px) {
  .src-grid { grid-template-columns: 1fr; }
}
.src-stat {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 10px 12px;
  border-radius: var(--r-2);
  display: flex; flex-direction: column; gap: 2px;
}
.src-stat__num {
  font: 500 22px/1 var(--font-mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.src-stat__lbl {
  font: 500 var(--t-micro)/1.2 var(--font-mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* =================================================================
   SYSTEM PAGE
   ================================================================= */
.sys {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 900px) { .sys { grid-template-columns: 1fr; } }
.sys__sec {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 18px 20px;
}
.sys__sec h3 {
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em;
  margin: 0 0 14px;
}
.sys-swatch {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.sys-swatch__cell {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 8px;
  border-radius: var(--r-2);
  display: flex; flex-direction: column; gap: 4px;
}
.sys-swatch__cell i {
  display: block; height: 32px; border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.05);
}
.sys-swatch__cell small {
  font: 500 var(--t-micro)/1 var(--font-mono);
  color: var(--muted);
}

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 1024px) {
  .ent { grid-template-columns: 1fr; }
  .ngrid { grid-template-columns: 1fr; }
  .nside { position: static; max-height: none; }
  .tpl { grid-template-columns: 1fr; }
  .tpl__detail { position: static; }
}

@media (max-width: 720px) {
  :root { --nav-h: 48px; }
  .nav__inner { padding: 0 14px; gap: 10px; }
  .nav__links {
    position: fixed; left: 0; right: 0;
    top: var(--nav-h);
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    flex-direction: column;
    padding: 8px 14px;
    align-items: stretch;
    gap: 2px;
    box-shadow: var(--shadow-1);
    display: none;
  }
  .nav__links.open { display: flex; }
  .nav__link { padding: 10px 12px; }
  .nav__toggle { display: inline-flex; }

  .page { padding: 14px; }
  .page__head { margin-bottom: 12px; }
  .page__title { font-size: 22px; }

  .filterbar { padding: 8px 0 10px; gap: 4px; margin-bottom: 12px; }
  .filterbar__label { display: none; }

  .ncards { grid-template-columns: 1fr; }
  .ncard { min-height: 240px; }
  .nside h4 { font-size: 11px; }

  .ent__hd { padding: 14px; gap: 10px; }
  .ent__hd .name { font-size: 22px; }
  .ent__hd .actions { margin-left: 0; flex-basis: 100%; flex-wrap: wrap; }

  .ent__section { padding: 14px 16px; }
  .indicator { grid-template-columns: 70px 1fr 40px; gap: 8px; }

  .tbl { font-size: var(--t-small); }
  .tbl thead th, .tbl tbody td { padding: 8px 10px; }
  .tbl__expand-grid { grid-template-columns: 1fr; }

  /* mobile-only horizontal scroll for the wide leads table */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-wrap .tbl { min-width: 640px; }

  .tpl__list { max-height: 280px; overflow: auto; }

  .sys-swatch { grid-template-columns: repeat(2, 1fr); }
}

.nav__toggle {
  display: none;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-3);
  padding: 5px 8px;
  border-radius: var(--r-2);
  cursor: pointer;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
}
.nav__toggle svg { width: 16px; height: 16px; }
.nav__toggle:hover { color: var(--ink); }

/* utility */
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.row--apart { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 8px; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
/* canonical uppercase micro eyebrow/section label */
.u-label { font: 500 var(--t-micro)/1 var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 14px; }
.mt-6 { margin-top: 22px; }
.tabular { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Settings layout: Pipeline gets the lion's share because its timeline
   has the most content; Schedule + Telegram credentials are short
   key-value blocks that only need a narrow column. (Sources is its own
   full-width section below.) */
.set-grid {
  display: grid;
  grid-template-columns: 2.4fr 1fr 1fr;
  gap: 18px;
  align-items: stretch;
}
.set-grid > .ent__section { display: flex; flex-direction: column; }
@media (max-width: 1100px) {
  .set-grid { grid-template-columns: 2fr 1fr; }
}
@media (max-width: 700px) {
  .set-grid { grid-template-columns: 1fr; }
}
.set__h4 {
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;
  margin: 20px 0 10px;
}
.set__saved {
  margin-left: 8px;
  font: 500 var(--t-small)/1 var(--font-mono);
  color: var(--good, var(--c-md));
  letter-spacing: 0;
  text-transform: none;
}
.set-toggle {
  position: relative;
  width: 32px; height: 18px;
  background: var(--rule);
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  padding: 0;
  transition: background 120ms;
}
.set-toggle--on { background: var(--accent); }
.set-toggle__knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 140ms;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.set-toggle--on .set-toggle__knob { transform: translateX(14px); }
.set-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font: 600 13px/1 var(--font-sans);
  flex-shrink: 0;
}

