/* ══════════════════════════════════════════════════════════════════════════
   CareOS — Component Library  ·  CAREOS-APP-SHELL-DESIGN-SYSTEM-FOUNDATION-001
   One card language, one table language, one form system, one status language,
   one modal/drawer/empty-state system. All classes are namespaced `cx-` so
   linking this file never perturbs un-migrated pages. Requires designTokens.css.
   Presentation only.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── SURFACES / CARDS ────────────────────────────────────────────────────── */
.cx-card {
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius-lg);
    box-shadow: var(--cx-shadow-subtle);
}
.cx-card--flat { box-shadow: var(--cx-shadow-flat); }
.cx-card--raised { box-shadow: var(--cx-shadow-raised); }
.cx-card__header {
    display: flex; align-items: center; justify-content: space-between; gap: var(--cx-space-3);
    padding: var(--cx-space-4) var(--cx-space-5);
    border-bottom: 1px solid var(--cx-border-subtle);
}
.cx-card__title { font-size: var(--cx-fs-h3); line-height: var(--cx-lh-h3); font-weight: var(--cx-fw-h3); color: var(--cx-text); margin: 0; }
.cx-card__subtitle { font-size: var(--cx-fs-meta); color: var(--cx-text-muted); margin: 2px 0 0; }
.cx-card__actions { display: flex; align-items: center; gap: var(--cx-space-2); flex-shrink: 0; }
.cx-card__body { padding: var(--cx-space-6); }
.cx-card__body--flush { padding: 0; }
.cx-card__footer { padding: var(--cx-space-3) var(--cx-space-5); border-top: 1px solid var(--cx-border-subtle); }

/* ══ CARE-PLAN CLINICAL PRESENTATION ══════════════════════════════════════════
   CAREOS-CARE-PLAN-CLINICAL-PRESENTATION-WORKLIST-DESIGN-001.
   Presentation only. Every class below exists to support a clinical or operational
   decision — none is decorative. All colour comes from theme tokens (no raw hex),
   and every state that uses colour also carries a label or an icon, so nothing is
   communicated by colour alone. */

/* Lanes stack vertically in reading order — clinical findings, patient-specific,
   monitoring, barriers, standard, legacy. A single column at every width: the old
   two-column grid put goals and the interventions serving them side by side, which
   is the wrong reading order on a wide screen and unusable on a narrow one. */
.cx-cp-lanes { display: flex; flex-direction: column; gap: var(--cx-space-5); }
.cx-cp-lane { scroll-margin-top: var(--cx-space-6); }

/* The clinical-findings lane is the only one that carries urgency by default. */
.cx-cp-lane--clinical { border-left: 3px solid var(--cx-danger); }
/* Standard program content and legacy context are visibly secondary — they are
   never mistaken for a finding about this patient. */
.cx-cp-lane--standard { background: var(--cx-surface-subtle, var(--cx-surface)); }
.cx-cp-lane--legacy { border-left: 3px solid var(--cx-border); opacity: 0.94; }

/* The 30-second summary. Emphasis without decoration. */
.cx-cp-summary { border-left: 3px solid var(--cx-action); }
.cx-cp-summary__reason { font-size: 15px; line-height: 1.45; color: var(--cx-text); margin: 0 0 var(--cx-space-3); font-weight: 550; }
.cx-cp-summary__grid {
    display: grid; gap: var(--cx-space-4);
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.cx-cp-summary__cell { min-width: 0; }
.cx-cp-summary__label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--cx-text-muted); margin-bottom: 4px;
}
.cx-cp-summary__value { font-size: 13.5px; line-height: 1.45; color: var(--cx-text); overflow-wrap: anywhere; }

/* The one dominant next action. There is exactly one of these on the page. */
.cx-cp-primary-action {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--cx-space-3);
    padding: var(--cx-space-4); margin-top: var(--cx-space-4);
    border: 1px solid var(--cx-border); border-radius: var(--cx-radius-md);
    background: var(--cx-surface-hover);
}
.cx-cp-primary-action__text { min-width: 0; flex: 1 1 260px; }

/* Collapsible detail (workflow checklist, standard bundle, legacy, provenance). */
.cx-cp-details { border: 1px solid var(--cx-border-subtle); border-radius: var(--cx-radius-md); }
.cx-cp-details__summary {
    cursor: pointer; padding: var(--cx-space-3) var(--cx-space-4);
    font-size: 13px; font-weight: 550; color: var(--cx-text-secondary);
    list-style: none; display: flex; align-items: center; gap: var(--cx-space-2);
}
.cx-cp-details__summary::-webkit-details-marker { display: none; }
.cx-cp-details__summary::before { content: "▸"; color: var(--cx-text-muted); }
.cx-cp-details[open] > .cx-cp-details__summary::before { content: "▾"; }
.cx-cp-details__summary:hover { color: var(--cx-text); }
.cx-cp-details__summary:focus-visible { outline: 2px solid var(--cx-focus); outline-offset: -2px; border-radius: var(--cx-radius-md); }
.cx-cp-details__body { padding: 0 var(--cx-space-4) var(--cx-space-4); }

/* One plan item — goal, intervention, barrier or finding. Same anatomy everywhere,
   so a clinician learns the shape once. */
.cx-cp-item {
    border: 1px solid var(--cx-border); border-radius: var(--cx-radius-md);
    padding: var(--cx-space-4); background: var(--cx-surface);
}
.cx-cp-item + .cx-cp-item { margin-top: var(--cx-space-3); }
.cx-cp-item--blocking { border-left: 3px solid var(--cx-danger); }
.cx-cp-item--legacy { border-left: 3px solid var(--cx-border); }
.cx-cp-item__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--cx-space-3); }
.cx-cp-item__title { font-weight: 600; font-size: 13.5px; color: var(--cx-text); min-width: 0; overflow-wrap: anywhere; }
.cx-cp-item__detail { font-size: 12.5px; line-height: 1.5; color: var(--cx-text-secondary); margin-top: 4px; overflow-wrap: anywhere; }
/* The field row: owner, cadence, due, linked goal. Wraps instead of scrolling. */
.cx-cp-item__fields {
    display: grid; gap: var(--cx-space-2) var(--cx-space-4); margin-top: var(--cx-space-3);
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.cx-cp-field { min-width: 0; }
.cx-cp-field__label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--cx-text-muted); }
.cx-cp-field__value { font-size: 12.5px; color: var(--cx-text); overflow-wrap: anywhere; }

