/* FDI Intelligence Monitor: dashboard styles.
   Editorial, research-report register: system fonts only (works offline), ink on warm paper,
   one deep accent, thin rules instead of cards. No gradients, no shadows, no JavaScript. */

:root {
  --paper: #f8f6f1;
  --paper-2: #efebe2;
  --paper-3: #e6e1d5;
  --ink: #1a1c1e;
  --ink-2: #42454a;
  --ink-3: #62656b;
  --ink-4: #aaa69c;           /* decoration only: never text */
  --rule: #d6d1c4;
  --rule-soft: #e4dfd4;
  --accent: #17475b;
  --accent-ink: #0d3342;
  --mark: #f2df98;
  --mark-edge: #c7a431;

  --ok: #3a6a4b;
  --empty: #5f5b53;
  --blocked: #7f520c;
  --error: #9a3a2b;
  --never: #9d998f;

  --heat-1: #e9eef0;
  --heat-2: #d7e2e6;
  --heat-3: #bfd2d8;
  --heat-4: #a3bec7;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  --gutter: clamp(16px, 4vw, 64px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: clamp(15px, calc(8.5px + 0.5vw), 18px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent-ink); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

code { font-family: var(--mono); font-size: 0.88em; background: var(--paper-2); padding: 0.08em 0.35em; }

.n, .num, table { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.sep { color: var(--ink-3); margin: 0 0.25em; }

.wrap { max-width: 88rem; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--ink); color: var(--paper); padding: 0.6rem 1rem; }
.skip-link:focus { left: 1rem; z-index: 10; }

/* ---------- masthead ---------- */

.masthead { border-top: 4px solid var(--ink); border-bottom: 1px solid var(--rule); }
.masthead-inner {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 0.6rem 2.5rem; padding-top: 1.1rem; padding-bottom: 0.9rem;
}
.brand {
  font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--ink);
  text-decoration: none; letter-spacing: -0.005em;
}
.brand:hover { color: var(--ink); }
.brand-tag {
  font-family: var(--sans); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-3); margin-left: 0.8rem; vertical-align: 0.15em;
}
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.2rem 1.7rem; }
.nav a {
  display: inline-block; color: var(--ink-2); text-decoration: none; font-size: 0.95rem;
  padding: 0.35rem 0 0.3rem; border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- page head ---------- */

.page-head {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(14rem, auto);
  gap: 1.5rem 4rem; align-items: end;
  padding: 3.2rem 0 2.2rem; border-bottom: 1px solid var(--ink);
}
.page-head--overview { padding-top: 4rem; }
.kicker {
  margin: 0 0 0.9rem; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent);
}
.kicker a { color: inherit; text-decoration: none; }
.kicker a:hover { text-decoration: underline; }
h1 {
  margin: 0; font-family: var(--serif); font-weight: 600; letter-spacing: -0.018em;
  font-size: clamp(2.1rem, 1.3rem + 2.6vw, 3.7rem); line-height: 1.04;
}
.doc-h1 { font-size: clamp(1.6rem, 1.1rem + 1.6vw, 2.5rem); line-height: 1.15; max-width: 48rem; overflow-wrap: anywhere; }
.subtitle { margin: 0.9rem 0 0; font-size: 1.1rem; color: var(--ink-2); max-width: 44rem; }
.division {
  margin: 2rem 0 0; font-family: var(--serif); font-size: clamp(1.3rem, 1rem + 0.9vw, 1.85rem);
  line-height: 1.3; max-width: 40rem;
}
.division-ours { color: var(--ink); }
.division-theirs { color: var(--accent); font-style: italic; }

