/* ════════════════════════════════════════════════════════
   CORVUS — UI Components

   All component CSS references SEMANTIC tokens (--cv-color-*,
   --cv-radius-*) from corvus-tokens.css, never primitives directly.
   Variants follow the semantic vocabulary:
       state:  danger / warning / success / info / neutral
       button: primary / secondary / destructive / ghost
   ════════════════════════════════════════════════════════ */

/* ── Lucide icons — global em-scaling ─────────────────────────────────────
   Every Lucide SVG (rendered by the {% icon %} tag with class="lucide …")
   scales to 1em, i.e. to the font-size of its context — mirroring the Bootstrap
   font-icon behaviour it replaces. This is what the icon system was designed
   for: sizing classes set font-size (e.g. .cv-empty-icon { font-size: 2.25rem })
   and expect the glyph to follow. Placed early so component rules can still
   override width/height where needed. The tag's px `size` arg is unused across
   the app; explicit sizing is done via font-size on a wrapper/class. */
.lucide {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  display: inline-block;
}

/* ── Card ────────────────────────────────────────────── */
/* Feature surface — detail pages, forms, modal bodies, page sections. */

.cv-card {
  background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-xl);
  box-shadow: var(--cv-shadow);
  transition: box-shadow .2s ease, transform .2s ease, border-color .15s;
}

.cv-card-hover:hover {
  box-shadow: var(--cv-shadow-md);
  border-color: var(--cv-color-border-strong);
  transform: translateY(-2px);
}

.cv-card-header {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--cv-color-border);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cv-color-text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

/* ── Widget tile chrome ──────────────────────────────── */
/* Tighter sibling of .cv-card — denser padding/radius, suitable for
   widgets that live on a 12-col grid alongside many peers.
   Compose with col-span-N on the parent grid cell:
       <div class="col-span-2"><div class="cv-widget">...</div></div>  */

.cv-widget {
  background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-lg);
  box-shadow: var(--cv-shadow);
  padding: 1rem 1.125rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow .18s, border-color .15s;
}

.cv-widget:hover {
  box-shadow: var(--cv-shadow-md);
  border-color: var(--cv-color-border-strong);
}

.cv-widget-title {
  font-size: .75rem;
  font-weight: 600;
  color: var(--cv-color-text);
}

.cv-widget-sub {
  font-size: .6875rem;
  color: var(--cv-color-text-muted);
  margin-top: .125rem;
}

/* State modifiers — left border draws the eye to attention-needing tiles */
.cv-widget-danger  { border-left: 3px solid var(--cv-color-danger); }
.cv-widget-warning { border-left: 3px solid var(--cv-color-warning); }
.cv-widget-success { border-left: 3px solid var(--cv-color-success); }
.cv-widget-implemented { border-left: 3px solid var(--cv-color-implemented); }
.cv-widget-info    { border-left: 3px solid var(--cv-color-info); }

/* ── Typography helpers ──────────────────────────────── */

.cv-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--cv-color-text-muted);
}

.cv-stat {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 3.25rem;
  line-height: .9;
  letter-spacing: -.04em;
  color: var(--cv-color-text);
}

.cv-stat-sm {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.6rem;
  line-height: 1;
  letter-spacing: -.03em;
  color: var(--cv-color-text);
}

/* Unit/suffix on a stat (the "%" after a number). em-based so it scales with
   whichever stat size it sits inside (cv-stat or cv-stat-sm). */
.cv-stat-unit {
  font-size: .5em;
  opacity: .55;
  font-weight: 400;
}

.cv-muted {
  color: var(--cv-color-text-muted);
}

/* Constrain prose to a comfortable measure (~70ch) for readability — use on
   explanatory paragraphs, never on data/layout. Replaces inline max-width. */
.cv-measure {
  max-width: 70ch;
}

/* Caption / meta-text tier — between Tailwind's text-xs (12px) and text-sm
   (14px). Used for table caption rows, field hints, inline status text. */
.cv-text-meta {
  font-size: .8125rem;        /* 13px */
  line-height: 1.4;
  color: var(--cv-color-text-muted);
}

/* ── Badges ──────────────────────────────────────────── */
/* Inline status / category indicators. Variants are SEMANTIC.

   Three emphasis levels — pick by how loud the badge needs to be:

     .cv-badge                          DEFAULT — coloured dot + plain text,
                                        no fill. The right choice 95% of the
                                        time. Reads as inline status, not as
                                        a clickable button.

     .cv-badge.cv-badge-outline         Transparent fill, coloured border +
                                        text. Use when status needs a little
                                        more visual weight (e.g. an "Active"
                                        pill on a card header).

     .cv-badge.cv-badge-solid           Filled background + dark text. RARE.
                                        Use only when the badge MUST shout —
                                        "OVERDUE" stamps, "LIVE" indicators.
                                        Colour-on-colour fills read as
                                        buttons; deploy sparingly. */

.cv-badge {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--cv-color-text);
  white-space: nowrap;
  line-height: 1.4;
  background: transparent;
  padding: 0;
  border: none;
  border-radius: 0;
}

/* The dot — rendered via ::before so markup stays one element */
.cv-badge::before {
  content: '';
  display: inline-block;
  width: .5rem;
  height: .5rem;
  border-radius: var(--cv-radius-full);
  background: var(--cv-color-neutral);
  flex-shrink: 0;
}

.cv-badge-danger::before  { background: var(--cv-color-danger); }
.cv-badge-warning::before { background: var(--cv-color-warning); }
.cv-badge-success::before { background: var(--cv-color-success); }
.cv-badge-neutral::before { background: var(--cv-color-neutral); }

/* Outline modifier — adds a border, keeps the dot */
.cv-badge.cv-badge-outline {
  padding: .15rem .5rem;
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-full);
}
.cv-badge.cv-badge-outline.cv-badge-danger  { border-color: var(--cv-color-danger);  color: var(--cv-color-danger); }
.cv-badge.cv-badge-outline.cv-badge-warning { border-color: var(--cv-color-warning); color: #b45309; }
.cv-badge.cv-badge-outline.cv-badge-success { border-color: var(--cv-color-success); color: var(--cv-color-success); }
.cv-badge.cv-badge-outline.cv-badge-neutral { border-color: var(--cv-color-border-strong); color: var(--cv-color-text-muted); }

/* Solid modifier — filled pill. Sparingly. */
.cv-badge.cv-badge-solid {
  padding: .2rem .55rem;
  border-radius: var(--cv-radius-full);
  font-weight: 600;
  letter-spacing: .03em;
  font-size: .69rem;
}
.cv-badge.cv-badge-solid::before { display: none; }   /* solid speaks loud enough without the dot */
.cv-badge.cv-badge-solid.cv-badge-danger  { background: var(--cv-color-danger-soft);  color: #991b1b; }
.cv-badge.cv-badge-solid.cv-badge-warning { background: var(--cv-color-warning-soft); color: #c2410c; }
.cv-badge.cv-badge-solid.cv-badge-success { background: var(--cv-color-success-soft); color: #166534; }
.cv-badge.cv-badge-solid.cv-badge-neutral { background: var(--cv-color-neutral-soft); color: var(--cv-color-text-muted); }

/* ── Buttons ─────────────────────────────────────────── */
/* MONOCHROME — no state colours on buttons. Emphasis comes from weight
   (filled vs outline vs ghost), not from hue. The colour budget is spent
   on signals that carry information (severity, alerts, fingerprints) —
   buttons just need to read as clickable.

   Buttons are for ACTION TRIGGERS — submit, save, delete, run, approve,
   reject. Navigation uses .cv-link / .cv-nav-link (see corvus-layout.css).
   For inline / row utility actions, use .cv-icon-btn (below).

   There is NO .cv-btn-destructive variant. Delete actions use
   .cv-btn-secondary or .cv-btn-ghost — the WORD "Delete" + the confirm
   dialog carry the destructive intent. */

.cv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font-size: .85rem;
  font-weight: 500;
  line-height: 1;
  padding: .55rem 1.1rem;
  border-radius: var(--cv-radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}

.cv-btn:focus-visible {
  outline: 2px solid var(--cv-color-focus-ring);
  outline-offset: 2px;
}

.cv-btn:disabled,
.cv-btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
}

.cv-btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.cv-btn-lg { padding: .75rem 1.5rem; font-size: .9375rem; font-weight: 600; }

/* Primary — filled navy. The page's MAIN action. */
.cv-btn-primary {
  background: var(--cv-navy);
  color: var(--cv-white);
  border-color: var(--cv-navy);
}

.cv-btn-primary:hover {
  background: var(--cv-navy-mid);
  border-color: var(--cv-navy-mid);
  color: var(--cv-white);   /* re-assert: beats the global a:hover link colour */
}

/* Secondary — outline. Alternative / Cancel / paired with primary. */
.cv-btn-secondary {
  background: var(--cv-color-bg-card);
  color: var(--cv-color-text);
  border-color: var(--cv-color-border-strong);
}

.cv-btn-secondary:hover {
  background: var(--cv-color-bg-alt);
  border-color: var(--cv-color-text-muted);
  color: var(--cv-color-text);   /* re-assert: beats the global a:hover link colour */
}

/* Ghost — borderless. Tertiary / dismiss / low-emphasis utility. */
.cv-btn-ghost {
  background: transparent;
  color: var(--cv-color-text-muted);
  border-color: transparent;
}

.cv-btn-ghost:hover {
  background: var(--cv-color-bg-alt);
  color: var(--cv-color-text);
}

/* ── Icon button — for inline / row / toolbar utility actions ──── */
/* Square (rounded) button with icon only. Always include aria-label.
   Used for: row edit/delete, "more" menu trigger, toolbar utilities.
   Distinct from .cv-btn so visual context tells the reader "this is an
   inline utility, not a page-level action." */

.cv-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.875rem;          /* 30px — comfortable touch target */
  height: 1.875rem;
  padding: 0;
  border-radius: var(--cv-radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--cv-color-text-muted);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  flex-shrink: 0;
}

.cv-icon-btn:hover {
  background: var(--cv-color-bg-alt);
  color: var(--cv-color-text);
}

.cv-icon-btn:focus-visible {
  outline: 2px solid var(--cv-color-focus-ring);
  outline-offset: 2px;
}

.cv-icon-btn:disabled,
.cv-icon-btn[aria-disabled="true"] {
  opacity: .4;
  cursor: not-allowed;
}

.cv-icon-btn-sm {
  width: 1.5rem;            /* 24px — for very dense rows */
  height: 1.5rem;
  font-size: .85rem;
}

.cv-icon-btn-lg {
  width: 2.25rem;           /* 36px */
  height: 2.25rem;
  font-size: 1.1rem;
}

.cv-icon-btn i { font-size: .95rem; line-height: 1; }
.cv-icon-btn-sm i { font-size: .8rem; }
.cv-icon-btn-lg i { font-size: 1.1rem; }

/* ── Loading state ───────────────────────────────────── */
/* Driven by aria-busy="true" — accessibility state and visual state are
   the same attribute. Always pair with the `disabled` attribute to prevent
   double-submit.

   <button class="cv-btn cv-btn-primary" aria-busy="true" disabled>
     Saving…
   </button>

   <button class="cv-icon-btn" aria-busy="true" disabled aria-label="Saving">
     <i class="bi bi-pencil"></i>
   </button>                                                              */

@keyframes cv-spin { to { transform: rotate(360deg); } }

/* Pill-button loading state — spinner inserted before existing content,
   text stays visible. Triggered by aria-busy OR by HTMX's htmx-request class
   (set on the element while an hx-* request is in flight, incl. via hx-indicator),
   so any cv-btn driving an HTMX call shows a working spinner for free. */
.cv-btn[aria-busy="true"],
.cv-btn.htmx-request {
  cursor: wait;
}

.cv-btn[aria-busy="true"]::before,
.cv-btn.htmx-request::before {
  content: '';
  width: .85rem;
  height: .85rem;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--cv-radius-full);
  animation: cv-spin .6s linear infinite;
  display: inline-block;
  flex-shrink: 0;
  /* opacity matches text-weight visually */
  opacity: .9;
}

/* Icon-button loading state — spinner replaces the icon entirely. */
.cv-icon-btn[aria-busy="true"] {
  cursor: wait;
}

.cv-icon-btn[aria-busy="true"] i {
  visibility: hidden;
}

.cv-icon-btn[aria-busy="true"]::after {
  content: '';
  position: absolute;
  width: .85rem;
  height: .85rem;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--cv-radius-full);
  animation: cv-spin .6s linear infinite;
  opacity: .9;
}

