/* ============================================================
   Legend Inc. — app stylesheet (Phase C restyle).

   Source of truth: LEGEND_INC_BRAND_GUIDELINES_v5.md + the approved
   Phase-A mocks in brand-explore/app/. One brand for customers:
   paper ground, ink text, forest action, bronze = the current best
   understanding. Three type roles — didone serif (display),
   humanist sans (body/UI), mono (data/labels; never sentences).

   LIGHT-ONLY for now (v5 is bright-by-default; dark parity is a
   deliberate follow-up — see the Phase-C plan). The old legacy
   token names (--bg, --accent, --amber, --rule, …) are kept and
   remapped onto the v5 palette so the per-template inline styles
   pick up the new system without markup churn.

   Colour discipline (v5 §5):
   - BRONZE marks the current best understanding + key figures.
   - AMBER/warning is action-required ONLY (needs-your-answer).
   - FOREST is the primary action: buttons, links, progress.
   - Severity never rides on hue alone: tier pills carry a
     3-bar glyph + label.
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS — v5 palette + legacy aliases
   ============================================================ */
:root,
[data-theme="light"] {
  /* v5 tokens */
  --paper:        #F8F6F1;
  --warm-paper:   #EFE9DE;
  --ink:          #111214;
  --muted-ink:    #706A61;
  --forest:       #123D34;
  --deep-forest:  #0B1D18;
  --bronze:       #B88628;
  --muted-bronze: #8E6A24;
  --line:         #DDD5C8;
  --success:      #4E7B68;
  --warning:      #C98A2E;
  --danger:       #C86454;
  --hair:         rgba(17,18,20,.1);

  /* legacy aliases — templates written against the old names keep working */
  --bg:        var(--paper);
  --surface:   #FFFFFF;
  --ink-2:     var(--muted-ink);
  --ink-3:     #8F8879;
  --rule:      var(--hair);
  --row-rule:  rgba(17,18,20,.07);

  --link:      var(--forest);

  --accent:    var(--forest);
  --accent-bg: rgba(18,61,52,.06);
  --accent-ink:var(--forest);

  --amber:     var(--muted-bronze);      /* action-required only */
  --amber-bg:  rgba(184,134,40,.10);

  --btn-bg:    var(--forest);
  --btn-ink:   var(--paper);

  --mark:      var(--ink);
  --mark-hole: var(--paper);
}

:root {
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans:  Inter, system-ui, -apple-system, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  /* legacy aliases */
  --font-mono:  var(--mono);
  --font-serif: var(--serif);
  --font-sans:  var(--sans);
  --radius:   9px;
  --measure:  76ch;
  --maxw:     1120px;
}

/* ============================================================
   2. BASE
   ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scrollbar-gutter: stable; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* Sticky footer: header/main/footer stack full-height. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--forest); text-decoration: none; }
a:hover { color: var(--deep-forest); text-decoration: underline; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding-left: 32px; padding-right: 32px; width: 100%; }
main.wrap { padding: 24px 32px 72px; flex: 1 0 auto; }

/* Display headings = didone serif (v5 §6 — whisper, not shout). */
h1 {
  font-family: var(--serif);
  font-size: 32px; font-weight: 600; line-height: 1.08;
  color: var(--ink); margin: 22px 0 12px;
}
h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--ink); margin: 26px 0 8px; }
h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 18px 0 6px; }

/* ============================================================
   3. LOGO — locked mark (construction order normative).
   ============================================================ */
.legend-mark { display: inline-block; vertical-align: middle; }
.legend-mark line   { stroke: var(--mark); stroke-width: 2.4; }
.legend-mark .node  { fill: var(--mark); }
.legend-mark .hole-cover { fill: var(--mark-hole); }
.legend-mark .hole-ring  { fill: var(--mark-hole); stroke: var(--mark); stroke-width: 2.4; }

/* ============================================================
   4. APP CHROME — quiet hairline nav (v5 §10).
   ============================================================ */
header { border-bottom: 1px solid var(--hair); }
.nav {
  display: flex; align-items: center; gap: 20px;
  padding-top: 13px; padding-bottom: 13px;
}
.brand-lockup { display: flex; align-items: center; gap: 9px; }
.brand-lockup .legend-mark { width: 20px; height: 22px; }
.brand-link, .brand-link:hover { text-decoration: none; }
.brand-word {
  font-family: var(--serif);
  font-size: 17px; font-weight: 600; color: var(--ink); letter-spacing: .01em;
}
.brand-beta {
  font-family: var(--mono);
  font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted-bronze); border: 1px solid rgba(184,134,40,.4);
  padding: 1px 6px; border-radius: 5px;
}

