:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #667085;
  --line: #dfe3e8;
  --accent: #14607a;
  --good: #1a7f4b;
  --bad: #b3261e;
  --warn: #8a6100;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); }

main { padding: 20px 24px 64px; max-width: 1600px; margin: 0 auto; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 6px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error {
  background: #fdeceb; border: 1px solid #f3c3bf; color: var(--bad);
  padding: 8px 10px; border-radius: 4px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 10px 24px;
}
.topbar .brand { font-weight: 600; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; gap: 14px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); }

/* ---------- login ---------- */
.login-wrap {
  max-width: 340px; margin: 12vh auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 24px;
}
.login-form { display: grid; gap: 12px; margin-top: 16px; }
.login-form label { display: grid; gap: 4px; font-weight: 500; }
input, select, textarea {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 4px; background: #fff; color: inherit;
}
button, .button {
  font: inherit; padding: 7px 12px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  text-decoration: none; display: inline-block;
}
button.ghost, .button.ghost {
  background: #fff; color: var(--ink); border-color: var(--line);
}
.link-button {
  background: none; border: none; color: var(--muted); padding: 0;
  text-decoration: underline; font-size: 12px;
}

/* ---------- layout bits ---------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 12px;
}
.head-right { display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs { color: var(--muted); margin: 0 0 8px; }
.pager { display: flex; gap: 14px; margin: 0 0 16px; }
.pager .current { font-weight: 600; color: var(--ink); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 16px; margin-bottom: 14px;
}
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* ---------- tables ---------- */
/* Only the table scrolls sideways -- the page itself never does. */
.table-scroll {
  overflow-x: auto; max-width: 100%;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
}
table.grid { border-collapse: collapse; width: 100%; background: var(--panel); }
/* 100%, never max-content: max-content sizes a wrapping cell to its longest
   UNWRAPPED line, so two prose columns would push the table far past the pane
   and force a sideways scroll over empty space. At 100% the browser shares the
   width out and prose wraps; columns that cannot wrap still overflow into the
   scroller, which is what it is for. */
table.grid.leads { width: 100%; }
table.grid th, table.grid td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line);
  vertical-align: top; white-space: nowrap;
}
/* Prose columns wrap and take whatever width is going spare; label columns stay
   on one line. Nothing is truncated to a fixed box, so three columns on screen
   show a whole sentence and twelve columns wrap it onto more lines. */
/* A prose column never goes below 200px: with a handful of columns the table
   fills the pane and a sentence sits on one or two lines, and with sixteen the
   floor holds so the table scrolls sideways instead of squeezing every
   sentence into a ribbon twelve lines tall. Measured: 4 columns -> table 1550
   in a 1550 pane; 16 -> 2719, row height 162px instead of 460. */