.head-meta { margin: 0; display: grid; gap: 0.9rem; justify-items: start; }
.head-meta > div { border-left: 1px solid var(--rule); padding-left: 1rem; }
.head-meta dt { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.head-meta dd { margin: 0.1rem 0 0; font-size: 1rem; }
.status-row { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; }
.status-count { white-space: nowrap; }

/* ---------- sections ---------- */

.section { padding: 3rem 0 0.5rem; }
.section--tight { padding-top: 2rem; }
.section-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 0.4rem 2rem; margin-bottom: 1.6rem;
}
h2 { margin: 0; font-family: var(--serif); font-size: 1.55rem; font-weight: 600; letter-spacing: -0.01em; }
.section-note { margin: 0; color: var(--ink-3); font-size: 0.9rem; max-width: 40rem; }

.notice {
  margin: 2rem 0 0; padding: 1rem 1.2rem; border-top: 2px solid var(--blocked);
  background: var(--paper-2); max-width: 60rem;
}
.notice p { margin: 0; }
.notice--inline { margin: 0 0 1.2rem; font-size: 0.9rem; }

.empty { padding: 2.2rem 0 1.4rem; border-top: 1px solid var(--rule); max-width: 44rem; }
.empty-title { margin: 0 0 0.4rem; font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.empty-body { margin: 0 0 0.6rem; color: var(--ink-2); }
.empty-cmd { margin: 0; color: var(--ink-3); font-size: 0.92rem; }
.empty-action { margin: 0 0 2rem; }

/* ---------- status marks ---------- */

.status {
  display: inline-flex; align-items: center; gap: 0.45em; white-space: nowrap;
  font-size: 0.8rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
}
.status::before { content: ""; width: 0.62em; height: 0.62em; flex: none; background: var(--empty); }
.status--ok { color: var(--ok); }
.status--ok::before { background: var(--ok); }
.status--empty { color: var(--empty); }
.status--empty::before { background: transparent; box-shadow: inset 0 0 0 2px var(--empty); }
.status--blocked { color: var(--blocked); }
.status--blocked::before { background: var(--blocked); }
.status--error { color: var(--error); }
.status--error::before { background: var(--error); }
.status--unfinished { color: var(--blocked); }
.status--unfinished::before { background: transparent; box-shadow: inset 0 0 0 2px var(--blocked); }
.status--never { color: var(--ink-3); }
.status--never::before { background: transparent; box-shadow: inset 0 0 0 1px var(--never); }

.conf { display: inline-flex; align-items: center; gap: 0.5em; font-size: 0.85rem; color: var(--ink-2); }
.conf-bars { display: inline-flex; gap: 2px; align-items: flex-end; }
.conf-bars i { display: block; width: 4px; background: var(--rule); }
.conf-bars i:nth-child(1) { height: 6px; }
.conf-bars i:nth-child(2) { height: 9px; }
.conf-bars i:nth-child(3) { height: 12px; }
.conf--high .conf-bars i { background: var(--ok); }
.conf--medium .conf-bars i:nth-child(-n+2) { background: var(--blocked); }
.conf--low .conf-bars i:nth-child(1) { background: var(--error); }
.conf--none { color: var(--ink-3); }

.rel { font-size: 0.88rem; white-space: nowrap; }
.rel--yes { color: var(--ink); }
.rel--no { color: var(--ink-3); }
.rel--unchecked { color: var(--ink-3); font-style: italic; }

.xstatus { font-size: 0.88rem; white-space: nowrap; padding-left: 0.6rem; border-left: 3px solid var(--rule); }
.xstatus--done, .xstatus--structured { border-left-color: var(--ok); }
.xstatus--pending, .xstatus--running { border-left-color: var(--blocked); }
.xstatus--error { border-left-color: var(--error); color: var(--error); }
.xstatus--no_facts, .xstatus--skipped { border-left-color: var(--never); color: var(--ink-2); }

.ok-text { color: var(--ok); }
.error-text { color: var(--error); }

/* ---------- pipeline ---------- */

.pipeline-owners, .stages {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 2.6rem;
}
.pipeline-owners { margin-bottom: 1.1rem; }
.owner {
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3);
}
.owner--ours { grid-column: 1 / span 4; }
.owner--theirs { grid-column: 5; color: var(--accent); }