.nav-collapse {
  display: flex; align-items: center; justify-content: flex-end;
  flex: 1; gap: 24px;
}
.nav-links { display: inline-flex; align-items: center; gap: 24px; }
.nav-links > a { color: var(--muted-ink); font-size: 13px; margin: 0; transition: color .15s; }
.nav-links > a:hover { color: var(--ink); text-decoration: none; }
.nav-links > a.active { color: var(--ink); font-weight: 500; }
.nav-utility { display: flex; align-items: center; gap: 18px; }
.nav-utility > a { color: var(--muted-ink); font-size: 13px; }
.nav-utility > a:hover { color: var(--ink); text-decoration: none; }
.acct { font-family: var(--mono); font-size: 11px; color: var(--muted-ink); }
.me { font-family: var(--mono); font-size: 11px; color: var(--muted-ink); }

.nav-toggle {
  display: none;
  background: transparent; border: 1px solid var(--hair);
  border-radius: 7px; padding: 4px 10px; cursor: pointer;
  color: var(--ink-2); font-size: 16px; line-height: 1.2;
}
.nav-toggle:hover { border-color: var(--ink-3); }

.count-pill {
  font-family: var(--mono);
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  background: var(--amber-bg); color: var(--amber); margin-left: 4px;
}

@media (max-width: 720px) {
  .nav { flex-wrap: wrap; gap: 12px; }
  .nav-toggle { display: inline-flex; align-items: center; margin-left: auto; }
  .nav-collapse {
    display: none;
    flex-basis: 100%; width: 100%;
    flex-direction: column; align-items: flex-start;
    gap: 14px; padding: 6px 0 4px;
  }
  .nav-collapse.open { display: flex; }
  .nav-links { flex-direction: column; align-items: flex-start; gap: 14px; width: 100%; }
  .nav-links > a { font-size: 14px; }
  .nav-utility { flex-direction: column; align-items: flex-start; gap: 14px; width: 100%; }
}
@media (max-width: 600px) {
  .wrap { padding-left: 18px; padding-right: 18px; }
  main.wrap { padding: 18px 18px 48px; }
}

/* ============================================================
   5. PAGE STRUCTURE
   ============================================================ */
h1.page-title {
  font-family: var(--serif);
  font-size: 32px; font-weight: 600; margin: 18px 0 0; color: var(--ink);
  line-height: 1.08;
}
.page-rule { height: 1px; background: var(--hair); margin: 14px 0; }
.sub { font-size: 12px; color: var(--ink-2); margin: 4px 0 16px; }
.sub a { color: var(--muted-ink); }
.sub a:hover { color: var(--forest); }
.sub .on { color: var(--muted-ink); font-family: var(--mono); }
.sub .on:hover { color: var(--forest); }
.lede {
  font-size: 13.5px; color: var(--ink-2); margin: 0 0 18px;
  max-width: var(--measure);
}
.lede em { color: var(--muted-bronze); font-style: normal; }

section.page { padding-bottom: 40px; }
.page-gap { height: 56px; }
.page-marker {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); padding: 10px 0 0;
}

/* Section band — mono uppercase muted-bronze + sans hint (v5 §10). */
.section-band, .band {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 7px; margin: 34px 0 16px;
}
.section-band h2, .band h2 {
  font-family: var(--mono); font-size: 11px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted-bronze);
  font-weight: 500; margin: 0;
}
.section-band .hint, .band .hint { font-size: 11.5px; color: var(--ink-2); }

/* ============================================================
   6. TABLES — hairline rows, mono heads, serif where display.
   ============================================================ */
table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 14px 0; }
th {
  font-family: var(--mono);
  text-align: left; font-weight: 500; font-size: 10.5px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2);
  padding: 10px 12px; border-bottom: 1px solid var(--hair);
  white-space: nowrap;
}
td {
  padding: 14px 12px; border-bottom: 1px solid var(--row-rule);
  vertical-align: middle; color: var(--ink);
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(239,233,222,.45); }
.closes-cell { white-space: nowrap; }
tr:last-child td { border-bottom: none; }
.q-link { color: var(--forest); }
.handle { color: var(--forest); }
.muted { color: var(--ink-3); }

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .05em; padding: 2px 8px;
  border-radius: 999px; border: 1px solid var(--hair);
  background: transparent; color: var(--ink-2);
  white-space: nowrap;
}
.close-soon { color: var(--amber); }
.rep-pos { color: var(--accent-ink); }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: " ↕"; font-size: 10px; color: var(--ink-3); }
th.sort-asc::after  { content: " ↑"; color: var(--muted-bronze); }
th.sort-desc::after { content: " ↓"; color: var(--muted-bronze); }