table.grid.leads td.wrap, table.grid.leads th.wrap {
  white-space: normal; min-width: 200px; overflow-wrap: anywhere;
}
table.grid.leads td:not(.wrap) {
  max-width: 420px; overflow: hidden; text-overflow: ellipsis;
}
/* Keep the company name pinned while the rest of the row scrolls. */
table.grid.leads th:first-child, table.grid.leads td:first-child {
  position: sticky; left: 0; background: var(--panel); z-index: 2;
  border-right: 1px solid var(--line);
}
table.grid.leads th:first-child { background: #eef1f3; z-index: 3; }
table.grid.leads tbody tr:hover td:first-child { background: #f4f8fa; }
table.grid th { background: #eef1f3; font-weight: 600; position: sticky; top: 0; z-index: 1; }
table.grid th a { color: inherit; text-decoration: none; }
table.grid th .arrow { font-size: 9px; margin-left: 4px; }
table.grid td.num, table.grid th.num { text-align: right; }
table.grid tbody tr:hover { background: #f4f8fa; }
table.grid td.brief { white-space: normal; max-width: 420px; }
table.small-grid th, table.small-grid td { white-space: normal; }
/* Jobs table: one line of text beside a button, so centre them on each other. */
table.grid.jobs th, table.grid.jobs td { vertical-align: middle; }
td.enrichments { white-space: nowrap; }
td.enrichments .sep { color: var(--line); margin: 0 6px; }

.jobid { font-size: 11px; color: var(--muted); }
.count { margin: 10px 0 6px; }
.lead-link { font-weight: 600; }

/* ---------- controls ---------- */
.controls {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px; margin-bottom: 8px;
}
.control-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.search { min-width: 300px; flex: 1; }
.filter { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.columns { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.columns summary { cursor: pointer; font-weight: 500; }
.column-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 4px 12px; margin: 10px 0;
}
.column-grid label { font-weight: normal; }
.column-actions { display: flex; gap: 8px; }

/* ---------- pills ---------- */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px;
  background: #eef1f3; border: 1px solid var(--line); white-space: nowrap;
}
.pill.faint { color: var(--muted); }
.pill.tier { background: #edf4f7; }
.verdict-meets-all-criteria { background: #e6f4ec; border-color: #b7e0c8; color: var(--good); }
.verdict-fails-a-criterion { background: #fdeceb; border-color: #f3c3bf; color: var(--bad); }
.verdict-insufficient-evidence { background: #fdf4e3; border-color: #ecd9ac; color: var(--warn); }

/* ---------- criteria ---------- */
.criterion { border-top: 1px solid var(--line); padding: 14px 0 4px; }
.criterion-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.criterion-head h3 { margin: 0; font-size: 15px; }
.pill.judgement-met { background: #e6f4ec; border-color: #b7e0c8; color: var(--good); }
.pill.judgement-not_met { background: #fdeceb; border-color: #f3c3bf; color: var(--bad); }
.pill.judgement-insufficient_evidence,
.pill.judgement-not_assessed { background: #fdf4e3; border-color: #ecd9ac; color: var(--warn); }
.definition { margin: 6px 0; }
.definition summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.definition p { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.reasoning { margin: 8px 0; }
ul.evidence { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.ev { display: flex; gap: 10px; padding: 8px 10px; border-radius: 4px; background: #f7f9fa; border-left: 3px solid var(--line); }
.ev-supports { border-left-color: var(--good); }
.ev-opposes { border-left-color: var(--bad); }
.ev-dir { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); min-width: 74px; }
.ev-claim { margin: 0 0 4px; }
.ev blockquote { margin: 0 0 4px; padding-left: 10px; border-left: 2px solid var(--line); color: #333; font-style: italic; }
.ev-src { margin: 0; font-size: 12px; word-break: break-all; }

/* ---------- facts ---------- */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
ul.plain { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 8px; }
ul.plain p { margin: 2px 0 0; }
ul.inline-list { display: flex; flex-wrap: wrap; gap: 6px 14px; }
blockquote { margin: 4px 0; padding-left: 10px; border-left: 2px solid var(--line); color: #333; }

/* ---------- feedback ---------- */
.fb-cell { white-space: nowrap; }
button.vote {
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  padding: 2px 7px; margin-right: 2px; line-height: 1.4;
}
button.vote.has { border-color: var(--accent); background: #eaf3f6; }
button.vote .badge { font-size: 11px; color: var(--muted); margin-left: 3px; }
button.vote.big {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; margin-right: 8px;
}
button.vote.big .glyph { font-size: 18px; }
.vote-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.fb-read { font-size: 12px; margin-left: 6px; }
ul.fb-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.fb-entry { border: 1px solid var(--line); border-left-width: 3px; border-radius: 4px; padding: 8px 12px; background: #fbfcfc; }
.fb-entry.vote-up { border-left-color: var(--good); }
.fb-entry.vote-down { border-left-color: var(--bad); }
.fb-entry.vote-question { border-left-color: var(--warn); }
.fb-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.fb-entry p { margin: 6px 0 0; white-space: pre-wrap; }
form.inline { display: inline; margin-left: auto; }
ul.fb-list.wide .fb-entry { background: var(--panel); }

dialog {
  border: 1px solid var(--line); border-radius: 6px; padding: 20px;
  max-width: 480px; width: 90%;
}
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { margin: 0 0 4px; }
dialog textarea { width: 100%; margin-top: 6px; }
dialog label { font-weight: 500; }
.req { color: var(--bad); font-weight: normal; font-size: 12px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

.count-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-controls { display: flex; align-items: center; gap: 10px; }
.page-controls .current { font-weight: 600; color: var(--ink); text-decoration: none; }

/* v2 additions */
.lede { font-size: 15px; margin: 0 0 8px; }
.pill.disputed { background: #fdf4e3; border-color: #ecd9ac; color: var(--warn); }
details.method {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 14px; margin-bottom: 12px;
}
details.method summary { cursor: pointer; font-weight: 500; }
details.method p { margin: 8px 0 0; }

/* Roles and entitlements */
.role-badge {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  background: var(--accent); color: #fff; border-radius: 3px; padding: 1px 5px;
}
td.enrichments .locked { color: var(--muted); text-decoration: line-through; }

/* The brief is a sentence: give it room rather than letting the table squeeze
   it into a column of single words. */
table.grid.jobs td.brief, table.grid.jobs th:nth-child(4) { min-width: 300px; }
table.grid.jobs { width: auto; min-width: 100%; }

/* The razor id is long and low-value per character: let it wrap so the row's
   useful columns -- and the View leads button -- stay on screen. */
table.grid.jobs .jobid {
  display: inline-block; max-width: 230px;
  white-space: normal; word-break: break-word; line-height: 1.3;
}

/* A two-letter country code with its name on hover. */
abbr.country {
  text-decoration: underline dotted; text-underline-offset: 2px; cursor: help;
}

/* A URL the safe_url filter refused renders with an empty href -- 216 of the
   values in the live job are the string "not stated" rather than a link. Show
   those as plain text rather than as an anchor that goes nowhere. */
a[href=""] { color: inherit; text-decoration: none; pointer-events: none; cursor: default; }

/* "How did we do?" box on a job page. */
.process-box { margin-top: 24px; max-width: 720px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 16px 20px; }
.process-box form { display: grid; gap: 10px; }
.process-box textarea { width: 100%; font: inherit; }
fieldset.rating { border: 0; padding: 0; margin: 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
fieldset.rating legend { padding: 0; margin-bottom: 6px; }
.rating-choice { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; cursor: pointer; }
.pf-note.good { color: var(--good); }
.pf-note.bad { color: var(--bad); }
.fb-entry.process-entry { border-left-color: var(--accent); }
