/* IFMS additions ONLY — everything else comes verbatim from the iFeed design system.
   New here: page scaffold for standalone pages, status additions (approved/superseded),
   priority pills, progress bars, stage track, chips, requirement rows, tables,
   home grids, tier banner, print watermark + controlled header. */

html, body { margin: 0; padding: 0; height: 100%; }
/* UIX-003 (A3 fix): the app-shell overflow lock is desktop-only. It used to beat the
   verbatim clin-qms responsive rule (.cq-root{overflow:auto} ≤1023px) on specificity,
   so nothing scrolled on tablet/mobile. ≤1023px rules live in the UIX-003 block below. */
@media (min-width: 1024px) {
  body { overflow: hidden; }
  #ifms-root { height: 100vh; overflow: hidden; }
}
#ifms-root { display: flex; flex-direction: column;
  background: var(--if-bg); color: var(--if-ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 13.5px; line-height: 1.5; }
#ifms-root .cq-cockpit { flex: 1; min-height: 0; }
#ifms-root > .cq-canvas-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 40px; }

/* status pills not in base css */
.cq-status-pill.approved  { background: oklch(93% 0.05 150); color: oklch(35% 0.09 150); border-color: oklch(80% 0.07 150); }
.cq-status-pill.superseded{ background: oklch(93% 0.01 230); color: oklch(45% 0.02 230); border-color: oklch(82% 0.015 230); text-decoration: line-through; }
[data-theme="dark"] .cq-status-pill.approved  { background: oklch(28% 0.06 150); color: oklch(80% 0.08 150); }
[data-theme="dark"] .cq-status-pill.superseded{ background: oklch(26% 0.01 230); color: oklch(65% 0.02 230); }

/* priority pills */
.ifms-prio { display: inline-block; font: 700 9.5px/1.6 "JetBrains Mono", monospace; letter-spacing: .04em; padding: 0 7px; border-radius: 20px; border: 1px solid transparent; }
.ifms-p-c { background: oklch(95% 0.05 25);  color: oklch(42% 0.15 25);  border-color: oklch(85% 0.08 25); }
.ifms-p-r { background: oklch(95% 0.04 65);  color: oklch(42% 0.11 65);  border-color: oklch(85% 0.07 65); }
.ifms-p-x { background: oklch(95% 0.02 230); color: oklch(45% 0.03 230); border-color: oklch(85% 0.02 230); }

/* progress bar */
.ifms-bar { display: inline-block; width: 90px; height: 7px; border-radius: 6px; background: var(--if-bg-2); border: 1px solid var(--if-rule); vertical-align: middle; overflow: hidden; }
.ifms-bar-fill { display: block; height: 100%; background: var(--if-accent); border-radius: 6px; }
.ifms-bar-num { font: 700 10px "JetBrains Mono", monospace; margin-left: 6px; color: var(--if-ink-2); }

/* stage track (left column) */
.ifms-stagetrack { display: flex; flex-direction: column; gap: 4px; padding: 4px 8px; }
.ifms-stage { text-align: left; border: 1px solid var(--if-rule); background: var(--if-surface); color: var(--if-ink-2);
  border-radius: 10px; padding: 5px 8px; font-size: 11.5px; cursor: pointer; }
.ifms-stage.cur { border-color: var(--if-accent); color: var(--if-ink); font-weight: 600; }
.ifms-stage.sel { background: var(--if-accent-bg); }
.ifms-stage-num { font: 700 10px "JetBrains Mono", monospace; color: var(--if-accent); margin-right: 4px; }

/* chips */
.ifms-chips { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px 8px; }
.ifms-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--if-rule); background: var(--if-surface);
  color: var(--if-ink-2); border-radius: 20px; padding: 3px 10px; font-size: 11.5px; cursor: pointer; text-decoration: none; }
.ifms-chip.sel { background: var(--if-accent-bg); border-color: var(--if-accent); color: var(--if-ink); }
.ifms-chip-pct { font: 700 9.5px "JetBrains Mono", monospace; color: var(--if-accent); }

/* requirement rows */
.ifms-req { display: flex; gap: 9px; align-items: flex-start; padding: 7px 4px; border-bottom: 1px dashed var(--if-rule); }
.ifms-req.done .cq-check-text { opacity: .55; text-decoration: line-through; }
.ifms-req-ref { font-size: 10.5px; color: var(--if-ink-3); }
.ifms-note-btn { margin-left: auto; border: none; background: none; cursor: pointer; font-size: 13px; opacity: .6; }
.ifms-note-btn:hover { opacity: 1; }
.ifms-pack-meta { margin-left: auto; font-size: 10.5px; color: var(--if-ink-3); display: inline-flex; align-items: center; gap: 6px; }

/* tables */
.ifms-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ifms-table th { text-align: left; font: 700 10px/1.8 "JetBrains Mono", monospace; letter-spacing: .05em; text-transform: uppercase;
  color: var(--if-ink-3); border-bottom: 1.5px solid var(--if-rule-2); padding: 4px 8px; }
.ifms-table td { padding: 6px 8px; border-bottom: 1px solid var(--if-rule); vertical-align: top; }
.ifms-table a { color: var(--if-accent); text-decoration: none; }

