/* ClinicOS Shell 2 — Patient CRM (Stage 5). Presentational only: every class, id and handler in js/crm.js is untouched.
   Scoped to `html body.cos-shell-on #page-crm`; classic shell is unaffected. Light is the reference; tokens: css/ds/tokens.css. */
html body.cos-shell-on #page-crm { --c-line: var(--cos-color-border); --c-line-soft: var(--cos-color-border-subtle); font-family: var(--cos-font); color: var(--cos-color-text-primary); max-width: 1160px !important; margin-left: auto !important; margin-right: auto !important; }   /* focused workstation width; extra monitor width becomes margin, not longer rows */
html body.cos-shell-on #page-crm * { box-sizing: border-box; }

html body.cos-shell-on #page-crm > .clinic-breadcrumb { display: none !important; }   /* the shell breadcrumb replaces the legacy "Home › Crm" trail */

/* ── Header ─────────────────────────────────────────────── */
html body.cos-shell-on #page-crm .crm-head { align-items: flex-end; margin: 0 0 var(--cos-space-4) !important; padding-top: var(--cos-space-2); }
html body.cos-shell-on #page-crm .crm-kicker { font: var(--cos-weight-semibold) 11px/1.3 var(--cos-font); letter-spacing: .08em; text-transform: uppercase; color: var(--cos-color-text-muted); }
html body.cos-shell-on #app #page-crm .crm-head h1 { margin: var(--cos-space-1) 0 0 !important; font: var(--cos-weight-bold) 2rem/1.15 var(--cos-font) !important; letter-spacing: -.03em !important; color: var(--cos-color-text-primary) !important; }
html body.cos-shell-on #page-crm .crm-head p { margin: var(--cos-space-2) 0 0; font-size: 0.9375rem; line-height: 1.5; color: var(--cos-color-text-secondary); max-width: 60ch; }

/* privacy statement: a quiet line, not a boxed alert (the wording and its placement are unchanged) */
html body.cos-shell-on #page-crm .crm-privacy { display: flex; align-items: center; gap: 6px; margin: 0 0 var(--cos-space-4) !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; background: none !important; font-size: 0.75rem !important; line-height: 1.5; color: var(--cos-color-text-muted); }

/* registry warning keeps its amber semantics, tightened */
html body.cos-shell-on #page-crm .crm-registry-warning { border-radius: var(--cos-radius-md); border-color: color-mix(in srgb, var(--cos-tone-amber) 45%, transparent); background: var(--cos-color-warning-bg); margin: 0 0 var(--cos-space-4); }

/* ── View switch → quiet underlined tabs ────────────────── */
html body.cos-shell-on #page-crm .crm-view-switch { display: flex; gap: var(--cos-space-6); margin: 0 0 var(--cos-space-5) !important; padding: 0; border: 0; border-bottom: 1px solid var(--c-line); border-radius: 0; background: none; }
html body.cos-shell-on #page-crm .crm-view-switch button { position: relative; min-height: 40px; padding: 0 2px var(--cos-space-3); border: 0; border-radius: 0; background: none; font: var(--cos-weight-medium) 0.9375rem/1.2 var(--cos-font); color: var(--cos-color-text-muted); cursor: pointer; }
html body.cos-shell-on #page-crm .crm-view-switch button:hover { color: var(--cos-color-brand-primary); }
html body.cos-shell-on #page-crm .crm-view-switch button.active { color: var(--cos-color-text-primary); font-weight: var(--cos-weight-semibold); background: none; box-shadow: none; }
html body.cos-shell-on #page-crm .crm-view-switch button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--cos-color-brand-accent); border-radius: 2px; }
html body.cos-shell-on #page-crm .crm-view-switch button:focus-visible, html body.cos-shell-on #page-crm .crm-tab:focus-visible, html body.cos-shell-on #page-crm .crm-patient-row:focus-visible,
html body.cos-shell-on #page-crm .crm-call-summary button:focus-visible { outline: 2px solid var(--cos-color-focus); outline-offset: 2px; }