/* ============================================================
   7. BUTTONS — forest primary, ghost outline.
   ============================================================ */
.btn,
button,
a.button {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 8px 15px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  background: var(--forest); color: var(--paper);
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover,
button:hover,
a.button:hover { background: var(--deep-forest); color: var(--paper); text-decoration: none; }
.btn-ghost, .btn--ghost {
  background: transparent; color: var(--forest);
  border-color: rgba(18,61,52,.28);
}
.btn-ghost:hover, .btn--ghost:hover { background: rgba(18,61,52,.06); color: var(--forest); }
.btn-amber { background: var(--warning); color: var(--ink); }
.btn-sm { padding: 4px 11px; font-size: 12px; border-radius: 7px; }

/* Destructive actions — the v5 terracotta danger hue. */
button.danger,
a.button.danger,
.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(200,100,84,.45);
}
button.danger:hover,
a.button.danger:hover { background: rgba(200,100,84,.07); color: var(--danger); }

/* ============================================================
   8. QUESTION / DETAIL FRAGMENTS (legacy shapes, retokened)
   ============================================================ */
.qblock,
blockquote.question-body {
  border-left: 2px solid var(--forest); padding: 12px 16px;
  font-size: 14px; color: var(--ink); margin: 0 0 4px;
  background: transparent;
}
.field-label {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-2); margin: 16px 0 4px;
}
.field-val { font-size: 12px; color: var(--ink); }
.badge-closed {
  font-family: var(--mono);
  font-size: 10px; padding: 2px 7px; border-radius: 4px;
  background: var(--amber-bg); color: var(--amber); margin-left: 8px;
}

.answer { margin-top: 8px; }
.answer-head { font-size: 13px; color: var(--ink); margin-bottom: 4px; }
.answer-head .handle { font-weight: 500; }
.value-block, .rationale-block {
  font-size: 12px; color: var(--ink); line-height: 1.7;
  max-width: var(--measure);
  white-space: pre-wrap; word-break: break-word;
}
.rationale-block {
  border: 1px solid var(--hair); border-radius: var(--radius);
  padding: 12px 14px; color: var(--ink-2); margin-top: 2px;
}

/* ============================================================
   9. FOOTER — two rows (v5 §10).
   ============================================================ */
footer {
  border-top: 1px solid var(--hair); margin-top: 8px;
  padding: 20px 0 24px; font-size: 12px; color: var(--ink-2);
}
footer a { color: var(--muted-ink); }
footer a:hover { color: var(--forest); }
.foot-row { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.foot-row + .foot-row { margin-top: 10px; }
.foot-brand { font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--ink); }
.foot-links { display: flex; gap: 18px; }
.foot-tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
}

/* ============================================================
   10. STATUS PILLS — neutral by default; amber = action only.
   ============================================================ */
.pill.format, .pill.useful { color: var(--forest); border-color: rgba(18,61,52,.35); }
.pill.open, .pill.closed, .pill.not-useful { color: var(--ink-2); }
.pill.cohort { font-weight: 500; }
.pill.cohort-graph      { color: var(--forest); border-color: rgba(18,61,52,.35); }
.pill.cohort-noise      { color: var(--ink-2); }
.pill.cohort-irrelevant { color: var(--amber); border-color: rgba(184,134,40,.4); }
.pill.cohort-production { color: var(--ink-2); }

/* ============================================================
   11. FORMS, MESSAGES, WIDGETS
   ============================================================ */
input[type="text"], input[type="password"], input[type="email"],
textarea, select {
  font-family: var(--sans); font-size: 14px; padding: 9px 12px;
  border: 1px solid rgba(17,18,20,.16); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
textarea { width: 100%; min-height: 80px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(18,61,52,.1);
}
.form-row { margin: 14px 0; max-width: var(--measure); }
.form-row label {
  display: block; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase;
  font-weight: 500; margin-bottom: 7px; color: var(--ink-2);
}

.err {
  color: #8f3a2e; background: rgba(200,100,84,.08);
  border-left: 2px solid var(--danger);
  padding: 9px 12px; border-radius: var(--radius); margin: 12px 0;
}
.ok {
  color: var(--forest); background: var(--accent-bg);
  border-left: 2px solid var(--forest);
  padding: 9px 12px; border-radius: var(--radius); margin: 12px 0;
}
.notice {
  color: var(--ink-2); background: transparent;
  border: 1px solid var(--hair); border-left: 2px solid var(--forest);
  padding: 10px 14px; border-radius: var(--radius); margin: 12px 0; font-size: 13px;
}

.filter-bar {
  margin: 12px 0; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius);
  display: flex; align-items: center; gap: 8px;
}
.filter-bar label { font-weight: 500; color: var(--ink-2); }
.filter-bar select { font-size: 12px; padding: 3px 6px; min-width: 360px; }