/* home layout */
.ifms-home .cq-stats-bar { margin-bottom: 14px; }
.ifms-lc-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 8px 0 18px; }
.ifms-lc-col { border: 1.5px solid var(--if-rule); border-radius: 14px; background: var(--if-surface); padding: 8px; min-height: 70px; display: flex; flex-direction: column; gap: 5px; }
.ifms-lc-col-head { font: 700 10px/1.6 "JetBrains Mono", monospace; letter-spacing: .04em; color: var(--if-ink-3); }
.ifms-gap { font-size: 10.5px; color: var(--if-ink-3); margin-top: 4px; }
.ifms-sysrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 20px; }
.ifms-side { font-size: 12px; color: var(--if-ink-2); padding: 8px 10px; }

/* doc extras */
/* readable measure — match ClinAssure .cq-doc (max-width:860px; margin:0 auto). The document
   body renders as .ifms-doc (carries the watermark), so it needs the same measure or prose
   runs full-width and becomes hard to read. Founder-directed readability / parity correction. */
.ifms-doc { position: relative; max-width: 860px; margin: 0 auto; }
.ifms-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 0 4px; }
.ifms-flag { margin-top: 8px; font-size: 11px; color: oklch(45% 0.14 25); background: oklch(96% 0.03 25); border: 1px solid oklch(87% 0.06 25); border-radius: 8px; padding: 5px 9px; }
.ifms-tier { flex-shrink: 0; font-size: 10.5px; color: var(--if-ink-3); text-align: center; padding: 5px 14px; border-top: 1px solid var(--if-rule); background: var(--if-bg-2); }
.ifms-overlay { position: fixed; inset: 0; background: oklch(20% 0.03 250 / .45); display: flex; align-items: center; justify-content: center; z-index: 60; }

/* toast (if base doesn't ship one) */
.cq-toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--if-ink); color: var(--if-bg);
  padding: 8px 16px; border-radius: 20px; font-size: 12.5px; z-index: 70; box-shadow: var(--if-shadow-2); }

/* ── PRINT DISCIPLINE ─────────────────────────────────────────
   EFFECTIVE → controlled-copy header band. Anything else → diagonal watermark.
   A clean print of a non-effective document is impossible. */
.ifms-wm::before { content: attr(data-status); position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 800 46px/1.15 Inter, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: oklch(50% 0.12 25 / .12);
  transform: rotate(-28deg); pointer-events: none; z-index: 5; }
.ifms-controlled::after { content: "CONTROLLED COPY — valid on print date only · ClinAssure Clinical Trial DMS"; display: block; margin-top: 14px;
  font: 700 10px/1.6 "JetBrains Mono", monospace; letter-spacing: .05em; color: var(--if-ink-3); border-top: 1.5px solid var(--if-rule-2); padding-top: 6px; }
@media print {
  body { overflow: visible; }
  #ifms-root { height: auto; overflow: visible; }
  .cq-topbar, .cq-left, .cq-right, .ifms-actions, .ifms-tier, .cq-nbtn, .ifms-sysrow, .cq-stats-bar { display: none !important; }
  .cq-cockpit { display: block; padding: 0; }
  .cq-canvas { display: block; overflow: visible; border: none; }
  .cq-canvas-scroll { overflow: visible; }
  .ifms-wm::before { color: oklch(50% 0.12 25 / .18); }
}

/* ── Five-module readiness workspace (MR-C1) ─────────────────────────────
   Uses the accepted IFMS/ClinAssure visual vocabulary: pills, cards, tables,
   forms and three-column cockpit. No alternate brand system is introduced. */