/* Provenance: one chip in the row, full detail behind a disclosure. Raw ids never
   clutter the default view but are always reachable. */
.cx-cp-prov { margin-top: var(--cx-space-3); }
.cx-cp-prov__list { margin: var(--cx-space-2) 0 0; padding-left: var(--cx-space-5); font-size: 12px; color: var(--cx-text-secondary); }
.cx-cp-prov__list li { margin: 2px 0; overflow-wrap: anywhere; }

/* Review progress. Text carries the meaning; the bar only reinforces it. */
.cx-cp-progress { display: flex; align-items: center; gap: var(--cx-space-3); flex-wrap: wrap; }
.cx-cp-progress__track { flex: 1 1 160px; height: 6px; border-radius: 3px; background: var(--cx-border); overflow: hidden; min-width: 120px; }
.cx-cp-progress__fill { height: 100%; background: var(--cx-action); }

/* ── RESPONSIVE (§20) ─────────────────────────────────────────────────────────
   At 900px the summary grid already reflows via auto-fit. At 390px everything
   stacks, labels stay, and no clinically essential field is hidden. */
@media (max-width: 900px) {
    .cx-cp-summary__grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}
@media (max-width: 560px) {
    .cx-cp-summary__grid,
    .cx-cp-item__fields { grid-template-columns: 1fr; }
    .cx-cp-primary-action { flex-direction: column; align-items: stretch; }
    .cx-cp-primary-action .cx-btn { width: 100%; justify-content: center; }
    /* Touch targets stay usable without hiding anything. */
    .cx-cp-details__summary { padding: var(--cx-space-4); min-height: 44px; }
    .cx-card__body { padding: var(--cx-space-4); }
}

/* Section header (between cards) */
.cx-section-header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--cx-space-3); margin: var(--cx-space-7) 0 var(--cx-space-4); }
.cx-section-header:first-child { margin-top: 0; }
.cx-section-title { font-size: var(--cx-fs-h2); line-height: var(--cx-lh-h2); font-weight: var(--cx-fw-h2); color: var(--cx-text); margin: 0; }
.cx-section-desc { font-size: var(--cx-fs-sm); color: var(--cx-text-muted); }

/* ── KPI / METRIC TILES ──────────────────────────────────────────────────── */
.cx-kpi-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--cx-space-4); }
.cx-kpi {
    background: var(--cx-surface); border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius-lg); box-shadow: var(--cx-shadow-subtle);
    padding: var(--cx-space-6); position: relative; min-width: 0;
    display: flex; flex-direction: column; gap: var(--cx-space-2);
}
/* CAREOS-FINAL-PILOT-POLISH-001 — THE TOP RULE IS A SEMANTIC STATE, NOT DECORATION.
   Every KPI carried a coloured 3px rule keyed to `tone`, and most tones on these dashboards are
   presentational: `info` and `intel` were chosen for visual variety, not to assert a state. The
   result was a rainbow of rules in which the two that DO mean something — an urgent count and a
   warning — carried no more weight than a neutral population figure, and the same component changed
   colour from role to role for no stated reason.

   The rule now appears ONLY for the three tones that name a real state, so colour again means
   something when it is present. Nothing is recoloured decoratively: `info`, `intel` and untoned
   cards simply have no rule. Values, labels and captions are untouched. */
.cx-kpi__topline { display: none; }
.cx-kpi--success .cx-kpi__topline,
.cx-kpi--warning .cx-kpi__topline,
.cx-kpi--danger  .cx-kpi__topline {
    display: block; height: 3px; border-radius: 3px 3px 0 0;
    position: absolute; top: 0; left: 0; right: 0;
}
.cx-kpi--success .cx-kpi__topline { background: var(--cx-success); }
.cx-kpi--warning .cx-kpi__topline { background: var(--cx-warning); }
.cx-kpi--danger  .cx-kpi__topline { background: var(--cx-danger); }
/* CAREOS-FINAL-PILOT-POLISH-001 — ONE KPI ANATOMY: label slot, value, caption slot.
   Labels wrap to one or two lines depending on their wording, so in a row of cards the large
   numerals sat on different baselines and the row read as misaligned rather than as a set. The
   label slot now reserves two lines and the card is a grid with a fixed row order, so values align
   whatever the label length — without shortening a single label. No caption or denominator is
   dropped to buy the alignment; the anatomy absorbs the variation instead. */
