/* ============================================================================
   BHW Tracker — design system
   ----------------------------------------------------------------------------
   A competitive-intelligence monitor: dense, numeric, checked daily. The visual
   language is a precision instrument — layered near-black surfaces, one accent,
   and semantic colour reserved strictly for what data MEANS (up, down, breakout).
   Numbers are set in tabular mono throughout, because figures are the subject.

   Deliberately single-theme (dark). This is an internal operations console that
   lives on a dark ground; a light variant would be an omission, not a feature.
   ========================================================================== */

/* ---- Tokens ------------------------------------------------------------- */
:root {
  /* Grounds & surfaces — blue-biased near-blacks, layered for real depth */
  --ground:        #0b0e14;
  --surface:       #12161f;
  --surface-2:     #171c27;
  --surface-3:     #1d2330;
  --line:          #232a39;
  --line-soft:     #1a2028;

  /* Ink */
  --ink:           #e8ecf4;
  --ink-2:         #b6c0d2;
  --ink-3:         #98a3b6;
  /* The quietest text tier, and still >= 4.5:1 on every surface — the old
     #626e83 fell to 3.0-3.5:1 wherever small labels and footnotes used it. */
  --ink-4:         #808da1;

  /* Accent — violet-indigo, the one brand colour */
  --accent:        #7c6cf7;
  --accent-hi:     #9186ff;
  --accent-lo:     #5b4fe0;
  --accent-ghost:  rgba(124, 108, 247, 0.12);
  --accent-line:   rgba(124, 108, 247, 0.34);

  /* Semantic — meaning only, never decoration */
  --pos:           #3ddc97;
  --pos-ghost:     rgba(61, 220, 151, 0.11);
  --neg:           #ff6b6b;
  --neg-ghost:     rgba(255, 107, 107, 0.11);
  --warn:          #f5a524;
  --warn-ghost:    rgba(245, 165, 36, 0.12);
  --info:          #4cc3f5;
  --info-ghost:    rgba(76, 195, 245, 0.12);
  /* Reserved exclusively for breakouts and your own thread */
  --gold:          #ffc857;
  --gold-ghost:    rgba(255, 200, 87, 0.10);
  --gold-line:     rgba(255, 200, 87, 0.30);

  /* Type */
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --fs-micro: 10.5px;
  --fs-xs:    11.5px;
  --fs-sm:    12.5px;
  --fs-base:  13.5px;
  --fs-md:    15px;
  --fs-lg:    18px;
  --fs-xl:    22px;
  --fs-2xl:   30px;

  /* Space, radius, elevation */
  --r-sm: 5px;
  --r:    8px;
  --r-lg: 11px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.035);
  --shadow-2: 0 4px 16px -4px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.045);
  --ring: 0 0 0 3px var(--accent-ghost);
}

/* ---- Reset & base ------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle depth behind the whole app so cards read as lifted, not pasted */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(124,108,247,.055), transparent 70%),
    radial-gradient(760px 380px at 92% -4%, rgba(76,195,245,.035), transparent 70%);
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.012em; line-height: 1.25; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p  { margin: 0; }