dl.meta dt {
  font-family: var(--mono); font-weight: 500; font-size: 10.5px;
  letter-spacing: .1em; color: var(--ink-2); text-transform: uppercase; margin-top: 10px;
}
dl.meta dd { margin: 2px 0 0 0; color: var(--ink); }
dl.meta dd code, dl.meta dd pre { max-width: var(--measure); }

.stats { display: flex; gap: 24px; margin: 16px 0; flex-wrap: wrap; }
.stat { background: var(--surface); padding: 12px 16px; border: 1px solid var(--hair); border-radius: var(--radius); min-width: 120px; }
.stat .num { font-family: var(--mono); font-size: 22px; font-weight: 500; display: block; font-variant-numeric: tabular-nums; }
.stat .label { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--ink-3); text-transform: uppercase; }

.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.answer-cell h3 { margin-top: 0; font-size: 12px; text-transform: uppercase; color: var(--ink-2); }
.answer-cell pre { min-height: 100px; max-height: 360px; overflow-y: auto; }

.label-options { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.label-options label { padding: 6px 10px; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); cursor: pointer; }
.label-options label:hover { background: var(--warm-paper); }

pre {
  font-family: var(--mono);
  background: var(--surface); padding: 8px 10px; border: 1px solid var(--hair);
  border-radius: var(--radius); white-space: pre-wrap; font-size: 12px; color: var(--ink);
}
pre.context-body { max-height: 400px; overflow-y: auto; }
code { font-family: var(--mono); font-size: 12px; background: var(--warm-paper); padding: 1px 4px; border-radius: 3px; color: var(--ink); }
.uuid { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }

/* ============================================================
   12. RISK VOCABULARY — tier pills, glyphs, lifecycle states.
   ============================================================ */

/* Tier pill (v5 §5): 3-bar glyph + label; bordered, tinted, mono —
   never hue alone. Bars are painted with layered gradients so the
   existing text-only markup (`<span class="tier tier-high">high</span>`)
   needs no change; opacity encodes 1/2/3 bars on. */