/* ── Patients: list + record ────────────────────────────── */
html body.cos-shell-on #page-crm .crm-layout { grid-template-columns: minmax(280px, 320px) minmax(0, 1fr) !important; gap: var(--cos-space-6) !important; align-items: start; min-height: 560px; }
html body.cos-shell-on #page-crm .crm-list-pane { border: 1px solid var(--c-line); border-radius: var(--cos-radius-md) !important; background: var(--cos-color-bg-surface); box-shadow: none; }
/* the record is a workspace, not a second card: a single hairline separates it from the selector */
html body.cos-shell-on #page-crm .crm-workspace { border: 0; border-radius: 0 !important; background: none; box-shadow: none; overflow: visible; }
html body.cos-shell-on #page-crm .crm-list-pane { padding: 0; display: flex; flex-direction: column; }
html body.cos-shell-on #page-crm .crm-search { padding: var(--cos-space-3) !important; border-bottom: 1px solid var(--c-line-soft); }
html body.cos-shell-on #page-crm .crm-search input, html body.cos-shell-on #page-crm .crm-search select { padding: 0 var(--cos-space-3); min-height: var(--cos-control-lg); border-radius: var(--cos-radius-md); border: 1px solid var(--c-line); background: var(--cos-color-bg-surface); font: 0.875rem var(--cos-font); color: var(--cos-color-text-primary); }
html body.cos-shell-on #page-crm .crm-search input:focus-visible, html body.cos-shell-on #page-crm .crm-search select:focus-visible { outline: 2px solid var(--cos-color-focus); outline-offset: 1px; }
html body.cos-shell-on #page-crm .crm-list-count { padding: var(--cos-space-3) var(--cos-space-4) var(--cos-space-1); font: var(--cos-weight-semibold) 11px/1.3 var(--cos-font); letter-spacing: .08em; color: var(--cos-color-text-muted); }
html body.cos-shell-on #page-crm .crm-patient-list { display: block; padding: var(--cos-space-1) var(--cos-space-2) var(--cos-space-3); }

/* rows follow the approved interactive-row treatment: quiet teal hover, keyboard-only blue focus */
html body.cos-shell-on #page-crm .crm-patient-row { cursor: pointer; min-height: 60px !important; align-items: center; padding: var(--cos-space-3) var(--cos-space-3) !important; border-radius: var(--cos-radius-md); transition: background-color var(--cos-duration-fast) var(--cos-ease); }
html body.cos-shell-on #page-crm .crm-patient-row + .crm-patient-row { margin-top: 2px; }
html body.cos-shell-on #page-crm .crm-patient-row:hover { background: color-mix(in srgb, var(--cos-color-brand-accent) 7%, var(--cos-color-bg-surface)); }
html body.cos-shell-on #page-crm .crm-patient-row:active { background: color-mix(in srgb, var(--cos-color-brand-accent) 12%, var(--cos-color-bg-surface)); }
html body.cos-shell-on #page-crm .crm-patient-row.active { background: var(--cos-color-bg-selected); box-shadow: inset 3px 0 var(--cos-color-brand-accent); }
html body.cos-shell-on #page-crm .crm-patient-row b { font: var(--cos-weight-semibold) 0.875rem/1.35 var(--cos-font); color: var(--cos-color-text-primary); }
html body.cos-shell-on #page-crm .crm-patient-row small { font-size: 0.75rem !important; line-height: 1.4; margin-top: 2px !important; color: var(--cos-color-text-muted); }
html body.cos-shell-on #page-crm .crm-patient-row .crm-next { color: var(--cos-color-brand-primary); font-weight: var(--cos-weight-medium); }
html body.cos-shell-on #page-crm .crm-list-empty { padding: var(--cos-space-8) var(--cos-space-4); font-size: 0.875rem; color: var(--cos-color-text-muted); }

/* avatars: calm neutral tile instead of the gradient */
html body.cos-shell-on #page-crm .crm-avatar { background: var(--cos-tone-teal-soft); color: var(--cos-tone-teal-ink); border-radius: 50%; width: 36px; height: 36px; flex-basis: 36px; font: var(--cos-weight-semibold) 0.875rem var(--cos-font); }
html body.cos-shell-on #page-crm .crm-avatar.large { width: 52px; height: 52px; flex-basis: 52px; font-size: 1.125rem; }
html body.cos-shell-on #page-crm .crm-duplicate-dot { background: var(--cos-color-warning-bg); color: var(--cos-color-warning); }

