* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f7f6f1;
  --surface: #ffffff;
  --ink: #1c1f26;
  --ink-soft: #4a5160;
  --ink-muted: #8a8f99;
  --line: #e3e0d6;
  --line-strong: #cdcabe;
  --accent: #1e4d6b;
  --accent-soft: #e8eef2;
  --pass: #2e7d4f;
  --pass-bg: #e6f4ec;
  --warn: #b46c00;
  --warn-bg: #fff4dd;
  --stop: #8b1a1a;
  --stop-bg: #fae0e0;
}
html, body {
  background: var(--bg); color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 22px 24px 60px; }
.narrow { max-width: 460px; margin: 0 auto; padding: 64px 24px; }

/* ===== NAV / MASTHEAD ===== */
.topnav { display: flex; align-items: center; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.topnav a { font-size: 13px; font-weight: 600; color: var(--ink-soft); text-decoration: none;
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.topnav a:hover { border-color: var(--line-strong); color: var(--ink); }
.topnav a.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.topnav .spacer { margin-left: auto; }
.topnav .who { font-size: 12px; color: var(--ink-muted); margin-right: 8px; }

.masthead { border-bottom: 2px solid var(--ink); padding-bottom: 16px; margin-bottom: 22px; }
.masthead h1 { font-size: 22px; letter-spacing: -0.01em; }
.masthead p { color: var(--ink-soft); margin-top: 4px; }

/* ===== CARDS / TILES ===== */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 18px 16px; text-decoration: none; color: inherit; transition: border-color .12s, transform .12s; }
a.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile h2 { font-size: 16px; margin-bottom: 4px; }
.tile p { color: var(--ink-soft); font-size: 13px; }
.tile .note { margin-top: 10px; font-size: 12px; color: var(--warn); background: var(--warn-bg);
  border-radius: 5px; padding: 6px 8px; }
.tile.unbuilt { opacity: .72; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; margin-bottom: 18px; }
.card h2 { font-size: 15px; margin-bottom: 12px; }
.card h3 { font-size: 14px; margin: 16px 0 8px; }

/* ===== FORMS ===== */
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: #fff; font: inherit; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 180px; margin-bottom: 0; }

button { font: inherit; font-weight: 600; padding: 9px 15px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; }
button:hover { filter: brightness(1.08); }
button.ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line-strong); }
button.ghost:hover { color: var(--ink); border-color: var(--ink-soft); filter: none; }
button.danger { background: var(--surface); color: var(--stop); border-color: #dcc2c2; }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }
button.small { padding: 5px 10px; font-size: 12px; }

/* ===== TABLES ===== */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-muted); border-bottom: 1px solid var(--line-strong); padding: 0 10px 7px; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px;
  border-radius: 20px; background: var(--accent-soft); color: var(--accent); margin: 0 4px 4px 0; }
.pill .x { margin-left: 6px; cursor: pointer; opacity: .6; }
.pill .x:hover { opacity: 1; }

/* ===== PERMISSION TICKS ===== */
.ticks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; margin: 8px 0 4px; }
.tick { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: #fcfbf8; }
.tick input { margin-top: 3px; }
.tick .desc { display: block; font-size: 11px; color: var(--ink-muted); }

.role-block { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.role-block .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.role-block .head strong { font-size: 14px; }

/* ===== MESSAGES ===== */
.msg { padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; font-size: 13px; }
.msg.err { background: var(--stop-bg); color: var(--stop); }
.msg.ok  { background: var(--pass-bg); color: var(--pass); }
.msg.info{ background: var(--warn-bg); color: var(--warn); }
.muted { color: var(--ink-muted); font-size: 12px; }
.hidden { display: none !important; }
.spinner { color: var(--ink-muted); padding: 14px 0; }

/* ===== BUILD TRACKER ===== */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { margin-left: auto; }
.chip { font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); }
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.item { display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px; margin-bottom: 10px; text-decoration: none; color: inherit; }
a.item:hover { border-color: var(--accent); }
.item .head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.item .head h2 { font-size: 16px; }
.item .desc { color: var(--ink-soft); margin-top: 5px; max-width: 78ch; }
.item .meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px;
  font-size: 12px; color: var(--ink-muted); }