.cv-icon-btn { position: relative; }   /* needed for the ::after positioning */

/* ── Forms ───────────────────────────────────────────── */

.cv-form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--cv-color-text);
  margin-bottom: .35rem;
  letter-spacing: .01em;
}

.cv-form-control,
.cv-form-select {
  display: block;
  width: 100%;
  font-size: .875rem;
  font-family: inherit;
  padding: .5rem .75rem;
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-lg);
  background: var(--cv-color-bg-card);
  color: var(--cv-color-text);
  transition: border-color .12s, box-shadow .12s;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  outline: none;
}

.cv-form-control:focus,
.cv-form-select:focus {
  border-color: var(--cv-color-focus-ring);
  box-shadow: 0 0 0 3px rgba(29,114,232,.1);
}

.cv-form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.25rem;
}

.cv-form-text {
  font-size: .775rem;
  color: var(--cv-color-text-muted);
  margin-top: .3rem;
}

.cv-form-lg .cv-form-control {
  padding: .65rem 1rem;
  font-size: .9375rem;
}

/* ── Checkbox ────────────────────────────────────────── */
/* Custom-styled. The native input is hidden but kept for keyboard +
   screen-reader support. The visible box is the adjacent .cv-checkbox-box
   span; the label text sits in .cv-checkbox-label.

   <label class="cv-checkbox">
     <input type="checkbox">
     <span class="cv-checkbox-box"></span>
     <span class="cv-checkbox-label">Option text</span>
   </label>                                                              */

.cv-checkbox {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .875rem;
  color: var(--cv-color-text);
  user-select: none;
}

.cv-checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1rem;
  height: 1rem;
  margin: 0;
  pointer-events: none;
}

.cv-checkbox-box {
  width: 1rem;
  height: 1rem;
  border: 1.5px solid var(--cv-color-border-strong);
  border-radius: var(--cv-radius-sm);
  background: var(--cv-color-bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .12s, border-color .12s;
  position: relative;
}

.cv-checkbox:hover .cv-checkbox-box {
  border-color: var(--cv-color-text-muted);
}

.cv-checkbox input:focus-visible + .cv-checkbox-box {
  outline: 2px solid var(--cv-color-focus-ring);
  outline-offset: 2px;
}

.cv-checkbox input:checked + .cv-checkbox-box {
  background: var(--cv-navy);
  border-color: var(--cv-navy);
}

.cv-checkbox input:checked + .cv-checkbox-box::after {
  content: '';
  width: .5rem;
  height: .25rem;
  border-left: 1.5px solid var(--cv-white);
  border-bottom: 1.5px solid var(--cv-white);
  transform: rotate(-45deg) translate(1px, -1px);
}

/* Indeterminate — half-checked state (used for "some children selected") */
.cv-checkbox input:indeterminate + .cv-checkbox-box {
  background: var(--cv-navy);
  border-color: var(--cv-navy);
}

.cv-checkbox input:indeterminate + .cv-checkbox-box::after {
  content: '';
  width: .5rem;
  height: 1.5px;
  background: var(--cv-white);
  border: none;
  transform: none;
}

.cv-checkbox input:disabled ~ .cv-checkbox-box,
.cv-checkbox input:disabled ~ .cv-checkbox-label {
  opacity: .45;
  cursor: not-allowed;
}

.cv-checkbox input:disabled ~ * { cursor: not-allowed; }

/* ── Pick tree — cascading multi-select over an area→risk→control hierarchy ──
   The create-assessment scope selector: the summary's area rows made
   selectable. A leading .cv-checkbox sits on each cv-disclosure trigger;
   ticking a parent ticks its descendants (a partially-ticked parent shows the
   checkbox :indeterminate state, above). Nested rows are .cv-pick-row inside a
   .cv-pick-children indent group (the guide line reads the hierarchy). Root
   carries .cv-pick-tree (marker). The cascade logic is wired by the host — no
   selection state lives in the CSS.

     <div class="cv-pick-tree">
       <div class="cv-disclosure ...">            (area row, checkbox in trigger)
         <div class="cv-disclosure-panel">
           <div class="cv-pick-children">
             <label class="cv-checkbox cv-pick-row"> … risk … </label>
             <div class="cv-pick-children">
               <label class="cv-checkbox cv-pick-row"> … control … </label>
             </div>
           </div>
         </div>
       </div>
     </div>                                                                    */
.cv-pick-tree { display: block; }

.cv-pick-children {
  margin-left: 1.25rem;
  padding-left: 1rem;
  border-left: 1px solid var(--cv-color-border);
}

.cv-pick-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem 0;
}

/* ── Radio ───────────────────────────────────────────── */
/* Same pattern as checkbox; rounded box with a centred dot when selected.

   <label class="cv-radio">
     <input type="radio" name="group">
     <span class="cv-radio-box"></span>
     <span class="cv-radio-label">Option text</span>
   </label>                                                              */

.cv-radio {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .875rem;
  color: var(--cv-color-text);
  user-select: none;
}

.cv-radio input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1rem;
  height: 1rem;
  margin: 0;
  pointer-events: none;
}

.cv-radio-box {
  width: 1rem;
  height: 1rem;
  border: 1.5px solid var(--cv-color-border-strong);
  border-radius: var(--cv-radius-full);
  background: var(--cv-color-bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .12s, border-color .12s;
}

.cv-radio:hover .cv-radio-box {
  border-color: var(--cv-color-text-muted);
}

.cv-radio input:focus-visible + .cv-radio-box {
  outline: 2px solid var(--cv-color-focus-ring);
  outline-offset: 2px;
}

.cv-radio input:checked + .cv-radio-box {
  border-color: var(--cv-navy);
  border-width: 1.5px;
}

.cv-radio input:checked + .cv-radio-box::after {
  content: '';
  width: .5rem;
  height: .5rem;
  border-radius: var(--cv-radius-full);
  background: var(--cv-navy);
}

.cv-radio input:disabled ~ .cv-radio-box,
.cv-radio input:disabled ~ .cv-radio-label {
  opacity: .45;
  cursor: not-allowed;
}

.cv-radio input:disabled ~ * { cursor: not-allowed; }

/* ── Switch ──────────────────────────────────────────── */
/* For binary on/off settings where the change is IMMEDIATE (no submit
   button). Use checkbox for "this is part of a form to submit." Use
   switch for "toggle this feature on/off right now."

   <label class="cv-switch">
     <input type="checkbox">
     <span class="cv-switch-track"></span>
     <span class="cv-switch-label">Enable notifications</span>
   </label>                                                              */

.cv-switch {
  display: inline-flex;
  align-items: center;
  gap: .625rem;
  cursor: pointer;
  font-size: .875rem;
  color: var(--cv-color-text);
  user-select: none;
}

.cv-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 2rem;
  height: 1.125rem;
  margin: 0;
  pointer-events: none;
}

.cv-switch-track {
  position: relative;
  display: inline-block;
  width: 2rem;
  height: 1.125rem;
  background: var(--cv-color-border-strong);
  border-radius: var(--cv-radius-full);
  transition: background .15s;
  flex-shrink: 0;
}

.cv-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.125rem - 4px);
  height: calc(1.125rem - 4px);
  background: var(--cv-white);
  border-radius: var(--cv-radius-full);
  transition: transform .18s ease, background .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}

.cv-switch:hover .cv-switch-track {
  background: var(--cv-color-text-muted);
}

.cv-switch input:focus-visible + .cv-switch-track {
  outline: 2px solid var(--cv-color-focus-ring);
  outline-offset: 2px;
}

.cv-switch input:checked + .cv-switch-track {
  background: var(--cv-navy);
}

.cv-switch input:checked + .cv-switch-track::after {
  transform: translateX(calc(2rem - 1.125rem));
}

.cv-switch:hover input:checked + .cv-switch-track {
  background: var(--cv-navy-mid);
}

.cv-switch input:disabled ~ .cv-switch-track,
.cv-switch input:disabled ~ .cv-switch-label {
  opacity: .45;
  cursor: not-allowed;
}

.cv-switch input:disabled ~ * { cursor: not-allowed; }

/* ── Form field wrapper + validation ─────────────────── */
/* Groups label + control + helper/error in one consistent block.

   Standard markup:
       <div class="cv-form-field">
         <label class="cv-form-label" for="…">
           Field name
           <span class="cv-form-required" aria-hidden="true">*</span>
         </label>
         <input class="cv-form-control" id="…" type="text"
                aria-describedby="…-helper">
         <div class="cv-form-message" id="…-helper">Helper text.</div>
       </div>

   Error state — add .cv-is-invalid to the control, swap helper for error:
         <input class="cv-form-control cv-is-invalid" aria-invalid="true"
                aria-describedby="…-error">
         <div class="cv-form-message cv-form-message-error" id="…-error">
           <i class="bi bi-exclamation-circle"></i>
           <span>Risk name is required.</span>
         </div>                                                            */

.cv-form-field {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1rem;
}

.cv-form-field:last-child { margin-bottom: 0; }

.cv-form-required {
  color: var(--cv-color-danger);
  margin-left: .15rem;
  font-weight: 600;
}

/* Helper / error message below the control */
.cv-form-message {
  display: flex;
  align-items: flex-start;
  gap: .3125rem;
  font-size: .72rem;
  color: var(--cv-color-text-muted);
  line-height: 1.4;
  margin-top: .15rem;
}

.cv-form-message i {
  font-size: .85rem;
  line-height: 1.2;
  flex-shrink: 0;
}

.cv-form-message-error {
  color: var(--cv-color-danger);
}

/* Invalid state — applies to text input / select / textarea */
.cv-form-control.cv-is-invalid,
.cv-form-select.cv-is-invalid {
  border-color: var(--cv-color-danger);
  background-color: rgba(220, 38, 38, .025);
}

.cv-form-control.cv-is-invalid:focus,
.cv-form-select.cv-is-invalid:focus {
  border-color: var(--cv-color-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

/* Optional success / valid state — same pattern in green. Rare but useful
   for fields that need explicit confirmation (e.g. password strength). */
.cv-form-control.cv-is-valid,
.cv-form-select.cv-is-valid {
  border-color: var(--cv-color-success);
}

.cv-form-control.cv-is-valid:focus,
.cv-form-select.cv-is-valid:focus {
  border-color: var(--cv-color-success);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, .12);
}

/* ── Tables ──────────────────────────────────────────── */

.cv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.cv-table thead th {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cv-color-text-muted);
  padding: .6rem .875rem;
  border-bottom: 2px solid var(--cv-color-border);
  text-align: left;
  white-space: nowrap;
}

.cv-table tbody td {
  padding: .75rem .875rem;
  border-bottom: 1px solid var(--cv-color-border);
  vertical-align: middle;
}

.cv-table tbody tr:last-child td { border-bottom: none; }
.cv-table tbody tr:hover td      { background: var(--cv-color-bg-alt); }

/* ── Breadcrumbs ─────────────────────────────────────── */

.cv-breadcrumb {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  color: var(--cv-color-text-muted);
  flex-wrap: wrap;
}

.cv-breadcrumb a         { color: var(--cv-color-text-link); }
.cv-breadcrumb a:hover   { color: var(--cv-color-text-link-hover); }
.cv-breadcrumb-sep       { color: var(--cv-color-border-strong); user-select: none; }
.cv-breadcrumb-active    { color: var(--cv-color-text-muted); }

/* ── Progress bars ───────────────────────────────────── */

.cv-progress {
  height: .4rem;
  background: var(--cv-color-border);
  border-radius: var(--cv-radius-full);
  overflow: hidden;
}