/* record header + tabs */
html body.cos-shell-on #page-crm .crm-profile-head { padding: var(--cos-space-1) 0 var(--cos-space-4) !important; }
html body.cos-shell-on #app #page-crm .crm-profile-id h2 { margin: 0 !important; font: var(--cos-weight-semibold) 1.375rem/1.25 var(--cos-font) !important; letter-spacing: -.02em !important; color: var(--cos-color-text-primary) !important; }
html body.cos-shell-on #page-crm .crm-profile-id p { margin: 2px 0 0; font-size: 0.8125rem; color: var(--cos-color-text-muted); }
html body.cos-shell-on #page-crm .crm-duplicate-alert { margin: 0 0 var(--cos-space-3); border-radius: var(--cos-radius-md); border-color: color-mix(in srgb, var(--cos-tone-amber) 40%, transparent); background: var(--cos-color-warning-bg); color: var(--cos-tone-amber-ink); }
html body.cos-shell-on #page-crm .crm-tabs { gap: var(--cos-space-5); padding: 0 !important; border-bottom: 1px solid var(--c-line); }
html body.cos-shell-on #page-crm .crm-tab { min-height: 42px; padding: 0 2px; font: var(--cos-weight-medium) 0.875rem/1.2 var(--cos-font); color: var(--cos-color-text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
html body.cos-shell-on #page-crm .crm-tab:hover { color: var(--cos-color-brand-primary); }
html body.cos-shell-on #page-crm .crm-tab.active { color: var(--cos-color-text-primary); font-weight: var(--cos-weight-semibold); border-bottom-color: var(--cos-color-brand-accent); }
html body.cos-shell-on #page-crm #crm-tab-body { padding: var(--cos-space-5) 0 var(--cos-space-6); }

/* overview: figures read as a ruled summary, not three filled blocks */
html body.cos-shell-on #page-crm .crm-kpis { gap: 0; margin-bottom: var(--cos-space-5); border-top: 1px solid var(--c-line); border-bottom: 1px solid var(--c-line); }
html body.cos-shell-on #page-crm .crm-kpis > div { padding: var(--cos-space-3) var(--cos-space-5); border: 0; border-radius: 0; background: none; }
html body.cos-shell-on #page-crm .crm-kpis > div:first-child { padding-left: 0; }
html body.cos-shell-on #page-crm .crm-kpis > div + div { border-left: 1px solid var(--c-line-soft); }
html body.cos-shell-on #page-crm .crm-kpis b { font: var(--cos-weight-semibold) 1.5rem/1.1 var(--cos-font); letter-spacing: -.02em; color: var(--cos-color-text-primary); }
html body.cos-shell-on #page-crm .crm-kpis span { margin-top: 4px; font-size: 0.75rem; color: var(--cos-color-text-muted); }
html body.cos-shell-on #page-crm .crm-overview-grid { gap: var(--cos-space-5) !important; margin-bottom: var(--cos-space-5) !important; }
html body.cos-shell-on #page-crm .crm-panel { padding: 0 !important; border: 0; border-top: 1px solid var(--c-line); border-radius: 0 !important; background: none; }
html body.cos-shell-on #page-crm .crm-panel-title { padding: var(--cos-space-3) 0 var(--cos-space-2); }
html body.cos-shell-on #app #page-crm .crm-panel-title h3, html body.cos-shell-on #app #page-crm .crm-section-actions h3, html body.cos-shell-on #app #page-crm .crm-call-title h3 { margin: 0 !important; font: var(--cos-weight-semibold) 0.9375rem/1.3 var(--cos-font) !important; letter-spacing: -.005em !important; color: var(--cos-color-text-primary) !important; }
html body.cos-shell-on #page-crm .crm-panel-title button { min-height: 32px; padding: 0 var(--cos-space-2); border: 0; border-radius: var(--cos-radius-sm); background: none; font: var(--cos-weight-medium) 0.8125rem var(--cos-font); color: var(--cos-color-brand-primary); cursor: pointer; }
html body.cos-shell-on #page-crm .crm-panel-title button:hover { background: color-mix(in srgb, var(--cos-color-brand-accent) 9%, transparent); }
html body.cos-shell-on #page-crm .crm-panel-title button:focus-visible { outline: 2px solid var(--cos-color-focus); outline-offset: 1px; }
html body.cos-shell-on #page-crm .crm-panel dl { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: baseline; gap: var(--cos-space-3) var(--cos-space-3); margin: var(--cos-space-2) 0 0; }
html body.cos-shell-on #page-crm .crm-panel dt { font: var(--cos-weight-semibold) 11px/1.3 var(--cos-font); letter-spacing: .06em; text-transform: uppercase; color: var(--cos-color-text-muted); margin: 0; }
html body.cos-shell-on #page-crm .crm-panel dd { margin: 0; overflow-wrap: anywhere; font-size: 0.875rem; color: var(--cos-color-text-primary); }
html body.cos-shell-on #page-crm .crm-muted, html body.cos-shell-on #page-crm .crm-empty-small { padding: var(--cos-space-6) var(--cos-space-3); font-size: 0.875rem; color: var(--cos-color-text-muted); }

