/* Rank Tracker IL — Heebo everywhere, quiet chrome, position tokens carry the color. */

:root {
  --page: #f6f6f2;
  --surface: #fffffe;
  --ink: #14141a;
  --ink-2: #55534e;
  --muted: #8a8781;
  --hair: #e5e3da;
  --hair-strong: #d5d3c9;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --up: #006300;
  --down: #c22f2f;
  --warn-bg: #fdf3d7;
  --warn-ink: #6b4e00;
  /* ordinal rank buckets, validated light ramp */
  --b1: #0d366b; --b1-ink: #ffffff;
  --b2: #256abf; --b2-ink: #ffffff;
  --b3: #5598e7; --b3-ink: #0b2547;
  --b4: #86b6ef; --b4-ink: #0b2547;
  --b0: transparent; --b0-ink: #8a8781;
  --shadow: 0 1px 2px rgba(20, 20, 26, 0.05), 0 4px 16px rgba(20, 20, 26, 0.05);
  --radius: 12px;
}
[data-theme="dark"] {
  --page: #0e0e0d;
  --surface: #1a1a19;
  --ink: #f4f4ef;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --hair: #2c2c2a;
  --hair-strong: #3a3a37;
  --accent: #3987e5;
  --up: #17b917;
  --down: #e66767;
  --warn-bg: #33290e;
  --warn-ink: #fab219;
  /* validated dark ramp: strongest bucket pops lightest on dark */
  --b1: #9ec5f4; --b1-ink: #0b2547;
  --b2: #5598e7; --b2-ink: #071c38;
  --b3: #2a78d6; --b3-ink: #ffffff;
  --b4: #184f95; --b4-ink: #cde2fb;
  --b0: transparent; --b0-ink: #898781;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 18px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* #app and #login set display on an id selector, which outranks the UA sheet's
   [hidden] { display: none }. Without this, both panes render stacked - the app
   shell on top and the login card a full viewport below - so signing in left the
   dashboard off-screen until you scrolled. Author-origin !important settles it. */
[hidden] { display: none !important; }
body {
  font-family: "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- layout ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: 236px; flex: none;
  border-right: 1px solid var(--hair);
  background: var(--surface);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--hair);
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
#topbar h1 { font-size: 17px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
#view { padding: 22px 24px 60px; max-width: 1200px; width: 100%; margin: 0 auto; }
#menuBtn { display: none; }

.brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px 14px; }
.brand-token {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--b1); color: var(--b1-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -0.02em; }
.brand-name em { font-style: normal; color: var(--accent); }

#mainNav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
#mainNav a {
  padding: 7px 10px; border-radius: 8px; font-weight: 500; color: var(--ink-2);
}
#mainNav a:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
#mainNav a.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--ink); font-weight: 600; }

.sites-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 4px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.site-list { display: flex; flex-direction: column; gap: 1px; }
.site-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; color: var(--ink-2);
  border: 0; background: none; text-align: left; width: 100%;
}
.site-item:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.site-item.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--ink); }
.site-item .si-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
/* The trailing cluster is a fixed set of slots so the dots, rank tokens and
   counts line up down the column instead of shifting with each row's content. */
.site-item .si-meta { display: flex; align-items: center; gap: 6px; flex: none; }
.site-item .si-tok { display: inline-flex; justify-content: flex-end; min-width: 26px; }
.site-item .si-count {
  font-size: 11px; color: var(--muted);
  min-width: 30px; text-align: right; font-variant-numeric: tabular-nums;
}

.lnk-open {
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
  padding: 3px 8px; border-radius: 7px;
  border: 1px solid var(--hair-strong); background: var(--surface);
  color: var(--ink-2); font-size: 11.5px; font-weight: 600; text-decoration: none;
}
.lnk-open:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- flags ---------- */
.flag {
  width: 16px; height: 12px; flex: none; border-radius: 2px;
  display: inline-block; vertical-align: -1px;
  /* Ring sits outside the artwork: flags that are largely white (Poland, Japan,
     the Dutch middle band) otherwise dissolve into the surface behind them. */
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 20%, transparent);
}
.flag-txt {
  width: 16px; height: 12px; line-height: 12px; text-align: center;
  font-size: 8.5px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--hair-strong); border-radius: 2px;
}