.tier {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .03em; text-transform: lowercase;
  padding: 3px 10px 3px 21px; border-radius: 999px;
  border: 1.4px solid; white-space: nowrap; position: relative;
  cursor: help; line-height: 1.5;
}
.tier::before {
  content: ""; position: absolute; left: 8px; top: 50%;
  width: 8px; height: 9px; transform: translateY(-50%);
  background:
    linear-gradient(currentColor, currentColor) 0 / 2px 100% no-repeat,
    linear-gradient(currentColor, currentColor) 3px 0 / 2px 100% no-repeat,
    linear-gradient(currentColor, currentColor) 6px 0 / 2px 100% no-repeat;
}
.tier-high   { color: #8f3a2e; border-color: var(--danger);  background: rgba(200,100,84,.09); }
.tier-medium { color: #8a5a15; border-color: var(--warning); background: rgba(201,138,46,.09); }
.tier-low    { color: #2f5a49; border-color: var(--success); background: rgba(78,123,104,.10); }
.tier-medium::before {
  background:
    linear-gradient(currentColor, currentColor) 0 / 2px 100% no-repeat,
    linear-gradient(currentColor, currentColor) 3px 0 / 2px 100% no-repeat,
    linear-gradient(rgba(0,0,0,.18), rgba(0,0,0,.18)) 6px 0 / 2px 100% no-repeat;
}
.tier-low::before {
  background:
    linear-gradient(currentColor, currentColor) 0 / 2px 100% no-repeat,
    linear-gradient(rgba(0,0,0,.18), rgba(0,0,0,.18)) 3px 0 / 2px 100% no-repeat,
    linear-gradient(rgba(0,0,0,.18), rgba(0,0,0,.18)) 6px 0 / 2px 100% no-repeat;
}

/* Segmented rating meter (sub-question estimates). */
.glyph { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.glyph-meter { display: inline-flex; gap: 2px; }
.glyph-seg { width: 6px; height: 12px; border-radius: 1px; background: var(--line); }
.glyph-seg.on { background: var(--forest); }
.glyph.hot .glyph-seg.on { background: var(--danger); }
.glyph-num { font-family: var(--mono); font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.glyph.hot .glyph-num { color: var(--danger); }
.glyph-label { font-family: var(--mono); font-size: 10px; letter-spacing: .05em; color: var(--ink-3); }

/* Lifecycle state pills — mono, neutral; nothing shouts. */
.state-pill {
  display: inline-block; font-family: var(--mono);
  font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 5px; white-space: nowrap;
}
.state-active     { color: var(--forest); border: 1px solid rgba(18,61,52,.35); }
.state-dormant    { color: var(--ink-3); border: 1px solid var(--row-rule); }
.state-resolved   { color: var(--success); border: 1px solid rgba(78,123,104,.45); }
.state-superseded { color: var(--ink-3); border: 1px dashed var(--row-rule); }
.state-pill.provisional { color: var(--muted-bronze); border: 1px solid rgba(184,134,40,.45); }
/* An ungrounded rating is a from-scratch estimate — quiet dashed chip (v5 §10). */
.state-pill.ungrounded { color: var(--ink-3); border: 1px dashed var(--hair); background: transparent; }

.timing { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }

/* Movement Δ: probability up = exposure rising = danger; down = success (v5 §10). */
.move { font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.move.rep-pos { color: var(--danger); }
.move.not-useful { color: var(--success); }

/* Confidence in a quality estimate — quieter than the number it qualifies. */
.conf { font-family: var(--mono); font-size: 10px; letter-spacing: .03em; }
.conf-low  { color: var(--amber); }
.conf-med  { color: var(--ink-3); }
.conf-high { color: var(--forest); }
.quality-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.quality { display: inline-flex; align-items: center; gap: 6px; }

/* Lens pills — neutral mono chips (coverage is the product; no per-lens hues). */
.lens-pill {
  display: inline-block; font-family: var(--mono);
  font-size: 10px; letter-spacing: .03em; padding: 2px 8px;
  border-radius: 6px; white-space: nowrap;
  border: 1px solid var(--hair); background: transparent; color: var(--ink-2);
}

/* ============================================================
   13. ENTITY DASHBOARD — head, risk table, quiet groups.
   ============================================================ */
.entity-head {
  margin-bottom: 22px; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.entity-head .sub { margin: 4px 0 0; font-family: var(--mono); }
.entity-head-actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; flex-wrap: wrap; }
.last-run { font-family: var(--mono); font-size: 11px; }
.inline-form { display: inline; margin: 0; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

.section-head { font-size: 13px; font-weight: 500; color: var(--ink-2); margin: 28px 0 2px; }
.section-major { margin: 30px 0 6px; padding-top: 22px; border-top: 1px solid var(--hair); }
.section-title { font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--ink); margin: 0; }
.section-lede { font-size: 13px; color: var(--ink-3); margin: 4px 0 0; max-width: var(--measure); }
.banner {
  background: var(--amber-bg); color: var(--amber); font-size: 13px;
  padding: 10px 12px; border-radius: var(--radius); margin-bottom: 16px;
}
.banner-progress { background: var(--accent-bg); color: var(--forest); }
.quiet-group { margin-top: 22px; }
.quiet-group > summary { cursor: pointer; font-size: 13px; color: var(--ink-2); padding: 8px 0; }
.quiet-group > summary:hover { color: var(--ink); }
.quiet-group .risk-table { opacity: 0.78; }

/* Risk-vector table. Fixed layout keeps columns steady under sorting;
   `.rk-scroll` is ALWAYS the horizontal scroll container so a wide table
   can never push the page wider than the viewport (the mid-width
   margin-loss bug). */
.rk-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; min-width: 0; max-width: 100%; }
.risk-table {
  width: 100%; border-collapse: collapse; table-layout: fixed; margin: 4px 0;
  min-width: 640px;
}
.risk-table thead th {
  font-family: var(--mono);
  text-align: left; font-weight: 500; font-size: 10.5px; letter-spacing: .12em;
  color: var(--ink-2); text-transform: uppercase; padding: 12px 10px;
  border-bottom: 1px solid var(--hair); white-space: nowrap;
}
.risk-table td {
  padding: 15px 10px; border-bottom: 1px solid var(--row-rule);
  font-size: 13px; vertical-align: middle;
}
.risk-table .col-risk { width: 40%; }
.risk-table .col-lens { width: 15%; padding-right: 18px; }
.risk-table .col-num { width: 13%; }
.risk-table .col-timing { width: 11%; }
.risk-table .col-state { width: 8%; }
.risk-table td.col-risk { padding-right: 18px; }
/* Risk questions read as statements — display serif (v5 §10). */
.risk-table td.col-risk a, .risk-table td.col-risk {
  font-family: var(--serif); font-weight: 500; font-size: 16.5px; line-height: 1.3;
  color: var(--ink); text-decoration: none;
}
.risk-table td.col-risk a:hover { color: var(--forest); }
.risk-table td.col-risk .state-pill { font-family: var(--mono); }
.risk-table tbody tr:hover { background: rgba(239,233,222,.45); }
.risk-table .col-lens .lens-pill {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: bottom;
}
.cell-move { margin-top: 4px; }
.cell-conf { margin-top: 3px; }

/* ============================================================
   14. COMPANY PROFILE (review surface) — retokened.
   ============================================================ */
.profile {
  position: relative;
  margin: 4px 0 20px; padding: 18px 20px; border: 1px solid var(--hair);
  border-radius: 12px; background: var(--surface);
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: start;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.profile > * { min-width: 0; }
.profile-edit-toggle { position: absolute; top: 14px; right: 16px; z-index: 2; }
.profile.editing { border-color: var(--forest); box-shadow: 0 0 0 1px var(--forest); }
.profile.editing .profile-edit-toggle { border-color: var(--forest); background: var(--accent-bg); color: var(--forest); }
.profile-aside > .res-collabel { padding-right: 64px; }
@media (max-width: 820px) { .profile-aside > .res-collabel { padding-right: 0; } }
.profile-solo { grid-template-columns: 1fr; }
@media (max-width: 820px) { .profile { grid-template-columns: 1fr; gap: 18px; } }
.profile-facts { margin: 0; }
.pf-empty { font-size: 12px; font-style: italic; }
.pf-row { display: grid; grid-template-columns: 134px 1fr; gap: 14px; padding: 9px 0;
  border-top: 1px solid var(--row-rule); align-items: baseline; }
.pf-row > * { min-width: 0; }
.pf-row:first-child { border-top: none; padding-top: 2px; }
.pf-label { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.pf-value { font-size: 13.5px; color: var(--ink); line-height: 1.5; overflow-wrap: anywhere; }
.pf-chip { display: inline-block; font-size: 12.5px; padding: 1px 8px; margin: 0 4px 4px 0;
  border-radius: 6px; background: var(--warm-paper); color: var(--ink); }
.profile-empty { font-size: 12px; margin: 10px 0 0; }
.profile-aside { border-left: 1px solid var(--hair); padding-left: 28px; }
@media (max-width: 820px) { .profile-aside { border-left: none; padding-left: 0; } }
.res-collabel {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; color: var(--muted-bronze);
  text-transform: uppercase; margin-bottom: 12px; min-height: 14px;
}
.res-collabel-dim { color: var(--ink-3); }
.rel-groups { display: flex; flex-direction: column; gap: 12px; }
.rg { display: grid; grid-template-columns: 100px 1fr; gap: 12px; align-items: baseline; }
.rg > * { min-width: 0; }
@media (max-width: 560px) { .rg { grid-template-columns: 1fr; gap: 4px; } }
.rg-label { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.rg-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ent-chip { display: inline-block; font-size: 12.5px; padding: 2px 9px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--hair); color: var(--ink);
  cursor: default; transition: border-color 0.12s ease, background 0.12s ease; }
.ent-chip:hover { border-color: rgba(184,134,40,.5); background: rgba(184,134,40,.06); }

/* Per-fact source links + review controls (Phase B). */
.fact-src { font-family: var(--mono); font-size: 10px; letter-spacing: .02em; color: var(--muted-bronze);
  text-decoration: none; border-bottom: 1px dotted rgba(184,134,40,.5); margin-left: 6px; opacity: .85; }
.fact-src:hover { color: var(--bronze); border-color: var(--bronze); opacity: 1; text-decoration: none; }
.pf-scalar { display: inline-flex; align-items: baseline; gap: 2px; flex-wrap: wrap; }
.fact-reject { display: inline; }
.fact-x { background: none; border: none; cursor: pointer; color: var(--ink-3); font-size: 14px;
  line-height: 1; padding: 0 3px; margin-left: 2px; display: none; transition: color 0.12s ease; }
.fact-x:hover { color: var(--danger); background: none; }
.fact-edit-form { display: none; gap: 5px; margin-left: 6px; align-items: baseline; }
.fact-edit-form input[type=text] { font-size: 12px; padding: 2px 6px; border: 1px solid rgba(17,18,20,.16);
  border-radius: 5px; background: var(--surface); color: var(--ink); }
.fact-edit-form button, .review-btn { font-size: 11px; padding: 2px 9px; border-radius: 5px;
  border: 1px solid var(--hair); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.fact-edit-form button:hover, .review-btn:hover { border-color: var(--forest); color: var(--forest); background: var(--surface); }
.profile.editing .fact-x { display: inline; }
.profile.editing .fact-edit-form { display: inline-flex; }
.profile.editing .pf-static { display: none; }
.profile-review { display: flex; align-items: center; gap: 10px; margin-top: 14px;
  padding-top: 10px; border-top: 1px solid var(--row-rule); }
.reviewed-by { font-size: 11px; }

/* Discovery actions. */
.discovery-actions { display: flex; align-items: flex-start; gap: 10px; margin: -8px 0 22px; }
.add-pages { display: inline-block; position: relative; }
.add-pages > summary { list-style: none; cursor: pointer; }
.add-pages > summary::-webkit-details-marker { display: none; }
.add-pages-form { display: flex; gap: 6px; margin-top: 8px; }
.add-pages-form input[type=text] { font-size: 12px; padding: 6px 9px; min-width: 320px; }

/* Sources panel. */
.sources-panel { margin: 18px 0; border: 1px solid var(--hair); border-radius: var(--radius);
  background: var(--surface); padding: 0 14px; }
.sources-panel > summary { cursor: pointer; padding: 10px 0; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.src-list { list-style: none; margin: 0; padding: 4px 0 12px; }
.src-list .src-url { padding: 5px 0; border-top: 1px solid var(--row-rule); }
.src-list .src-url:first-child { border-top: none; }
.src-url { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.src-url a { color: var(--muted-ink); text-decoration: none; }
.src-url a:hover { color: var(--forest); text-decoration: underline; }

/* ============================================================
   15. ANALYSING PROGRESS — the Line as the instrument (v5 §10).
   The five modes are the progress bar; the pipeline steps play
   beneath as the live detail. Markup lives in entity.html.
   ============================================================ */
.progress { margin: 20px auto 34px; max-width: 780px; text-align: center; }
.progress-eyebrow {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--muted-bronze); margin: 18px 0 10px;
}
.progress-title { font-family: var(--serif); font-weight: 600; font-size: 26px; margin: 0 0 4px; line-height: 1.1; }
.progress-elapsed { font-family: var(--mono); font-size: 11px; color: var(--ink-2); margin: 2px 0 0; }

.lsvg { display: block; width: 100%; height: 110px; overflow: visible; margin-top: 34px; }
.lsvg .track { fill: none; stroke: var(--line); stroke-width: 1.4; stroke-linecap: round; }
.lsvg .prog { fill: none; stroke: var(--forest); stroke-width: 2; stroke-linecap: round;
  transition: stroke-dashoffset .9s cubic-bezier(.22,.61,.36,1); }
.lsvg .ret { fill: none; stroke: var(--bronze); stroke-width: 2; stroke-linecap: round;
  stroke-linejoin: round; transition: stroke-dashoffset 1.4s ease; }
.lsvg .arw { fill: var(--bronze); opacity: 0; transition: opacity .4s ease 1.2s; }
.lsvg .mnode { stroke-width: 1.6; transition: fill .4s, stroke .4s; }
.lsvg .mnode.pending { fill: var(--paper); stroke: rgba(17,18,20,.35); }
.lsvg .mnode.active { fill: var(--bronze); stroke: var(--bronze); }
.lsvg .mnode.done { fill: var(--forest); stroke: var(--forest); }
.lsvg .halo { fill: none; stroke: var(--bronze); stroke-width: 1.6; opacity: 0; }
.lsvg .halo.on { animation: lhalo 1.8s ease-out infinite; }
@keyframes lhalo { 0% { opacity: .5; r: 9; } 100% { opacity: 0; r: 20; } }
.lsvg .tick { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  fill: rgba(17,18,20,.35); text-anchor: middle; transition: fill .4s; }
.lsvg .tick.active { fill: var(--muted-bronze); }
.lsvg .tick.done { fill: rgba(17,18,20,.6); }
@media (prefers-reduced-motion: reduce) {
  .lsvg .halo.on { animation: none; opacity: .4; }
  .lsvg .prog, .lsvg .ret { transition: none; }
}

.progress-detail-wrap { margin-top: 24px; min-height: 54px; }
.progress-detail { font-size: 15px; color: var(--ink); }
.progress-detail::after { content: "…"; }
.progress-note { font-size: 12px; color: var(--ink-2); margin: 6px auto 0; max-width: 58ch; }
.progress-lenses { display: flex; justify-content: center; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.progress-lenses .muted { font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; margin-right: 4px; align-self: center; }
.progress-done { margin-top: 32px; opacity: 0; transform: translateY(12px);
  transition: opacity .8s ease, transform .8s ease; pointer-events: none; }
.progress-done.on { opacity: 1; transform: none; pointer-events: auto; }
.progress-done .msg { font-family: var(--serif); font-weight: 500; font-size: 20px; margin-bottom: 16px; }
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line);
  border-top-color: var(--forest); display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   16. TRAJECTORY + DECOMPOSITION + RELATIONS (risk detail)
   ============================================================ */
.traj-wrap { margin: 6px 0 4px; }
.traj { width: 100%; max-width: 520px; height: 120px; display: block; }
.traj-guide { stroke: var(--line); stroke-width: 0.6; }
.traj-prob { fill: none; stroke: var(--bronze); stroke-width: 2; }
.traj-base { fill: none; stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 4 3; }
.dot-prob { fill: var(--bronze); }
.dot-base { fill: var(--ink-3); }
.traj-legend { display: flex; gap: 14px; font-family: var(--mono); font-size: 10.5px; margin-top: 4px; align-items: center; }
.traj-legend .k::before {
  content: ""; display: inline-block; width: 10px; height: 0; vertical-align: middle;
  margin-right: 5px; border-top-width: 2px; border-top-style: solid;
}
.k-prob { color: var(--muted-bronze); }
.k-prob::before { border-top-color: var(--bronze); }
.k-base { color: var(--ink-2); }
.k-base::before { border-top-color: var(--ink-3); border-top-style: dashed; }

.decomp-mode { margin: 10px 0 18px; }
.decomp-head { font-size: 13px; font-weight: 500; color: var(--ink); margin: 12px 0 6px; }
.decomp-target { margin: 8px 0 8px 4px; }
.decomp-target-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
}
.node-list { list-style: none; margin: 4px 0 0; padding: 0; }
.node {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--row-rule);
}
.node-d2 { padding-left: 18px; }
.node-d3 { padding-left: 36px; }
.node-text { color: var(--ink); flex: 1; }
.node-certainty { font-family: var(--mono); font-size: 11px; color: var(--forest); white-space: nowrap; }
.node-estimate { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.node-state { font-size: 10px; }
.band-line { font-size: 12px; margin: 4px 0 0; }
.mitigation { color: var(--ink); font-size: 14px; margin: 4px 0 0; }
.deepen-form { margin: 10px 0 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.deepen-btn {
  font-size: 13px; padding: 8px 15px; border-radius: var(--radius); cursor: pointer;
  background: var(--forest); color: var(--paper); border: 1px solid transparent;
}
.deepen-btn:hover { background: var(--deep-forest); }
.deepen-note { font-size: 11px; }

.rel-group { margin: 10px 0 18px; }
.rel-head { font-size: 13px; font-weight: 500; color: var(--ink); margin: 12px 0 6px; }
.rel-sub { margin: 8px 0 8px 4px; }
.rel-sub-label { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-bronze); }
.rel-list { list-style: none; margin: 4px 0 0; padding: 0; }
.rel-row {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--row-rule);
}
.rel-link { font-weight: 500; }
.rel-support { display: inline-flex; align-items: center; gap: 6px; }
.rel-support-label { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.rel-rationale { color: var(--ink-2); font-size: 13px; flex: 1; }
.rel-provisional .rel-rationale { color: var(--ink-3); }
.rel-provisional .rel-support .glyph-seg.on { background: var(--ink-3); }

/* ============================================================
   17. PRINT — every page exports as a brand-faithful report
   (the entity page adds its own report rules; see entity.html).
   ============================================================ */
@page { size: A4; margin: 12mm 12mm 14mm; }
@media print {
  html, body { background: var(--paper) !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { display: block; min-height: 0; font-size: 12.5px; }
  /* Chrome quiets down to the lockup; actions and navigation don't print. */
  .nav-links, .nav-utility, .nav-toggle { display: none !important; }
  .foot-links { display: none !important; }
  a { text-decoration: none; }
  th.sortable::after, th.sort-asc::after, th.sort-desc::after { content: "" !important; }
  tr, .q-item, .pf-row, .ev-card, .node { break-inside: avoid; }
  .rk-scroll { overflow: visible; }
  .risk-table { min-width: 0; }
  .risk-table thead th { position: static; }
}

/* Print-only report masthead — hidden on screen; pages that opt in
   (entity.html) reveal it in print. */
.print-head { display: none; }
@media print {
  .print-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
    border-bottom: 1px solid var(--hair); padding: 2px 0 10px; margin-bottom: 6px;
  }
  .print-head .ph-title {
    font-family: var(--mono); font-size: 10px; letter-spacing: .18em;
    text-transform: uppercase; color: var(--muted-bronze);
  }
  .print-head .ph-meta { font-family: var(--mono); font-size: 10px; color: var(--ink-2); }
}