.cx-kpi__label {
    font-size: var(--cx-fs-label); font-weight: var(--cx-fw-label); letter-spacing: var(--cx-tracking-label);
    text-transform: uppercase; color: var(--cx-text-muted); display: flex; align-items: flex-start; gap: 6px;
    /* The slot reserves THREE lines, which is the measured maximum across the pilot surfaces
       ("Patients where clinician review is required" and "Patients with an open care-loop context
       (inferred)" both wrap to three at 1440px, while their row-mates wrap to two). Reserving the
       maximum rather than truncating is deliberate: these labels carry the denominator and scope
       that earlier audits found missing, so none may be shortened or clipped to buy alignment.
       A future label longer than three lines would push its value again — the honest fix then is a
       better display label, never a clipped one. */
    min-height: calc(var(--cx-fs-label) * 1.35 * 3);
    line-height: 1.35;
}
.cx-kpi__label .cx-kpi__ico { margin-top: 1px; flex-shrink: 0; }
.cx-kpi__value { font-size: var(--cx-fs-kpi); line-height: var(--cx-lh-kpi); font-weight: var(--cx-fw-kpi); color: var(--cx-text); font-variant-numeric: tabular-nums; }
.cx-kpi__value.is-empty { color: var(--cx-text-faint); font-weight: 600; font-size: 18px; }
.cx-kpi__sub { font-size: var(--cx-fs-meta); color: var(--cx-text-muted); }
.cx-kpi__delta { font-size: var(--cx-fs-meta); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.cx-kpi__delta.is-up { color: var(--cx-success-ink); }
.cx-kpi__delta.is-down { color: var(--cx-danger-ink); }
.cx-kpi__delta.is-flat { color: var(--cx-text-muted); }
.cx-kpi__spark { margin-top: 4px; }
.cx-spark { display: inline-flex; align-items: center; }
.cx-spark svg { display: block; }

/* ── STATUS BADGES (one status language) ─────────────────────────────────── */
.cx-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: var(--cx-radius-pill);
    font-size: 11.5px; font-weight: 600; line-height: 1.4; letter-spacing: 0.01em; white-space: nowrap;
    background: var(--cx-neutral-soft); color: var(--cx-neutral-ink);
}
.cx-badge__ico { width: 12px; height: 12px; display: inline-flex; flex-shrink: 0; }
.cx-badge__ico svg { width: 12px; height: 12px; }
/* Tones */
.cx-badge--info    { background: var(--cx-info-soft);    color: var(--cx-info-ink); }
.cx-badge--success { background: var(--cx-success-soft); color: var(--cx-success-ink); }
.cx-badge--warning { background: var(--cx-warning-soft); color: var(--cx-warning-ink); }
.cx-badge--danger  { background: var(--cx-danger-soft);  color: var(--cx-danger-ink); }
.cx-badge--neutral { background: var(--cx-neutral-soft); color: var(--cx-neutral-ink); }
.cx-badge--disabled{ background: var(--cx-disabled-soft);color: var(--cx-disabled-ink); }
.cx-badge--intel   { background: var(--cx-intel-soft);   color: var(--cx-intel-ink); }
/* Solid variant for high-emphasis (urgent) */
.cx-badge--solid.cx-badge--danger { background: var(--cx-danger); color: #fff; }
.cx-badge--solid.cx-badge--warning { background: var(--cx-warning); color: #fff; }
/* Clinical risk pills */
.cx-badge--risk-low       { background: var(--cx-risk-low-soft);       color: var(--cx-success-ink); }
.cx-badge--risk-moderate  { background: var(--cx-risk-moderate-soft);  color: #713F12; }
.cx-badge--risk-high      { background: var(--cx-risk-high-soft);      color: #7C2D12; }
.cx-badge--risk-very-high { background: var(--cx-risk-very-high-soft); color: var(--cx-danger-ink); }
/* Role badge */
.cx-rolebadge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--cx-radius-sm); font-size: 11px; font-weight: 600; background: var(--cx-surface-sunken); color: var(--cx-text-secondary); }
.cx-rolebadge--owner { background: var(--cx-intel-soft); color: var(--cx-intel-ink); }
/* Program tag */
.cx-progtag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--cx-radius-sm); font-size: 11px; font-weight: 600; background: var(--cx-neutral-soft); color: var(--cx-text-secondary); }
.cx-progtag--ccm, .cx-progtag--rpm { background: var(--cx-action-soft); color: var(--cx-info-ink); }
.cx-progtag--pcm { background: var(--cx-intel-soft); color: var(--cx-intel-ink); }
.cx-progtag--bhi { background: var(--cx-success-soft); color: var(--cx-success-ink); }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.cx-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 16px; min-height: 38px;
    border-radius: var(--cx-radius-pill); border: 1px solid transparent;
    font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background var(--cx-motion-fast), border-color var(--cx-motion-fast), color var(--cx-motion-fast);
}
.cx-btn__ico { width: 16px; height: 16px; display: inline-flex; }
.cx-btn__ico svg { width: 16px; height: 16px; }
.cx-btn:disabled, .cx-btn.is-disabled { opacity: 0.5; cursor: not-allowed; }
.cx-btn--primary { background: var(--cx-action); color: #fff; }
.cx-btn--primary:hover:not(:disabled):not(.is-disabled) { background: var(--cx-action-hover); }
.cx-btn--secondary { background: var(--cx-surface); color: var(--cx-text-secondary); border-color: var(--cx-border-strong); }
.cx-btn--secondary:hover:not(:disabled):not(.is-disabled) { background: var(--cx-surface-hover); color: var(--cx-text); }
.cx-btn--ghost { background: transparent; color: var(--cx-text-secondary); }
.cx-btn--ghost:hover:not(:disabled):not(.is-disabled) { background: var(--cx-surface-hover); color: var(--cx-text); }
.cx-btn--danger { background: var(--cx-danger); color: #fff; }
.cx-btn--danger:hover:not(:disabled):not(.is-disabled) { background: var(--cx-danger-ink); }
.cx-btn--link { background: transparent; border: none; color: var(--cx-action); padding: 4px 6px; min-height: auto; }
.cx-btn--link:hover:not(:disabled) { text-decoration: underline; }
.cx-btn--sm { min-height: 30px; padding: 5px 10px; font-size: 12px; }
.cx-btn--lg { min-height: 42px; padding: 11px 18px; font-size: 14px; }
.cx-btn--block { width: 100%; }

.cx-iconaction {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; min-width: 34px; border-radius: var(--cx-radius-md);
    border: 1px solid var(--cx-border); background: var(--cx-surface); color: var(--cx-text-secondary); cursor: pointer;
}
.cx-iconaction:hover:not(:disabled) { background: var(--cx-surface-hover); color: var(--cx-text); }
.cx-iconaction:disabled { opacity: 0.5; cursor: not-allowed; }
/* CAREOS-CARE-PLAN-STATE-DUPLICATE-OUTREACH-RPM-SCOPING-001 (§20) — dialog close focus.
   The modal moves focus to its close button programmatically when it opens. A programmatic .focus()
   does NOT match :focus-visible when the dialog was opened by pointer, so the global keyboard-only
   focus ring never painted and the focused control was invisible — while `button:focus:not(
   :focus-visible) { outline: none }` actively suppressed the fallback. The close control therefore
   gets an explicit :focus style that does not depend on the :focus-visible heuristic.
   Non-colour-only (outline + ring), inherits the theme token in light and dark, and native focus
   behaviour is untouched. */
.cx-iconaction:focus,
.cx-iconaction:focus-visible {
    outline: 2px solid var(--cx-focus);
    outline-offset: 2px;
    box-shadow: var(--cx-focus-ring);
}
/* The close button sits flush against the modal edge; keep its ring inside so it is never clipped. */
.cx-modal__close .cx-iconaction:focus,
.cx-modal__close .cx-iconaction:focus-visible { outline-offset: -1px; }

/* ── FORM SYSTEM ─────────────────────────────────────────────────────────── */
.cx-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--cx-space-4); }
.cx-field__label { font-size: var(--cx-fs-sm); font-weight: 600; color: var(--cx-text-secondary); }
.cx-field__req { color: var(--cx-danger); margin-left: 2px; }
.cx-field__hint { font-size: var(--cx-fs-meta); color: var(--cx-text-muted); }
.cx-input, .cx-select, .cx-textarea {
    font-family: inherit; font-size: 13.5px; color: var(--cx-text);
    background: var(--cx-surface); border: 1px solid var(--cx-border-strong);
    border-radius: var(--cx-radius-md); padding: 9px 12px; width: 100%;
    transition: border-color var(--cx-motion-fast), box-shadow var(--cx-motion-fast);
}
.cx-input::placeholder, .cx-textarea::placeholder { color: var(--cx-text-faint); }
.cx-input:hover, .cx-select:hover, .cx-textarea:hover { border-color: var(--cx-text-muted); }
.cx-input:focus, .cx-select:focus, .cx-textarea:focus { outline: none; border-color: var(--cx-action); box-shadow: var(--cx-focus-ring); }
.cx-input[aria-invalid="true"], .cx-select[aria-invalid="true"], .cx-textarea[aria-invalid="true"] { border-color: var(--cx-danger); }
.cx-input:disabled, .cx-select:disabled, .cx-textarea:disabled { background: var(--cx-surface-sunken); color: var(--cx-text-muted); cursor: not-allowed; }
.cx-textarea { min-height: 84px; resize: vertical; }
.cx-inline-error { font-size: var(--cx-fs-meta); color: var(--cx-danger-ink); display: flex; align-items: center; gap: 5px; }

