/* Scanner live monitor — dark operator console, modern pass.
   Committed single look (dark). Funnel ordinal ramp + status colors are the
   validated dataviz reference values (--ordinal --mode dark) — do not eyeball-edit. */

:root {
  color-scheme: dark;
  --page: #0a0c10;
  --surface: #12151c;
  --surface-2: #181c25;
  --ink: #f2f4f8;
  --ink-2: #a9b0bd;
  --muted: #697180;
  --grid: rgba(255, 255, 255, 0.05);
  --baseline: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.07);
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, 0.14);
  --good: #22b34a;
  --good-soft: rgba(34, 179, 74, 0.12);
  --warning: #fab219;
  --warning-soft: rgba(250, 178, 25, 0.14);
  --serious: #ec835a;
  --serious-soft: rgba(236, 131, 90, 0.14);
  --critical: #e0442f;
  --critical-soft: rgba(224, 68, 47, 0.14);
  --radius: 14px;
  --radius-s: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  /* funnel ordinal ramp (validated --ordinal --mode dark) */
  --f1: #cde2fb; --f2: #9ec5f4; --f3: #6da7ec;
  --f4: #3987e5; --f5: #256abf; --f6: #184f95;
}

* { box-sizing: border-box; }
::selection { background: var(--accent-soft); }

html { scrollbar-color: #2a2f3a var(--page); }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(57, 135, 229, 0.08), transparent 70%),
    var(--page);
  color: var(--ink);
  font: 14px/1.5 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1440px; margin: 0 auto; padding: 14px 20px 56px; }

/* ---------------- health banner (sticky) ---------------- */

.banner {
  position: sticky;
  top: 10px;
  z-index: 20;
  border-radius: var(--radius);
  padding: 12px 18px;
  margin: 0 0 16px;
  font-weight: 650;
  font-size: 15px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  border: 1px solid var(--border);
  background: rgba(18, 21, 28, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.banner .sub { font-weight: 400; color: var(--ink-2); font-size: 13px; }
.banner.alive::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px var(--good-soft);
  align-self: center;
  flex: none;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--good-soft); }
  50% { box-shadow: 0 0 0 7px rgba(34, 179, 74, 0.05); }
}
@media (prefers-reduced-motion: reduce) {
  .banner.alive::before { animation: none; }
  * { transition: none !important; }
}
.banner.dead {
  background: linear-gradient(0deg, var(--critical-soft), var(--critical-soft)), rgba(18, 21, 28, 0.9);
  border-color: var(--critical);
  font-size: 20px;
}
.banner.dead .sub { color: #f0b9b9; font-size: 14px; }

/* ---------------- stat tiles ---------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.tile {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  transition: border-color 0.15s;
}
.tile:hover { border-color: var(--baseline); }
.tile .label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.tile .value {
  font-size: 27px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.tile .value .unit { font-size: 13px; color: var(--ink-2); font-weight: 450; letter-spacing: 0; }
.tile .note { color: var(--ink-2); font-size: 12px; margin-top: 3px; }
.tile details summary { cursor: pointer; color: var(--accent); font-size: 12px; }
.tile details summary:hover { text-decoration: underline; }
.tile details ul { margin: 6px 0 0; padding-left: 16px; color: var(--ink-2); font-size: 12px; }

/* ---------------- panels ---------------- */

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1020px) { .grid2 { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.panel h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h2 .age { margin-left: auto; text-transform: none; letter-spacing: 0; }

.age { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
.badge {
  display: inline-block;
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  vertical-align: middle;
}
.badge.stale { background: var(--warning-soft); color: var(--warning); }
.badge.dead, .badge.urgent { background: var(--critical-soft); color: #ff7a68; }
.badge.blocked { background: var(--serious-soft); color: var(--serious); }
.badge.watch { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }

.honest-zero { color: var(--muted); font-style: italic; }
.err { color: var(--serious); font-size: 13px; }

/* ---------------- linkages table ---------------- */

#linkages { overflow-x: auto; }
/* wide unbreakable content (polymarket hex event ids, symbol->venue chains,
   auto-layout tables with long codes/labels) -- scroll the table itself
   inside its own panel, never the page. Every panel with a raw <table> gets
   this so a narrow viewport (~900px) scrolls the panel, not the grid. */
#carry, #markout, #predictions, #blockers, #history, #rates, #graph, #options {
  overflow-x: auto;
}

table { border-collapse: collapse; width: 100%; }
th {
  text-align: left;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 6px 10px;
  border-bottom: 1px solid var(--baseline);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--surface);
}
td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--grid);
  font-size: 13px;
  vertical-align: top;
}
tbody tr:not(.family-head):hover td { background: rgba(255, 255, 255, 0.025); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.pos { color: var(--good); font-weight: 650; }
td.neg { color: var(--ink-2); }

tr.family-head td {
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 13.5px;
  padding: 16px 10px 6px;
  border-bottom: 1px solid var(--baseline);
}
tr.family-head td::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 3px;
  background: var(--accent);
  margin-right: 8px;
  vertical-align: 1px;
}
tr.family-head .count {
  color: var(--ink-2);
  font-weight: 500;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  margin-left: 6px;
}