/* rows inside record tabs: hairline separated, no boxes */
html body.cos-shell-on #page-crm .crm-section-actions { padding-bottom: var(--cos-space-3); margin-bottom: var(--cos-space-2); border-bottom: 1px solid var(--c-line-soft); }
html body.cos-shell-on #page-crm .crm-section-actions p { font-size: 0.8125rem; color: var(--cos-color-text-muted); margin-top: 2px; }
html body.cos-shell-on #page-crm .crm-appointment-row, html body.cos-shell-on #page-crm .crm-form-row { padding: var(--cos-space-2) 0; border-bottom: 1px solid var(--c-line-soft); }
html body.cos-shell-on #page-crm .crm-appointment b, html body.cos-shell-on #page-crm .crm-form-row b, html body.cos-shell-on #page-crm .crm-activity b { font: var(--cos-weight-semibold) 0.875rem/1.35 var(--cos-font); }
html body.cos-shell-on #page-crm .crm-appointment small, html body.cos-shell-on #page-crm .crm-form-row small, html body.cos-shell-on #page-crm .crm-activity small, html body.cos-shell-on #page-crm .crm-activity time { font-size: 0.75rem !important; color: var(--cos-color-text-muted); }
html body.cos-shell-on #page-crm .crm-activity { border-bottom-color: var(--c-line-soft); }
html body.cos-shell-on #page-crm .crm-date-tile { background: var(--cos-color-bg-subtle); color: var(--cos-color-text-primary); border-radius: var(--cos-radius-md); }
html body.cos-shell-on #page-crm .crm-activity-icon { background: var(--cos-color-bg-subtle); border-radius: 50%; }
html body.cos-shell-on #page-crm .status-chip { background: var(--cos-color-neutral-bg); color: var(--cos-color-neutral); }

/* empty / locked states */
html body.cos-shell-on #page-crm .crm-empty { min-height: 420px; }
html body.cos-shell-on #page-crm .crm-empty > div { color: var(--cos-color-text-muted); font-size: 2rem; }
html body.cos-shell-on #app #page-crm .crm-empty h2 { font: var(--cos-weight-semibold) 1.125rem/1.3 var(--cos-font) !important; letter-spacing: -.01em !important; color: var(--cos-color-text-primary) !important; }
html body.cos-shell-on #page-crm .crm-locked { border: 1px solid var(--c-line); border-radius: var(--cos-radius-lg); background: var(--cos-color-bg-surface); }