.stages { list-style: none; margin: 0; padding: 0; }
.stage { position: relative; border-top: 2px solid var(--ink); padding-top: 1rem; display: flex; flex-direction: column; }
.stage:not(:last-child)::after {
  content: ""; position: absolute; top: -6px; right: calc(-1.3rem - 5px);
  width: 9px; height: 9px; border-top: 2px solid var(--ink); border-right: 2px solid var(--ink);
  transform: rotate(45deg);
}
.stage:nth-child(4)::after { border-color: var(--accent); }
.stage--theirs { border-top-color: var(--accent); }
.stage-owner { display: none; }
.stage-num { margin: 0 0 0.3rem; font-size: 0.78rem; letter-spacing: 0.12em; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.stage--theirs .stage-num { color: var(--accent); }
.stage-name { margin: 0 0 0.9rem; font-family: var(--serif); font-size: 1.22rem; font-weight: 600; line-height: 1.2; min-height: 2.4em; }
.stage-figure {
  margin: 0; font-size: clamp(2.2rem, 1.4rem + 1.8vw, 3.4rem); font-weight: 300; line-height: 1;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums lining-nums;
}
.stage-figure--word {
  font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--accent);
  font-size: clamp(1.4rem, 1rem + 0.9vw, 1.9rem); letter-spacing: 0; line-height: 1.2;
  min-height: calc(clamp(2.2rem, 1.4rem + 1.8vw, 3.4rem) * 1); display: flex; align-items: flex-end;
}
.stage-caption { margin: 0.45rem 0 0; font-size: 0.92rem; color: var(--ink-2); }
.stage-breakdown { list-style: none; margin: 0.9rem 0 0; padding: 0; display: grid; gap: 0.25rem; }
.stage-breakdown li { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; font-size: 0.86rem; color: var(--ink-2); max-width: 15rem; }
.stage-breakdown--plain li { display: block; }
.stage-breakdown .n { font-size: 0.9rem; }
.stage-pending { color: var(--blocked) !important; }
.stage-desc { margin: 1.1rem 0 0; padding-top: 0.8rem; border-top: 1px solid var(--rule-soft); font-size: 0.86rem; line-height: 1.45; color: var(--ink-3); }
.stage-link { margin: auto 0 0; padding-top: 0.8rem; font-size: 0.88rem; }

/* ---------- limits strip ---------- */

.limits {
  margin-top: 2.8rem; padding: 1.2rem 0 1.3rem;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 1rem 2.6rem; align-items: start;
}
.limits-title {
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--ink-3); letter-spacing: 0.13em; padding-top: 0.2rem;
}
.limits-list { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem 2.6rem; }
.limits-list dt { font-size: 0.84rem; color: var(--ink-3); }
.limits-list dd { margin: 0.15rem 0 0; font-size: 1.05rem; }
.limits-sub { display: block; font-size: 0.82rem; color: var(--ink-3); }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; vertical-align: top; padding: 0.75rem 1.2rem 0.75rem 0; border-bottom: 1px solid var(--rule); }
th:last-child, td:last-child { padding-right: 0; }
thead th {
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1px solid var(--ink); vertical-align: bottom; padding-top: 0;
}
tbody th { font-weight: 600; }
.num { text-align: right; }
.cell-sub { display: block; margin: 0.25rem 0 0; font-size: 0.86rem; color: var(--ink-3); overflow-wrap: anywhere; font-weight: 400; letter-spacing: 0; text-transform: none; }