/* ---------- buttons, chips ---------- */
.btn {
  border: 1px solid var(--hair-strong); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 7px 14px; font-weight: 600;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 40%, transparent); background: none; }
.btn-danger:hover { background: color-mix(in srgb, var(--down) 8%, transparent); }
.btn-ghost { border: 0; background: none; color: var(--ink-2); border-radius: 8px; padding: 6px 9px; font-weight: 500; }
.btn-ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled, .btn-primary:disabled { opacity: 0.55; cursor: default; }

.balance-chip { font-size: 12.5px; color: var(--ink-2); padding: 5px 10px; border: 1px solid var(--hair); border-radius: 99px; background: var(--surface); }
.run-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--accent);
  padding: 5px 12px; border-radius: 99px;
  background: color-mix(in srgb, var(--accent) 11%, transparent);
}
.run-pill .spin {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- rank tokens (the signature) ---------- */
.tok {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 26px; padding: 0 5px;
  border-radius: 8px; font-weight: 700; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.tok.b1 { background: var(--b1); color: var(--b1-ink); }
.tok.b2 { background: var(--b2); color: var(--b2-ink); }
.tok.b3 { background: var(--b3); color: var(--b3-ink); }
.tok.b4 { background: var(--b4); color: var(--b4-ink); }
.tok.b0 { background: var(--b0); color: var(--b0-ink); border: 1.5px dashed var(--hair-strong); font-weight: 600; }
.tok.sm { min-width: 24px; height: 20px; font-size: 11px; border-radius: 6px; }

.delta { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--muted); font-weight: 500; }

/* ---------- cards & tiles ---------- */
.card {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}
.card h2 { margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.tile { padding: 14px 16px; }
.tile .t-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile .t-value { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }
.tile .t-sub { font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.two-col { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- spectrum bar ---------- */
.spectrum { display: flex; height: 30px; border-radius: 8px; overflow: hidden; gap: 2px; background: var(--page); }
.spectrum .seg { min-width: 3px; transition: flex-basis 0.4s ease; position: relative; }
.spectrum .seg.s1 { background: var(--b1); }
.spectrum .seg.s2 { background: var(--b2); }
.spectrum .seg.s3 { background: var(--b3); }
.spectrum .seg.s4 { background: var(--b4); }
.spectrum .seg.s0 { background: repeating-linear-gradient(45deg, var(--hair), var(--hair) 4px, transparent 4px, transparent 8px); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.legend .li { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--hair);
  white-space: nowrap; user-select: none;
}
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--ink-2); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background 0.1s; }
.tbl tbody tr.rowlink { cursor: pointer; }
.tbl tbody tr.rowlink:hover { background: color-mix(in srgb, var(--ink) 3.5%, transparent); }
.kw-cell { font-weight: 600; font-size: 14.5px; unicode-bidi: plaintext; }
.url-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); direction: ltr; }
.num { font-variant-numeric: tabular-nums; }
.dev-tag { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--hair-strong); padding: 1px 6px; border-radius: 5px; }
.kw-label {
  display: inline-block; font-size: 11px; font-weight: 600; unicode-bidi: plaintext;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, transparent);
  padding: 1px 8px; border-radius: 999px; margin-inline-start: 4px; white-space: nowrap; cursor: pointer;
}
.label-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.label-bar[hidden] { display: none; }
.label-chip {
  font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; unicode-bidi: plaintext;
  background: var(--surface); border: 1px solid var(--hair-strong); border-radius: 999px;
  padding: 4px 12px; color: var(--ink-2);
}
.label-chip b { font-weight: 700; color: var(--muted); margin-inline-start: 2px; }
.label-chip:hover { border-color: var(--accent); color: var(--ink); }
.label-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.label-chip.active b { color: var(--accent-ink); opacity: 0.8; }