.cv-progress-bar {
  height: 100%;
  border-radius: var(--cv-radius-full);
  transition: width .4s ease;
}

/* ── Segmented progress bar — for activity widget stages ─────────
   One segment per workflow stage. Each segment takes a colour state
   matching the locked vocabulary:
       (no class)               → not started — grey
       .cv-progress-segment-in-progress → active — blue
       .cv-progress-segment-done        → complete — green
       .cv-progress-segment-overdue     → behind — amber
       .cv-progress-segment-failed      → rejected/blocked — red

   Each segment should carry a `title` attribute showing the stage name +
   owner so hover reveals detail without consuming tile space. */

.cv-progress-segmented {
  display: flex;
  height: .5rem;
  border-radius: var(--cv-radius-full);
  overflow: hidden;
  gap: 1px;
  background: var(--cv-color-border);
}

.cv-progress-segment {
  flex: 1;
  height: 100%;
  background: var(--cv-color-neutral);
  opacity: .25;                     /* default = not started — muted grey */
  transition: background .2s, opacity .2s;
  cursor: help;                     /* hint that hover reveals title */
}

.cv-progress-segment-in-progress { background: var(--cv-color-primary); opacity: 1; }
.cv-progress-segment-done        { background: var(--cv-color-success); opacity: 1; }
.cv-progress-segment-overdue     { background: var(--cv-color-warning); opacity: 1; }
.cv-progress-segment-failed      { background: var(--cv-color-danger);  opacity: 1; }

/* ── Empty states ────────────────────────────────────── */

.cv-empty {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--cv-color-text-muted);
}

.cv-empty-icon {
  font-size: 2.25rem;
  margin-bottom: .85rem;
  display: block;
  opacity: .2;
}

.cv-empty h5 {
  font-family: 'DM Sans', sans-serif;
  font-size: .9375rem;
  font-weight: 600;
  color: #334155;
  margin: 0 0 .4rem;
}

.cv-empty p {
  font-size: .85rem;
  color: var(--cv-color-text-muted);
  max-width: 28ch;
  margin: 0 auto;
  line-height: 1.6;
}

.cv-empty-positive .cv-empty-icon { opacity: .4; color: var(--cv-color-success); }
.cv-empty-prompt   .cv-empty-icon { opacity: .25; color: var(--cv-color-info); }

/* ── Alerts ──────────────────────────────────────────── */
/* Page-level messages. Variants follow the same semantic vocabulary as badges. */

.cv-alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  border-radius: var(--cv-radius-lg);
  font-size: .875rem;
  line-height: 1.5;
  border: 1px solid transparent;
}

.cv-alert-danger  { background: var(--cv-color-danger-soft);  color: #991b1b; border-color: #fecaca; }
.cv-alert-success { background: var(--cv-color-success-soft); color: #166534; border-color: #bbf7d0; }
.cv-alert-warning { background: #fef9c3;                      color: #854d0e; border-color: #fde68a; }

/* `info` alerts are now a neutral surface with a small blue accent stripe —
   blue is the brand colour, not a state. Use sparingly; most "info" content
   doesn't need an alert at all. */
.cv-alert-info    {
  background: var(--cv-color-neutral-soft);
  color: var(--cv-color-text);
  border-color: var(--cv-color-border);
  border-left: 3px solid var(--cv-color-primary);
}

.cv-alert i {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: .1rem;
}

/* ── Nav tile (programme areas) ──────────────────────── */

.cv-nav-tile {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1rem;
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-lg);
  background: var(--cv-color-bg-card);
  color: var(--cv-color-text);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  box-shadow: var(--cv-shadow);
  transition: box-shadow .18s, transform .18s, border-color .15s, background .15s, color .15s;
  min-height: 3.5rem;
}

.cv-nav-tile:hover {
  border-color: var(--cv-color-primary);
  background: var(--cv-color-primary-soft);
  color: var(--cv-color-primary);
  box-shadow: var(--cv-shadow-md);
  transform: translateY(-1px);
}

.cv-nav-tile i               { font-size: 1rem; flex-shrink: 0; transition: transform .15s; }
.cv-nav-tile:hover i         { transform: scale(1.1); }

/* ── Inline disclosure ───────────────────────────────── */
/* Row-level expandable detail. Chevron is its own click target — clicking
   it toggles a panel beneath the row WITHOUT navigating. The row body
   remains clickable for navigating to the detail page.

   Markup:
       <div class="cv-disclosure">
         <div class="cv-disclosure-trigger">
           <button class="cv-icon-btn cv-icon-btn-sm cv-disclosure-chevron"
                   aria-expanded="false"
                   aria-controls="related-r042"
                   aria-label="Show related items">
             <i class="bi bi-chevron-right"></i>
           </button>
           <a class="cv-disclosure-main" href="/risks/R-042/">
             … row content …
           </a>
         </div>
         <div class="cv-disclosure-panel" id="related-r042" hidden>
           … related content …
         </div>
       </div>

   HTMX integration — server returns the panel content on first expand:
       <button … hx-get="/risks/R-042/related/"
                 hx-target="#related-r042"
                 hx-trigger="click once">

   The JS helper toggles aria-expanded + hidden state. With HTMX's
   "click once" trigger, content fetches the first time; subsequent
   clicks just toggle visibility. */

.cv-disclosure {
  border-bottom: 1px solid var(--cv-color-border);
}

.cv-disclosure:last-child {
  border-bottom: none;
}

.cv-disclosure-trigger {
  display: flex;
  align-items: center;
  gap: .25rem;
  padding-left: .25rem;
}

/* The chevron — uses .cv-icon-btn styling; this class adds the rotation
   on expand. Use alongside .cv-icon-btn .cv-icon-btn-sm. */
.cv-disclosure-chevron i {
  transition: transform .2s ease;
}

.cv-disclosure-chevron[aria-expanded="true"] i {
  transform: rotate(90deg);
}

/* The clickable row body — navigates to detail page on click */
.cv-disclosure-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .625rem .75rem;
  color: inherit;
  text-decoration: none;
  border-radius: var(--cv-radius-md);
  transition: background .12s;
  min-width: 0;
}

.cv-disclosure-main:hover {
  background: var(--cv-color-bg-alt);
}

/* The expanding panel — indented under the row, distinguished background */
.cv-disclosure-panel {
  padding: .75rem 1rem .875rem 2.5rem;
  background: var(--cv-color-bg-alt);
  border-top: 1px solid var(--cv-color-border);
}

.cv-disclosure-panel[hidden] {
  display: none;
}

/* Common content inside the panel — a small section label, then content */
.cv-disclosure-panel-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cv-color-text-muted);
  margin-bottom: .5rem;
}

/* Left severity/status bar — the row's headline signal, read before any text.
   Risk registers key it to severity (critical/high/medium/low); other entity
   registers (processes, systems, controls) key it to status via the semantic
   variants. Mirrors the cv-sev-badge colour mapping exactly. Colour lives in
   the bar ONLY — never a row-background tint (keeps the list calm and the
   signal unambiguous). */
.cv-disclosure-critical { border-left: 3px solid var(--cv-color-danger); }
.cv-disclosure-high     { border-left: 3px solid var(--cv-color-warning); }
.cv-disclosure-medium   { border-left: 3px solid var(--cv-color-warning); }
.cv-disclosure-low      { border-left: 3px solid var(--cv-color-success); }
.cv-disclosure-neutral  { border-left: 3px solid var(--cv-color-border-strong); }

/* The upstream-component reference (the system / process / location the entity
   hangs off) — muted, icon-led, never wraps. The "useful context" that replaces
   a prose description in the register row. */
.cv-disclosure-upstream {
  font-size: .8125rem;
  color: var(--cv-color-text-muted);
  white-space: nowrap;
}

/* Fixed-width slot for the at-a-glance control-health bar in the row — holds a
   cv-readiness-bar (proportion across effective/degraded/failed/untested). Width
   lives here so the segment widths stay pure data (inline flex). */
.cv-disclosure-health {
  width: 7rem;
  flex-shrink: 0;
}

/* The headline metric on the right (residual score, count) — mono, right-aligned,
   coloured by the cv-text-{state} utility, fixed width so columns line up. */
.cv-disclosure-metric {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .875rem;
  font-weight: 600;
  min-width: 2rem;
  text-align: right;
}

/* ── Register group + labelled column strip ───────────────────────────────
   A titled band of disclosure rows (Governance / Operational on the control
   register; an Annex A theme on the ISO-coverage register). The column-label
   strip labels the row slots ONCE at the group head, so the rows themselves
   stay label-free and dense. Fixed slot widths line the labels up with the
   values below them. */
.cv-register-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.cv-register-colstrip {
  display: flex;
  align-items: center;
  gap: 1rem;
  /* Left pad = the row's exact title offset so the header columns line up with
     the row slots: .25 (trigger pad) + 1.5 (chevron) + .25 (trigger gap)
     + .75 (disclosure-main pad) = 2.75rem. Right pad + gap mirror the row too. */
  padding: .5rem .75rem .5rem 2.75rem;
  border-bottom: 1px solid var(--cv-color-border);
}
.cv-col-iso    { width: 8rem;   flex-shrink: 0; }
.cv-col-risk   { width: 9rem;   flex-shrink: 0; text-align: right; }
.cv-col-state  { width: 8.5rem; flex-shrink: 0; text-align: right; }
.cv-col-cover  { width: 11rem;  flex-shrink: 0; }

/* Fixed-width row slots, aligned under the column strip above. */
.cv-iso-ref    { width: 8rem;   flex-shrink: 0; }
.cv-state-slot { width: 8.5rem; flex-shrink: 0; display: flex; justify-content: flex-end; }
.cv-cov-health { width: 11rem;  flex-shrink: 0; }

/* Specificity signal — the "+n" overflow on the ISO-ref chip: how many
   requirements beyond the primary one this single control satisfies. A specific
   control maps to ~one requirement; "+n" means it is more generic than the
   requirements it claims to satisfy. Colour follows the band via cv-text-*
   (2–3 reqs → warning, 4+ → danger); absent when the control is specific. */
.cv-spec-more { font-weight: 600; margin-left: .25rem; }

/* Risk-coverage chip — the labelled replacement for the bare metric number.
   "3 risks" when mapped; "No risk mapped" when hanging. Muted by default
   (informational, e.g. a governance control); the template adds cv-text-warning
   for a hanging OPERATIONAL control (a risk-identification red flag). The icon
   is currentColor, so it follows the text colour. */
.cv-risk-cover {
  width: 9rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .375rem;
  font-size: .8125rem;
  white-space: nowrap;
  color: var(--cv-color-text-muted);
}

/* ── Toast / Snackbar ────────────────────────────────── */
/* Transient feedback after async actions ("Saved", "Evidence uploaded").
   Different from .cv-alert (page-level, persistent, demands attention).

   The container is created on demand by the cvToast() JS helper at the
   bottom of visual_inventory.html. Markup spawned per toast:

       <div class="cv-toast cv-toast-success" role="status">
         <i class="bi bi-check-circle cv-toast-icon"></i>
         <div class="cv-toast-message">Engagement saved.</div>
         <button class="cv-icon-btn cv-icon-btn-sm" aria-label="Dismiss">
           <i class="bi bi-x-lg"></i>
         </button>
       </div>

   Variants follow the colour vocabulary — neutral surface + coloured
   icon + coloured left border. NEVER solid-filled toasts (they'd read
   as buttons). */

.cv-toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column-reverse;       /* newest toast at the bottom (closest to user) */
  gap: .625rem;
  pointer-events: none;                 /* container doesn't intercept clicks */
  max-width: calc(100vw - 3rem);
  width: 22rem;
}

.cv-toast {
  pointer-events: auto;                 /* but individual toasts do */
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  padding: .75rem .875rem;
  background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border);
  border-left: 3px solid var(--cv-color-text-muted);
  border-radius: var(--cv-radius-lg);
  box-shadow: 0 6px 20px rgba(15,23,42,.12), 0 2px 4px rgba(15,23,42,.06);
  font-size: .82rem;
  line-height: 1.4;
  color: var(--cv-color-text);
  /* Entry animation */
  animation: cv-toast-in .22s cubic-bezier(.16, 1, .3, 1);
}

