:root {
  --bg: #0f1420;
  --panel: #171d2c;
  --border: #2a3247;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --green: #33c481;
  --red: #ef5a6f;
  --gold: #e0b04d;
  --maxw: 1100px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  font-size: 16px;
}

a { color: var(--accent); }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.38rem;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}
/* The emblem is a tall portrait stack — dome above the letter — so it is sized
   by height and left to find its own width. */
.brand-mark {
  height: 46px;
  width: auto;
  display: block;
}
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.95rem;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent); color: #fff; }

/* ---------- Layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 28px 24px 48px; }

h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 14px; }
h2 { font-size: 1.25rem; margin: 36px 0 10px; }
p { margin: 0 0 16px; max-width: 74ch; }

.lede { font-size: 1.1rem; color: var(--text); }
.note { color: var(--muted); font-size: 0.92rem; }
.na { color: var(--muted); }

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 18px;
}
.breadcrumbs a { color: var(--muted); }

.callout {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  padding: 12px 16px;
  color: var(--muted);
  max-width: none;
}

.highlights { max-width: 74ch; padding-left: 20px; }
.highlights li { margin-bottom: 8px; }

.inline-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- Stats ---------- */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0 8px;
}
.stat {
  flex: 1 1 130px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.stat-value { font-size: 1.3rem; font-weight: 600; margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 16px 0 24px;
  scrollbar-color: var(--accent) var(--panel);
}
.table-wrap::-webkit-scrollbar { height: 12px; }
.table-wrap::-webkit-scrollbar-track { background: var(--panel); }
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 6px;
  border: 2px solid var(--panel);
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--panel);
  /* Deliberately not sticky. .table-wrap sets overflow-x, which forces
     overflow-y to auto, so a sticky header here sticks inside that container
     rather than to the viewport -- and since the container has no height
     limit and never scrolls vertically, it buys nothing while any non-zero
     top offset pushes the header down over the first rows of data. Making
     this work needs a max-height on .table-wrap, which is a layout decision,
     not a style tweak. */
}
.data-table td.num, .data-table th.num { text-align: right; }
/* Opt-out of the nowrap above for cells holding a long name rather than a
   date, ticker or percentage -- committee names in particular run to 90-odd
   characters and would otherwise push the table past its container. */