/* ---------- Looker setup guide ---------- */
.steps { margin: 10px 0 16px; padding-inline-start: 20px; }
.steps li { margin: 7px 0; font-size: 13.5px; line-height: 1.55; }
.steps code, .copy-row code { font-size: 12px; background: color-mix(in srgb, var(--ink) 6%, transparent); padding: 1px 5px; border-radius: 4px; }
.mini-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 16px 0 8px; }
.looker-warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 10px 14px; margin: 12px 0; font-size: 13px; line-height: 1.55; }
.looker-warn b:first-child { display: block; margin-bottom: 4px; }
.looker-warn ul { margin: 4px 0 0; padding-inline-start: 18px; }
.looker-warn li { margin: 4px 0; }
.looker-warn code { background: color-mix(in srgb, var(--warn-ink) 12%, transparent); font-size: 12px; padding: 1px 5px; border-radius: 4px; }
.view-table { width: 100%; border-collapse: collapse; margin: 8px 0 4px; font-size: 12.5px; }
.view-table th, .view-table td { text-align: start; padding: 6px 8px; border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); vertical-align: top; }
.view-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.copy-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
.copy-row .cr-label { width: 82px; flex: none; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.copy-row .cr-value {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  direction: ltr; text-align: left; padding: 5px 9px; border: 1px solid var(--hair-strong); border-radius: 7px;
}
.copy-row .cr-copy { padding: 4px 10px; font-size: 12px; flex: none; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.input, .select {
  background: var(--surface); border: 1px solid var(--hair-strong); border-radius: 9px;
  padding: 7px 11px; color: var(--ink); min-width: 0;
}
.input::placeholder { color: var(--muted); }
.input:focus, .select:focus { border-color: var(--accent); outline: none; }

/* ---------- site header ---------- */
/* Three columns on the title row - favicon, name, actions - with the stats and
   the spectrum spanning the full width underneath so nothing gets squeezed. */
.site-head { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 16px; align-items: start; }
.site-head .sh-info { min-width: 0; }
.site-head .sh-full { grid-column: 1 / -1; margin-top: 10px; }
.site-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; text-transform: none; color: var(--ink); }
.site-head .sh-domain { color: var(--muted); font-size: 13px; direction: ltr; unicode-bidi: embed; }
.site-head .sh-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* Below this the three-column title row squeezes the domain line to one word
   per line, so the actions drop to a row of their own. */
@media (max-width: 1000px) {
  .site-head { grid-template-columns: auto 1fr; }
  .site-head .sh-actions { grid-column: 1 / -1; justify-content: flex-start; margin-top: 10px; }
}
.mini-stats { display: flex; gap: 22px; margin-top: 12px; flex-wrap: wrap; }
.mini-stats .ms { font-size: 12px; color: var(--muted); font-weight: 600; }
.mini-stats .ms b { display: block; font-size: 19px; color: var(--ink); font-weight: 800; letter-spacing: -0.01em; }

/* ---------- sparkline ---------- */
.spark { display: block; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: var(--accent); }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(10, 10, 12, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 16px; z-index: 100;
  animation: fadeIn 0.12s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--surface); border: 1px solid var(--hair);
  border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 520px; max-height: 84vh; overflow-y: auto;
  padding: 20px;
  animation: pop 0.15s ease;
}
.modal.wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal h3 { margin: 0 0 4px; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.modal .m-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 12px 0 4px; }
.modal .input, .modal .select, .modal textarea { width: 100%; }
.modal textarea {
  background: var(--surface); border: 1px solid var(--hair-strong); border-radius: 9px;
  padding: 9px 11px; min-height: 130px; resize: vertical; unicode-bidi: plaintext;
}
.modal textarea:focus { border-color: var(--accent); outline: none; }
.m-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.m-row { display: flex; gap: 10px; }
.m-row > * { flex: 1; }

/* ---------- history chart ---------- */
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: var(--page);
  font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 7px;
  transform: translate(-50%, -130%); white-space: nowrap;
}
.hist-chart .grid-line { stroke: var(--hair); stroke-width: 1; }
.hist-chart .axis-label { fill: var(--muted); font-size: 10px; font-family: inherit; }
.hist-chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.hist-chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.hist-chart .crosshair { stroke: var(--muted); stroke-dasharray: 3 3; }