a { color: var(--accent-hi); text-decoration: none; }
a:hover { color: var(--ink); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

[x-cloak] { display: none !important; }

::selection { background: var(--accent-lo); color: #fff; }

/* Scrollbars — part of the instrument, not an afterthought */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border: 2px solid var(--ground);
  border-radius: 6px;
}
*::-webkit-scrollbar-thumb:hover { background: #2a3140; }

/* ---- Layout ------------------------------------------------------------- */
.shell { max-width: 1240px; margin: 0 auto; padding: 0 22px; }
/* Longhands: a padding shorthand here zeroed .shell's side gutter on
   <main class="shell main">, so below ~1284px content touched the window edge. */
.main  { padding-top: 26px; padding-bottom: 72px; }

.stack   { display: flex; flex-direction: column; gap: 18px; }
.row     { display: flex; align-items: center; gap: 10px; }
.row-wrap{ display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer  { margin-left: auto; }

/* ---- Navigation --------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11, 14, 20, 0.82);
  backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.nav-inner { display: flex; align-items: center; gap: 26px; height: 56px; }

.brand {
  white-space: nowrap;
  display: flex; align-items: center; gap: 9px;
  font-weight: 650; font-size: var(--fs-md); letter-spacing: -0.02em;
  color: var(--ink);
}
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: linear-gradient(145deg, var(--accent-hi), var(--accent-lo));
  box-shadow: 0 0 14px rgba(124,108,247,.35);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px 5px;
  border-left: 1.5px solid rgba(255,255,255,.85);
  border-bottom: 1.5px solid rgba(255,255,255,.85);
}

.nav-links { display: flex; align-items: center; gap: 3px; }
.nav-link {
  position: relative;
  padding: 7px 11px; border-radius: var(--r-sm);
  font-size: var(--fs-base); color: var(--ink-3);
  transition: color .14s ease, background-color .14s ease;
}
.nav-link:hover { color: var(--ink-2); background: var(--surface); }
.nav-link.is-active { color: var(--ink); background: var(--surface-2); }
.nav-link.is-active::after {
  content: ""; position: absolute; left: 11px; right: 11px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--accent);
}

/* Brand, five links and the scrape button need ~670px in one row, so on a
   phone every page scrolled sideways. Below the tablet breakpoint the brand and
   button share the top row and the links take a full-width row of their own,
   which scrolls within itself if it must — the page never does. */
@media (max-width: 820px) {
  .shell { padding-left: 16px; padding-right: 16px; }
  /* Vertical only: .nav-inner shares its element with .shell, whose side gutter must stay. */
  .nav-inner { flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 6px; column-gap: 12px; row-gap: 4px; }
  .brand { white-space: nowrap; }
  .nav-links {
    order: 3; width: 100%;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-link { padding: 7px 9px; white-space: nowrap; }
}

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 13px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  font-family: inherit; font-size: var(--fs-base); font-weight: 550;
  color: var(--ink-2); background: var(--surface-2);
  border-color: var(--line);
  cursor: pointer; white-space: nowrap;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease;
}
.btn:hover { background: var(--surface-3); color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); border-color: var(--accent-lo); color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.10) inset, 0 2px 10px -2px rgba(124,108,247,.5);
}
.btn-primary:hover { background: var(--accent-hi); color: #fff; }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger { background: rgba(255,107,107,.08); border-color: rgba(255,107,107,.28); color: #ffb0b0; }
.btn-danger:hover { background: rgba(255,107,107,.16); color: #fff; }

.btn-sm { height: 27px; padding: 0 10px; font-size: var(--fs-sm); }

/* Link-style action inside dense tables */
.act {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: var(--fs-sm); color: var(--accent-hi);
}
.act:hover { color: var(--ink); text-decoration: underline; }
.act-muted { color: var(--ink-3); }
.act-danger { color: var(--neg); }

/* ---- Form controls ------------------------------------------------------ */
.field, .select {
  height: 32px; padding: 0 10px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: inherit; font-size: var(--fs-base);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.field::placeholder { color: var(--ink-4); }
.field:focus, .select:focus {
  outline: none; border-color: var(--accent-line); box-shadow: var(--ring);
}
.select {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 13px, calc(100% - 10px) 13px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.field-lg { height: 36px; }
textarea.field { height: auto; padding: 9px 10px; line-height: 1.5; resize: vertical; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink-2); font-size: var(--fs-base); }
.check input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

.label {
  display: block; margin-bottom: 6px;
  font-size: var(--fs-sm); font-weight: 550; color: var(--ink-3);
}

/* ---- Cards -------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { font-size: var(--fs-md); }
.card-body { padding: 18px 20px; }
.card-foot {
  padding: 11px 20px; border-top: 1px solid var(--line-soft);
  font-size: var(--fs-sm); color: var(--ink-4);
}

.sub { color: var(--ink-3); font-size: var(--fs-sm); }
.hint { color: var(--ink-4); font-size: var(--fs-sm); }

/* ---- Stat tiles --------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px 15px;
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden; min-width: 0;
}
/* Inside a card a stat is a cell, not another card: no second border, fill or
   shadow, and the cells share the card's surface separated by hairlines. */
.card .stats { gap: 0; }
.card .stat {
  background: none; border: 0; border-radius: 0; box-shadow: none;
  border-left: 1px solid var(--line-soft); padding: 4px 20px;
}
.card .stat:first-of-type { border-left: 0; padding-left: 0; }
.stat-k {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: var(--fs-sm); font-weight: 550; color: var(--ink-3);
}
.stat-k .dot { display: inline-block; vertical-align: 1px; margin-right: 6px; }
.stat-v {
  font-family: var(--mono); font-size: var(--fs-2xl); font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.1;
  color: var(--ink);
}
.stat-v-sm { font-family: var(--sans); font-size: var(--fs-md); font-weight: 600; letter-spacing: -.005em; }
.stat-note { font-size: var(--fs-sm); color: var(--ink-4); }
.stat.is-alert { border-color: rgba(245, 165, 36, .32); }
.stat.is-alert .stat-v { color: var(--warn); }
.stat.is-bad { border-color: rgba(255, 107, 107, .34); }
.stat.is-bad .stat-v { color: var(--neg); }

/* ---- Tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }

.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3);
  text-align: left; white-space: nowrap;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.tbl thead th.sortable { cursor: pointer; user-select: none; }
.tbl thead th.sortable:hover { color: var(--ink-2); }

.tbl tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  font-size: var(--fs-base);
  color: var(--ink-2);
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background-color .12s ease; }
.tbl tbody tr:hover { background: rgba(255,255,255,.022); }

.tbl .num {
  text-align: right;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  color: var(--ink); white-space: nowrap;
}
.tbl .num-strong { font-weight: 600; }
.rank { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-4); font-weight: 600; }
.rank-1 { color: var(--gold); }

/* Row emphasis: your own thread, and dead threads */
tr.is-mine { background: var(--gold-ghost) !important; box-shadow: inset 2px 0 0 var(--gold); }
tr.is-dim td { opacity: .5; }

/* Sub-line under a primary figure (the delta beneath a total) */
.subline {
  display: block; margin-top: 1px;
  font-family: var(--mono); font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

/* The break between the leaders and the rows around your own thread. Reads as
   a fold in one continuous ranking, not as the start of a second table. */
.tbl tbody tr.row-elide td {
  padding: 5px 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-xs); font-weight: 550; color: var(--ink-3);
  text-align: center;
}

/* Row tints for severity in dense log output */
.tint-neg  { background: rgba(255, 107, 107, .06); }
.tint-warn { background: rgba(245, 165, 36, .05); }

/* ---- Standing against the field (scorecard) ----------------------------- */
/* A measured figure and how it sits against the competitor median. Colour on
   the figure tracks the direction it moved; the dot carries standing, so a
   thread that is merely trailing the median never shouts in error red. */
.change { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.change-v {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: var(--fs-md); font-weight: 600; letter-spacing: -.01em;
}

.standing {
  display: inline-flex; align-items: center; gap: 6px;
  /* ink-3, not ink-4: at this size ink-4 falls under 4.5:1 on every surface. */
  font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap;
}
.standing::before {
  content: ""; flex: none; width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink-4);
  /* Pinned to the optical centre of the first line so a wrapped line on narrow
     screens does not drag the marker down beside the middle of the text. */
  align-self: flex-start; margin-top: .45em;
}
.standing-ahead::before  { background: var(--pos); }
/* Amber, not red: trailing the median while still growing is a heads-up, and
   error red belongs to figures that actually went down. */
.standing-behind::before { background: var(--warn); }
.standing-bare::before   { display: none; }
.standing .mono { font-size: inherit; color: var(--ink-2); }

/* A metric x window matrix. Side-scrolling this table would defeat it — the
   comparison across windows is the whole point — so on narrow screens each
   metric becomes a stacked block and every figure carries its own window
   label, which the header row supplies at wider widths. */
@media (max-width: 820px) {
  .tbl-matrix, .tbl-matrix tbody, .tbl-matrix tr, .tbl-matrix td { display: block; width: 100%; }
  .tbl-matrix thead { display: none; }
  .tbl-matrix tbody tr { padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
  .tbl-matrix tbody tr:last-child { border-bottom: 0; }
  .tbl-matrix tbody td { border-bottom: 0; }
  .tbl-matrix .matrix-row-key { padding-bottom: 2px; }
  .tbl-matrix td.num {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 14px; text-align: left; padding: 4px 12px 4px 24px;
  }
  /* Side by side with its window label there is no room to hold the supporting
     line on one line, and forcing it would scroll the table sideways. */
  .tbl-matrix td.num .change { min-width: 0; }
  .tbl-matrix td.num .standing { white-space: normal; text-align: right; }
  .tbl-matrix td.num::before {
    content: attr(data-window);
    font-size: var(--fs-xs); font-weight: 600; color: var(--ink-3);
    white-space: nowrap;
  }
}

/* ---- Semantic value colouring ------------------------------------------ */
.v-pos  { color: var(--pos); }
.v-neg  { color: var(--neg); }
.v-flat { color: var(--ink-4); }
.v-warn { color: var(--warn); }
.v-mute { color: var(--ink-4); }

/* ---- Badges ------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1.5px 7px; border-radius: 999px;
  font-size: var(--fs-micro); font-weight: 600;
  letter-spacing: .04em;
  border: 1px solid transparent; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-3);
}
.badge-pos  { background: var(--pos-ghost);  color: var(--pos);  border-color: rgba(61,220,151,.22); }
.badge-neg  { background: var(--neg-ghost);  color: var(--neg);  border-color: rgba(255,107,107,.22); }
.badge-warn { background: var(--warn-ghost); color: var(--warn); border-color: rgba(245,165,36,.24); }
.badge-info { background: var(--info-ghost); color: var(--info); border-color: rgba(76,195,245,.22); }
.badge-accent { background: var(--accent-ghost); color: var(--accent-hi); border-color: var(--accent-line); }
.badge-gold { background: var(--gold-ghost); color: var(--gold); border-color: var(--gold-line); }
.badge-quiet { background: transparent; border-color: var(--line); color: var(--ink-4); }

/* Breakout gets a deliberate glow — it is the one thing worth interrupting for */
.badge-breakout {
  background: var(--gold-ghost); color: var(--gold);
  border-color: var(--gold-line);
  box-shadow: 0 0 12px -2px rgba(255,200,87,.35);
}

/* ---- Meta strip (key/value run under a heading) ------------------------- */
.meta {
  display: flex; flex-wrap: wrap; gap: 6px 20px;
  font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.meta b { color: var(--ink-2); font-weight: 600; }

/* ---- Empty & loading states -------------------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 46px 24px; text-align: center;
}
.empty-mark {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px dashed var(--line);
  display: grid; place-items: center;
  color: var(--ink-4); font-family: var(--mono); font-size: var(--fs-md);
}
.empty-title { font-size: var(--fs-base); color: var(--ink-2); font-weight: 550; }
.empty-hint { font-size: var(--fs-sm); color: var(--ink-4); max-width: 44ch; }

.skeleton {
  height: 11px; border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* ---- Notices ------------------------------------------------------------ */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: var(--fs-base); color: var(--ink-2);
}
.notice-warn { background: var(--warn-ghost); border-color: rgba(245,165,36,.26); color: #f7d08a; }
.notice-neg  { background: var(--neg-ghost);  border-color: rgba(255,107,107,.26); color: #ffb3b3; }
.notice-pos  { background: var(--pos-ghost);  border-color: rgba(61,220,151,.24); color: #a5efcd; }
.notice-gold { background: var(--gold-ghost); border-color: var(--gold-line); color: #ffdb96; }

/* ---- Modal -------------------------------------------------------------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 7, 11, .68);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 470px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  padding: 20px;
}
.modal h3 { margin-bottom: 14px; font-size: var(--fs-md); }

/* ---- Access gate (standalone page, no app shell) ----------------------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  padding: 26px;
}
.gate-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.gate-brand span { font-weight: 650; font-size: var(--fs-md); letter-spacing: -.02em; }
.gate h1 { font-size: var(--fs-lg); margin-bottom: 5px; }
.gate .sub { margin-bottom: 18px; }

/* ---- Utility (small, intentional set) ---------------------------------- */
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.tiny { font-size: var(--fs-xs); }
.muted { color: var(--ink-3); }
.faint { color: var(--ink-4); }
.strong { font-weight: 600; color: var(--ink); }
.nowrap { white-space: nowrap; }
.hide { display: none; }
@media (max-width: 820px) { .hide-sm { display: none; } }

/* ---- At-a-glance components -------------------------------------------- */
/* A trend line drawn from real values, always beside the number it shapes —
   the line answers "steady climb or one-day spike?", the number answers "how much". */
.spark { display: block; overflow: visible; }
.spark-line { fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spark-area { stroke: none; opacity: .14; }
.spark-end { stroke-width: 6; stroke-linecap: round; }
.spark.tone-pos { color: var(--pos); }
.spark.tone-neg { color: var(--neg); }
.spark.tone-flat { color: var(--ink-3); }
.spark.tone-accent { color: var(--accent-hi); }
.spark-line, .spark-end { stroke: currentColor; }

.spark-area { fill: currentColor; }
.stat .spark { margin-top: 6px; width: 100%; height: 34px; }

/* Run history: one mark per scrape, oldest left, so a pattern of failures
   reads as a pattern rather than as a single latest status. */
.runs { display: flex; align-items: flex-end; gap: 3px; height: 18px; margin-top: 6px; }
.run { flex: 1 1 0; max-width: 12px; min-width: 4px; height: 100%; border-radius: 2px; background: var(--pos); opacity: .85; }
.run.is-partial { background: var(--warn); height: 70%; }
.run.is-failed { background: var(--neg); height: 45%; }
.run.is-running { background: var(--info); }
.runs-legend { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--ink-4); margin-top: 4px; }

/* Filter chips: the familiar segmented filter above a list, each with its count. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-3); font: inherit; font-size: var(--fs-sm); font-weight: 550;
  cursor: pointer; white-space: nowrap;
  transition: color .14s ease, background-color .14s ease, border-color .14s ease;
}
.chip:hover { color: var(--ink); border-color: var(--surface-3); }
.chip.is-active { color: var(--ink); background: var(--accent-ghost); border-color: var(--accent-line); }
.chip-n { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--fs-xs); color: var(--ink-4); }
.chip.is-active .chip-n { color: var(--accent-hi); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:focus-visible) { box-shadow: var(--ring); }

/* Status dot used in headings and tiles. */
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-4); }
.dot.is-pos { background: var(--pos); }
.dot.is-warn { background: var(--warn); }
.dot.is-neg { background: var(--neg); }

.stat-link { color: inherit; }
.stat-link:hover .stat-v { color: var(--accent-hi); }
.stat-sub { font-size: var(--fs-sm); color: var(--ink-2); min-width: 0; }
.stat-sub .truncate { display: block; }

@media (max-width: 820px) {
  .card .stat { border-left: 0; border-top: 1px solid var(--line-soft); padding: 12px 0; }
  .card .stat:first-of-type { border-top: 0; }
}

/* In-page links land below the sticky nav, not under it. */
.anchor { scroll-margin-top: 72px; }
@media (max-width: 820px) { .anchor { scroll-margin-top: 104px; } }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.tbl td.trend-cell { padding-top: 6px; padding-bottom: 4px; vertical-align: middle; }
.tbl td.trend-cell .spark { width: 112px; height: 26px; }
.field-group { border: 0; margin: 0; padding: 0; min-width: 0; }
.field-group > legend { padding: 0; }

/* System health: an issue row, and the compact line of passing checks. */
.health-row { display: flex; align-items: flex-start; gap: 11px; padding: 11px 20px; border-bottom: 1px solid var(--line-soft); }
.health-row .dot { margin-top: 6px; }
.health-row.is-fail { background: var(--neg-ghost); }
.health-passes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 20px; }
.runs-wide { height: 28px; margin-top: 0; gap: 4px; }
.runs-wide .run { max-width: none; }

/* Remove on every member row read as a wall of red. With a mouse it appears on
   the row being pointed at; touch screens have no hover, so it stays visible. */
@media (hover: hover) {
  .member-row .member-remove { opacity: 0; transition: opacity .12s ease; }
  .member-row:hover .member-remove, .member-remove:focus-visible { opacity: 1; }
}
/* Every group's scoreboard on the same column grid, so groups compare by eye. */
.tbl-members { table-layout: fixed; }
.tbl-members th:nth-child(2), .tbl-members th:nth-child(3), .tbl-members th:nth-child(5) { width: 104px; }
.tbl-members th:nth-child(4) { width: 140px; }
.tbl-members th:nth-child(6) { width: 92px; }
.tbl-members td:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 820px) {
  .tbl-members th:nth-child(2), .tbl-members th:nth-child(3), .tbl-members th:nth-child(5) { width: 76px; }
  .tbl-members th:nth-child(6) { width: 70px; }
}
/* As a full sentence (group headers) the standing line wraps; the inline form
   used in table cells keeps nowrap. */
p.standing { display: flex; white-space: normal; }
.card-head > div { min-width: 0; }
/* On a phone the five pulse tiles pair up, momentum full width, so the
   overview fits about one screen instead of five. */
@media (max-width: 820px) {
  .pulse { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pulse > .stat:first-child { grid-column: 1 / -1; }
  .pulse .stat { padding: 12px 14px 13px; }
  .pulse .stat-v { font-size: var(--fs-xl); }
  .pulse .stat-v.stat-v-sm { font-size: var(--fs-md); }
}

/* Sign-in pages */
.btn-lg { height: 38px; padding: 0 16px; font-size: var(--fs-base); }
.gate .notice { display: block; margin-bottom: 14px; line-height: 1.5; }
.gate-foot { margin-top: 16px; font-size: var(--fs-sm); color: var(--ink-3); text-align: center; }
.gate code { font-family: var(--mono); font-size: .92em; color: var(--ink-2); }

/* Account menu in the nav */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 4px;
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  color: var(--ink-2); font-size: var(--fs-sm); font-weight: 550;
}
.user-chip:hover, .user-menu[open] .user-chip { background: var(--surface-2); color: var(--ink); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-ghost); color: var(--accent-hi); font-size: var(--fs-xs); font-weight: 700;
}
.user-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 220px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); padding: 6px;
}
.user-pop-who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }
.user-pop-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--r-sm);
  background: none; border: 0; font: inherit; font-size: var(--fs-sm); color: var(--ink-2); cursor: pointer;
}
.user-pop-item:hover { background: var(--surface-3); color: var(--ink); }

/* Status toast (scrape progress and results) */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; max-width: min(420px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 10px; padding: 11px 12px 11px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); font-size: var(--fs-sm); color: var(--ink-2);
}
.toast.is-bad { border-color: rgba(255, 107, 107, .4); }
.toast.is-good { border-color: rgba(61, 220, 151, .35); }
.toast-close { background: none; border: 0; color: var(--ink-3); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.toast-close:hover { color: var(--ink); }
@media (max-width: 820px) { .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; } }