.data-table td.wrap, .data-table th.wrap { white-space: normal; min-width: 220px; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Nine columns of real data. Tighter cells and two wrapping columns keep it
   inside the content width on a laptop instead of relying on the scroll
   fallback for everyone. */
.flagged-table th,
.flagged-table td { padding: 10px 10px; }
.flagged-table td.wrap,
.flagged-table th.wrap { min-width: 150px; }
.flagged-table .sector { white-space: normal; min-width: 92px; }
.data-table tr.top-quartile { background: rgba(79, 140, 255, 0.07); }

.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge.type-buy { background: rgba(51, 196, 129, 0.15); color: var(--green); }
.badge.type-sell { background: rgba(239, 90, 111, 0.15); color: var(--red); }
.badge.type-other { background: rgba(139, 147, 167, 0.15); color: var(--muted); }
.badge.tag-cluster { background: rgba(239, 90, 111, 0.18); color: var(--red); }
.badge.tag-notable { background: rgba(224, 176, 77, 0.18); color: var(--gold); }
.badge.tag-aligned-mega-cap { background: rgba(139, 147, 167, 0.18); color: var(--muted); }

/* ---------- Charts (server-rendered SVG) ---------- */
.chart-figure {
  margin: 18px 0 28px;
  padding: 16px 12px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-label { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-line-0 { stroke: var(--accent); }
.chart-line-1 { stroke: var(--gold); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}
.chart-key { display: flex; align-items: center; gap: 7px; }
.chart-swatch { width: 20px; height: 0; border-top: 2px solid var(--accent); }
.chart-swatch-1 { border-top-color: var(--gold); }
.chart-swatch.dashed { border-top-style: dashed; }
.chart-figure figcaption { margin-top: 10px; }

/* ---------- Article list ---------- */
.article-list { display: grid; gap: 12px; margin: 20px 0 28px; }
.article-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
}
.article-card h2 { margin: 0 0 6px; font-size: 1.05rem; }
.article-card h2 a { text-decoration: none; }
.article-card p { margin: 0; max-width: none; }

/* ---------- Long-form prose ---------- */
.prose h1 { margin-bottom: 18px; }
.prose h2 { margin-top: 32px; }
.prose h3 { margin-top: 24px; font-size: 1.05rem; }
.prose ul, .prose ol { max-width: 74ch; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose blockquote {
  border-left: 3px solid var(--accent);
  margin: 18px 0;
  padding: 4px 0 4px 16px;
  color: var(--muted);
}
.prose table { border-collapse: collapse; margin: 18px 0; font-size: 0.9rem; }
.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.prose th { background: var(--panel); color: var(--muted); }
.prose code {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.88em;
}

/* ---------- FAQ ---------- */
.faq details {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 10px;
  background: var(--panel);
}
.faq summary { cursor: pointer; font-weight: 600; }
.faq-answer { color: var(--muted); margin-top: 10px; }
.faq-answer p { margin: 0; }

/* ---------- Footer ---------- */
.updated {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.footer {
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 24px;
}
.footer-links {
  max-width: var(--maxw);
  margin: 0 auto 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 0.9rem;
}
.footer-note {
  max-width: var(--maxw);
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  main { padding: 20px 16px 40px; }
  /* Left to wrap, five nav items plus the brand stack onto three lines at
     phone widths and the bar becomes 148px -- nearly a fifth of the screen,
     which is far too much to hand a sticky header. Keeping it on one line and
     letting the nav scroll sideways holds it near 57px instead. */
  .topbar { gap: 12px; padding: 12px 16px; flex-wrap: nowrap; }
  .brand { flex: 0 0 auto; }
  .brand-mark { height: 37px; }
  .nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }
}
.badge.tag-unaligned { background: rgba(139, 147, 167, 0.12); color: var(--muted); }

/* ---------- Sector coverage ---------- */
.badge.megacap { background: rgba(139, 147, 167, 0.18); color: var(--muted); }
.muted { color: var(--muted); }

/* These tables carry long prose -- committee names and filing descriptions --
   rather than the dates and percentages the shared .data-table rule assumes,
   so its white-space: nowrap has to be lifted here. Fixed layout with explicit
   column widths keeps the columns from being dragged wide by one long cell;
   the min-width preserves horizontal scroll on phones rather than crushing six
   columns into 375px. */
.coverage-table { table-layout: fixed; width: 100%; min-width: 680px; }
.coverage-table th,
.coverage-table td {
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: top;
}
.cell-list { font-size: 0.85rem; color: var(--muted); line-height: 1.5; }

/* ---------- Table filters ---------- */
/* Rendered hidden and revealed by filter.js, so a reader without JavaScript
   gets the full table rather than controls that do nothing. */
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 -4px;
  font-size: 0.9rem;
  color: var(--muted);
}
.filters label { font-weight: 600; }
.filters select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
  max-width: 100%;
}
.filters select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters-count { margin-left: auto; font-variant-numeric: tabular-nums; }
.filter-empty { color: var(--muted); padding: 16px 14px; margin: 0; }

/* ---------- Buy-timing table ---------- */
.timing-table th, .timing-table td { padding: 10px 10px; vertical-align: top; }
.timing-table .dates { white-space: nowrap; }
.timing-table .news-cell { min-width: 150px; font-size: 0.85rem; }
/* Sector wraps here for the same reason it does in the flagged table:
   "Media & Entertainment" on one line drags the column far wider than
   the information in it deserves. */
.timing-table .sector { white-space: normal; min-width: 92px; }
.timing-table summary { cursor: pointer; color: var(--accent); }
.timing-table summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.news-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.news-list li { line-height: 1.4; }
.news-list a { display: block; }
.news-list .na { font-size: 0.8rem; }

/* The topbar is sticky, so a heading jumped to via an #anchor would otherwise
   land underneath it. One generous value rather than a variable tracking the
   bar's exact height: it only has to clear the tallest version (75px), and a
   number that must be kept in sync is a number that drifts.
   :where() keeps specificity at zero so this can never fight a real rule. */
:where(h1, h2, h3, h4)[id] { scroll-margin-top: 92px; }

/* ---------- Data downloads ---------- */
.downloads { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 20px 0 28px; }
@media (max-width: 640px) { .downloads { grid-template-columns: 1fr; } }
.download {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}
.download h2 { margin: 0 0 8px; font-size: 1.05rem; }
.download p { max-width: none; margin: 0 0 10px; }
.download-meta { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.download-link {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 600;
}
.download-link:hover { text-decoration: none; background: #3f7ae8; }
.download-link:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---------- Cookie consent ---------- */
.consent {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 60;
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}
.consent-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.consent-text { margin: 0; flex: 1 1 320px; font-size: 0.9rem; color: var(--muted); }
.consent-actions { display: flex; gap: 10px; flex: 0 0 auto; }
/* Identical weight on both buttons is the point: a prominent Accept beside a
   quiet Reject is not consent under ICO guidance. */
.consent-btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  min-width: 104px;
}
.consent-btn:hover { background: rgba(79, 140, 255, 0.14); }
.consent-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
@media (max-width: 640px) {
  .consent-inner { padding: 14px 16px; gap: 12px; }
  .consent-actions { width: 100%; }
  .consent-btn { flex: 1; }
}

/* ---------- Article byline ---------- */
.byline {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

/* Evidence badge on the rankings table. Muted on purpose: it qualifies the
   Composite figure beside it rather than competing with it, and a red/green
   scale would read as a judgement on the politician rather than on the
   sample size. */
.evidence {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}
.evidence-strong   { background: rgba(51, 196, 129, 0.14); border-color: rgba(51, 196, 129, 0.35); }
.evidence-moderate { background: rgba(148, 163, 184, 0.16); border-color: rgba(148, 163, 184, 0.35); }
.evidence-limited  { background: rgba(148, 163, 184, 0.07); border-color: rgba(148, 163, 184, 0.22); opacity: 0.85; }

/* Homepage hooks. Questions with real answers, not a nav menu -- so the answer
   is the thing that gets the visual weight and the question sets it up. */
.hooks {
  list-style: none;
  margin: 1.5rem 0 2rem;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, calc(50% - 0.375rem)));
}
.hook a {
  display: block;
  height: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border, #2a3245);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, transform .15s ease;
}
.hook a:hover, .hook a:focus-visible {
  border-color: var(--accent, #33c481);
  transform: translateY(-2px);
}
.hook-q {
  display: block;
  font-weight: 700;
  margin-bottom: 0.3rem;
  color: var(--accent, #33c481);
}
.hook-a { display: block; font-size: 0.93rem; line-height: 1.5; }
@media (prefers-reduced-motion: reduce) {
  .hook a { transition: none; }
  .hook a:hover, .hook a:focus-visible { transform: none; }
}