/* Exit state — applied by JS just before removal */
.cv-toast.cv-toast-leaving {
  animation: cv-toast-out .18s ease-in forwards;
}

@keyframes cv-toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes cv-toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* Variants — left border + icon colour */
.cv-toast-success { border-left-color: var(--cv-color-success); }
.cv-toast-success .cv-toast-icon { color: var(--cv-color-success); }

.cv-toast-warning { border-left-color: var(--cv-color-warning); }
.cv-toast-warning .cv-toast-icon { color: var(--cv-color-warning); }

.cv-toast-danger  { border-left-color: var(--cv-color-danger); }
.cv-toast-danger  .cv-toast-icon { color: var(--cv-color-danger); }

.cv-toast-info    { border-left-color: var(--cv-color-primary); }
.cv-toast-info    .cv-toast-icon { color: var(--cv-color-primary); }

.cv-toast-icon {
  font-size: 1rem;
  line-height: 1.3;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--cv-color-text-muted);
}

.cv-toast-message {
  flex: 1;
  min-width: 0;
}

.cv-toast-message strong {
  font-weight: 600;
  color: var(--cv-color-text);
}

/* Optional action button inline in the toast (e.g. "Undo") */
.cv-toast-action {
  background: transparent;
  border: none;
  padding: 0 .25rem;
  margin-left: .25rem;
  font: inherit;
  font-weight: 500;
  color: var(--cv-color-text-link);
  cursor: pointer;
  border-radius: var(--cv-radius-sm);
}

.cv-toast-action:hover {
  color: var(--cv-color-text-link-hover);
  text-decoration: underline;
}

.cv-toast-action:focus-visible {
  outline: 2px solid var(--cv-color-focus-ring);
  outline-offset: 2px;
}

/* ── Modal / Dialog ──────────────────────────────────── */
/* Built on the native HTML <dialog> element via .showModal() — which gives
   us a free focus trap, native Escape-to-close, body scroll lock, and the
   ::backdrop pseudo-element. We just style and wire open/close handlers.

   Markup:
       <dialog class="cv-modal" id="my-modal">
         <header class="cv-modal-header">
           <h2 class="cv-modal-title">Title</h2>
           <button class="cv-icon-btn cv-tooltip" data-tooltip="Close"
                   aria-label="Close" data-cv-modal-close>
             <i class="bi bi-x-lg"></i>
           </button>
         </header>
         <div class="cv-modal-body">…</div>
         <footer class="cv-modal-footer">
           <button class="cv-btn cv-btn-ghost" data-cv-modal-close>Cancel</button>
           <button class="cv-btn cv-btn-primary">Confirm</button>
         </footer>
       </dialog>

   Trigger:
       <button data-cv-modal-open="my-modal">Open</button>

   Size variants:
       .cv-modal-sm   ~24rem — confirm dialogs
       (default)      ~32rem — short forms
       .cv-modal-lg   ~48rem — multi-section forms / wider content    */

.cv-modal {
  /* Reset the dialog defaults */
  padding: 0;
  border: none;
  border-radius: var(--cv-radius-xl);
  background: var(--cv-color-bg-card);
  color: var(--cv-color-text);
  box-shadow: 0 20px 50px rgba(15,23,42,.25), 0 6px 12px rgba(15,23,42,.12);
  overflow: hidden;

  /* Sizing */
  width: 32rem;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 4rem);

  /* When open, become a flex column so header / scrollable body / footer
     layout correctly. The display change is necessary because <dialog>
     uses display: block by default which doesn't constrain body scroll. */
}

.cv-modal[open] {
  display: flex;
  flex-direction: column;
  animation: cv-modal-in .15s cubic-bezier(.16, 1, .3, 1);
}

.cv-modal::backdrop {
  background: rgba(15, 23, 42, .45);
  animation: cv-modal-backdrop-in .15s ease-out;
}

@keyframes cv-modal-in {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

@keyframes cv-modal-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Size modifiers */
.cv-modal.cv-modal-sm { width: 24rem; }
.cv-modal.cv-modal-lg { width: 48rem; }

/* Anatomy */
.cv-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem 1rem 1.5rem;
  border-bottom: 1px solid var(--cv-color-border);
  flex-shrink: 0;
}

.cv-modal-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: -.01em;
  color: var(--cv-color-text);
  margin: 0;
  line-height: 1.3;
}

.cv-modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  line-height: 1.55;
}

.cv-modal-body p { margin-bottom: .75rem; }
.cv-modal-body p:last-child { margin-bottom: 0; }

.cv-modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--cv-color-border);
  background: var(--cv-color-bg-alt);
  flex-shrink: 0;
}

/* Optional helper for left-aligned info inside footer (e.g. "Step 2 of 3") */
.cv-modal-footer-info {
  margin-right: auto;
  font-size: .78rem;
  color: var(--cv-color-text-muted);
}

/* ── Slide-over drawer (cv-drawer) ──────────────────────────────────────────
   A RIGHT-ANCHORED, FULL-HEIGHT <dialog> for browse-and-pick / side-panel
   workflows (first use: "Add activity to a phase" library browser on the
   Delivery Plan). A drawer is a persistent-feeling edge panel; a modal is a
   centred interruption — distinct components, but the drawer reuses the same
   native <dialog> mechanics (focus-trap, Esc, inert background, ::backdrop).
   Driven by corvus-drawer.js via data-cv-drawer-open / data-cv-drawer-close.

     <button data-cv-drawer-open="my-drawer">Open</button>
     <dialog class="cv-drawer" id="my-drawer">
       <header class="cv-drawer-header">
         <h2 class="cv-drawer-title">Title</h2>
         <button class="cv-icon-btn cv-icon-btn-sm" data-cv-drawer-close
                 aria-label="Close">…</button>
       </header>
       <div class="cv-drawer-body">…</div>
       <footer class="cv-drawer-footer">…</footer>
     </dialog>                                                                  */
.cv-drawer {
  padding: 0;
  border: none;
  border-radius: 0;
  background: var(--cv-color-bg-card);
  color: var(--cv-color-text);
  box-shadow: -16px 0 40px rgba(15, 23, 42, .18);
  width: 32rem;
  max-width: calc(100vw - 3rem);
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  inset: 0 0 0 auto;                 /* pin to the right edge, full height */
}

.cv-drawer[open] {
  display: flex;
  flex-direction: column;
  animation: cv-drawer-in .2s cubic-bezier(.16, 1, .3, 1);
}

.cv-drawer::backdrop {
  background: rgba(15, 23, 42, .45);
  animation: cv-modal-backdrop-in .15s ease-out;   /* shared with cv-modal */
}

@keyframes cv-drawer-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* Anatomy — mirrors the modal so headers/footers read consistently. */
.cv-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem 1rem 1.5rem;
  border-bottom: 1px solid var(--cv-color-border);
  flex-shrink: 0;
}

.cv-drawer-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: -.01em;
  color: var(--cv-color-text);
  margin: 0;
  line-height: 1.3;
}

.cv-drawer-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  line-height: 1.55;
}

.cv-drawer-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--cv-color-border);
  background: var(--cv-color-bg-alt);
  flex-shrink: 0;
}

.cv-drawer-footer-info {
  margin-right: auto;
  font-size: .78rem;
  color: var(--cv-color-text-muted);
}

/* A browse-and-pick list row inside a drawer body: catalogue item + action. */
.cv-drawer-pick {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--cv-color-border);
}
.cv-drawer-pick:last-child { border-bottom: 0; }

/* ── AI advice draft (cv-advice) ────────────────────────────────────────────
   A grounded AI DRAFT for a written-justification field, shown inside a
   cv-drawer body. Reuses the drawer verbatim (dialog / header / body / footer,
   corvus-drawer.js, focus-trap, Esc, backdrop); only the body content is new.

   Anatomy (all inside .cv-drawer-body.cv-advice):
     .cv-advice-intro          honest framing line (advisory; edit-and-own)
     .cv-advice-grounding      the fact-trail — WHY the draft says what it says,
       .cv-advice-grounding-list   traceable to the client's own records
     .cv-advice-draft          the proposed prose (read-only; Copy / Insert)
       .cv-advice-draft-head   label + "Draft" badge
       .cv-advice-draft-body   the wording itself
     .cv-advice-validated      "references checked against your catalogue" trust line
     .cv-advice-btn            the trigger beside the field (marker on cv-btn)

   Conveys: ONE grounded prose draft the user copies into a free-text field
   (distinct from cv-ai-suggest, which offers a LIST of pickable items).
   ─────────────────────────────────────────────────────────────────────────── */
.cv-advice-btn .lucide { color: var(--cv-color-primary); }

.cv-advice-intro {
  font-size: .82rem;
  color: var(--cv-color-text-muted);
  line-height: 1.55;
  margin: 0 0 1.25rem;
}

.cv-advice-grounding {
  background: var(--cv-color-neutral-soft);
  border-left: 3px solid var(--cv-color-primary);
  border-radius: var(--cv-radius-md);
  padding: .85rem 1rem;
  margin-bottom: 1.25rem;
}
.cv-advice-grounding-list {
  list-style: none;
  margin: .5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.cv-advice-grounding-list li {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  font-size: .84rem;
  line-height: 1.5;
  color: var(--cv-color-text);
}
.cv-advice-grounding-list .lucide {
  color: var(--cv-color-text-muted);
  margin-top: .15rem;
  flex-shrink: 0;
}

.cv-advice-draft {
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-md);
  background: var(--cv-color-bg-card);
  overflow: hidden;
}
.cv-advice-draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--cv-color-border);
  background: var(--cv-color-bg-alt);
}
.cv-advice-draft-body {
  padding: 1rem;
  font-size: .92rem;
  line-height: 1.6;
  color: var(--cv-color-text);
}
.cv-advice-draft-body p { margin: 0 0 .8rem; }
.cv-advice-draft-body p:last-child { margin-bottom: 0; }

.cv-advice-validated {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .76rem;
  color: var(--cv-color-text-muted);
  margin: .85rem 0 0;
}
.cv-advice-validated .lucide { color: var(--cv-color-success); }

/* ── Tooltip ─────────────────────────────────────────── */
/* CSS-only tooltip — no JS dependency. Activates on hover, on keyboard
   focus, and on focus-within (so a tooltip on a wrapper element still
   appears when its child receives focus).

   Usage:
       <button class="cv-icon-btn cv-tooltip" data-tooltip="Edit">
         <i class="bi bi-pencil"></i>
       </button>

   Placement modifiers:
       (none)              → tooltip appears above (default)
       .cv-tooltip-bottom  → below
       .cv-tooltip-left    → to the left
       .cv-tooltip-right   → to the right

   The tooltip text comes from the data-tooltip attribute. Long text
   wraps at max-width 16rem. For interactive popovers (with links inside),
   use a popover component (TBC — different concept). */

.cv-tooltip {
  position: relative;
}

.cv-tooltip[data-tooltip]::after,
.cv-tooltip[data-tooltip]::before {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  transition-delay: .25s;
  z-index: 100;
}

/* The tooltip body */
.cv-tooltip[data-tooltip]::after {
  content: attr(data-tooltip);
  background: var(--cv-navy);
  color: var(--cv-text-on-dark);
  padding: .375rem .625rem;
  border-radius: var(--cv-radius-md);
  font-size: .72rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  white-space: normal;
  text-align: center;
  max-width: 16rem;
  width: max-content;
  box-shadow: var(--cv-shadow-md);
}

/* The arrow — small triangle pointing at the trigger */
.cv-tooltip[data-tooltip]::before {
  content: '';
  border: .3125rem solid transparent;
}

/* Default placement: above */
.cv-tooltip[data-tooltip]::after {
  bottom: calc(100% + .5rem);
  left: 50%;
  transform: translateX(-50%);
}
.cv-tooltip[data-tooltip]::before {
  bottom: calc(100% + .1875rem);
  left: 50%;
  transform: translateX(-50%);
  border-top-color: var(--cv-navy);
}