.mr-module-row{display:flex;gap:7px;padding:10px 13px;border-bottom:1px solid var(--if-line);overflow-x:auto;flex:0 0 auto;background:var(--if-panel)}
.mr-module-pill{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;text-decoration:none;border:1px solid var(--if-line);border-radius:999px;padding:7px 11px;color:var(--if-ink-2);font-size:11px;font-weight:800;letter-spacing:.02em;background:var(--if-surface)}
.mr-module-pill:hover,.mr-module-pill.on{border-color:var(--if-accent);color:var(--if-accent);background:color-mix(in srgb,var(--if-accent) 8%,var(--if-surface))}
.mr-tabrow{overflow-x:auto;flex:0 0 auto}.mr-tabrow .ifms-docrow-tabs{min-width:max-content}.mr-tabrow a{text-decoration:none}
.mr-workspace{padding-top:14px}.mr-honesty,.mr-error{border:1px solid var(--if-warn,#b88717);border-radius:9px;padding:10px 12px;margin-bottom:12px;background:color-mix(in srgb,var(--if-warn,#b88717) 8%,var(--if-surface));font-size:11.5px;line-height:1.55;color:var(--if-ink-2)}
.mr-error{border-color:var(--if-danger,#a74655);background:color-mix(in srgb,var(--if-danger,#a74655) 8%,var(--if-surface))}
.mr-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.mr-form-grid label{display:grid;gap:5px;font-family:"JetBrains Mono",monospace;font-size:9.5px;font-weight:800;letter-spacing:.08em;color:var(--if-ink-3)}
.mr-span-2{grid-column:1/-1}.mr-textarea{min-height:88px;resize:vertical}.mr-mini{min-height:56px;resize:vertical;margin-bottom:5px}
.mr-market-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.mr-market-card{display:grid;grid-template-columns:auto 1fr;gap:2px 7px;align-items:start;border:1px solid var(--if-line);border-radius:8px;padding:9px;background:var(--if-surface);font-size:11px}.mr-market-card input{grid-row:1/3}.mr-market-card small{display:block;color:var(--if-ink-3);font-size:9.5px;line-height:1.35}
.mr-kpi-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-bottom:10px}.mr-kpi-row>div{border:1px solid var(--if-line);border-radius:8px;padding:10px;background:var(--if-surface)}.mr-kpi-row strong{display:block;font-size:19px;color:var(--if-accent)}.mr-kpi-row span{font-size:9px;text-transform:uppercase;letter-spacing:.08em;color:var(--if-ink-3)}
.mr-flow{max-width:900px}.mr-req-table td:first-child{min-width:230px}.mr-req-table td:nth-child(3),.mr-req-table td:nth-child(4){min-width:170px}.mr-req-table td:last-child{min-width:250px}.mr-req-table select,.mr-req-table textarea,.mr-req-table input{font-size:10.5px}
.mr-ref{padding:13px;font-size:11.5px;line-height:1.55;color:var(--if-ink-2)}.mr-ref-icon{font-size:28px}.mr-ref h3{margin:4px 0 8px;color:var(--if-ink);font-size:14px}.mr-ref dl{display:grid;grid-template-columns:auto 1fr;gap:5px 8px}.mr-ref dt{font-family:"JetBrains Mono",monospace;font-size:9px;font-weight:800;color:var(--if-ink-3);text-transform:uppercase}.mr-ref dd{margin:0}.mr-warning{border-left:3px solid var(--if-warn,#b88717);padding-left:8px}
.mr-report{max-width:860px;margin:0 auto}.mr-report h1{font-family:"Source Serif 4",serif}.mr-report h2{font-size:14px;margin-top:18px}
@media(max-width:900px){.mr-form-grid{grid-template-columns:1fr}.mr-span-2{grid-column:auto}.mr-kpi-row{grid-template-columns:1fr}.mr-req-table{min-width:980px}}
@media print{.mr-module-row,.mr-tabrow,.mr-honesty,.mr-error{display:none!important}.mr-report{max-width:none}}

.cq-fam-item.cur { border-left: 3px solid var(--if-accent); }

/* ── Round-3 additions (WP1–WP6) ──────────────────────────── */
/* multi-paragraph section prose (documents authored with \n\n paragraphs) */
.ifms-doc .cq-doc-section-text, .cq-tabpanel .cq-doc-section-text { white-space: pre-wrap; }

/* selects inside modals reuse the e-sig input look */
select.cq-esig-input { appearance: auto; cursor: pointer; }

/* letterhead company block line (visible in print header only — clin-print.css shows .cq-print-header on print) */
.ifms-lh-co { font-size: 7.5pt; font-weight: 400; color: #94a3b8; letter-spacing: 0.02em; margin-top: 2pt; font-family: Arial, Helvetica, sans-serif; }

@media print {
  /* keep tab panels printable with the letterhead; the fixed header needs first-page breathing room */
  .cq-canvas-scroll { padding-top: 0 !important; }
  .ifms-doc, .cq-tabpanel { padding-top: 70pt !important; } /* clear the fixed letterhead on page 1 */
  .ifms-doc { max-width: none; margin: 0; } /* print full page width, like ClinAssure .cq-doc */
  .ifms-lh-co { color: #6b7280; }
}

/* ── G1-UIX-001 (founder-directed, 2026-07-14): document header + meta layout ──
   Title flush-left with ID·version·status BELOW it; meta grid on its own full-width
   row with breathing room (was: all squeezed into one flex row, meta flush to card edge).
   Scoped to .ifms-doc — verbatim ClinAssure reference CSS untouched. */
.ifms-doc .cq-doc-header.ifms-doc-header { display: block; margin-bottom: 18px; }
.ifms-doc .ifms-doc-head-main { max-width: 100%; }
.ifms-doc .ifms-doc-head-main .cq-doc-title { margin: 0; }
.ifms-doc .ifms-doc-head-main .cq-doc-ids { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; }
.ifms-doc > .cq-doc-meta { margin: 0 0 26px; }
.ifms-doc .ifms-flag { margin: 0 0 18px; }
/* BACK control on its own row above the document card */
.ifms-backrow { display: block; margin: 2px 0 14px; }

/* ── UIX-002 breathable-space pass (founder-directed 2026-07-14) ──
   Spacing ONLY — no colors, fonts, sizes, borders or layout structure changed.
   All rules scoped under #ifms-root and @media screen (print pipeline untouched);
   identical in dark and light themes. Root causes fixed:
   R1  IFMS cockpit views render bare into .cq-canvas-scroll without the reference's
       padded view wrappers (.cq-dir/.cq-famlist give 20px 28px in ClinAssure) →
       dir-grid, dossier/PM/audit cards, CLN readiness blocks, module registers and
       index home all sat flush against the canvas edges (measured 0px gutters).
       Fix: reference-rhythm gutters on the cockpit scroll itself; views that carry
       their own reference padding (.cq-home/.cq-tabpanel/.ifms-doc) are trimmed so
       their NET gutters stay reference-exact (24px top / 28px sides).
   R2  Stacked blocks (.cq-card/.cq-nbtn/.ifms-table/.cq-dir-grid directly in the
       scroll) had 0px vertical rhythm — cards touched each other.
   R3  IFMS-custom values denser than the reference tokens: .ifms-home stats bar
       mb 14px (ref 24), table cells 6px/4px, req rows 7px 4px, lc-grid gap 8px,
       dir-card id/title row gaps 4px/6px (founder target 8–10px). */
@media screen and (min-width: 768px) {
  /* R1 — container gutters (reference .cq-dir = 20px 28px; ≤767px keeps its own 12px rule) */
  #ifms-root .cq-cockpit .cq-canvas-scroll { padding: 20px 28px 40px; }
  /* self-padded views: keep net gutters reference-exact (24px top / 28px sides) */
  #ifms-root .cq-cockpit .cq-canvas-scroll > .cq-home,
  #ifms-root .cq-cockpit .cq-canvas-scroll > .cq-tabpanel { padding: 4px 0 0; }
  /* document canvas — same net measure as reference .cq-doc (24px 28px 48px) */
  #ifms-root .cq-cockpit .cq-canvas-scroll > .ifms-doc { padding: 4px 0 8px; }
}
@media screen {
  /* R2 — vertical rhythm for blocks stacked directly in the canvas scroll */
  #ifms-root .cq-canvas-scroll > .cq-card { margin-bottom: 16px; }
  #ifms-root .cq-canvas-scroll > .cq-nbtn { margin: 0 0 18px; }
  #ifms-root .cq-canvas-scroll > .ifms-table { margin-bottom: 16px; }
  #ifms-root .cq-canvas-scroll > .cq-dir-grid { margin-bottom: 28px; } /* section rhythm before next title */

  /* R3 — grid gaps to founder-directed range (was 12/10/10/8) */
  #ifms-root .cq-dir-grid { gap: 14px; }
  #ifms-root .cq-qcards { gap: 14px; }
  #ifms-root .cq-stats-bar { gap: 12px; }
  #ifms-root .cq-fam-grid { gap: 12px; }

  /* dir-card internal rows: 8–10px between id / title / badges (was 4px/6px) */
  #ifms-root .cq-dir-card-id { margin-bottom: 8px; }
  #ifms-root .cq-dir-card-title { margin-bottom: 10px; }
  #ifms-root .cq-dir-card .ifms-gap { margin-top: 8px; } /* gap line clears the badge row */

  /* index home rhythm back to reference scale */
  #ifms-root .ifms-home .cq-stats-bar { margin-bottom: 24px; } /* was 14px; reference 24px */
  #ifms-root .ifms-lc-grid { gap: 12px; margin: 10px 0 28px; }
  #ifms-root .ifms-lc-col { padding: 12px; gap: 7px; }

  /* register/table cells: 10px vertical (was 6px/4px; reference .cq-stbl 7px 10px, .cq-annex-table 8px 10px) */
  #ifms-root .ifms-table th { padding: 6px 10px; }
  #ifms-root .ifms-table td { padding: 10px; }

  /* requirement rows breathe inside the card body (was 7px 4px, gap 9px) */
  #ifms-root .ifms-req { padding: 9px 6px; gap: 10px; }
}

/* ── UIX-003+005 navigation redesign (founder-approved 2026-07-14) ────────────
   Existing design-system tokens only; verbatim reference CSS untouched.
   1  Mobile/tablet scroll unlock ≤1023px (A3 root cause: #ifms-root overflow lock,
      now media-scoped at the top of this file — here the page becomes the scroller).
   2  .ifms-docrow — slim sticky document row at the top of .cq-canvas: section pills
      left (all six ≥1200px; DOCUMENT/WORKFLOW/MORE ▾ below), PDF/ISSUE/SHARE right.
   3  .ifms-menu — tiny overlay menu on .cq-card styling (DATA ⇅, MORE ▾).
   4  Topbar view group — .cq-eptabs reused inside .cq-nav-actions.
   5  Doc select breathing room — topbar no longer carries doc tabs/actions. */

/* 1 · ≤1023px: the document scrolls; panels flow (pairs with clin-qms tier-3/4 rules).
   overflow:visible (not auto) on the root — an auto root becomes the nearest scrollport
   and would defeat the .ifms-docrow position:sticky against the page scroll. */
@media (max-width: 1023px) {
  html, body { height: auto; }
  body { overflow: auto; }
  #ifms-root { overflow: visible; height: auto; min-height: 100vh; }
}

/* 2 · document row — sticky within the scroll at every breakpoint */
.ifms-docrow { position: sticky; top: 0; z-index: 12; flex-shrink: 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; row-gap: 5px;
  padding: 7px 12px; background: var(--if-surface); border-bottom: 1px solid var(--if-rule); }
.ifms-docrow-tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; row-gap: 4px; min-width: 0; }
.ifms-docrow-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.ifms-docrow .cq-nbtn[disabled] { opacity: .45; cursor: not-allowed; }
.ifms-docrow .cq-nbtn[disabled]:hover { border-color: var(--if-rule); color: var(--if-ink-3); background: var(--if-surface); }
/* six-section strip ≥1200px reuses the reference .cq-eptabs/.cq-eptab grammar WITHOUT
   the 620px clip (base: flex:1; overflow-x:auto; max-width:620px) — wrap, never clip */
.ifms-docrow .cq-eptabs { flex: 0 1 auto; max-width: none; overflow: visible; flex-wrap: wrap; min-width: 0; }
/* DOCUMENT / WORKFLOW / MORE ▾ pills collapse below 1200px */
.ifms-docrow-full { display: none; }
@media (min-width: 1200px) {
  .ifms-docrow-full { display: flex; }
  .ifms-docrow-compact { display: none; }
}

/* 3 · overlay menu — .cq-card carries border/surface/shadow; this adds placement + items */
.ifms-menu { position: fixed; z-index: 90; min-width: 190px; padding: 5px;
  display: flex; flex-direction: column; gap: 2px; }
.ifms-menu-item { display: block; width: 100%; text-align: left; border: none; background: transparent;
  color: var(--if-ink-2); font: 600 11px/1.5 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: .06em; text-transform: uppercase; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.ifms-menu-item:hover, .ifms-menu-item:focus-visible { background: var(--if-accent-bg); color: var(--if-accent); outline: none; }
.ifms-menu-item.on { color: var(--if-accent); font-weight: 800; }
.ifms-menu-item[disabled] { opacity: .45; cursor: not-allowed; }

/* 4 · topbar view group — neutralise the eptab strip's flex/max-width/scroll in this slot */
.cq-nav-actions .ifms-viewtabs { flex: 0 0 auto; max-width: none; overflow: visible; flex-wrap: wrap; }

/* 5 · doc select gets the freed room (≤1023px keeps the verbatim responsive caps) */
@media (min-width: 1024px) { .cq-sop-sel { max-width: none; } }

/* module BACK row rides above the doc row, inside the canvas frame */
.cq-canvas > .ifms-backrow { margin: 8px 12px 6px; flex-shrink: 0; }

/* 6 · mobile reachability companions to the scroll unlock (A3):
   a) the rotated status watermark (.ifms-wm::before is inset:0 over the full document
      height, rotate -28deg) has a transformed bounding box ~5x the viewport width —
      once the page scrolls it produced ~2000px of phantom horizontal scroll. Clip the
      watermark to the document card on screen; print pipeline untouched. */
@media screen {
  .ifms-wm { overflow: hidden; }
}
/* b) <768px the verbatim tier-4 cockpit uses grid-template-columns:1fr (min-content
      floor) — the 4-cell doc meta grid held the canvas at ~434px on a 390px viewport,
      forcing sideways reading. Let the column shrink, stack meta 2×2, and give wide
      document tables their own horizontal scroll so nothing is clipped by (a). */
@media screen and (max-width: 767px) {
  #ifms-root .cq-cockpit { grid-template-columns: minmax(0, 1fr); }
  #ifms-root .ifms-doc .cq-doc-meta { grid-template-columns: 1fr 1fr; }
  #ifms-root .ifms-doc .cq-annex-table, #ifms-root .ifms-doc .cq-resp-table,
  #ifms-root .cq-tabpanel .cq-annex-table { display: block; overflow-x: auto; }
}

/* ── UIX-OPS (Gate F) — api-mode operational layer additions ONLY ─────────────
   Everything below serves ifms-ops.js (server-backed OPERATE view). Additions
   only, existing tokens/vocabulary only; static mode never mounts these nodes.
   Screen rules first; the small @media print block at the end is the Gate G
   controlled-PDF pipeline (builds on clin-print.css classes — reference CSS
   untouched). */
@media screen {
  /* server registry / operate panel rhythm (cards sit inside .ifms-ops, not
     directly in the canvas scroll, so the UIX-002 rhythm rule is re-applied) */
  #ifms-root .ifms-ops > .cq-card { margin-bottom: 16px; }
  #ifms-root .ifms-ops > .ifms-doc { margin-bottom: 16px; }
  #ifms-root .ifms-ops-strip { margin: 0 0 14px; }
  /* Client authoring surface: Markdown remains internal storage only. The author works
     in a familiar paper-like document canvas with a bounded formatting toolbar. */
  .ifms-author-source { display: none !important; }
  .ifms-author-shell { margin: 14px 0 0; border: 1px solid var(--if-rule); border-radius: 14px;
    overflow: hidden; background: var(--if-bg-2); }
  .ifms-author-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
    padding: 8px 10px; border-bottom: 1px solid var(--if-rule); background: var(--if-surface);
    position: sticky; top: 0; z-index: 2; }
  .ifms-author-toolbar button, .ifms-author-format { min-height: 30px; border: 1px solid transparent;
    border-radius: 7px; background: transparent; color: var(--if-ink-2); padding: 4px 8px;
    font: 700 10px/1.2 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .035em; cursor: pointer; }
  .ifms-author-toolbar button:hover:not(:disabled), .ifms-author-toolbar button:focus-visible,
  .ifms-author-format:focus-visible { color: var(--if-accent); border-color: var(--if-accent); background: var(--if-accent-bg); outline: none; }
  .ifms-author-toolbar button:disabled, .ifms-author-format:disabled { opacity: .45; cursor: not-allowed; }
  .ifms-author-format { border-color: var(--if-rule); background: var(--if-bg); min-width: 120px; }
  .ifms-author-sep { width: 1px; height: 20px; background: var(--if-rule); margin: 0 3px; }
  .ifms-author-page { width: min(860px, calc(100% - 34px)); min-height: 520px; margin: 18px auto 24px;
    padding: 42px 48px 56px; box-sizing: border-box; background: var(--if-surface); color: var(--if-ink);
    border: 1px solid var(--if-rule); border-radius: 4px; box-shadow: 0 8px 24px rgb(18 57 66 / .09);
    font: 14.5px/1.7 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; caret-color: var(--if-accent); }
  .ifms-author-page[contenteditable="true"]:focus { outline: 2px solid var(--if-accent); outline-offset: -2px; }
  .ifms-author-page[contenteditable="false"] { background: var(--if-bg); cursor: default; }
  .ifms-author-page h1, .ifms-author-page h2, .ifms-author-page h3,
  .ifms-author-page h4, .ifms-author-page h5, .ifms-author-page h6 { color: var(--if-ink); line-height: 1.28; margin: 1.1em 0 .45em; }
  .ifms-author-page h1 { font-size: 25px; } .ifms-author-page h2 { font-size: 20px; }
  .ifms-author-page h3 { font-size: 17px; } .ifms-author-page p { margin: 0 0 .8em; }
  .ifms-author-page ul, .ifms-author-page ol { margin: 0 0 .9em; padding-left: 28px; }
  .ifms-author-page blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--if-accent); color: var(--if-ink-2); background: var(--if-accent-bg); }
  .ifms-author-page table { width: 100%; border-collapse: collapse; margin: 14px 0; }
  .ifms-author-page th, .ifms-author-page td { border: 1px solid var(--if-rule); padding: 7px 9px; text-align: left; vertical-align: top; }
  .ifms-author-page th { background: var(--if-bg-2); font-weight: 700; }
  .ifms-author-placeholder { display: inline-block; min-width: min(320px, 75%); padding: 4px 8px;
    border: 1px dashed var(--if-accent); border-radius: 6px; background: var(--if-accent-bg);
    color: var(--if-accent); font-style: italic; cursor: text; }
  .ifms-author-placeholder:focus { outline: 2px solid var(--if-accent); outline-offset: 2px; }
  .ifms-required-label { display: inline-block; margin: 3px 3px 0 0; padding: 2px 7px;
    border: 1px solid currentColor; border-radius: 999px; font-weight: 700; }
  .ifms-author-shell-modal .ifms-author-page { min-height: 360px; width: calc(100% - 24px); margin: 12px auto; padding: 28px 32px; }
  .ifms-ops-savestat { font: 700 10px/1.6 "JetBrains Mono", ui-monospace, monospace;
    letter-spacing: .05em; color: var(--if-ink-3); padding: 6px 2px 0; }
  /* template preview in the New Document modal */
  .ifms-ops-tplprev { margin: 0; border: 1px solid var(--if-rule); border-radius: 10px;
    background: var(--if-surface); color: var(--if-ink-2); padding: 16px 20px;
    max-height: 260px; overflow: auto; font: 13px/1.6 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
  .ifms-template-human-preview h1, .ifms-template-human-preview h2, .ifms-template-human-preview h3 { margin: 12px 0 5px; color: var(--if-ink); }
  .ifms-template-human-preview h1 { font-size: 20px; } .ifms-template-human-preview h2 { font-size: 17px; }
  .ifms-template-human-preview p { margin: 0 0 7px; }
  /* server search results dropdown reuses the .ifms-menu overlay grammar */
  .ifms-ops-results { min-width: 260px; max-width: 460px; max-height: 320px; overflow-y: auto; }
  .ifms-ops-results .ifms-menu-item { text-transform: none; letter-spacing: .02em; }
  /* Gate G print-only nodes stay out of the screen flow */
  .ifms-ops-cover { display: none; }
  .ifms-ops-bodyprint { display: none; }
  /* R1-E · rendered Markdown preview (on-screen) — the editor stays the source of truth,
     this shows the SAME sanitized HTML that prints, so no literal '#'/'##' is ever shown. */
  .ifms-ops-preview { margin: 10px 0 0; padding: 14px 16px; border: 1px solid var(--if-rule);
    border-radius: 12px; background: var(--if-surface); color: var(--if-ink);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13.5px; line-height: 1.6; }
  .ifms-ops-preview:empty { display: none; }
  /* shared rendered-markdown typography (preview + print body) */
  .ifms-md-body .ifms-md-h, .ifms-ops-preview .ifms-md-h { font-weight: 700; line-height: 1.25; margin: 14px 0 6px; }
  .ifms-md-body .ifms-md-h1, .ifms-ops-preview .ifms-md-h1 { font-size: 1.5em; }
  .ifms-md-body .ifms-md-h2, .ifms-ops-preview .ifms-md-h2 { font-size: 1.28em; }
  .ifms-md-body .ifms-md-h3, .ifms-ops-preview .ifms-md-h3 { font-size: 1.12em; }
  .ifms-md-body p, .ifms-ops-preview p { margin: 0 0 8px; }
  .ifms-md-body ul, .ifms-md-body ol, .ifms-ops-preview ul, .ifms-ops-preview ol { margin: 0 0 8px; padding-left: 22px; }
  .ifms-md-body li, .ifms-ops-preview li { margin: 2px 0; }
  .ifms-md-body .ifms-md-code, .ifms-ops-preview .ifms-md-code { font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: .9em; background: var(--if-bg-2); border: 1px solid var(--if-rule); border-radius: 4px; padding: 0 4px; }
  .ifms-md-body .ifms-md-quote, .ifms-ops-preview .ifms-md-quote { margin: 0 0 8px; padding: 4px 12px;
    border-left: 3px solid var(--if-accent); color: var(--if-ink-2); }
  .ifms-md-body .ifms-md-hr, .ifms-ops-preview .ifms-md-hr { border: none; border-top: 1px solid var(--if-rule); margin: 12px 0; }
  .ifms-md-body .ifms-md-table, .ifms-ops-preview .ifms-md-table { border-collapse: collapse; width: 100%; margin: 0 0 10px; font-size: .95em; }
  .ifms-md-body .ifms-md-table th, .ifms-md-body .ifms-md-table td,
  .ifms-ops-preview .ifms-md-table th, .ifms-ops-preview .ifms-md-table td {
    border: 1px solid var(--if-rule); padding: 5px 8px; text-align: left; vertical-align: top; }
  .ifms-md-body .ifms-md-table th, .ifms-ops-preview .ifms-md-table th { background: var(--if-bg-2); font-weight: 700; }
  @media (max-width: 680px) {
    .ifms-author-page { width: calc(100% - 16px); min-height: 420px; margin: 8px auto 14px; padding: 26px 22px 40px; }
    .ifms-author-toolbar { position: static; }
    .ifms-author-sep { display: none; }
  }
}
/* server lifecycle badge states not in the base css — existing recipes reused:
   returned = no_source recipe, approved = authorized recipe, superseded/withdrawn/
   archived = neutral draft recipe (superseded adds the line-through already used by
   .cq-status-pill.superseded in this file). No new colors. */
.cq-badge.returned   { color: oklch(62% 0.16 30); border-color: oklch(62% 0.16 30); background: oklch(62% 0.16 30 / 0.08); }
.cq-badge.approved   { color: oklch(55% 0.15 145); border-color: oklch(55% 0.15 145); background: oklch(55% 0.15 145 / 0.08); }
.cq-badge.superseded { color: var(--if-ink-4); border-color: var(--if-rule); background: transparent; text-decoration: line-through; }
.cq-badge.withdrawn  { color: var(--if-ink-4); border-color: var(--if-rule); background: transparent; }
.cq-badge.archived   { color: var(--if-ink-4); border-color: var(--if-rule); background: transparent; }

/* ── UIX-OPS (Gate G) — controlled print pipeline for api-mode documents ──
   Watermark matrix + cover + body come from ifms-ops.js DOM; the diagonal state
   watermark reuses the existing .ifms-wm::before pattern (attr(data-status)) and
   the effective-only footer statement reuses .ifms-controlled::after. Scoped to
   .ifms-ops so static-mode print output is untouched. */
@media print {
  /* operate chrome never prints (registry strip, docbar, action cards carry
     .cq-print-hide which clin-print.css already hides) */
  .ifms-ops .ifms-docrow, .ifms-ops .ifms-ops-strip, .ifms-ops .ifms-ops-savestat { display: none !important; }
  /* the authored Markdown body prints as RENDERED prose (R1-E: no literal '#'/'##');
     #opsBodyPrint now carries sanitized HTML, not raw markdown. The on-screen preview
     and editor are hidden for print. */
  .ifms-ops .ifms-ops-bodyprint { display: block; word-break: break-word;
    font-family: 'Times New Roman', Times, serif; font-size: 11pt; line-height: 1.5; color: #000;
    border: none; margin: 0; padding: 0; }
  .ifms-ops .ifms-ops-preview { display: none !important; }
  /* cover/letterhead block per document type (first page) */
  .ifms-ops .ifms-ops-cover { display: block; }
  /* operate cards print as plain sections (version history + approval table at
     the document end) */
  .ifms-ops .cq-card, .ifms-ops .cq-card-body { border: none; background: white; padding: 0; }
  .ifms-ops .ifms-doc { max-width: none; margin: 0; }
  /* print ink: #ifms-root sets color:var(--if-ink) (theme token) which would leave
     operate tables washed on paper — force document black inside .ifms-ops only */
  .ifms-ops, .ifms-ops .cq-card-title, .ifms-ops .ifms-table th, .ifms-ops .ifms-table td,
  .ifms-ops .cq-print-issuance-table td, .ifms-ops .cq-doc-meta-value { color: #000; }
}

/* ════════════════════════════════════════════════════════════════════════════
   R1-E · PDF page-master / anti-overlap / rendered-markdown print block (REV-009 H02)
   Additions only; builds on clin-print.css classes WITHOUT editing that file.
   Fixes: (a) page-2+ body underlapping the repeating header; (b) clipped approval/
   signature continuation content; (c) raw-markdown body; (d) effective-only clean render.
   Two render paths are supported:
     · page.pdf + Chromium header/footer templates (the golden-suite path): ifms-ops.js
       adds body.ifms-print-templated before page.pdf. Chromium's own margin box reserves
       header/footer space and repeats the templates, so the IN-BODY fixed header/footer/
       diagonal must NOT paint (they would overlap). We hide them in that mode.
     · window.print() from a browser (no Chromium templates): the in-body fixed header
       repeats and we reserve a UNIFORM @page top/bottom margin sized to it, so EVERY page
       (not just page 1) clears the header — this is the anti-overlap fix.
   ════════════════════════════════════════════════════════════════════════════ */
@media print {
  /* rendered-markdown print typography (mirrors the screen .ifms-md-body rules, print units) */
  .ifms-ops .ifms-ops-bodyprint .ifms-md-h { font-family: Arial, Helvetica, sans-serif; font-weight: 700;
    color: #000; margin: 10pt 0 4pt; line-height: 1.25; page-break-after: avoid; break-after: avoid; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-h1 { font-size: 15pt; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-h2 { font-size: 12.5pt; border-bottom: 0.5pt solid #ccc; padding-bottom: 2pt; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-h3 { font-size: 11pt; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-h4,
  .ifms-ops .ifms-ops-bodyprint .ifms-md-h5,
  .ifms-ops .ifms-ops-bodyprint .ifms-md-h6 { font-size: 10pt; }
  .ifms-ops .ifms-ops-bodyprint p { margin: 0 0 6pt; }
  .ifms-ops .ifms-ops-bodyprint ul, .ifms-ops .ifms-ops-bodyprint ol { margin: 0 0 6pt; padding-left: 20pt; }
  .ifms-ops .ifms-ops-bodyprint li { margin: 1pt 0; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-code { font-family: 'Courier New', Courier, monospace; font-size: 9pt;
    background: #f3f4f6; border: 0.3pt solid #ddd; border-radius: 2pt; padding: 0 2pt; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-quote { margin: 0 0 6pt; padding: 2pt 10pt; border-left: 2pt solid #94a3b8; color: #374151; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-hr { border: none; border-top: 0.5pt solid #ccc; margin: 8pt 0; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-table { border-collapse: collapse; width: 100%; margin: 0 0 8pt; font-size: 9.5pt; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-table th,
  .ifms-ops .ifms-ops-bodyprint .ifms-md-table td { border: 0.5pt solid #ccc; padding: 3pt 6pt; text-align: left; vertical-align: top; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-table th { background: #f3f4f6; font-weight: 700; }

  /* ── page-break safety (R1-E): keep structured content whole ── */
  /* tables never split a row across pages; header row repeats on continuation */
  .ifms-ops .ifms-ops-bodyprint .ifms-md-table thead { display: table-header-group; }
  .ifms-ops .ifms-ops-bodyprint .ifms-md-table tr { page-break-inside: avoid; break-inside: avoid; }
  /* approval table rows and the signature block are kept whole and never clipped mid-row */
  .ifms-ops .cq-approval-row { page-break-inside: avoid; break-inside: avoid; }
  .ifms-ops .sig-block { page-break-inside: avoid; break-inside: avoid; }
  /* headings kept with the following content; list items not orphaned */
  .ifms-ops .cq-card-head, .ifms-ops .cq-tabpanel-head { page-break-after: avoid; break-after: avoid; }
  .ifms-ops .ifms-ops-bodyprint li, .ifms-ops .cq-hist-row { page-break-inside: avoid; break-inside: avoid; }
  /* version-history / signatures tables: avoid breaking a single row */
  .ifms-ops .ifms-table tr { page-break-inside: avoid; break-inside: avoid; }

  /* ── path A: Chromium header/footer templates active (page.pdf) ──
     The margin box reserves + repeats the header/footer, so the IN-BODY fixed header/footer
     must NOT paint (that is the page-2 overlap cause). The diagonal state watermark
     (.cq-print-watermark) is KEPT — it is a centred, low-opacity, pointer-events:none
     overprint that Chromium templates cannot reproduce and it does not cause header overlap;
     it is already removed by ifms-ops.js for EFFECTIVE (clean render). Body top padding is 0
     because page.pdf's margin.top reserves the header band on EVERY page. */
  body.ifms-print-templated .cq-print-header,
  body.ifms-print-templated .cq-print-footer { display: none !important; }
  body.ifms-print-templated .ifms-ops .ifms-doc { padding-top: 0 !important; }

  /* ── path B: window.print() fallback (no Chromium templates) ──
     Reserve a uniform top/bottom margin on EVERY page equal to the fixed header/footer
     height so page-2+ body never underlaps the header (the actual REV-009 overlap fix).
     26mm top clears the two-line letterhead band; 18mm bottom clears the footer. */
  body:not(.ifms-print-templated) .ifms-ops .ifms-doc { padding-top: 4pt; }
  @page { margin-top: 26mm; margin-bottom: 18mm; }
  /* the first-page override in clin-print.css (@page :first { margin-top: 5mm }) would let
     the fixed header overlap the cover on page 1 too — restore a full top margin there. */
  @page :first { margin-top: 26mm; }
}

/* ════════════════════════════════════════════════════════════════════════════
   R1-C / R1-D · document experience + controlled distribution (REV-009 M02)
   Additions only; screen-only affordances scoped to .ifms-ops (api mode). Reuses the
   existing cq-* form/card/badge vocabulary and theme tokens — no new colors/fonts.
   Every card below already carries .cq-print-hide in the DOM, so print output is
   byte-unaffected (the golden/visual PDF suites are untouched).
   ════════════════════════════════════════════════════════════════════════════ */
/* placeholder-awareness banner (mirrors the server; SUBMIT is disabled-with-reason until clear) */
.ifms-ops .ifms-ph-banner { margin: 10px 0 0; line-height: 1.5; }
.ifms-ops .ifms-ph-banner .ifms-md-code { white-space: nowrap; }
/* controlled-metadata + review-route + distribution cards read as the house cards; the meta
   grid reuses .cq-doc-meta but relaxes to fill smaller cells cleanly */
.ifms-ops .ifms-meta-grid { margin-top: 0; }
.ifms-ops .ifms-assigned-review { margin-top: 12px; padding: 12px; border: 1px solid var(--if-accent);
  border-radius: 12px; background: var(--if-accent-bg); }
/* checkbox rows (route pickers + release checklist) */
.ifms-ck-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13.5px; color: var(--if-ink); cursor: pointer; }
.ifms-ck-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--if-accent); }
.ifms-ck-list { max-height: 180px; overflow: auto; border: 1px solid var(--if-rule); border-radius: 10px; padding: 8px 12px; background: var(--if-surface); }
/* two-column route picker + metadata form grid inside the modal */
.ifms-route-cols, .ifms-meta-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .ifms-route-cols, .ifms-meta-form { grid-template-columns: 1fr; } }
.ifms-route-modal, .ifms-meta-modal { max-width: 620px; }
/* the release-checklist block inside the ceremony modal */
.ifms-ceklist { margin: 4px 0 10px; padding: 12px 14px; border: 1px solid var(--if-rule); border-radius: 12px; background: var(--if-bg-2); }