/* Radio / checkbox groups (accessible, real inputs) */
.cx-choice-group { display: flex; flex-direction: column; gap: 6px; border: none; margin: 0; padding: 0; }
.cx-choice { display: flex; align-items: flex-start; gap: 9px; padding: 9px 12px; border: 1px solid var(--cx-border); border-radius: var(--cx-radius-md); cursor: pointer; transition: background var(--cx-motion-fast), border-color var(--cx-motion-fast); }
.cx-choice:hover { background: var(--cx-surface-hover); }
.cx-choice input { margin-top: 2px; accent-color: var(--cx-action); width: 16px; height: 16px; flex-shrink: 0; }
.cx-choice input:checked ~ .cx-choice__text { color: var(--cx-text); font-weight: 550; }
.cx-choice:has(input:checked) { border-color: var(--cx-action); background: var(--cx-action-soft); }
.cx-choice__text { font-size: 13.5px; color: var(--cx-text-secondary); }

/* Filter bar / search field */
.cx-filterbar { display: flex; align-items: center; gap: var(--cx-space-3); flex-wrap: wrap; }
.cx-searchfield { position: relative; display: inline-flex; align-items: center; }
.cx-searchfield__ico { position: absolute; left: 10px; color: var(--cx-text-faint); pointer-events: none; display: inline-flex; }
.cx-searchfield .cx-input { padding-left: 34px; }

/* ── DATA TABLE (one table language) ─────────────────────────────────────── */
.cx-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); background: var(--cx-surface); }
.cx-table { width: 100%; border-collapse: collapse; font-size: var(--cx-fs-table); }
.cx-table thead th {
    position: sticky; top: 0; z-index: 1;
    text-align: left; font-size: var(--cx-fs-label); font-weight: var(--cx-fw-label);
    letter-spacing: var(--cx-tracking-label); text-transform: uppercase; color: var(--cx-text-muted);
    background: var(--cx-surface-subtle); padding: 11px var(--cx-space-4);
    border-bottom: 1px solid var(--cx-border); white-space: nowrap;
}
.cx-table th.is-sortable { cursor: pointer; user-select: none; }
.cx-table th.is-sortable:hover { color: var(--cx-text-secondary); }
.cx-table th .cx-sort-ind { margin-left: 5px; opacity: 0.5; }
.cx-table th[aria-sort="ascending"] .cx-sort-ind,
.cx-table th[aria-sort="descending"] .cx-sort-ind { opacity: 1; color: var(--cx-action); }
.cx-table tbody td { padding: 11px var(--cx-space-4); border-bottom: 1px solid var(--cx-border-subtle); color: var(--cx-text); line-height: var(--cx-lh-table); vertical-align: middle; }
.cx-table tbody tr:last-child td { border-bottom: none; }
.cx-table tbody tr.is-clickable { cursor: pointer; }
.cx-table tbody tr.is-clickable:hover { background: var(--cx-surface-hover); }
.cx-table tbody tr:focus-visible { outline: 2px solid var(--cx-focus); outline-offset: -2px; }
.cx-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.cx-table .cx-cell-strong { font-weight: 600; color: var(--cx-text); }
.cx-table .cx-cell-muted { color: var(--cx-text-muted); }
/* Sticky action column */
.cx-table .cx-col-action { position: sticky; right: 0; background: var(--cx-surface); box-shadow: -6px 0 8px -6px rgba(15,23,42,0.12); }
.cx-table tbody tr:hover .cx-col-action { background: var(--cx-surface-hover); }

/* Responsive: reflow the widest tables to stacked cards */
.cx-table--reflow tbody tr { display: block; }
@media (min-width: 901px) { .cx-table--reflow { } }
@media (max-width: 900px) {
    .cx-table--reflow thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .cx-table--reflow tbody tr { display: block; border: 1px solid var(--cx-border); border-radius: var(--cx-radius-md); margin-bottom: var(--cx-space-3); padding: 6px 4px; }
    .cx-table--reflow tbody td { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--cx-border-subtle); padding: 8px 12px; text-align: right; }
    .cx-table--reflow tbody td::before { content: attr(data-label); font-size: var(--cx-fs-label); font-weight: 600; text-transform: uppercase; letter-spacing: var(--cx-tracking-label); color: var(--cx-text-muted); text-align: left; }
    .cx-table--reflow .cx-col-action { position: static; box-shadow: none; }
}