/* Below */
.cv-tooltip.cv-tooltip-bottom[data-tooltip]::after {
  bottom: auto;
  top: calc(100% + .5rem);
}
.cv-tooltip.cv-tooltip-bottom[data-tooltip]::before {
  bottom: auto;
  top: calc(100% + .1875rem);
  border-top-color: transparent;
  border-bottom-color: var(--cv-navy);
}

/* Left */
.cv-tooltip.cv-tooltip-left[data-tooltip]::after {
  bottom: auto;
  top: 50%;
  left: auto;
  right: calc(100% + .5rem);
  transform: translateY(-50%);
}
.cv-tooltip.cv-tooltip-left[data-tooltip]::before {
  bottom: auto;
  top: 50%;
  left: auto;
  right: calc(100% + .1875rem);
  transform: translateY(-50%);
  border-top-color: transparent;
  border-left-color: var(--cv-navy);
}

/* Right */
.cv-tooltip.cv-tooltip-right[data-tooltip]::after {
  bottom: auto;
  top: 50%;
  left: calc(100% + .5rem);
  transform: translateY(-50%);
}
.cv-tooltip.cv-tooltip-right[data-tooltip]::before {
  bottom: auto;
  top: 50%;
  left: calc(100% + .1875rem);
  transform: translateY(-50%);
  border-top-color: transparent;
  border-right-color: var(--cv-navy);
}

/* Show on hover, focus, focus-within */
.cv-tooltip[data-tooltip]:hover::after,
.cv-tooltip[data-tooltip]:hover::before,
.cv-tooltip[data-tooltip]:focus::after,
.cv-tooltip[data-tooltip]:focus::before,
.cv-tooltip[data-tooltip]:focus-within::after,
.cv-tooltip[data-tooltip]:focus-within::before {
  opacity: 1;
}

/* ── Tabs ────────────────────────────────────────────── */
/* Underline-style tabs. Visual state is driven by [aria-selected="true"]
   on the tab button — so the rendering and the accessibility state can
   never diverge. Pair with the tabs JS helper (see visual_inventory.html
   bottom) for click + keyboard activation.

   Markup:
       <div class="cv-tabs">
         <div class="cv-tablist" role="tablist">
           <button class="cv-tab" role="tab" id="t-overview"
                   aria-controls="p-overview" aria-selected="true" tabindex="0">
             Overview
           </button>
           <button class="cv-tab" role="tab" id="t-pm"
                   aria-controls="p-pm" aria-selected="false" tabindex="-1">
             Project Management
             <span class="cv-tab-count">12</span>
           </button>
         </div>
         <div class="cv-tabpanel" role="tabpanel" id="p-overview"
              aria-labelledby="t-overview">…</div>
         <div class="cv-tabpanel" role="tabpanel" id="p-pm"
              aria-labelledby="t-pm" hidden>…</div>
       </div>                                                              */

.cv-tabs {
  display: flex;
  flex-direction: column;
}

.cv-tablist {
  display: flex;
  border-bottom: 1px solid var(--cv-color-border);
  gap: 0;
}

.cv-tab {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 500;
  color: var(--cv-color-text-muted);
  padding: .75rem 1.25rem;
  margin-bottom: -1px;                /* overlap parent border so active underline doesn't double */
  border-bottom: 2px solid transparent;
  transition: color .12s, border-color .12s;
  white-space: nowrap;
}

.cv-tab:hover {
  color: var(--cv-color-text);
}

.cv-tab:focus-visible {
  outline: 2px solid var(--cv-color-focus-ring);
  outline-offset: -2px;
}

.cv-tab[aria-selected="true"] {
  color: var(--cv-color-text);
  border-bottom-color: var(--cv-navy);
}

.cv-tab[disabled],
.cv-tab[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
}

/* Tab icon — smaller, muted unless tab is active */
.cv-tab i {
  font-size: .95rem;
  line-height: 1;
}

/* Optional count badge inline in tab */
.cv-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.125rem;
  padding: 0 .35rem;
  border-radius: var(--cv-radius-full);
  background: var(--cv-color-bg-alt);
  color: var(--cv-color-text-muted);
  font-size: .65rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.cv-tab[aria-selected="true"] .cv-tab-count {
  background: var(--cv-navy);
  color: var(--cv-text-on-dark);
}

/* Tabpanel — content area for each tab. Inactive panels use [hidden]. */
.cv-tabpanel {
  padding: 1.25rem 0;
}

.cv-tabpanel[hidden] {
  display: none;
}

.cv-tabpanel:focus-visible {
  outline: 2px solid var(--cv-color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--cv-radius-md);
}

/* ── Stepper (process / workflow stages) ─────────────── */
/* Horizontal stepper for showing process progress — used inside the
   activity tile to display the stages of a workflow. Numbered circles
   connected by a line; current step has stronger weight.

   Markup:
       <ol class="cv-stepper">
         <li class="cv-stepper-step cv-stepper-step-done">
           <span class="cv-stepper-marker">✓</span>
           <span class="cv-stepper-label">Scope</span>
         </li>
         <li class="cv-stepper-step cv-stepper-step-current">
           <span class="cv-stepper-marker">3</span>
           <span class="cv-stepper-label">Evidence</span>
         </li>
         <li class="cv-stepper-step">  <!-- todo, default -->
           <span class="cv-stepper-marker">4</span>
           <span class="cv-stepper-label">Test</span>
         </li>
       </ol>                                                                  */

.cv-stepper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
}

.cv-stepper-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .375rem;
  position: relative;
  min-width: 0;
}

/* The connecting line — drawn as a ::after pseudo on each step except the
   last, anchored to the right of the marker */
.cv-stepper-step::after {
  content: '';
  position: absolute;
  top: .6875rem;            /* aligns to the centre of the 1.375rem marker */
  left: calc(50% + .8rem);  /* starts at marker edge */
  right: calc(-50% + .8rem);
  height: 1px;
  background: var(--cv-color-border);
}

.cv-stepper-step:last-child::after { display: none; }

/* Done step — line to the right is filled */
.cv-stepper-step-done::after { background: var(--cv-color-success); }

.cv-stepper-marker {
  width: 1.375rem;
  height: 1.375rem;
  border-radius: var(--cv-radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .6875rem;
  font-weight: 600;
  background: var(--cv-color-bg-card);
  border: 1.5px solid var(--cv-color-border);
  color: var(--cv-color-text-muted);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.cv-stepper-step-done .cv-stepper-marker {
  background: var(--cv-color-success);
  border-color: var(--cv-color-success);
  color: var(--cv-white);
}

.cv-stepper-step-current .cv-stepper-marker {
  background: var(--cv-color-bg-card);
  border-color: var(--cv-color-primary);
  border-width: 2px;
  color: var(--cv-color-primary);
}

.cv-stepper-label {
  font-size: .68rem;
  color: var(--cv-color-text-muted);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cv-stepper-step-current .cv-stepper-label {
  color: var(--cv-color-text);
  font-weight: 500;
}

.cv-stepper-step-done .cv-stepper-label {
  color: var(--cv-color-text-muted);
}

/* ── Donut / ring ────────────────────────────────────── */

.cv-ring-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cv-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ── Avatar ──────────────────────────────────────────── */
/* NOT for representing individual people. Two-letter initials collide
   ("DS" = David Sherratt AND Doug Smith) and are useless identifiers.
   For people, use a person icon + "I. Surname" format instead — see the
   work_item_list widget's assignee meta-item.

   This class is retained for non-person uses: organisation logos,
   anonymous group indicators, "+3 others" counters, etc. */

.cv-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--cv-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
  background: var(--cv-navy);
  color: var(--cv-color-text-on-dark);
  letter-spacing: .05em;
}

/* ── Activity timeline ───────────────────────────────────
   Chronological history: date · event · person. A vertical list
   with a left date column, a connecting line + dot, and the event
   text + person on the right. Reused by risk lifecycle, and later
   incident / CAPA / audit history. Tokens only — no inline colour. */

.cv-timeline {
  display: flex;
  flex-direction: column;
}

.cv-timeline-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1rem;
  position: relative;
  padding: 0 0 1.25rem 1.25rem;
}

/* Connecting line down the left of the event column */
.cv-timeline-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: .5rem;
  bottom: 0;
  width: 2px;
  background: var(--cv-color-border);
}

/* Dot on the line, aligned to the first line of text */
.cv-timeline-row::after {
  content: "";
  position: absolute;
  left: -3px;
  top: .35rem;
  width: 8px;
  height: 8px;
  border-radius: var(--cv-radius-full);
  background: var(--cv-color-bg-card);
  border: 2px solid var(--cv-color-border-strong);
}

.cv-timeline-row:last-child {
  padding-bottom: 0;
}

.cv-timeline-row:last-child::before {
  bottom: auto;
  height: .5rem;
}

.cv-timeline-date {
  font-size: .8125rem;
  color: var(--cv-color-text-muted);
  white-space: nowrap;
  line-height: 1.4;
}

.cv-timeline-event {
  font-size: .875rem;
  color: var(--cv-color-text);
  line-height: 1.45;
}

.cv-timeline-person {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-top: .25rem;
  font-size: .8125rem;
  color: var(--cv-color-text-muted);
}

/* ── Page fade-up animation — REMOVED ────────────────────
   `.cv-card { animation: cv-up .22s ease both }` (from { opacity:0 }) left cards
   pinned transparent whenever the animation didn't advance on first paint (busy
   main thread during load, bfcache restore, HTMX swap) — the long-standing
   "divs greyed-out until you hover/click" bug, since `both` holds the backwards
   fill. Resting visibility must never depend on an animation completing. The
   cv-stagger-* classes it relied on were never used in any template. */

/* ── Inbox rows: notifications & message threads ─────── */
/* Flat list rows for the Inbox alert + conversation streams. Unread rows carry a
   left accent (brand, an emphasis cue — not a state colour); read rows mute via
   the markup. Layout lives in the markup (Tailwind); these are chrome + state. */
.cv-notification,
.cv-thread {
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--cv-color-border);
  transition: background .12s;
}
.cv-notification:last-child,
.cv-thread:last-child { border-bottom: none; }
.cv-notification:hover,
.cv-thread:hover { background: var(--cv-color-bg-alt); }
.cv-notification-unread,
.cv-thread-unread { border-left-color: var(--cv-color-primary); }

/* Unread count pill on a message thread (small, brand — a count, not a status). */
.cv-thread-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .375rem;
  border-radius: var(--cv-radius-full);
  background: var(--cv-color-primary);
  color: var(--cv-color-text-on-dark);
  font-size: .6875rem;
  font-weight: 600;
}

/* ── Message thread — chat bubbles (component: message_thread_item) ───────────
   Conveys one message in a conversation: sender, time, body, read state. The
   viewer's own messages align right on a primary-soft ground; the other party's
   align left on a neutral card ground. An unread incoming message carries a
   left brand accent. Used in any artifact's Discussion (assessment, then
   control/risk/... via list_threads_for_subject). */
.cv-msg { display: flex; margin-bottom: .75rem; }
.cv-msg:last-child { margin-bottom: 0; }
.cv-msg-own { justify-content: flex-end; }
.cv-msg-bubble {
  max-width: 32rem;
  padding: .5rem .75rem;
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-lg);
  background: var(--cv-color-bg-card);
}
.cv-msg-own .cv-msg-bubble {
  background: var(--cv-color-primary-soft);
  border-color: var(--cv-color-primary-soft);
}
.cv-msg-unread .cv-msg-bubble { border-left: 3px solid var(--cv-color-primary); }

/* ── L1 Scoping wizard — section confirm summary ─────────────────────────────
   Conveys a completed L1 scoping section as an attested fact sheet.
   Used by l1_section_confirm.html (cv-scoping-section-review pattern, §12.7).
   Three confirm modes: facts (org section), agenda (subject_discovery),
   capas (governance). All share the card chrome; mode drives the content. */