.matrix { min-width: 52rem; }
.matrix thead th { font-size: 0.8rem; line-height: 1.3; padding-left: 0.6rem; }
.matrix tbody th, .matrix tfoot th { padding-right: 1.5rem; white-space: nowrap; }
.matrix tbody th a { color: var(--ink); text-decoration: none; }
.matrix tbody th a:hover { color: var(--accent); text-decoration: underline; }
.matrix td.cell { padding: 0; text-align: right; font-size: 1.05rem; border-left: 1px solid var(--paper); }
.matrix td.cell > a, .matrix td.cell > span { display: block; padding: 0.75rem 0.8rem; }
.matrix td.cell > a { color: var(--ink); text-decoration: none; font-weight: 500; }
.matrix td.cell > a:hover { background: var(--accent); color: var(--paper); }
.matrix .cell-scope { display: block; margin-top: 0.2rem; font-size: 0.72rem; font-weight: 400; line-height: 1.25; color: var(--ink-2); white-space: normal; }
.matrix td.cell > a:hover .cell-scope { color: var(--paper); }
.fact-scope--unstated { color: var(--ink-3); }
.matrix .heat-0 > span { color: var(--ink-3); }
.matrix .heat-1 { background: var(--heat-1); }
.matrix .heat-2 { background: var(--heat-2); }
.matrix .heat-3 { background: var(--heat-3); }
.matrix .heat-4 { background: var(--heat-4); }
.matrix td.cell--total { padding: 0.75rem 0.8rem; color: var(--ink-2); }
.matrix td.cell--total > a { display: inline; padding: 0; color: var(--ink-2); font-weight: 600; text-decoration: underline; text-decoration-color: var(--ink-4); }
.matrix td.cell--total > a:hover { background: transparent; color: var(--accent); }
.matrix tbody th, .matrix tfoot th { vertical-align: middle; }
.matrix td.cell--total { vertical-align: middle; }
.matrix tfoot th, .matrix tfoot td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 600; }
.indicator { text-decoration: underline dotted var(--ink-4); text-underline-offset: 0.25em; cursor: help; }

.data-table { min-width: 56rem; }
.sources-table { min-width: 70rem; }
.source-cell { min-width: 17rem; max-width: 24rem; }
.source-org { margin: 0; font-weight: 600; }
.source-org a { color: var(--ink); text-decoration: none; }
.source-org a:hover { color: var(--accent); text-decoration: underline; }
.source-meta { margin: 0.15rem 0 0; font-size: 0.82rem; color: var(--ink-3); }
.source-want { margin: 0.35rem 0 0; font-size: 0.84rem; color: var(--ink-2); }
.col-note { min-width: 16rem; max-width: 28rem; }
td.col-note { font-size: 0.92rem; color: var(--ink-2); }
.data-table td { font-size: 0.92rem; }
.shorttext { margin: 0 0 0.3rem; overflow-wrap: anywhere; }
.longtext { margin: 0 0 0.3rem; }
.longtext summary { cursor: pointer; overflow-wrap: anywhere; list-style: none; }
.longtext summary::-webkit-details-marker { display: none; }
.longtext summary::marker { content: ""; }
.longtext-more { color: var(--accent); font-size: 0.8rem; text-decoration: underline; text-underline-offset: 0.2em; margin-left: 0.3rem; white-space: nowrap; }
.longtext[open] .longtext-more { display: none; }
.longtext-full { margin-top: 0.5rem; padding: 0.6rem 0.8rem; background: var(--paper-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.84rem; }
.longtext--error { color: var(--error); }

.doc-cell { min-width: 20rem; max-width: 34rem; }
.doc-title { font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.doc-title:hover { color: var(--accent); text-decoration: underline; }

/* ---------- gaps ---------- */

.gaps { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 0 2.6rem; }
.gap { border-top: 1px solid var(--rule); padding: 0.9rem 0 1.1rem; }
.gap dt { font-weight: 600; margin-bottom: 0.25rem; }
.gap dd { margin: 0; color: var(--ink-2); font-size: 0.92rem; }

/* ---------- filters ---------- */

.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 1.6rem;
  padding: 1.6rem 0 1.4rem; border-bottom: 1px solid var(--rule);
}
.field { display: flex; flex-direction: column; gap: 0.3rem; flex: 1 1 11rem; min-width: 0; max-width: 17rem; }
.field label { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.field--check { flex: 0 1 auto; justify-content: flex-end; }
.field .check {
  font-size: 0.92rem; letter-spacing: 0; text-transform: none; color: var(--ink-2); font-weight: 400;
  display: flex; align-items: center; gap: 0.5rem; min-height: 44px; cursor: pointer;
}
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); margin: 0; }
select {
  font: inherit; font-size: 0.95rem; color: var(--ink); background-color: #fffdf8;
  border: 1px solid #8f8a7e; border-radius: 2px; min-height: 44px; padding: 0.45rem 0.55rem; width: 100%;
}
select:hover { border-color: var(--ink-3); }
.filter-actions { display: flex; align-items: center; gap: 1.3rem; min-height: 44px; }
.button {
  font: inherit; font-size: 0.92rem; font-weight: 500; color: var(--paper); background: var(--ink);
  border: 1px solid var(--ink); border-radius: 2px; padding: 0.55rem 1.2rem; min-height: 44px; cursor: pointer;
}
.button:hover { background: var(--accent); border-color: var(--accent); }
.link-quiet { color: var(--ink-2); font-size: 0.92rem; }
.active-filters { margin: 1rem 0 0; font-size: 0.92rem; color: var(--ink-3); }
.active-filter { color: var(--ink); font-weight: 600; }