/* ---------- serp list ---------- */
.serp-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.serp-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
}
.serp-row.ours { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.serp-row .sr-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; unicode-bidi: plaintext; }
.serp-row .sr-domain { font-size: 12px; color: var(--muted); direction: ltr; }
.serp-row .sr-badge { font-size: 10px; font-weight: 800; letter-spacing: 0.06em; color: var(--accent); }

/* ---------- generic line/bar charts ---------- */
.viz .grid-line { stroke: var(--hair); stroke-width: 1; }
.viz .axis-label { fill: var(--muted); font-size: 10px; font-family: inherit; }
.viz .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.viz .area { fill: color-mix(in srgb, var(--accent) 10%, transparent); }
.viz .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.viz .crosshair { stroke: var(--muted); stroke-dasharray: 3 3; }
.viz .bar-up { fill: var(--up); }
.viz .bar-down { fill: var(--down); }
.viz .zero-axis { stroke: var(--hair-strong); stroke-width: 1; }

/* ---------- events feed ---------- */
.feed { display: flex; flex-direction: column; }
.feed-day { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 12px 0 5px; border-bottom: 1px solid var(--hair); }
.feed-row { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--hair); font-size: 13px; }
.feed-row:last-child { border-bottom: 0; }
.feed-row .fr-kw { font-weight: 600; unicode-bidi: plaintext; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-row .fr-site { color: var(--muted); font-size: 12px; white-space: nowrap; }
.feed-row .fr-what { margin-left: auto; white-space: nowrap; }
.ev-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.ev-chip.good { color: var(--up); background: color-mix(in srgb, var(--up) 10%, transparent); }
.ev-chip.bad { color: var(--down); background: color-mix(in srgb, var(--down) 10%, transparent); }
.ev-chip.star { color: var(--accent); background: color-mix(in srgb, var(--accent) 11%, transparent); }

/* ---------- runs ---------- */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 7px; }
.status-dot.done { background: var(--up); }
.status-dot.running { background: var(--accent); animation: pulse 1.4s ease infinite; }
.status-dot.error { background: var(--down); }
.status-dot.skipped { background: var(--muted); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- banner, empty, toast ---------- */
.banner {
  background: var(--warn-bg); color: var(--warn-ink);
  border-radius: 10px; padding: 11px 14px; margin-bottom: 16px;
  font-weight: 600; font-size: 13px; display: flex; gap: 9px; align-items: center;
}
.empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.empty .e-title { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

#toastRoot { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: var(--page); font-weight: 600; font-size: 13px;
  padding: 9px 16px; border-radius: 10px; box-shadow: var(--shadow);
  animation: pop 0.18s ease;
}
.toast.err { background: var(--down); color: #fff; }

/* ---------- login ---------- */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--hair); border-radius: 16px; box-shadow: var(--shadow);
  padding: 30px 28px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px;
}
.login-card .login-sub { text-align: center; color: var(--muted); font-size: 12.5px; margin: 0 0 10px; }
.login-card input {
  background: var(--surface); border: 1px solid var(--hair-strong); border-radius: 9px; padding: 10px 12px;
}
.login-card input:focus { border-color: var(--accent); outline: none; }
.login-error { color: var(--down); font-size: 12.5px; text-align: center; margin: 0; }

/* ---------- insights ---------- */
.insights { display: flex; flex-direction: column; gap: 8px; }
.insight {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 12px; border: 1px solid var(--hair); border-radius: 10px;
  background: var(--surface); position: relative;
}
.insight .ins-sev {
  flex: none; font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px; margin-top: 1px; white-space: nowrap;
}
.insight .ins-body { flex: 1; min-width: 0; }
/* Findings are English sentences with a keyword inside, and the keyword is often
   Hebrew. `isolate` keeps the sentence left to right and lets the keyword render
   right to left inside it; `plaintext` would flip the whole line. */