.cv-scoping-section-review {
  background: color-mix(in srgb, var(--cv-color-success) 5%, var(--cv-color-bg-card));
  border: 1px solid color-mix(in srgb, var(--cv-color-success) 25%, var(--cv-color-border));
  border-radius: var(--cv-radius-lg);
  padding: 1.5rem;
  position: relative;
}
.cv-scoping-section-review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--cv-color-border);
}

/* Two-column grid: label on the left, badge on the right. */
.cv-scoping-fact-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .4rem 1.5rem;
  align-items: center;
}
/* The right-column answer (a badge, or the plain Yes/No value) sits at the column end
   and never wraps (component owns this layout — the template carries no inline style). */
.cv-scoping-fact-grid > .cv-badge,
.cv-scoping-fact-grid > .cv-scoping-fact-value {
  justify-self: end;
  white-space: nowrap;
}
/* Top-aligned variant — used where the row content is multi-line (e.g. the
   exclusion-defence rows) so the icon aligns to the first line, not centre. */
.cv-scoping-capa-item.is-top {
  align-items: flex-start;
}

/* Agenda item — entity type to enumerate at L2 (subject_discovery confirm). */
.cv-scoping-agenda-item {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .65rem .9rem;
  background: var(--cv-color-bg-alt);
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-md);
  font-size: .875rem;
}

/* CAPA item — governance gap raised at L1 (governance confirm). */
.cv-scoping-capa-item {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .65rem .9rem;
  background: color-mix(in srgb, var(--cv-color-warning) 8%, var(--cv-color-bg-card));
  border: 1px solid color-mix(in srgb, var(--cv-color-warning) 30%, var(--cv-color-border));
  border-radius: var(--cv-radius-md);
  font-size: .875rem;
}

/* ── cv-evidence-item — one evidence-backed claim/exclusion + its review lifecycle.
   CONVEYS: a single requirement's evidence state (gap / awaiting review / accepted /
   rejected / frozen) plus the actions allowed on it (attach, view, delete, accept /
   reject). The ONE component for evidence rows across scoping — the Boundary confirm
   page (Yes-claim evidence + exclusion defence) and the Scope Sign-Off review — so the
   same data renders the same way everywhere (fixes finding C, "renders four ways").
   The left status bar carries the state in colour ONLY (mirrors cv-disclosure; never a
   row tint), read before any text. Icon + status line are secondary.
   USE: any list of evidence-backed claims/exclusions. DON'T use for governance CAPA
   gaps (→ cv-scoping-capa-item) or L2 enumeration rows (→ cv-enum-row).
   Marker class: cv-evidence-item (+ one state modifier). */
.cv-evidence-item {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: .65rem .9rem;
  background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border);
  border-left-width: 3px;
  border-radius: var(--cv-radius-md);
  font-size: .875rem;
}
/* State → left-bar colour (five-colour vocabulary, same tokens as cv-disclosure). */
.cv-evidence-item-gap      { border-left-color: var(--cv-color-danger); }
.cv-evidence-item-awaiting { border-left-color: var(--cv-color-warning); }
.cv-evidence-item-accepted { border-left-color: var(--cv-color-success); }
.cv-evidence-item-rejected { border-left-color: var(--cv-color-danger); }
.cv-evidence-item-frozen   { border-left-color: var(--cv-color-border-strong); }
.cv-evidence-item-body { flex: 1; min-width: 0; }

/* ── cv-signature-block — the SIGNATURE CHAIN on an attestation. Baselined 2026-08-07.
   CONVEYS: one row per signature — the ROLE it attests, WHO signed, WHEN, and its
   state: pending (an earlier signature is outstanding) / awaiting (this party's turn) /
   signed / rejected, with the RECORDED REASON.
   RATIONALE: an assessment carries TWO signatures — the OWNER (ownership: "this is our
   position"; the signature that sets effectiveness) then the CONSULTANT (independent
   assurance). Order is meaningful and the second cannot precede the first, so a pending
   signature is SHOWN, not hidden — the chain is the audit story. Rejection must carry a
   reason (audit requirement), so the reason is part of the row, not a separate note.
   Chrome is the cv-evidence-item idiom (left status bar carries state in colour ONLY,
   never a row tint) so states read the same way across the product.
   USE: any attestation signed by named parties — control/risk assessment sign-off,
   over-appetite acceptance (CEM + Consultant), mapping + scope sign-offs. DON'T use for
   the sections of a gate (→ cv-gate-tile), evidence review (→ cv-evidence-item), or a
   conversation (→ message_thread_item).
   Marker class: cv-signature-block (root) + cv-signature (row) + one state modifier. */
.cv-signature-block { display: flex; flex-direction: column; gap: .5rem; }
.cv-signature {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  padding: .65rem .9rem;
  background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border);
  border-left-width: 3px;
  border-radius: var(--cv-radius-md);
  font-size: .875rem;
}
/* State → left-bar colour (five-colour vocabulary, same tokens as cv-evidence-item). */
.cv-signature-pending  { border-left-color: var(--cv-color-border-strong); }
.cv-signature-awaiting { border-left-color: var(--cv-color-warning); }
.cv-signature-signed   { border-left-color: var(--cv-color-success); }
.cv-signature-rejected { border-left-color: var(--cv-color-danger); }
/* A pending signature is legible but visibly not-yet-live — a placeholder in the
   chain, not an action. Muted via colour, never opacity. */
.cv-signature-pending .cv-signature-role { color: var(--cv-color-text-muted); }
.cv-signature-icon { flex-shrink: 0; margin-top: .1rem; color: var(--cv-color-text-muted); }
.cv-signature-signed   .cv-signature-icon { color: var(--cv-color-success); }
.cv-signature-awaiting .cv-signature-icon { color: var(--cv-color-warning); }
.cv-signature-rejected .cv-signature-icon { color: var(--cv-color-danger); }
.cv-signature-body { flex: 1; min-width: 0; }
.cv-signature-role { font-weight: 600; }
.cv-signature-attest { color: var(--cv-color-text-muted); }
/* The recorded rejection reason — mandatory, and the thing the owner must act on.
   Inline state (never a cv-alert: this is not a page-level message). */
.cv-signature-reason {
  margin-top: .35rem;
  padding-left: .65rem;
  border-left: 2px solid var(--cv-color-danger);
}
.cv-signature-actions { flex-shrink: 0; }

/* ── cv-enum-row / cv-enum-table — L2 artifact enumeration ───────────────────
   Conveys one artifact instance being enumerated at L2 — its NAME and its OWNER —
   as an editable row, repeated under an entity-type section. L2 turns each affirmed
   L1 fact ("you run systems") into a concrete list of named artifacts WITH owners;
   the owner column is always present so ownership is a first-class, non-skippable
   field (an unowned in-scope artifact is an audit gap).
   Use: the L2 enumeration surface, one row per artifact. Don't use: read-only
   registers (→ cv-system-register / cv-process-register) or full detail forms.
   Marker class: cv-enum-table (wrapper), cv-enum-row (each row). */
.cv-enum-table { display: flex; flex-direction: column; gap: .5rem; }
.cv-enum-head,
.cv-enum-row {
  display: grid;
  grid-template-columns: 1fr 15rem 2.25rem;
  gap: .75rem;
  align-items: center;
}
.cv-enum-head { padding: 0 2.25rem .35rem .1rem; }
.cv-enum-row {
  background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-md);
  padding: .5rem .6rem;
}
.cv-enum-row .cv-form-control,
.cv-enum-row .cv-form-select { margin: 0; }
.cv-enum-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border-radius: var(--cv-radius-sm);
  color: var(--cv-color-text-muted); background: transparent;
  border: 1px solid transparent; cursor: pointer;
}
.cv-enum-remove:hover { color: var(--cv-color-danger); background: var(--cv-color-bg-alt); }
.cv-enum-add { margin-top: .25rem; align-self: flex-start; }

/* Add-one capture row column variants — name + (owner) + an Add button whose
   column is `auto` (wider than the default 2.25rem icon column). Picked by whether
   the artifact type carries an owner, so the template needs no inline grid style. */
.cv-enum-head.cv-enum-cols-owned,
.cv-enum-row.cv-enum-cols-owned   { grid-template-columns: 1fr 15rem auto; }
.cv-enum-head.cv-enum-cols-unowned,
.cv-enum-row.cv-enum-cols-unowned { grid-template-columns: 1fr auto; }
/* Two-column name + owner (no action column) — the "added so far" summary rows. */
.cv-enum-head.cv-enum-cols-pair,
.cv-enum-row.cv-enum-cols-pair { grid-template-columns: 1fr 15rem; }
/* Bare variant — a borderless, transparent summary row (read-only confirm lists). */
.cv-enum-row.cv-enum-row-bare {
  background: transparent;
  border-color: transparent;
  padding: .35rem .1rem;
}

/* Owner display token — person icon + "I. Surname" (per the naming rule). */
.cv-person { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.cv-person > .lucide,
.cv-person > svg { color: var(--cv-color-text-muted); }
.cv-person-unset { color: var(--cv-color-danger); }
/* A cv-person used as a link is an entity reference, not a text link — it reads
   as normal text (like cv-disclosure-main), overriding the global blue a{}. */
a.cv-person { color: inherit; text-decoration: none; }
a.cv-person:hover { text-decoration: underline; }

/* ── cv-ai-suggest — advisory AI suggestions panel ───────────────────────────
   Conveys AI-generated, ADVISORY suggestions — typical artifacts an organisation
   of this size/sector would have — from the org profile + L1 answers, as optional
   starting points for enumeration. NOT prescriptive findings: the L1 agenda
   (cv-scoping-agenda-item) is the prescriptive block. A dashed border + sparkles +
   an "AI · advisory" badge keep these visually distinct, so advice is never mistaken
   for a finding. No new status colour — primary token at low strength.
   Use: above an enumeration/capture list, one panel per artifact type. Don't use:
   for prescriptive facts (→ cv-scoping-agenda-item) or validation messages.
   Marker class: cv-ai-suggest (root). */
.cv-ai-suggest {
  background: color-mix(in srgb, var(--cv-color-primary) 4%, var(--cv-color-bg-card));
  border: 1px dashed color-mix(in srgb, var(--cv-color-primary) 38%, var(--cv-color-border));
  border-radius: var(--cv-radius-md);
  padding: 1rem 1.15rem;
}
.cv-ai-suggest-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.cv-ai-suggest-list { display: flex; flex-direction: column; gap: .4rem; }
.cv-ai-suggest-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .55rem .75rem; background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border); border-radius: var(--cv-radius-sm);
}
.cv-ai-suggest-item.is-added { opacity: .5; }

/* ── cv-ai-suggest--risk — risk-led advisory grouping ────────────────────────
   The cv-ai-suggest advisory chrome repurposed as a RISK GROUP: the head carries a
   RISK identity (title + cv-signal-chip library code + category + "Add risk") over
   the cv-ai-suggest-item controls that MITIGATE that risk (each a suggested control
   with its Annex A ref + "Add", or an already-captured control via --have). One
   grouping = "two recommendations in one": the risk to add, and the controls for it.
   Use: the walkthrough Review advisory board (Decision 12 grounded advice), one
   group per suggested risk. Don't use: for a flat suggestion list (→ plain
   cv-ai-suggest) or a read-only register (→ cv-disclosure). Marker: cv-ai-suggest--risk. */
.cv-ai-suggest--risk .cv-ai-suggest-head { align-items: flex-start; }
/* An already-captured control shown IN a risk's context — present & positive (you
   already have this), NOT faded like .is-added (which means "already suggested"). */
.cv-ai-suggest-item--have {
  border-left: 3px solid var(--cv-color-success);
  background: color-mix(in srgb, var(--cv-color-success) 8%, var(--cv-color-bg-card));
}