/* ── Worklist ───────────────────────────────────────────── */
html body.cos-shell-on #page-crm .crm-call-lists { padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
html body.cos-shell-on #page-crm .crm-call-head { margin-bottom: var(--cos-space-4); }
html body.cos-shell-on #app #page-crm .crm-call-head h2 { margin: 2px 0 0 !important; font: var(--cos-weight-semibold) 1.375rem/1.25 var(--cos-font) !important; letter-spacing: -.02em !important; color: var(--cos-color-text-primary) !important; }
html body.cos-shell-on #page-crm .crm-call-head p { margin: var(--cos-space-1) 0 0; font-size: 0.875rem; color: var(--cos-color-text-secondary); }

/* queue selector: one ruled strip of four, the active queue underlined */
html body.cos-shell-on #page-crm .crm-call-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 0 !important; margin: 0 0 var(--cos-space-4) !important; border: 1px solid var(--c-line); border-radius: var(--cos-radius-md); background: var(--cos-color-bg-surface); overflow: hidden; }
html body.cos-shell-on #page-crm .crm-call-summary button { position: relative; min-height: 76px !important; padding: var(--cos-space-3) var(--cos-space-5) !important; border: 0 !important; border-radius: 0 !important; background: none !important; box-shadow: none !important; text-align: left; cursor: pointer; transition: background-color var(--cos-duration-fast) var(--cos-ease); }
html body.cos-shell-on #page-crm .crm-call-summary button + button { border-left: 1px solid var(--c-line) !important; }
html body.cos-shell-on #page-crm .crm-call-summary button:hover { background: color-mix(in srgb, var(--cos-color-brand-accent) 7%, var(--cos-color-bg-surface)) !important; }
html body.cos-shell-on #page-crm .crm-call-summary button b { display: block; font: var(--cos-weight-semibold) 1.5rem/1.1 var(--cos-font); letter-spacing: -.02em; color: var(--cos-color-text-primary); }
html body.cos-shell-on #page-crm .crm-call-summary button span { display: block; margin-top: 4px; font: var(--cos-weight-medium) 0.8125rem var(--cos-font); color: var(--cos-color-text-muted); }
html body.cos-shell-on #page-crm .crm-call-summary button.active { background: var(--cos-color-bg-selected) !important; }
html body.cos-shell-on #page-crm .crm-call-summary button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--cos-color-brand-accent); }
html body.cos-shell-on #page-crm .crm-call-summary button.active span { color: var(--cos-color-brand-primary); }

html body.cos-shell-on #page-crm .crm-call-panel { border: 0; border-top: 1px solid var(--c-line); border-radius: 0 !important; background: none; overflow: visible; }
html body.cos-shell-on #page-crm .crm-call-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--cos-space-4); padding: var(--cos-space-3) 0; border-bottom: 1px solid var(--c-line-soft); }
html body.cos-shell-on #page-crm .crm-call-title span { display: block; margin-top: 2px; font-size: 0.8125rem; color: var(--cos-color-text-muted); }
html body.cos-shell-on #page-crm .crm-call-row { display: grid; grid-template-columns: 36px minmax(200px, 300px) minmax(150px, 1fr) auto; align-items: center; padding: var(--cos-space-3) var(--cos-space-3) !important; gap: var(--cos-space-3) !important; border-bottom: 1px solid var(--c-line-soft); border-left: 3px solid transparent; }
html body.cos-shell-on #page-crm .crm-call-row:last-child { border-bottom: 0; }
html body.cos-shell-on #page-crm .crm-call-row.priority-urgent { border-left-color: var(--cos-tone-red); background: none; }
html body.cos-shell-on #page-crm .crm-call-row.priority-normal { border-left-color: var(--cos-tone-amber); }
html body.cos-shell-on #page-crm .crm-call-row.priority-low { border-left-color: var(--cos-color-border-strong); }
html body.cos-shell-on #page-crm .crm-call-patient b { font: var(--cos-weight-semibold) 0.9375rem/1.35 var(--cos-font); color: var(--cos-color-text-primary); }
html body.cos-shell-on #page-crm .crm-call-patient small { font-size: 0.75rem; color: var(--cos-color-text-muted); }
html body.cos-shell-on #page-crm .crm-call-reason { font-size: 0.8125rem; color: var(--cos-color-text-secondary); }
html body.cos-shell-on #page-crm .crm-call-reason em { display: block; padding: 0; background: none; border-radius: 0; font-style: normal; font: var(--cos-weight-semibold) 11px/1.3 var(--cos-font); letter-spacing: .06em; text-transform: uppercase; color: var(--cos-color-text-muted); }
html body.cos-shell-on #page-crm .priority-urgent .crm-call-reason em { color: var(--cos-color-danger); }