.pager {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 0.5rem 2rem; padding: 1.1rem 0; font-size: 0.9rem; color: var(--ink-3);
}
.pager p { margin: 0; }
.pager-links { display: flex; gap: 1.6rem; }
.pager-off { color: var(--ink-3); }

/* ---------- facts ---------- */

.fact-list { border-top: 1px solid var(--ink); }
.fact {
  display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 0.8rem 3rem;
  padding: 1.9rem 0 2rem; border-bottom: 1px solid var(--rule);
}
.fact-meta p { margin: 0 0 0.4rem; font-size: 0.86rem; color: var(--ink-2); }
.fact-meta .fact-country { font-size: 0.74rem; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); }
.fact-meta .fact-indicator { font-size: 0.95rem; color: var(--ink); font-weight: 500; }
.revision-flag {
  display: inline-block; margin-top: 0.3rem !important; padding: 0.1rem 0.45rem;
  border: 1px solid var(--accent); color: var(--accent) !important; font-size: 0.8rem !important;
  font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
}
.fact-body { min-width: 0; }
.fact-headline { margin: 0 0 0.7rem; font-family: var(--serif); font-size: 1.32rem; font-weight: 600; line-height: 1.28; max-width: 52rem; overflow-wrap: anywhere; }
.fact-figure { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 1.6rem; margin: 0 0 1.1rem; }
.figure { white-space: nowrap; }
.figure-value { font-size: 2rem; font-weight: 400; letter-spacing: -0.02em; font-variant-numeric: tabular-nums lining-nums; }
.figure-unit { font-size: 1rem; color: var(--ink-2); margin-left: 0.2rem; white-space: normal; }
.fact .figure { white-space: normal; }
.kind-flag {
  display: inline-block; margin-top: 0.3rem !important; padding: 0.1rem 0.45rem; font-size: 0.8rem !important;
  font-weight: 600; border: 1px solid var(--blocked); color: var(--blocked) !important;
}
.kind-flag--outbound { border-color: var(--ink-2); color: var(--ink-2) !important; }
.fact-scope { font-size: 0.86rem; color: var(--ink-2); }
.api-record { margin: 0 0 1rem; max-width: 54rem; padding: 0.7rem 0.9rem; background: var(--paper-2); border-left: 3px solid var(--rule); }
.api-record-label { margin: 0 0 0.3rem; font-size: 0.8rem; font-weight: 600; color: var(--ink-3); }
.api-record code { background: transparent; padding: 0; font-size: 0.84rem; overflow-wrap: anywhere; word-break: break-all; }
.figure-none { font-size: 0.95rem; color: var(--ink-3); font-style: italic; }
.figure-period, .figure-change { font-size: 0.92rem; color: var(--ink-2); padding-left: 1rem; border-left: 1px solid var(--rule); }
.revision-note { margin: -0.4rem 0 1rem; font-size: 0.88rem; color: var(--accent); }