/* ── cv-risk-build — editable risk-led group (the Finalise record surface) ────
   Conveys: a RISK you have accepted, with the controls that TREAT it grouped
   beneath — as COMMITTED, EDITABLE records. Same risk-led layout as
   cv-ai-suggest--risk, but a SOLID record surface (not the dashed/sparkles
   advisory chrome), because Finalise holds decided records you Edit / Reject,
   not advice you accept. Each risk row and each control row carries a cv-owner
   (the person an assessment routes to). Rationale: Finalise mirrors the Advice
   board's shape so the consultant reads the same risk-first structure, but the
   affordances are edit-a-record, not accept-a-suggestion — a different meaning
   needs a different (non-advisory) chrome. Use: the walkthrough Finalise page,
   one group per accepted risk. Don't use: for advice/suggestions (→
   cv-ai-suggest--risk) or a read-only register (→ cv-disclosure). Marker:
   cv-risk-build (root), cv-risk-build-head / -body / -item / -actions. */
.cv-risk-build {
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-md);
  background: var(--cv-color-bg-card);
  margin-bottom: .75rem;
}
.cv-risk-build-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--cv-color-border);
}
.cv-risk-build-head .lucide { color: var(--cv-color-warning); }
.cv-risk-build-body { padding: .5rem 1rem .75rem; }
.cv-risk-build-item {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--cv-color-border);
}
.cv-risk-build-item:first-child { border-top: 0; }
.cv-risk-build-actions { display: inline-flex; gap: .25rem; flex-shrink: 0; }

/* cv-owner — a person responsible, shown as a person-icon + "I. Surname" (cv-person)
   with its DEFAULT source ("default · <entity> owner") or an override cue. The owner
   defaults to the mapped entity's owner and is overridable per row; it is who an
   assessment is routed to. Marker: cv-owner (+ cv-owner-src / --override / cv-owner-unset). */
.cv-owner { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.cv-owner-src { font-size: .72rem; color: var(--cv-color-text-muted); }
.cv-owner-src--override { color: var(--cv-color-warning); }
.cv-owner-unset { color: var(--cv-color-danger); }

/* ── cv-consolidation-advisory — anti-sprawl inventory-review panel ───────────
   Conveys advisory CONSOLIDATION suggestions: fold commodity items into one
   generic functional category. Reuses the cv-ai-suggest dashed advisory chrome
   (wrap the panel in `cv-ai-suggest cv-consolidation-advisory`); each suggestion
   is a richer group-item — category · member chips · rationale · optional
   link-impact warning · Accept/Dismiss. Marker class: cv-consolidation-advisory.
   See docs/ANTI-SPRAWL-ADVISORY-BRIEF.md (Stage 3). */
.cv-consolidation-list { display: flex; flex-direction: column; gap: .6rem; margin-top: .85rem; }
.cv-consolidation-suggestion {
  background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-sm);
  padding: .85rem 1rem;
}
.cv-consolidation-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.cv-consolidation-into { font-size: .9375rem; font-weight: 600; }
.cv-consolidation-arrow { color: var(--cv-color-text-muted); }
.cv-consolidation-members { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; }
.cv-consolidation-rationale { font-size: .8125rem; color: var(--cv-color-text-muted); line-height: 1.5; }
.cv-consolidation-actions { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; }
.cv-consolidation-actions .cv-consolidation-dismiss { margin-left: auto; }

/* Loading state — shown while the AI is generating (auto-fetch on first view).
   A prominent, centred spinner so it's clear work is happening. */
.cv-ai-suggest-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .85rem; padding: 1.75rem 0;
}

/* ── cv-spinner — standalone async/loading spinner ───────────────────────────
   Conveys "work in progress" for an async region (e.g. an AI fetch). Monochrome
   navy on a neutral ring — NEVER a status colour (red is reserved for danger).
   Use: a loading region or as an htmx-indicator next to an action. Don't use:
   inside a button (the cv-btn busy state handles that). Marker class: cv-spinner. */
.cv-spinner {
  display: inline-block;
  width: 2.5rem; height: 2.5rem;
  border: 3px solid var(--cv-color-border);
  border-top-color: var(--cv-navy);
  border-radius: var(--cv-radius-full);
  animation: cv-spin .7s linear infinite;
  flex-shrink: 0;
}
.cv-spinner-sm { width: 1.15rem; height: 1.15rem; border-width: 2px; }

/* ── Preliminary applicability table — L1 applicability detail page ───────────
   Conveys requirement-by-requirement applicability determinations in a dense,
   sortable table. Used by l1_applicability.html. */
.cv-applicability-table table { font-size: .875rem; }
.cv-applicability-table thead th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--cv-color-text-muted);
  font-weight: 600;
  padding: .5rem 1rem;
  background: var(--cv-color-bg-alt);
  border-bottom: 1px solid var(--cv-color-border);
}
.cv-applicability-table tbody td {
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--cv-color-border);
  vertical-align: top;
}
.cv-applicability-table tbody tr:last-child td { border-bottom: none; }
/* Fixed columns: Ref / Level / Outcome (component owns the layout — the template
   carries no inline width). Requirement + Signals columns flex. */
.cv-applicability-table th:nth-child(1) { width: 6rem; }
.cv-applicability-table th:nth-child(3) { width: 7rem; }
.cv-applicability-table th:nth-child(4) { width: 11rem; }

/* Signal chip — the question code that triggered a determination.
   Also used for short requirement-reference chips (A.5.2) in the question family. */
.cv-signal-chip {
  display: inline-flex;
  align-items: center;
  padding: .1rem .4rem;
  border: 1px solid var(--cv-color-border);
  border-radius: var(--cv-radius-sm);
  background: var(--cv-color-bg-alt);
  font-family: var(--cv-font-mono);
  font-size: .72rem;
  color: var(--cv-color-text-secondary);
  white-space: nowrap;
}

/* ── Scoping-question family ─────────────────────────── */
/* ONE block shell for a scoping/SAQ/assessment question, with three pluggable
   answer-region modes so the L1 wizard, baseline editor, applicability-review
   library and per-engagement applicability detail all render a question identically.
   The head (prompt + help + meta + actions) is constant; only the answer region
   varies — A: input (cv-question-answers, wraps cv-radio/cv-checkbox), B: outcomes
   (cv-question-outcomes table), C: toggle (leading cv-switch + cv-question-reason).
   Marker class cv-question identifies the block in rendered HTML.
   Baselined 2026-06-17 from corvus-prototype/component-questionnaire-family.html. */
.cv-question { padding: 1.15rem 1.25rem; }
.cv-question-list > .cv-question + .cv-question { border-top: 1px solid var(--cv-color-border); }

/* Head — prompt + meta on the left; optional actions on the right. */
.cv-question-head { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.cv-question-main { min-width: 0; flex: 1; }              /* fills the head so actions sit right (any mode) */
.cv-question-prompt { font-size: 1rem; font-weight: 600; line-height: 1.4; color: var(--cv-color-text); margin: 0; }
.cv-question-help { font-size: .875rem; line-height: 1.5; color: var(--cv-color-text-muted); margin: .25rem 0 0; }
.cv-question-actions { display: flex; gap: .25rem; flex-shrink: 0; }

/* Meta strip — identity code + classification badges (plane / deferrability / level / effects). */
.cv-question-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .55rem; }
.cv-question-id { font-family: var(--cv-font-mono); font-size: .72rem; color: var(--cv-color-text-muted); }

/* Mode A — input (capture): the answer choices. Reuses cv-radio / cv-checkbox. */
.cv-question-answers { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: .7rem; }
.cv-question-answers--stack { flex-direction: column; gap: .55rem; }

/* Mode B — outcomes (review): the answer -> outcome logic table. */
table.cv-question-outcomes { width: 100%; border-collapse: collapse; margin-top: .7rem; font-size: .82rem; }
.cv-question-outcomes thead th {
  text-align: left; font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--cv-color-text-muted);
  padding: .3rem .6rem; border-bottom: 1px solid var(--cv-color-border);
}
.cv-question-outcomes td { padding: .5rem .6rem; border-bottom: 1px solid var(--cv-color-border); vertical-align: top; }
.cv-question-outcomes tr:last-child td { border-bottom: none; }
.cv-question-outcomes th:nth-child(1) { width: 7rem; }   /* Answer */
.cv-question-outcomes th:nth-child(2) { width: 6rem; }   /* Requirement */
.cv-question-outcomes th:nth-child(3) { width: 10rem; }  /* Outcome */

/* Mode C — toggle (baseline include/exclude): leading switch + optional reason.
   flex-start (not the head's default space-between) keeps the switch beside the prompt. */
.cv-question--toggle .cv-question-head { gap: .85rem; justify-content: flex-start; }
.cv-question-toggle { flex-shrink: 0; margin-top: .1rem; }   /* the cv-switch, leading */
.cv-question-reason {
  font-size: .82rem; color: var(--cv-color-text-muted); margin-top: .45rem;
  padding-left: .7rem; border-left: 2px solid var(--cv-color-border);
}
.cv-question--excluded .cv-question-prompt { color: var(--cv-color-text-muted); }

/* Mode D — given (the RECORD): the answer that was actually given, read-only.
   Added 2026-08-07. A completed assessment is signed off by someone who did not fill it
   in (the owner, then the consultant) and later read by an auditor — all three need to
   see WHAT was answered, question by question, not a prose gloss of it. Same head as
   every other mode; the answer region is the recorded value (cv-answer-value), with a
   red-flag answer carrying cv-text-danger so the thing that capped the judgment is
   visible at a glance. cv-question--record tightens the padding, since a record shows
   every question at once rather than asking one. */
.cv-question--record { padding: .7rem 1.25rem; }
.cv-question--record .cv-question-prompt { font-size: .875rem; font-weight: 500; color: var(--cv-color-text-muted); }
.cv-question-given { margin-top: .2rem; font-size: .9375rem; }

/* Answer-value token (Yes / No / Unsure) — colour FOLLOWS the outcome, not the word
   (use cv-text-success / cv-text-danger / cv-text-warning, or none for a clean exclusion). */
.cv-answer-value { font-weight: 600; }

/* cv-scoping-answer — the always-open answer row (David 2026-11-10, walkthrough
   wt-sendback v2). No chevron, so the main area is not a link: no hover tint. The
   consultancy's Reject opens the reason box below the row — pure CSS (:has), no script;
   a disabled (already sent back) Reject never opens it. */
.cv-scoping-answer .cv-disclosure-main:hover { background: transparent; }
.cv-disclosure-panel.cv-scoping-answer-reject { display: none; }
.cv-scoping-answer:has(input[name="decision"][value="reject"]:checked:not(:disabled)) .cv-scoping-answer-reject {
  display: block;
}

/* ── cv-board — two-pane relational mapping surface ──────────────────────────
   Conveys a many-to-many relationship being stitched between two registers
   (first use: §4 Compliance, risks <-> SoA controls). Bidirectional
   ANCHOR-AND-TOGGLE: click an item in one pane (it becomes the anchor) and the
   other pane's rows become a map/unmap checklist scoped to that anchor; each
   toggle is one HTMX post. The chrome is deliberately thin — the panes are
   cv-card, the rows are cv-list-item, badges/bars/AI panel are the usual
   vocabulary; cv-board only adds the pane head, the scrollable list, and the
   anchored / mapped row states.
   Use: any N<->M mapping the consultant stitches by hand (control<->requirement,
   risk<->asset, vendor<->risk). Don't use: a read-only register (-> cv-card +
   cv-disclosure rows) or a single-parent attach list (-> related_items_panel).
   Marker classes: cv-board (the two-pane wrapper), cv-board-pane, cv-board-row. */
.cv-board-pane { display: flex; flex-direction: column; }
.cv-board-pane-head {
  display: flex; align-items: center; gap: .75rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--cv-color-border);
}
.cv-board-pane-title { font-size: .9375rem; font-weight: 600; }
.cv-board-list { overflow-y: auto; max-height: 32rem; }

/* the anchored row — the item currently driving the other pane. Primary-soft
   fill + a 3px inset primary rail (inset so it never shifts the row layout). */
.cv-board-row.is-anchor {
  background: var(--cv-color-primary-soft);
  box-shadow: inset 3px 0 0 var(--cv-color-primary);
}
/* a row that IS mapped to the current anchor (toggle mode) — a quiet success
   rail so the mapped set reads as a column at a glance. */
.cv-board-row.is-mapped { box-shadow: inset 3px 0 0 var(--cv-color-success); }