/* ── Buttons that live inside the CRM: consistent height and focus ── */
html body.cos-shell-on #page-crm .btn:focus-visible { outline: 2px solid var(--cos-color-focus); outline-offset: 2px; }
html body.cos-shell-on #page-crm .btn-xs { min-height: 30px; }
html body.cos-shell-on #page-crm .crm-call-row .crm-row-actions { align-items: center; gap: var(--cos-space-2) !important; flex-wrap: nowrap; }
/* Outcome = primary, Call = secondary, Manage / Open = quiet text actions */
html body.cos-shell-on #page-crm .crm-call-row .crm-row-actions .btn-ghost { min-height: 30px; padding: 0 var(--cos-space-2); border: 0; background: none; box-shadow: none; font-weight: var(--cos-weight-medium); color: var(--cos-color-text-secondary); }
html body.cos-shell-on #page-crm .crm-call-row .crm-row-actions .btn-ghost:hover { color: var(--cos-color-brand-primary); text-decoration: underline; text-underline-offset: 3px; background: none; }
html body.cos-shell-on #page-crm .crm-call-row .crm-row-actions .btn-secondary { font-weight: var(--cos-weight-medium); }
html body.cos-shell-on #page-crm .crm-ico { width: 15px; height: 15px; margin-right: 6px; vertical-align: -2px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
html body.cos-shell-on #page-crm .crm-privacy .crm-ico { display: none; }

/* ── Tablet ─────────────────────────────────────────────── */
@media (max-width: 1023px) {
  html body.cos-shell-on #page-crm .crm-call-row { grid-template-columns: 36px minmax(0, 1fr); }
  html body.cos-shell-on #page-crm .crm-call-row .crm-call-reason, html body.cos-shell-on #page-crm .crm-call-row .crm-row-actions { grid-column: 2; }
  html body.cos-shell-on #page-crm .crm-call-row .crm-row-actions { justify-content: flex-start; flex-wrap: wrap; }
  html body.cos-shell-on #page-crm .crm-workspace { border-top: 1px solid var(--c-line); padding-top: var(--cos-space-5); }
  html body.cos-shell-on #page-crm { max-width: none; }
  html body.cos-shell-on #page-crm .crm-layout { grid-template-columns: 1fr !important; }
  html body.cos-shell-on #page-crm .crm-patient-list { max-height: 300px; overflow-y: auto; }
  html body.cos-shell-on #page-crm .crm-overview-grid { grid-template-columns: 1fr !important; }
  html body.cos-shell-on #page-crm .crm-call-summary { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  html body.cos-shell-on #page-crm .crm-call-summary button:nth-child(3) { border-left: 0 !important; }
  html body.cos-shell-on #page-crm .crm-call-summary button:nth-child(n+3) { border-top: 1px solid var(--c-line) !important; }
}
@media (max-width: 767px) {
  html body.cos-shell-on #page-crm .crm-head { flex-direction: column; align-items: stretch; }
  html body.cos-shell-on #page-crm .crm-form-row { grid-template-columns: 1fr; }
  html body.cos-shell-on #page-crm .crm-kpis { grid-template-columns: 1fr; }
  html body.cos-shell-on #page-crm .crm-kpis > div + div { border-left: 0; border-top: 1px solid var(--c-line); }
}
@media (hover: none) { html body.cos-shell-on #page-crm .crm-patient-row { min-height: 64px !important; } html body.cos-shell-on #page-crm .crm-tab, html body.cos-shell-on #page-crm .crm-view-switch button { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { html body.cos-shell-on #page-crm .crm-patient-row, html body.cos-shell-on #page-crm .crm-call-summary button { transition: none; } }