.item.closed { opacity: .6; }

/* One status, from the code. Nothing to reconcile it against, so nothing to
   colour as a disagreement. */
.status { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; display: inline-block; }
.status.not_built         { background: #f0ecf5; color: #6b4595; }
.status.partly_built      { background: var(--warn-bg); color: var(--warn); }
/* Built and doing nothing is not Built and live. It gets its own colour so
   the list never reads as further along than it is. */
.status.built_but_off     { background: #efe7dc; color: #855b1f; }
.status.built_and_running { background: var(--pass-bg); color: var(--pass); }
.status.could_not_check   { background: #eceff3; color: #4a5560; }
.status.unchecked         { background: #eceff3; color: #4a5560; }

/* ===== THE LIST AS A TABLE ===== */
.wrap.wide { max-width: 1400px; }
.table-scroll { overflow-x: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; }
table.items { min-width: 980px; }
table.items th { padding: 12px 12px 9px; background: var(--surface); }
table.items td { padding: 12px; }
table.items tr:hover td { background: #fcfbf8; }
table.items tr.closed td { opacity: .55; }
table.items tr.is-hidden td { background: #f4f3ee; }

.col-topic { width: 40%; }
.col-topic a { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 14px; }
.col-topic a:hover { color: var(--accent); text-decoration: underline; }
/* One extra line per row buys a list you can read rather than one you must
   click through. Clamped so a long description cannot own the table. */
.col-topic .desc { color: var(--ink-soft); font-size: 12.5px; margin-top: 3px; max-width: 62ch;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.col-num { width: 48px; color: var(--ink-muted); font-variant-numeric: tabular-nums;
  font-size: 12.5px; font-weight: 600; }
.col-status { width: 13%; }
.col-flags { width: 18%; }
.col-changed { width: 10%; font-size: 12.5px; white-space: nowrap; }
.col-changed.recent { color: var(--pass); font-weight: 600; }
.col-money, .col-owner, .col-clients { width: 8%; font-size: 12.5px; }

/* Sorting. The header you are sorted by says so, and says which way. */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable.sorted { color: var(--accent); }
th.sortable.sorted::after { content: ' ▼'; font-size: 9px; }
th.sortable.sorted.asc::after { content: ' ▲'; }

/* ===== FILTERS ===== */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 14px; }
.filter-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 12px; }
.filter-row:last-child { margin-bottom: 0; }
.filter { min-width: 130px; }
.filter.search { flex: 1 1 240px; }
.filter.wide-filter { flex: 1 1 380px; }
.filter.grow-end { margin-left: auto; }
.filter label { margin-bottom: 5px; }
.tickrow { display: flex; gap: 6px; flex-wrap: wrap; }
.tickrow .tick { font-size: 12.5px; padding: 5px 9px; }
.tickrow .tick .count { font-style: normal; color: var(--ink-muted); font-size: 11px; }

.item-number { font-size: 13px; font-weight: 700; color: var(--ink-muted);
  font-variant-numeric: tabular-nums; }

/* ===== WHAT CHANGED ===== */
.change { border-left: 2px solid var(--line-strong); padding-left: 12px; margin-bottom: 14px; }
.change .when { font-size: 12px; color: var(--ink-muted); margin-bottom: 4px; }
.change .before { white-space: pre-wrap; font-size: 13px; color: var(--ink-soft);
  background: #faf9f5; border-radius: 6px; padding: 8px 10px; }

.stage-note { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; line-height: 1.35; }
.stage-note.ready { color: var(--pass); font-weight: 600; }

.stage-explain { margin-top: 8px; font-size: 13px; color: var(--ink-soft);
  background: #f4f3ee; border-left: 3px solid var(--line-strong);
  border-radius: 6px; padding: 8px 11px; max-width: 80ch; }
.stage-explain.override { background: var(--warn-bg); color: #7a4a00; border-left-color: var(--warn); }

/* The audit's proposed wording. It sits beside your words and never
   replaces them — copying it in is your act, not the machine's. */
.suggestion { border: 1px solid var(--line-strong); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 11px 13px; margin-top: 10px; background: #fbfaf6; }
.suggestion .head { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--accent); }
.suggestion .why { font-size: 12.5px; color: var(--ink-soft); margin: 5px 0; }
.suggestion .proposed { white-space: pre-wrap; background: #fff; border: 1px solid var(--line);
  border-radius: 6px; padding: 9px 11px; margin: 7px 0; }
.suggestion .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Drafted by the audit, or confirmed by you. Never ambiguous. */
.prov { font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: none;
  padding: 2px 7px; border-radius: 20px; margin-left: 6px; vertical-align: middle; }
.prov.draft     { background: var(--warn-bg); color: var(--warn); }
.prov.confirmed { background: var(--pass-bg); color: var(--pass); }

/* The audit's opinion, shown beside yours. A disagreement is loud on purpose. */
.audit-line { margin-top: 10px; font-size: 13px; padding: 8px 11px; border-radius: 6px;
  background: #f4f3ee; color: var(--ink-soft); border-left: 3px solid var(--line-strong); }
.audit-line.disagrees { background: var(--warn-bg); color: #7a4a00; border-left-color: var(--warn); }
.audit-line.unchecked { background: #eceff3; color: #4a5560; border-left-color: #8a97a5; }
.audit-line strong { font-weight: 700; }

.flag { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; background: var(--stop-bg); color: var(--stop); margin-left: 6px; }
.flag.soft { background: var(--warn-bg); color: var(--warn); }

/* ===== ITEM PAGE ===== */
.section { margin-bottom: 8px; }
.section h3 { font-size: 13px; letter-spacing: .03em; text-transform: uppercase;
  color: var(--ink-muted); margin-bottom: 6px; }
.section .body { white-space: pre-wrap; }
.section .empty { color: var(--ink-muted); font-style: italic; }

.finding { border: 1px solid var(--line); border-left: 3px solid var(--stop);
  border-radius: 8px; padding: 13px 15px; margin-bottom: 10px; background: #fffdfd; }
.finding.ruled { border-left-color: var(--line-strong); background: #fafaf8; opacity: .8; }
.finding .kind { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--stop); }
.finding.ruled .kind { color: var(--ink-muted); }
.finding p { margin: 5px 0; }
.finding .where { font-size: 12px; color: var(--ink-muted); }
.finding.security { border-left-width: 5px; background: #fff8f8; }
/* What the kind is waiting on, so nobody has to remember which findings need
   a ruling and which need a document corrected. */
.finding .what-next { font-size: 12px; color: var(--ink-soft); background: #f4f3ee;
  border-radius: 5px; padding: 6px 8px; margin: 6px 0; }
.finding .actions { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }

.trail { border-left: 2px solid var(--line); padding-left: 16px; margin-left: 4px; }
.trail .entry { position: relative; padding-bottom: 14px; }
.trail .entry::before { content: ''; position: absolute; left: -21px; top: 5px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.trail .entry .when { font-size: 12px; color: var(--ink-muted); }
.trail .entry .what { font-weight: 600; }
.trail .entry .added { color: var(--ink-soft); }

.two-col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

/* ===== THE TRAIL ===== */
.anchor { border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; margin-bottom: 8px; background: #fcfbf8; }
.anchor.retired { opacity: .55; }
.anchor .top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.anchor .kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.anchor .conf { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.anchor .conf.confirmed { background: var(--pass-bg); color: var(--pass); }
.anchor .conf.guess     { background: var(--warn-bg); color: var(--warn); }
.anchor .conf.stale     { background: var(--stop-bg); color: var(--stop); }
.anchor .proves { margin: 5px 0 6px; }
.anchor .recipe { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  background: #f1efe8; border-radius: 4px; padding: 5px 7px; display: block; word-break: break-word; }
.anchor .whereabouts { font-size: 12px; color: var(--ink-muted); margin-top: 5px; }
.searched { font-size: 12px; color: var(--ink-soft); margin-top: 6px; padding-left: 14px; }
.searched li { margin-bottom: 2px; }

/* A ruling you replaced, kept where the finding is. */
.prior-rulings { font-size: 12px; color: var(--ink-muted); margin-top: 5px;
  border-left: 2px solid var(--line-strong); padding-left: 9px; }
.prior-rulings div { margin-bottom: 3px; }