/* the instruction strip the target pane shows in toggle mode (an anchor is
   selected) — neutral-soft, same idiom as a section intro. */
.cv-board-scope-note {
  display: flex; align-items: center; gap: .5rem;
  padding: .625rem 1rem;
  background: var(--cv-color-neutral-soft);
  border-bottom: 1px solid var(--cv-color-border);
  font-size: .8125rem; color: var(--cv-color-text-muted);
}

/* Outcome pill — the Rule C outcome vocabulary. CSS-free MARKER; colour comes from the
   cv-badge variant it is paired with. cv-outcome marks an outcome in rendered HTML and is
   the single anchor for the agreed outcome->colour mapping:
     INCLUDE_EVIDENCE  -> cv-badge cv-badge-success                (Include · evidence)
     INCLUDE_GAP       -> cv-badge cv-badge-danger                 (Include · gap)
     INCLUDE_DEFER     -> cv-badge cv-badge-outline cv-badge-warning (Include · defer)
     EXCLUDE_STATEMENT -> cv-badge cv-badge-neutral                (Exclude · statement)
     EXCLUDE_EVIDENCE  -> cv-badge cv-badge-outline cv-badge-neutral (Exclude · evidence)
     REVIEW            -> cv-badge cv-badge-outline cv-badge-warning (Review) */
.cv-outcome { /* marker only — styling comes from the paired cv-badge variant */ }

/* ── cv-capture-strip — "what this answer just recorded" ─────────────────────
   Conveys records CREATED FROM AN ANSWER during a question-driven capture flow
   (first use: §4 artifact walkthrough sessions) — the specific control or risk
   recorded in the client's own words, each with suggested catalogue refs
   (cv-signal-chip) awaiting the CONSULTANT'S confirmation. The client's
   specific mechanism is the first-class record; the ISO ref is a suggestion
   pinned to it (the control-specificity rule enforced at the point of capture).
   Use: walkthrough sessions (controls, risks), L1 answer effects made visible
   (creates-entity / seeds-document), W3 assessment SAQ (failing answer ->
   draft finding). Don't use: static related-items display (-> related_items_panel)
   or AI suggestions not yet accepted (-> cv-ai-suggest).
   Variants: default success rail (a control/record captured);
   cv-capture-strip--risk warning rail (a risk captured).
   Marker classes: cv-capture-strip (root), cv-capture-item (each record).
   Baselined 2026-07-02 from corvus-prototype/engagement-walkthrough-session.html. */
.cv-capture-strip {
  margin-top: .75rem;
  border: 1px solid var(--cv-color-border);
  border-left: 3px solid var(--cv-color-success);
  border-radius: var(--cv-radius-md);
  background: var(--cv-color-bg-alt);
}
.cv-capture-strip-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .875rem;
  font-size: .75rem; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--cv-color-text-muted);
  border-bottom: 1px solid var(--cv-color-border);
}
.cv-capture-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem .875rem;
}
.cv-capture-item + .cv-capture-item { border-top: 1px solid var(--cv-color-border); }
.cv-capture-strip--risk { border-left-color: var(--cv-color-warning); }

/* ── cv-inventory — the definition inventory ─────────────────────────────────
   Conveys: a set you BUILD by defining items — each captured fully in ONE inline form
   (identity + attributes + ownership), optionally seeded by AI suggestions.
   Structure (locked): (1) Defined-so-far list at the top, edit INLINE in the row;
   (2) ONE inline Add form (fields + a single confirm — nothing created until confirmed);
   (3) a cv-ai-suggest list that PRE-FILLS the Add form. No dialogs / pop-ups; no
   create-then-patch.
   Use for: Processes / Systems / Vendors / Risk Inventory (any "define an inventory of
   X" surface). Don't use for: monitoring existing items with status (that's the
   entity-register / inline-disclosure list) or a single-record form.
   Composed from cv-card / cv-form-* / cv-btn-* / cv-badge / cv-person / cv-ai-suggest.
   Marker class: cv-inventory (root). Baselined 2026-07-11 (prototype
   corvus-prototype/component-inventory.html). */
.cv-inventory { display: flex; flex-direction: column; gap: 1.5rem; }

.cv-inventory-item { padding: .85rem 1rem; border-bottom: 1px solid var(--cv-color-border); }
.cv-inventory-item:last-child { border-bottom: 0; }
.cv-inventory-item-head { display: flex; align-items: baseline; gap: .75rem; }
.cv-inventory-item-name { font-size: .875rem; font-weight: 600; }
.cv-inventory-item-owner { margin-left: auto; }
.cv-inventory-item-head .cv-person { font-size: .8125rem; color: var(--cv-color-text-muted); }
.cv-inventory-item-desc { font-size: .8125rem; color: var(--cv-color-text-muted); margin-top: .2rem; line-height: 1.5; max-width: 70ch; }
.cv-inventory-edit-toggle { cursor: pointer; font-size: .8125rem; margin-top: .5rem; list-style: none; }
.cv-inventory-edit { margin-top: .5rem; padding-top: .75rem; border-top: 1px dashed var(--cv-color-border); display: grid; gap: .85rem; }

.cv-inventory-add .cv-card-header { background: var(--cv-color-bg-alt); }
.cv-inventory-add-from { margin-left: auto; font-size: .75rem; color: var(--cv-color-info); display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; }
.cv-inventory-form { padding: 1rem 1.25rem; display: grid; gap: 1rem; }
.cv-inventory-actions { display: flex; align-items: center; justify-content: flex-end; gap: .75rem; }
.cv-inventory-actions .cv-hint { margin-right: auto; font-size: .75rem; color: var(--cv-color-text-muted); }
.cv-inventory-suggest-note { padding: 0 1rem; }

/* ── cv-assess-stepper — guided assessment sequence rail ──────────────────────
   Conveys: an ORDERED, gated sequence of steps with per-step status (done /
   current / blocked / pending). Rationale: an assessment is a staged workflow
   (review → assess controls → record → treat → sign off); a flat form stack hides
   the order, so the rail makes "what to do next" explicit. Use: at the top of a
   staged workspace (risk/control/process/system assessment). Don't use for
   navigation (that's the sidebar) or for non-sequential status. Marker: cv-assess-stepper. */
.cv-assess-stepper { display: flex; gap: .25rem; align-items: stretch; flex-wrap: wrap; margin-bottom: 1.25rem; }
.cv-assess-step {
  flex: 1; min-width: 9rem; display: flex; gap: .6rem; align-items: center;
  padding: .6rem .8rem; background: var(--cv-color-bg-card);
  border: 1px solid var(--cv-color-border); border-radius: var(--cv-radius-md);
}
.cv-assess-step-num {
  flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; background: var(--cv-color-neutral-soft);
  color: var(--cv-color-text-muted); border: 1px solid var(--cv-color-border);
}
.cv-assess-step-txt { font-size: .78rem; line-height: 1.2; }
.cv-assess-step-txt small { display: block; color: var(--cv-color-text-muted); font-size: .68rem; }
.cv-assess-step.is-current { border-color: var(--cv-color-primary); }
.cv-assess-step.is-current .cv-assess-step-num { background: var(--cv-color-bg-card); color: var(--cv-color-primary); border-color: var(--cv-color-primary); }
.cv-assess-step.is-done .cv-assess-step-num { background: var(--cv-color-success); color: var(--cv-white); border-color: var(--cv-color-success); }
.cv-assess-step.is-blocked .cv-assess-step-num { background: var(--cv-color-danger-soft); color: var(--cv-color-danger-text); border-color: var(--cv-color-danger); }
/* is-attention — a step that needs action but does NOT hard-block progression
   (e.g. "1 control to assess"). Amber OUTLINE, never a red fill — red is reserved
   for a genuine block (is-blocked). */
.cv-assess-step.is-attention { border-color: var(--cv-color-warning); }
.cv-assess-step.is-attention .cv-assess-step-num { background: var(--cv-color-bg-card); color: var(--cv-color-warning-text); border-color: var(--cv-color-warning); }

/* ── cv-risk-position — single-risk inherent→residual matrix ──────────────────
   Conveys: ONE risk's position and movement on the 5×5 likelihood×impact matrix —
   an inherent marker, a residual marker, and the appetite band — plus a score
   readout. Rationale: risk reduction is the point of an assessment, so the
   before→after and where it sits vs appetite must be visible; a bare residual
   number can't show it. DIFFERENT SHAPE from the distribution heatmap
   (components/widgets/heatmap.html), which shows COUNTS across many risks — do not
   substitute one for the other. Use: on a single risk's assessment/detail surface.
   Marker: cv-risk-position (+ cv-rp-* internals). */
.cv-risk-position { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; }
.cv-rp-matrix-wrap { display: flex; gap: .4rem; }
.cv-rp-ylab {
  writing-mode: vertical-rl; transform: rotate(180deg); align-self: center;
  text-align: center; font-size: .62rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--cv-color-text-muted); font-weight: 700;
}
.cv-rp-grid-block { display: flex; flex-direction: column; gap: .3rem; }
.cv-rp-rows { display: flex; }
.cv-rp-rowlabels { display: flex; flex-direction: column; gap: 3px; margin-right: 4px; }
.cv-rp-rowlabels span {
  height: 2.6rem; width: 1rem; display: flex; align-items: center; justify-content: center;
  font-size: .66rem; font-weight: 700; color: var(--cv-color-text-muted);
}
.cv-rp-grid { display: grid; grid-template-columns: repeat(5, 2.6rem); grid-auto-rows: 2.6rem; gap: 3px; }
.cv-rp-cell { position: relative; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.cv-rp-score { position: absolute; top: 2px; right: 4px; font-size: .56rem; font-weight: 700; color: rgba(15, 23, 42, .4); }
.cv-rp-tier-low  { background: var(--cv-green-soft); }   /* score ≤ 4  */
.cv-rp-tier-med  { background: var(--cv-amber-soft); }   /* score 5–9  */
.cv-rp-tier-high { background: var(--cv-amber); }        /* score 10–14 */
.cv-rp-tier-crit { background: var(--cv-red); }          /* score ≥ 15 */
.cv-rp-appetite  { box-shadow: inset 0 0 0 2px rgba(22, 101, 52, .4); }  /* within effective appetite */
.cv-rp-marker {
  width: 1.35rem; height: 1.35rem; border-radius: 50%; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  font-size: .6rem; font-weight: 700; color: var(--cv-white);
  border: 2px solid var(--cv-white); box-shadow: 0 1px 2px rgba(15, 23, 42, .5);
}
.cv-rp-marker-inh { background: var(--cv-color-text); }
.cv-rp-marker-res { background: var(--cv-color-danger); }
.cv-rp-marker-both { display: flex; gap: 2px; }
.cv-rp-xlabels { display: flex; gap: 3px; margin-left: calc(1rem + 4px); }
.cv-rp-xlabels span { width: 2.6rem; text-align: center; font-size: .6rem; font-weight: 600; color: var(--cv-color-text-muted); }
.cv-rp-xtitle {
  margin-left: calc(1rem + 4px); margin-top: .15rem; text-align: center;
  font-size: .62rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--cv-color-text-muted); font-weight: 700;
}
.cv-rp-readout { min-width: 15rem; }
.cv-rp-bignum { font-size: 2.4rem; font-weight: 700; line-height: 1; }
.cv-rp-arrow { font-size: 1.4rem; color: var(--cv-color-text-muted); }
.cv-rp-legend { display: flex; flex-direction: column; gap: .45rem; font-size: .76rem; }
.cv-rp-legend-row { display: flex; align-items: center; gap: .5rem; }
.cv-rp-dot { width: 1rem; height: 1rem; border-radius: 50%; flex: none; border: 2px solid var(--cv-white); box-shadow: 0 1px 2px rgba(15, 23, 42, .4); }
.cv-rp-dot-inh { background: var(--cv-color-text); }
.cv-rp-dot-res { background: var(--cv-color-danger); }
.cv-rp-dot-appetite { background: var(--cv-white); box-shadow: inset 0 0 0 2px rgba(22, 101, 52, .55); }