/* ── ALERTS / SAFETY BANNERS ─────────────────────────────────────────────── */
.cx-alert { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--cx-radius-md); border: 1px solid var(--cx-border); background: var(--cx-surface-subtle); color: var(--cx-text-secondary); font-size: 13px; line-height: 1.45; }
.cx-alert__ico { flex-shrink: 0; display: inline-flex; margin-top: 1px; }
.cx-alert__body { flex: 1; min-width: 0; }
.cx-alert__title { font-weight: 600; color: var(--cx-text); margin-bottom: 2px; }
.cx-alert--info    { background: var(--cx-info-soft);    border-color: var(--cx-action-soft-border); color: var(--cx-info-ink); }
.cx-alert--success { background: var(--cx-success-soft); border-color: var(--cx-success); color: var(--cx-success-ink); }
.cx-alert--warning { background: var(--cx-warning-soft); border-color: var(--cx-warning); color: var(--cx-warning-ink); }
.cx-alert--danger  { background: var(--cx-danger-soft);  border-color: var(--cx-danger);  color: var(--cx-danger-ink); }
/* Safety note — clinical decision-support framing (left accent) */
.cx-safety { display: flex; align-items: flex-start; gap: 8px; padding: 9px 13px; border-left: 3px solid var(--cx-warning); border-radius: 4px; background: var(--cx-warning-soft); color: var(--cx-text-secondary); font-size: 12px; line-height: 1.45; }
.cx-safety--info { border-left-color: var(--cx-action); background: var(--cx-info-soft); }
.cx-safety--muted { border-left-color: var(--cx-border-strong); background: var(--cx-surface-subtle); color: var(--cx-text-muted); }

/* ── EMPTY / LOADING / ERROR / SKELETON STATES ───────────────────────────── */
.cx-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--cx-space-9) var(--cx-space-5); gap: var(--cx-space-3); color: var(--cx-text-muted); }
.cx-state__ico { color: var(--cx-text-faint); opacity: 0.7; }
.cx-state__title { font-size: 14px; font-weight: 600; color: var(--cx-text-secondary); }
.cx-state__msg { font-size: 13px; color: var(--cx-text-muted); max-width: 420px; }
.cx-state--error .cx-state__title { color: var(--cx-danger-ink); }
.cx-state__actions { margin-top: var(--cx-space-2); display: flex; gap: var(--cx-space-2); flex-wrap: wrap; justify-content: center; }
.cx-spinner { width: 18px; height: 18px; border: 2px solid var(--cx-border-strong); border-top-color: var(--cx-action); border-radius: 50%; animation: cx-spin 0.6s linear infinite; }
@keyframes cx-spin { to { transform: rotate(360deg); } }
.cx-skel { background: linear-gradient(90deg, var(--cx-surface-sunken) 25%, var(--cx-surface-hover) 37%, var(--cx-surface-sunken) 63%); background-size: 400% 100%; animation: cx-shimmer 1.3s ease infinite; border-radius: 6px; }
@keyframes cx-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.cx-skel--line { height: 12px; margin: 6px 0; }
.cx-skel--row { height: 44px; margin: 6px 0; }

/* Disabled-feature panel (program not configured / preview) */
.cx-feature-off { border: 1px dashed var(--cx-border-strong); background: var(--cx-surface-subtle); border-radius: var(--cx-radius-lg); padding: var(--cx-space-5); color: var(--cx-text-muted); }
.cx-feature-off__head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--cx-text-secondary); font-size: 13.5px; }
.cx-feature-off__msg { font-size: 12.5px; margin-top: 4px; }

/* ── PROGRESS / TIMELINE ─────────────────────────────────────────────────── */
.cx-progress { height: 6px; background: var(--cx-surface-sunken); border-radius: var(--cx-radius-pill); overflow: hidden; }
.cx-progress__bar { height: 100%; background: var(--cx-action); border-radius: var(--cx-radius-pill); transition: width var(--cx-motion-standard); }
.cx-progress__bar.is-success { background: var(--cx-success); }
.cx-progress__bar.is-warning { background: var(--cx-warning); }
.cx-progress__bar.is-danger  { background: var(--cx-danger); }
.cx-timeline { list-style: none; margin: 0; padding: 0; }
.cx-timeline__item { position: relative; padding: 0 0 var(--cx-space-4) var(--cx-space-6); border-left: 2px solid var(--cx-border); }
.cx-timeline__item:last-child { border-left-color: transparent; padding-bottom: 0; }
.cx-timeline__dot { position: absolute; left: -6px; top: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--cx-action); border: 2px solid var(--cx-surface); }
.cx-timeline__time { font-size: var(--cx-fs-meta); color: var(--cx-text-muted); }
.cx-timeline__title { font-size: 13px; font-weight: 550; color: var(--cx-text); }

/* ── CLINICAL INTELLIGENCE PATTERNS (presentation only) ──────────────────── */
/* Clearly separates observed data / derived signal / recommendation / action. */
.cx-intel-card { border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); background: var(--cx-surface); box-shadow: var(--cx-shadow-subtle); overflow: hidden; }
.cx-intel-card__band { height: 3px; background: var(--cx-intel); }
.cx-intel-card__body { padding: var(--cx-space-4) var(--cx-space-5); display: flex; flex-direction: column; gap: var(--cx-space-3); }
.cx-intel-row { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.cx-intel-row__k { font-size: var(--cx-fs-label); font-weight: 600; letter-spacing: var(--cx-tracking-label); text-transform: uppercase; color: var(--cx-text-muted); min-width: 92px; flex-shrink: 0; }
.cx-intel-row__v { color: var(--cx-text); }
.cx-trend { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 13px; }
.cx-trend--improving { color: var(--cx-success-ink); }
.cx-trend--stable    { color: var(--cx-text-secondary); }
.cx-trend--declining { color: var(--cx-danger-ink); }
.cx-trend--insufficient { color: var(--cx-text-muted); font-style: italic; font-weight: 500; }
.cx-evidence { display: inline-flex; align-items: center; gap: 5px; font-size: var(--cx-fs-meta); color: var(--cx-text-muted); }
.cx-evidence__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cx-success); }
.cx-evidence__dot.is-stale { background: var(--cx-warning); }
.cx-evidence__dot.is-missing { background: var(--cx-text-faint); }
.cx-confidence { font-size: var(--cx-fs-meta); font-weight: 600; padding: 1px 7px; border-radius: var(--cx-radius-pill); background: var(--cx-neutral-soft); color: var(--cx-text-secondary); }
/* Next-action card — the "safest next action" surface */
.cx-nextaction { display: flex; align-items: center; gap: var(--cx-space-3); padding: var(--cx-space-3) var(--cx-space-4); border: 1px solid var(--cx-action-soft-border); background: var(--cx-action-soft); border-radius: var(--cx-radius-md); }
.cx-nextaction__ico { color: var(--cx-action); flex-shrink: 0; display: inline-flex; }
.cx-nextaction__text { flex: 1; min-width: 0; }
.cx-nextaction__label { font-size: var(--cx-fs-label); font-weight: 600; letter-spacing: var(--cx-tracking-label); text-transform: uppercase; color: var(--cx-info-ink); }
.cx-nextaction__value { font-size: 13.5px; font-weight: 550; color: var(--cx-text); }