td .desc { color: var(--ink); font-weight: 550; }
td .desc-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }

.family-hint { color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }

/* композиция связки — цепочка кубиков конструктора */
.tag {
  display: inline-block;
  border-radius: 6px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 550;
  line-height: 17px;
  vertical-align: 1px;
  margin-left: 4px;
}
.tag.comp { background: var(--accent-soft); color: #9ec5f4; border: 1px solid rgba(57, 135, 229, 0.25); }
.tag.ref { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

tr.skeleton-line td { padding: 8px 10px; }
tr.skeleton-line a { color: var(--ink-2); text-decoration: none; font-weight: 550; }
tr.skeleton-line a:hover { color: var(--ink); }
.skel-why { color: var(--muted); font-size: 12px; margin-left: 8px; }

td .blocker {
  display: inline-block;
  max-width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 11px;
  padding: 1px 7px;
  margin: 1px 3px 1px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
td.more { color: var(--muted); font-size: 12px; font-style: italic; }

/* evidence pill: dot + mode */
.ev {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px 1px 7px;
  font-size: 11.5px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ev::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.ev.ev-live { color: var(--good); border-color: rgba(34, 179, 74, 0.35); }
.ev.ev-live::before { background: var(--good); }
.ev.ev-sim { color: var(--accent); border-color: rgba(57, 135, 229, 0.35); }
.ev.ev-sim::before { background: var(--accent); }
.ev .weakest { color: var(--muted); }

/* ---------------- filters ---------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.filters input[type="number"], .filters input[type="search"] {
  background: var(--page);
  color: var(--ink);
  border: 1px solid var(--baseline);
  border-radius: var(--radius-s);
  padding: 5px 10px;
  font: inherit;
  width: 110px;
  transition: border-color 0.15s;
}
.filters input[type="search"] { width: 170px; }
.filters input:focus { outline: none; border-color: var(--accent); }
.filters label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.filters input[type="checkbox"] { accent-color: var(--accent); }

.chip {
  border: 1px solid var(--baseline);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  padding: 4px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip.on { border-color: var(--accent); color: #cde2fb; background: var(--accent-soft); }

/* ---------------- funnel ---------------- */

.funnel { display: grid; grid-template-columns: max-content 1fr max-content; gap: 6px 12px; align-items: center; }
.funnel .stage { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.funnel .bar-track { position: relative; height: 20px; background: rgba(255, 255, 255, 0.03); border-radius: 0 6px 6px 0; }
.funnel .bar {
  height: 20px;
  border-radius: 0 6px 6px 0; /* rounded data-end, square at baseline */
  min-width: 2px;
}
.funnel .bar.zero { background: transparent; border-left: 2px solid var(--baseline); border-radius: 0; }
.funnel .val { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 650; text-align: right; }
.funnel-note { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* ---------------- events ---------------- */

.events { margin: 0; padding: 0; }
.events li {
  list-style: none;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--baseline);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  font-size: 13px;
}
.events li.urgent { border-left-color: var(--critical); }
.events li.stale-event { border-left-color: var(--warning); }
.events .ev-line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.events .ev-type { font-weight: 650; }
.events .ev-meta { color: var(--ink-2); }
.events .ev-gap { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--ink); }
.events .ev-next { color: var(--muted); font-size: 12px; margin-top: 2px; }
.recheck-line {
  color: var(--ink-2);
  font-size: 13px;
  margin-bottom: 10px;
  padding: 7px 10px;
  background: var(--accent-soft);
  border: 1px solid rgba(57, 135, 229, 0.25);
  border-radius: var(--radius-s);
}

details.ref-section > summary {
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 650;
  padding: 10px 0 6px;
}
details.ref-section > summary:hover { color: var(--ink); }
.next-action { color: var(--muted); font-size: 12px; }
.footer-note { color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------------- карточка связки (drawer) ---------------- */

.hidden { display: none !important; }
.drawer-veil {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(560px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--baseline);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}
.dr-pad { padding: 22px 24px 32px; position: relative; }
.dr-close {
  position: absolute; top: 14px; right: 16px;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 14px; padding: 4px 10px; cursor: pointer;
}
.dr-close:hover { color: var(--ink); border-color: var(--baseline); }
.dr-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.dr-asset { font-size: 24px; font-weight: 750; letter-spacing: -0.01em; }
.dr-net { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.dr-net.pos { color: var(--good); }
.dr-net-sub { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 6px; }
.drawer h3 {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin: 22px 0 10px; border-top: 1px solid var(--grid); padding-top: 14px;
}
.dr-step {
  padding: 8px 12px; margin-bottom: 6px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px;
}
.dr-step-act { color: var(--accent); font-weight: 600; margin-right: 4px; }
.dr-step-where { color: var(--ink-2); }
.dr-step-addr { color: var(--muted); font-size: 11px; font-family: ui-monospace, monospace; margin-top: 2px; }
.dr-water { display: flex; flex-direction: column; gap: 4px; }
.dr-cost {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 14px; padding: 5px 0; border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
}
.dr-cost span { color: var(--ink-2); }
.dr-conf { color: var(--muted); font-size: 12px; }
.dr-total { border-bottom: none; border-top: 1px solid var(--baseline); font-weight: 700; }
.dr-total b.pos { color: var(--good); }
.dr-ladder { color: var(--muted); font-size: 12px; margin-top: 8px; }
.dr-block {
  padding: 8px 12px; margin-bottom: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--serious); border-radius: 8px; font-size: 14px;
}
.dr-block-why { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.dr-block-code { color: var(--muted); font-size: 11px; font-family: ui-monospace, monospace; margin-top: 3px; }
.dr-evrow { color: var(--ink-2); font-size: 13px; }
tr.rowlink { cursor: pointer; }
.tag.cat { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }

/* Категория — короткий словарь (FAMILY_SHORT_RU в app.js), не многоточие:
   переносится на 2 строки, если нужно, но целыми словами, не серединой
   слова. Полный текст — в title. */
td.catcell {
  color: var(--ink-2);
  font-size: 12.5px;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.3;
}

/* Net/Gross слиты в одну колонку: net жирным сверху, gross серым мельче
   снизу — обе сортируемые независимо (два <span data-sort>). */
td.netgross { line-height: 1.35; }
.net-val { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.net-val.pos { color: var(--good); }
.net-val.neg { color: var(--ink-2); }
.gross-val { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
th.netgross { text-align: right; }
th.netgross .sortable { display: block; }
th.netgross .sub-sort {
  display: block;
  font-size: 9.5px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  margin-top: 1px;
}
th.netgross .sub-sort:hover { color: var(--ink); }

td.catcell:hover { color: var(--ink); text-decoration: underline dotted; cursor: pointer; }

/* события сверху — компактная полоса триггеров */
.panel-events-top .events li { margin-bottom: 4px; padding: 6px 10px; font-size: 12.5px; }
.panel-events-top .ev-next { display: none; }
.panel-events-top .recheck-line { margin-bottom: 8px; font-size: 12.5px; padding: 5px 10px; }

/* верхний ряд: события шире воронки */
.grid-top { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 1020px) { .grid-top { grid-template-columns: 1fr; } }

/* верхний ряд: одинаковая высота карточек; события скроллятся внутри,
   воронка заполняет рост барами, а не пустотой */
.grid-top { align-items: stretch; }
.grid-top .panel { display: flex; flex-direction: column; min-height: 0; }
.panel-events-top #events { overflow-y: auto; min-height: 0; flex: 1; }
#panel-funnel #funnel { flex: 1; display: flex; flex-direction: column; justify-content: center; }
#panel-funnel .funnel { gap: 12px 14px; }
#panel-funnel .bar-track, #panel-funnel .bar { height: 24px; }

/* воронка: сверху вниз без центрирующей дыры; ряд пониже */
.grid-top .panel { height: 420px; }
#panel-funnel #funnel { justify-content: flex-start; padding-top: 6px; }
.badge.identity_suspect { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }

/* сетка таблицы связок неподвижна: авторазметка отключена. min-width держит
   колонки читаемыми на узких панелях (мобильная ширина ~900px и уже) --
   #linkages сам скроллится по X, а не сжимает "Что мешает"/"Данные" в кашу. */
#linkages table { table-layout: fixed; min-width: 760px; }
#linkages td, #linkages th { overflow-wrap: break-word; }
#linkages td.num, #linkages th.num { white-space: nowrap; }

/* ---------------- история ---------------- */

.hist-sub {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 18px 0 10px; border-top: 1px solid var(--grid);
  padding-top: 14px;
}
#history > table:first-child, #history > .honest-zero:first-child { margin-top: 0; }

.hist-trend { display: flex; flex-direction: column; gap: 8px; }
.hist-row { display: grid; grid-template-columns: 220px 1fr; align-items: center; gap: 10px; }
.hist-label {
  color: var(--ink-2); font-size: 12.5px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.spark {
  display: flex; align-items: flex-end; gap: 2px; height: 26px;
  background: rgba(255, 255, 255, 0.03); border-radius: 4px; padding: 2px 4px;
  overflow-x: auto;
}
.spark i {
  flex: none; width: 5px; min-height: 1px; background: var(--accent);
  border-radius: 1px 1px 0 0; opacity: 0.85;
}

.hist-events { margin: 0; padding: 0; }
.hist-events li {
  list-style: none; padding: 6px 10px; margin-bottom: 4px;
  border: 1px solid var(--border); border-left: 3px solid var(--baseline);
  border-radius: var(--radius-s); background: var(--surface-2); font-size: 13px;
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
}
.hist-events li.in { border-left-color: var(--good); }
.hist-events li.out { border-left-color: var(--muted); }
.hist-events li .age { margin-left: auto; }

/* ---------------- panel nav + ГЛАЗА F ---------------- */

.panel-nav { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 14px; font-size: 12px; }
.panel-nav a { color: var(--ink-2); text-decoration: none; text-transform: uppercase; letter-spacing: 0.06em; }
.panel-nav a:hover { color: var(--ink); text-decoration: underline; }
.panel-nav a.nav-eyes { color: var(--accent); font-weight: 650; }
.eyes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 10px; }
.eye-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 10px;
  min-width: 0;
}
.eye-card .eye-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.eye-card .eye-title { font-weight: 700; font-size: 13px; letter-spacing: 0.03em; }
.eye-card .eye-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.eye-card .eye-age { font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.eye-card .eye-age.fresh { color: var(--good); }
.eye-card .eye-age.stale { color: var(--warning); }
.eye-card .eye-age.dead { color: var(--serious); }
.eye-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.eye-num .label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.eye-num .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.eye-num .value.pos { color: var(--good); }
.eye-num .value.zero { color: var(--muted); }
.eye-note { color: var(--ink-2); font-size: 12px; margin-top: 8px; }
.eye-card details { margin-top: 8px; }
.eye-card details > summary { cursor: pointer; color: var(--accent); font-size: 12px; }
.eye-card details > summary:hover { text-decoration: underline; }
.eye-card .tbl-wrap { overflow-x: auto; margin-top: 6px; }
.eye-card table { font-size: 11.5px; }
.eye-card td, .eye-card th { padding: 4px 6px; white-space: nowrap; }
.eye-card td.flags { white-space: normal; }
.eye-card td.flags { color: var(--muted); font-size: 11px; max-width: 260px; }
.eye-card .err { margin-top: 8px; }