.insight .ins-title { font-weight: 600; font-size: 13.5px; direction: ltr; text-align: left; unicode-bidi: isolate; }
.insight .ins-detail { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; direction: ltr; text-align: left; unicode-bidi: isolate; }
.insight .ins-site { flex: none; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; align-self: center; }
.insight .ins-site:hover { color: var(--accent); }
.insight .ins-x {
  flex: none; border: 0; background: none; color: var(--muted); font-size: 17px; line-height: 1;
  padding: 2px 4px; border-radius: 6px; opacity: 0; transition: opacity 0.12s;
}
.insight:hover .ins-x, .ins-x:focus-visible { opacity: 1; }
.insight .ins-x:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.sev-alert { border-inline-start: 3px solid var(--down); }
.sev-alert .ins-sev { background: color-mix(in srgb, var(--down) 12%, transparent); color: var(--down); }
.sev-warn { border-inline-start: 3px solid var(--warn-ink); }
.sev-warn .ins-sev { background: var(--warn-bg); color: var(--warn-ink); }
.sev-opp { border-inline-start: 3px solid var(--accent); }
.sev-opp .ins-sev { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.sev-win { border-inline-start: 3px solid var(--up); }
.sev-win .ins-sev { background: color-mix(in srgb, var(--up) 12%, transparent); color: var(--up); }
.sev-info { border-inline-start: 3px solid var(--hair-strong); }
.sev-info .ins-sev { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--muted); }

.pill-alert, .pill-opp {
  display: inline-block; min-width: 20px; text-align: center;
  font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; margin-inline-start: 4px;
}
.pill-alert { background: color-mix(in srgb, var(--down) 13%, transparent); color: var(--down); }
.pill-opp { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; font-weight: 500; }
.conn-ok { color: var(--up); font-weight: 600; font-size: 12.5px; }
.si-alert { width: 6px; height: 6px; border-radius: 50%; background: var(--down); flex: none; }
/* Kept in the layout when there is nothing to report, so rows stay in column. */
.si-alert.off { background: none; }
.btn-attn { border-color: var(--accent); color: var(--accent); }

.connect-cta { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.connect-cta > div { flex: 1; min-width: 260px; }
.connect-cta h2 { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink); }

/* ---------- tabs ---------- */
.tabs {
  display: flex; gap: 2px; margin: 16px 0 14px;
  border-bottom: 1px solid var(--hair); overflow-x: auto;
}
.tabs .tab {
  border: 0; background: none; color: var(--ink-2); font-weight: 600; font-size: 13.5px;
  padding: 9px 14px; border-radius: 8px 8px 0 0; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs .tab:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, transparent); }
.tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.whoami {
  font-size: 12.5px; color: var(--ink-2); font-weight: 600;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 760px) { .whoami { display: none; } }

/* ---------- table affordances ---------- */
/* Horizontal scroll only where it is needed. An overflow value other than
   visible makes the wrapper a scroll container, which breaks the sticky header,
   so wide screens keep it visible and narrow ones trade sticky for scroll. */
.tbl-wrap { overflow-x: auto; }
@media (min-width: 900px) { .tbl-wrap { overflow: visible; } }
.tbl.sticky-head thead th {
  position: sticky; top: 55px; background: var(--surface); z-index: 5;
  box-shadow: inset 0 -1px 0 var(--hair);
}
.tbl th.sortable::after { content: ""; opacity: 0.35; margin-inline-start: 5px; font-size: 9px; }
.tbl th.sortable.sorted { color: var(--ink); }
.tbl th.sortable.sorted[data-dir="asc"]::after { content: "\25B2"; opacity: 1; }
.tbl th.sortable.sorted[data-dir="desc"]::after { content: "\25BC"; opacity: 1; }
.quick-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.viz .line.imp { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 3; fill: none; }
.viz .axis-label.imp { fill: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  #sidebar {
    position: fixed; z-index: 50; height: 100vh; transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  #sidebar.open { transform: none; }
  #menuBtn { display: inline-flex; }
  #view { padding: 16px 14px 60px; }
  .url-cell { display: none; }
}

/* ---------- site explorer ---------- */
.ex-search { display: flex; gap: 8px; }
.ex-search .input { flex: 1; min-width: 0; }
.ex-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.ex-head > div:first-child { flex: 1; min-width: 220px; }
.ex-head h2 { text-transform: none; letter-spacing: 0; font-size: 18px; color: var(--ink); }
.ex-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