/* ── MODAL / DRAWER ──────────────────────────────────────────────────────── */
.cx-overlay { position: fixed; inset: 0; background: rgba(8,15,26,0.5); z-index: var(--cx-z-overlay); display: flex; align-items: center; justify-content: center; padding: var(--cx-space-5); }
.cx-overlay[hidden] { display: none; }
.cx-modal { background: var(--cx-surface); border-radius: var(--cx-radius-xl); box-shadow: var(--cx-shadow-modal); width: 100%; max-width: 540px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.cx-modal--sm { max-width: 420px; }
.cx-modal--lg { max-width: 760px; }
.cx-modal__header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--cx-space-3); padding: var(--cx-space-5) var(--cx-space-5) var(--cx-space-4); border-bottom: 1px solid var(--cx-border-subtle); }
.cx-modal__title { margin: 0; font-size: var(--cx-fs-h2); font-weight: var(--cx-fw-h2); color: var(--cx-text); }
.cx-modal__sub { font-size: var(--cx-fs-meta); color: var(--cx-text-muted); margin-top: 3px; }
.cx-modal__close { flex-shrink: 0; }
.cx-modal__body { padding: var(--cx-space-5); overflow-y: auto; }
.cx-modal__footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--cx-space-2); padding: var(--cx-space-4) var(--cx-space-5); border-top: 1px solid var(--cx-border-subtle); }
/* Drawer — right sheet */
.cx-drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 420px; max-width: 92vw; background: var(--cx-surface); box-shadow: var(--cx-shadow-modal); z-index: var(--cx-z-drawer); display: flex; flex-direction: column; transform: translateX(100%); transition: transform var(--cx-motion-standard); }
.cx-drawer.is-open { transform: translateX(0); }
.cx-drawer__header { display: flex; align-items: center; justify-content: space-between; padding: var(--cx-space-5); border-bottom: 1px solid var(--cx-border-subtle); }
.cx-drawer__body { flex: 1; overflow-y: auto; padding: var(--cx-space-5); }
@media (max-width: 600px) {
    .cx-modal { max-width: none; max-height: 100vh; height: 100vh; border-radius: 0; }
    .cx-overlay { padding: 0; align-items: stretch; }
    .cx-drawer { width: 100vw; max-width: 100vw; }
}

/* ── TOAST (re-homed so migrated pages need not link page.css) ───────────── */
.careos-toast-container { position: fixed; bottom: 24px; right: 24px; z-index: var(--cx-z-toast); display: flex; flex-direction: column; gap: 10px; max-width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.careos-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--cx-surface); color: var(--cx-text); border: 1px solid var(--cx-border); border-left: 3px solid var(--cx-neutral); box-shadow: var(--cx-shadow-raised); font-size: 13px; line-height: 1.4; animation: cx-toast-in 0.18s ease; }
.careos-toast-leaving { animation: cx-toast-out 0.18s ease forwards; }
@keyframes cx-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes cx-toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(8px); } }
.careos-toast-icon { font-size: 14px; font-weight: 700; flex-shrink: 0; }
.careos-toast-body { flex: 1; min-width: 0; }
.careos-toast-title { font-weight: 600; word-wrap: break-word; }
.careos-toast-message { color: var(--cx-text-secondary); margin-top: 2px; word-wrap: break-word; }
.careos-toast-close { flex-shrink: 0; background: none; border: none; cursor: pointer; color: var(--cx-text-muted); font-size: 16px; line-height: 1; padding: 0 2px; }
.careos-toast-success { border-left-color: var(--cx-success); } .careos-toast-success .careos-toast-icon { color: var(--cx-success); }
.careos-toast-error   { border-left-color: var(--cx-danger); }  .careos-toast-error .careos-toast-icon { color: var(--cx-danger); }
.careos-toast-warning { border-left-color: var(--cx-warning); } .careos-toast-warning .careos-toast-icon { color: var(--cx-warning); }
.careos-toast-info    { border-left-color: var(--cx-action); }  .careos-toast-info .careos-toast-icon { color: var(--cx-action); }
@media (max-width: 480px) { .careos-toast-container { left: 16px; right: 16px; bottom: 16px; max-width: none; } }

/* ── GLOBAL FOCUS RING (keyboard only) ───────────────────────────────────── */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible,
[role="button"]:focus-visible, [role="tab"]:focus-visible {
    outline: 2px solid var(--cx-focus); outline-offset: 2px; border-radius: 3px;
}
a:focus:not(:focus-visible), button:focus:not(:focus-visible) { outline: none; }