.evidence {
  margin: 0 0 1rem; padding: 0.95rem 1.3rem 0.85rem; max-width: 54rem;
  background: var(--paper-2); border-left: 3px solid var(--accent);
  font-family: var(--serif); font-size: 1.06rem; line-height: 1.6; overflow-wrap: anywhere;
}
.evidence p { margin: 0; }
.evidence p::before { content: "\201C"; }
.evidence p::after { content: "\201D"; }
.evidence footer {
  margin-top: 0.55rem; font-family: var(--sans); font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
}
.evidence-missing { margin: 0 0 1rem; font-size: 0.9rem; color: var(--error); }
.quote-state { margin: -0.4rem 0 1rem; font-size: 0.82rem; color: var(--ink-3); }
.quote-state--missing { color: var(--error); }
.fact-summary { margin: 0 0 0.9rem; max-width: 52rem; color: var(--ink-2); }
.label-inline { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-right: 0.4rem; }
.fact-attrs { margin: 0 0 0.9rem; display: flex; flex-wrap: wrap; gap: 0.3rem 2rem; font-size: 0.88rem; }
.fact-attrs div { display: flex; gap: 0.5rem; }
.fact-attrs dt { color: var(--ink-3); }
.fact-attrs dd { margin: 0; }
.fact-links { margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.8rem; font-size: 0.92rem; }

.fact--compact { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; padding: 1.4rem 0 1.5rem; }
.fact--compact .fact-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 1rem; }
.fact--compact .fact-meta p { margin: 0; }
.fact--compact .revision-flag { margin-top: 0 !important; }
.fact--compact .fact-headline { font-size: 1.12rem; margin-top: 0.3rem; }
.fact--compact .figure-value { font-size: 1.6rem; }
.fact--compact .evidence { font-size: 0.98rem; }

/* ---------- documents ---------- */

.funnel { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 1.4rem 3rem; }
.funnel-group-label { margin: 0 0 0.5rem; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.funnel-items {
  list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(6.8rem, 1fr));
}
.funnel-item a {
  display: block; padding: 0.8rem 0.9rem 0.85rem 0; color: var(--ink); text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.funnel-item a:hover .funnel-label { color: var(--accent); text-decoration: underline; }
.funnel-item.is-active a { border-bottom: 3px solid var(--accent); }
.funnel-item.is-active .funnel-label { color: var(--accent); font-weight: 600; }
.funnel-value { display: block; font-size: 1.9rem; font-weight: 300; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums lining-nums; }
.funnel-label { display: block; margin-top: 0.2rem; font-size: 0.82rem; color: var(--ink-2); }
.funnel-item--pending .funnel-value { color: var(--blocked); }
.funnel-item--error .funnel-value { color: var(--error); }

.doc-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 0 3.5rem; align-items: start; }
.meta-table th { width: 9.5rem; font-weight: 500; font-size: 0.86rem; color: var(--ink-3); }
.meta-table td { font-size: 0.92rem; overflow-wrap: anywhere; }
.hash { font-size: 0.78rem; background: transparent; padding: 0; overflow-wrap: anywhere; word-break: break-all; }
.doc-text {
  white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--serif); font-size: 1rem; line-height: 1.75;
  max-height: 76vh; overflow-y: auto; padding: 1.1rem 1.3rem 1.3rem 0; border-top: 1px solid var(--ink);
}
mark.evidence-mark { background: var(--mark); color: var(--ink); border-bottom: 2px solid var(--mark-edge); padding: 0 0.08em; }
mark.evidence-mark:has(.q-anchor:target) { outline: 2px solid var(--accent); outline-offset: 2px; }
.q-anchor { scroll-margin-top: 4rem; }

/* ---------- brief ---------- */