/* ── TABS (accessible tablist) ───────────────────────────────────────────── */
.cx-tablist { display: flex; gap: 2px; border-bottom: 1px solid var(--cx-border); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cx-tab {
    appearance: none; background: transparent; border: none; cursor: pointer;
    padding: 11px 14px; font-family: inherit; font-size: 13.5px; font-weight: 550;
    color: var(--cx-text-muted); border-bottom: 2px solid transparent; white-space: nowrap;
    transition: color var(--cx-motion-fast), border-color var(--cx-motion-fast);
}
.cx-tab:hover { color: var(--cx-text-secondary); }
.cx-tab.is-active { color: var(--cx-action); border-bottom-color: var(--cx-action); }
.cx-tabpanels { padding-top: var(--cx-space-5); }
.cx-tabpanel:focus-visible { outline: 2px solid var(--cx-focus); outline-offset: 4px; border-radius: 4px; }

/* ── PATIENT WORKSPACE HEADER ────────────────────────────────────────────── */
.cx-pw-header { display: flex; gap: var(--cx-space-4); align-items: flex-start; flex-wrap: wrap; }
.cx-pw-id { display: flex; gap: var(--cx-space-4); align-items: center; min-width: 0; flex: 1; }
.cx-pw-meta { display: flex; flex-wrap: wrap; gap: var(--cx-space-2) var(--cx-space-5); margin-top: 6px; }
.cx-pw-meta__item { font-size: 12.5px; color: var(--cx-text-muted); }
.cx-pw-meta__item strong { color: var(--cx-text-secondary); font-weight: 600; }
.cx-pw-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cx-pw-actions { display: flex; gap: var(--cx-space-2); flex-wrap: wrap; align-items: center; }
@media (max-width: 600px) { .cx-pw-actions { width: 100%; } .cx-pw-actions > * { flex: 1 1 auto; } }

/* ── DEFINITION ROWS (overview key/value) ────────────────────────────────── */
.cx-dl { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 8px var(--cx-space-4); }
.cx-dl dt { font-size: var(--cx-fs-label); font-weight: 600; letter-spacing: var(--cx-tracking-label); text-transform: uppercase; color: var(--cx-text-muted); }
.cx-dl dd { margin: 0; font-size: 13.5px; color: var(--cx-text); }
@media (max-width: 480px) { .cx-dl { grid-template-columns: 1fr; gap: 2px var(--cx-space-4); } .cx-dl dd { margin-bottom: 8px; } }

/* ── AVATAR ──────────────────────────────────────────────────────────────── */
.cx-avatar {
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cx-action), var(--cx-intel));
    color: #fff; font-size: 12px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.cx-avatar--xs { width: 26px; height: 26px; font-size: 10.5px; }
.cx-avatar--sm { width: 30px; height: 30px; font-size: 11px; }
.cx-avatar--lg { width: 44px; height: 44px; font-size: 15px; }

/* Screen-reader-only utility */
.cx-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Utility layout helpers (token-driven) */
.cx-stack-3 > * + * { margin-top: var(--cx-space-3); }
.cx-stack-4 > * + * { margin-top: var(--cx-space-4); }
.cx-stack-6 > * + * { margin-top: var(--cx-space-6); }
.cx-row { display: flex; align-items: center; gap: var(--cx-space-3); }
.cx-row--wrap { flex-wrap: wrap; }
.cx-grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: var(--cx-space-5); }
.cx-grid-main { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: var(--cx-space-5); }
@media (max-width: 1200px) { .cx-grid-main { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 900px) { .cx-grid-2 { grid-template-columns: minmax(0,1fr); } }
.cx-muted { color: var(--cx-text-muted); }
.cx-num { font-variant-numeric: tabular-nums; }

/* ══════════════════════════════════════════════════════════════════════════
   CAREOS SIGNATURE PATTERNS · CAREOS-NEXT-GENERATION-CLINICAL-OPERATING-SYSTEM-REDESIGN-001
   Six recognizable CareOS patterns. Presentation only, token-driven (theme +
   reduced-motion inherited). They FORMALIZE the emerging primitives above
   (cx-evidence → stamp, cx-nextaction → dock, cx-intel-card → boundary,
   cx-timeline → thread) and add the two that were missing (attention rail,
   operational pulse). Rationale + usage: docs/design/CAREOS-SIGNATURE-PATTERNS-001.md
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 1. ATTENTION RAIL — what needs a human, why, urgency, owner, safest next act ── */
.cx-attn { display: flex; flex-direction: column; gap: var(--cx-space-2); }
.cx-attn__item {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--cx-space-3);
    padding: var(--cx-space-3) var(--cx-space-4);
    border: 1px solid var(--cx-border); border-left: 3px solid var(--cx-neutral);
    border-radius: var(--cx-radius-md); background: var(--cx-surface);
}
.cx-attn__item--urgent { border-left-color: var(--cx-danger); background: var(--cx-danger-soft); }
.cx-attn__item--soon   { border-left-color: var(--cx-warning); background: var(--cx-warning-soft); }
.cx-attn__item--info   { border-left-color: var(--cx-action); }
.cx-attn__ico { color: var(--cx-text-muted); display: inline-flex; align-self: start; margin-top: 2px; }
.cx-attn__main { min-width: 0; }
.cx-attn__reason { font-size: 13.5px; font-weight: 600; color: var(--cx-text); }
.cx-attn__detail { font-size: 12.5px; color: var(--cx-text-secondary); margin-top: 2px; }
.cx-attn__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.cx-attn__owner { font-size: var(--cx-fs-meta); color: var(--cx-text-muted); }
.cx-attn__cta { flex-shrink: 0; }
@media (max-width: 600px) {
    .cx-attn__item { grid-template-columns: auto 1fr; }
    .cx-attn__cta { grid-column: 2; justify-self: start; margin-top: 4px; }
}

/* ── 2. EVIDENCE STAMP — source · freshness · completeness · review state ──────── */
.cx-stamp { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 3px 10px; font-size: var(--cx-fs-meta); color: var(--cx-text-muted); }
.cx-stamp__seg { display: inline-flex; align-items: center; gap: 4px; }
.cx-stamp__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cx-success); flex-shrink: 0; }
.cx-stamp__dot.is-stale   { background: var(--cx-warning); }
.cx-stamp__dot.is-missing { background: var(--cx-text-faint); }
.cx-stamp__k { font-weight: 600; color: var(--cx-text-secondary); }
.cx-stamp__sep { color: var(--cx-border-strong); }
.cx-stamp__review { font-weight: 600; }
.cx-stamp--review-pending .cx-stamp__review { color: var(--cx-warning-ink); }
.cx-stamp--reviewed .cx-stamp__review { color: var(--cx-success-ink); }