.brief-layout { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 2rem 5rem; padding-top: 2.4rem; align-items: start; }
.prose { max-width: 46rem; font-family: var(--serif); font-size: 1.08rem; line-height: 1.68; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--serif); line-height: 1.25; margin: 2.2rem 0 0.7rem; letter-spacing: -0.01em; }
.prose h1 { font-size: 2rem; }
.prose h2 { font-size: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.prose h3 { font-size: 1.2rem; }
.prose h4 { font-size: 1rem; font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.08em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose li { margin-bottom: 0.35rem; }
.prose blockquote { margin: 1.2rem 0; padding: 0.3rem 0 0.3rem 1.2rem; border-left: 3px solid var(--accent); color: var(--ink-2); background: var(--paper-2); }
.prose blockquote p { margin: 0.5rem 0.8rem 0.5rem 0; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }
.prose .table-scroll { margin: 1.2rem 0 1.6rem; }
.prose table { font-family: var(--sans); font-size: 0.9rem; line-height: 1.45; }
.prose th, .prose td { padding: 0.55rem 1rem 0.55rem 0; }
.prose th { overflow-wrap: normal; word-break: normal; white-space: nowrap; }
.prose td { overflow-wrap: break-word; }
.prose code { font-size: 0.85em; }
.aside-title { font-family: var(--sans); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 0.7rem; }
.brief-index { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.brief-index li { padding: 0.8rem 0; border-bottom: 1px solid var(--rule); }
.brief-index li > a { color: var(--ink); font-weight: 500; text-decoration: none; }
.brief-index li > a:hover { color: var(--accent); text-decoration: underline; }
.brief-index li.is-current { border-left: 3px solid var(--accent); padding-left: 0.8rem; }

/* ---------- method ---------- */

.method-row {
  display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 1rem 4rem;
  padding: 2.4rem 0 2.2rem; border-bottom: 1px solid var(--rule);
}
.method-label { font-size: 1.25rem; line-height: 1.25; }
.method-body { max-width: 50rem; }
.method-body > p { margin: 0 0 1rem; color: var(--ink-2); }
.method-lede { font-family: var(--serif); font-size: 1.4rem; line-height: 1.4; color: var(--ink) !important; }
.plain-list { margin: 0; padding-left: 1.1rem; color: var(--ink-2); }
.plain-list li { margin-bottom: 0.35rem; }
.method-stages { margin: 0; padding: 0; list-style: none; counter-reset: stage; }
.method-stages li { counter-increment: stage; position: relative; padding: 0 0 1.2rem 3rem; }
.method-stages li::before {
  content: counter(stage, decimal-leading-zero); position: absolute; left: 0; top: 0.2rem;
  font-size: 0.8rem; letter-spacing: 0.1em; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.method-stages h3 { margin: 0 0 0.25rem; font-family: var(--serif); font-size: 1.1rem; }
.method-stages p { margin: 0; color: var(--ink-2); }
.method-stage--theirs h3, .method-stage--theirs::before { color: var(--accent) !important; }
.taxonomy { margin: 1rem 0 0; }
.taxonomy-row { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: 0.3rem 2rem; padding: 0.75rem 0; border-top: 1px solid var(--rule); }
.taxonomy-row dt { font-weight: 600; }
.taxonomy-row dd { margin: 0; color: var(--ink-2); }
.muted-note { font-size: 0.9rem; color: var(--ink-3) !important; margin-top: 1rem !important; }

/* ---------- error ---------- */

.error-page { padding: 5rem 0 3rem; max-width: 44rem; }
.error-code { margin: 0 0 0.6rem; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.14em; color: var(--ink-3); }
.error-links { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.8rem; }

/* ---------- footer ---------- */

.site-footer { margin-top: 5rem; border-top: 1px solid var(--rule); padding: 1.4rem 0 2.6rem; color: var(--ink-3); font-size: 0.86rem; }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .limits { grid-template-columns: minmax(0, 1fr); }
  .limits-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .pipeline-owners { display: none; }
  .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 2.4rem; }
  .stage::after { display: none; }
  .stage-owner {
    display: block; margin: 0 0 0.2rem; font-size: 0.68rem; font-weight: 600;
    letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
  }
  .stage--theirs .stage-owner { color: var(--accent); }
  .stage-name { min-height: 0; }
  .brief-layout { grid-template-columns: minmax(0, 1fr); }
  .method-row { grid-template-columns: minmax(0, 1fr); }
  .funnel { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .page-head { grid-template-columns: minmax(0, 1fr); padding: 2.2rem 0 1.6rem; }
  .page-head--overview { padding-top: 2.4rem; }
  .fact { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
  .fact-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 1rem; }
  .fact-meta p { margin: 0; }
  .fact-meta .revision-flag { margin-top: 0 !important; }
  .taxonomy-row { grid-template-columns: minmax(0, 1fr); }
  .field { max-width: none; flex-basis: 100%; }
  .doc-text { max-height: none; overflow-y: visible; padding-right: 0; }
  .masthead-inner { gap: 0.4rem 1rem; }
  .nav ul { gap: 0.1rem 1.1rem; }
}

@media (max-width: 520px) {
  .stages { grid-template-columns: minmax(0, 1fr); }
  .limits-list { grid-template-columns: minmax(0, 1fr); }
  .evidence { padding: 0.8rem 0.9rem; }
}

/* ---------- sign-in (web/auth.py) ----------
   The sign-in page and the signed-in account in the masthead. Same register as the rest:
   thin rules, no cards, one accent. The reCAPTCHA checkbox is a fixed 304px iframe, so it is
   scaled down on the narrowest phones instead of overflowing the page. */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.masthead-end {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end;
  gap: 0.2rem 1.4rem; min-width: 0;
}
.account {
  display: flex; align-items: baseline; gap: 0 1rem; min-width: 0;
  padding-left: 1.4rem; border-left: 1px solid var(--rule); font-size: 0.88rem; color: var(--ink-3);
}
.account-email { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-signout { margin: 0; }
.link-button {
  font: inherit; color: var(--ink-2); background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 0.35rem 0 0.3rem; cursor: pointer;
}
.link-button:hover { color: var(--ink); border-bottom-color: var(--rule); }

.signin { max-width: 25rem; padding: clamp(2.6rem, 9vh, 6rem) 0 1rem; }
.signin-title { font-size: clamp(2.2rem, 1.7rem + 1.6vw, 3rem); }
.signin-message { margin: 1.6rem 0 0; padding: 0.8rem 1rem; background: var(--paper-2); border-left: 3px solid var(--accent); }
.signin-message p { margin: 0; }
.signin-message--error { border-left-color: var(--error); }
.signin-message--error > p:first-child { color: var(--error); font-weight: 600; }
.signin-hint { margin: 0.35rem 0 0 !important; font-size: 0.86rem; color: var(--ink-2); }
.signin-form {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.3rem;
  margin-top: 1.8rem; padding-top: 1.7rem; border-top: 1px solid var(--ink);
}
/* minmax(0, 1fr) and min-width: 0: an input's intrinsic width must never widen the column past the gutter */
.signin-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.35rem; }
.signin-field label { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.signin-field input {
  font: inherit; font-size: 1rem; color: var(--ink); background-color: #fffdf8; width: 100%;
  border: 1px solid #8f8a7e; border-radius: 2px; min-height: 48px; padding: 0.55rem 0.7rem; min-width: 0;
}
.signin-field input:hover { border-color: var(--ink-3); }
.signin-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.signin-check { min-height: 78px; }
.signin-submit { width: 100%; min-height: 48px; font-size: 1rem; margin-top: 0.2rem; }
.signin-local-note {
  margin: 1.6rem 0 0; padding-top: 0.8rem; border-top: 1px solid var(--rule-soft);
  font-family: var(--mono); font-size: 0.8rem; color: var(--ink-3);
}

@media (max-width: 760px) {
  .masthead-end { justify-content: flex-start; width: 100%; }
  .account { padding-left: 0; border-left: 0; width: 100%; justify-content: space-between; }
}

@media (max-width: 350px) {
  .signin-check .g-recaptcha { transform: scale(0.92); transform-origin: 0 0; }
  .signin-check { min-height: 72px; }
}