/* ── 3. CONFIRMATION BOUNDARY — observation → signal → recommendation → confirmed ── */
.cx-boundary { border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); background: var(--cx-surface); overflow: hidden; box-shadow: var(--cx-shadow-subtle); }
.cx-boundary__layer {
    display: grid; grid-template-columns: 104px 1fr; gap: var(--cx-space-3);
    padding: var(--cx-space-3) var(--cx-space-4);
    border-bottom: 1px solid var(--cx-border-subtle); border-left: 3px solid var(--cx-border-strong);
}
.cx-boundary__layer:last-of-type { border-bottom: none; }
.cx-boundary__layer--observed { border-left-color: var(--cx-neutral); }
.cx-boundary__layer--signal   { border-left-color: var(--cx-info); }
.cx-boundary__layer--reco     { border-left-color: var(--cx-intel); }
.cx-boundary__layer--action   { border-left-color: var(--cx-success); }
.cx-boundary__tier { font-size: var(--cx-fs-label); font-weight: 600; letter-spacing: var(--cx-tracking-label); text-transform: uppercase; color: var(--cx-text-muted); }
.cx-boundary__content { font-size: 13.5px; color: var(--cx-text); min-width: 0; }
.cx-boundary__foot { display: flex; align-items: center; gap: 6px; padding: var(--cx-space-2) var(--cx-space-4); font-size: var(--cx-fs-meta); background: var(--cx-surface-subtle); color: var(--cx-text-muted); }
.cx-boundary__foot.is-pending   { color: var(--cx-warning-ink); background: var(--cx-warning-soft); }
.cx-boundary__foot.is-confirmed { color: var(--cx-success-ink); background: var(--cx-success-soft); }

/* ── 4. NEXT ACTION DOCK — role-aware single safest action, alternatives subordinate ── */
.cx-dock { border: 1px solid var(--cx-action-soft-border); background: var(--cx-action-soft); border-radius: var(--cx-radius-lg); padding: var(--cx-space-4); display: flex; flex-direction: column; gap: var(--cx-space-3); }
.cx-dock__head { display: flex; align-items: flex-start; gap: var(--cx-space-3); }
.cx-dock__ico { color: var(--cx-action); flex-shrink: 0; display: inline-flex; margin-top: 2px; }
.cx-dock__body { min-width: 0; flex: 1; }
.cx-dock__label { font-size: var(--cx-fs-label); font-weight: 600; letter-spacing: var(--cx-tracking-label); text-transform: uppercase; color: var(--cx-info-ink); }
.cx-dock__primary { font-size: 15px; font-weight: 600; color: var(--cx-text); margin-top: 2px; }
.cx-dock__why { font-size: 12.5px; color: var(--cx-text-secondary); margin-top: 2px; }
.cx-dock__actions { display: flex; flex-wrap: wrap; gap: var(--cx-space-2); }
.cx-dock__alt { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cx-space-2); padding-top: var(--cx-space-2); border-top: 1px dashed var(--cx-action-soft-border); }
.cx-dock__alt-label { font-size: var(--cx-fs-meta); color: var(--cx-text-muted); margin-right: 2px; }

/* ── 5. OPERATIONAL PULSE — population/program flow + exceptions, not a card wall ── */
.cx-pulse { display: flex; flex-direction: column; gap: var(--cx-space-3); }
.cx-pulse__track { display: flex; align-items: stretch; gap: 4px; }
.cx-pulse__seg { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; padding: var(--cx-space-3) var(--cx-space-2); border-radius: var(--cx-radius-sm); background: var(--cx-surface-sunken); text-align: center; }
.cx-pulse__seg-val { font-size: 18px; font-weight: 700; color: var(--cx-text); font-variant-numeric: tabular-nums; line-height: 1; }
.cx-pulse__seg-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: var(--cx-tracking-label); color: var(--cx-text-muted); white-space: nowrap; }
.cx-pulse__seg.is-attention { background: var(--cx-warning-soft); }
.cx-pulse__seg.is-attention .cx-pulse__seg-val { color: var(--cx-warning-ink); }
.cx-pulse__seg.is-off { opacity: 0.5; }
.cx-pulse__seg.is-off .cx-pulse__seg-val { color: var(--cx-text-muted); font-size: 13px; }
.cx-pulse__arrow { align-self: center; color: var(--cx-text-faint); flex-shrink: 0; display: inline-flex; }
.cx-pulse__legend { display: flex; flex-wrap: wrap; gap: var(--cx-space-2) var(--cx-space-4); font-size: var(--cx-fs-meta); color: var(--cx-text-muted); }
@media (max-width: 600px) { .cx-pulse__track { flex-wrap: wrap; } .cx-pulse__seg { flex-basis: calc(50% - 2px); } .cx-pulse__arrow { display: none; } }

/* ── 6. LONGITUDINAL THREAD — one time-ordered, categorized, attributed history ──── */
.cx-thread { list-style: none; margin: 0; padding: 0; }
.cx-thread__daygroup { margin-bottom: var(--cx-space-5); }
.cx-thread__daygroup:last-child { margin-bottom: 0; }
.cx-thread__date { font-size: var(--cx-fs-label); font-weight: 600; letter-spacing: var(--cx-tracking-label); text-transform: uppercase; color: var(--cx-text-muted); margin-bottom: var(--cx-space-2); }
.cx-thread__item { position: relative; padding: 0 0 var(--cx-space-4) var(--cx-space-6); border-left: 2px solid var(--cx-border); }
.cx-thread__item:last-child { padding-bottom: 4px; }
.cx-thread__dot { position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--cx-neutral); border: 2px solid var(--cx-surface); }
.cx-thread__item--measurement .cx-thread__dot { background: var(--cx-info); }
.cx-thread__item--outreach    .cx-thread__dot { background: var(--cx-action); }
.cx-thread__item--careplan    .cx-thread__dot { background: var(--cx-intel); }
.cx-thread__item--review      .cx-thread__dot { background: var(--cx-success); }
.cx-thread__item--barrier     .cx-thread__dot { background: var(--cx-warning); }
.cx-thread__item--outcome     .cx-thread__dot { background: var(--cx-success); }
.cx-thread__cat { font-size: var(--cx-fs-meta); font-weight: 600; text-transform: uppercase; letter-spacing: var(--cx-tracking-label); color: var(--cx-text-muted); }
.cx-thread__title { font-size: 13.5px; font-weight: 550; color: var(--cx-text); margin-top: 1px; }
.cx-thread__by { font-size: var(--cx-fs-meta); color: var(--cx-text-muted); margin-top: 2px; }
.cx-thread__time { font-size: var(--cx-fs-meta); color: var(--cx-text-muted); }
