/* ===========================================================================
   Provider Insight Panel — page-scoped theme (CLX-767)

   Faithful port of the approved design handoff (design_handoff_insight_panel)
   for the /provider-insights route ONLY. Everything is scoped under the root
   class `.cip-insight-panel` and every class is prefixed `cip-` so:
     1. nothing leaks to other CIP routes (verify /ortho, /ckd unchanged), and
     2. the handoff's generic class names (card/row/col/btn/tag) do NOT cascade
        onto reused Bootstrap / CIP components (AiScribe, AiResponseGenerator)
        rendered INSIDE the panel.

   Tokens + component CSS mirror styles.css from the handoff. Figtree is the
   body font (CIP already loads it); IBM Plex Mono is added for code/numbers.
   This page-scoped theme is the agreed, contained exception to the global
   typography rule — it does not restyle any other surface.
   =========================================================================== */

.cip-insight-panel {
  /* Brand */
  --brand: #0F62B5;
  --brand-deep: #0A4A8C;
  --brand-tint: #E8F1FB;
  --brand-tint-2: #D4E5F7;
  --accent: #00A8B5;
  --accent-tint: #DFF5F6;

  /* Neutrals */
  --bg: #F4F6FA;
  --bg-cool: #EDF1F6;
  --surface: #FFFFFF;
  --surface-2: #FAFBFD;
  --ink: #0B1B2E;
  --ink-2: #2A3A4D;
  --muted: #5E6F82;
  --muted-2: #8694A3;
  --border: #E3E8EF;
  --border-strong: #CBD3DD;
  --divider: #EFF2F6;

  /* Semantic */
  --success: #138A36;
  --success-tint: #E4F4E9;
  --warn: #B26904;
  --warn-tint: #FCEFD9;
  --danger: #BF2E2E;
  --danger-tint: #FBE4E4;
  --info: #0F62B5;
  --info-tint: #E8F1FB;

  /* Density (compact default) */
  --pad-card: 14px;
  --pad-card-y: 12px;
  --gap-grid: 12px;
  --gap-row: 8px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 22px;
  --text-2xl: 28px;
  --text-3xl: 36px;
  --line: 1.45;

  /* Shadows */
  --shadow-card: 0 1px 0 rgba(11,27,46,0.04), 0 1px 2px rgba(11,27,46,0.04);
  --shadow-pop: 0 8px 24px rgba(11,27,46,0.10), 0 2px 6px rgba(11,27,46,0.06);

  background: var(--bg);
  color: var(--ink);
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--text-base);
  line-height: var(--line);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01";
  padding: var(--gap-grid);
}

.cip-insight-panel *,
.cip-insight-panel *::before,
.cip-insight-panel *::after { box-sizing: border-box; }

.cip-insight-panel .cip-mono {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
  font-feature-settings: "zero", "ss01";
}
.cip-insight-panel .cip-num { font-variant-numeric: tabular-nums; }

/* === generic helpers === */
.cip-insight-panel .cip-row { display: flex; align-items: center; gap: 8px; }
.cip-insight-panel .cip-row.cip-wrap { flex-wrap: wrap; }
.cip-insight-panel .cip-col { display: flex; flex-direction: column; gap: var(--gap-row); }
.cip-insight-panel .cip-spacer { flex: 1; }
.cip-insight-panel .cip-muted { color: var(--muted); }
.cip-insight-panel .cip-center { text-align: center; }
.cip-insight-panel .cip-div { border: 0; border-top: 1px solid var(--divider); margin: 10px 0; }

/* === Buttons === */
.cip-insight-panel .cip-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink);
  font-size: var(--text-sm); font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.cip-insight-panel .cip-btn:hover { background: var(--bg-cool); }
.cip-insight-panel .cip-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.cip-insight-panel .cip-btn.primary:hover { background: var(--brand-deep); }
.cip-insight-panel .cip-btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.cip-insight-panel .cip-btn.ghost:hover { background: var(--bg-cool); }
.cip-insight-panel .cip-btn.success { background: var(--success); color: #fff; border-color: var(--success); }
.cip-insight-panel .cip-btn.success:hover { filter: brightness(0.95); }
.cip-insight-panel .cip-btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.cip-insight-panel .cip-btn.accent:hover { filter: brightness(0.95); }
.cip-insight-panel .cip-btn.sm { padding: 4px 10px; font-size: var(--text-xs); border-radius: 6px; }
.cip-insight-panel .cip-btn.icon { padding: 6px; }

/* === Card === */
.cip-insight-panel .cip-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.cip-insight-panel .cip-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px var(--pad-card);
  border-bottom: 1px solid var(--divider);
  gap: 8px;
}
.cip-insight-panel .cip-card-head h3 {
  margin: 0; font-size: var(--text-md); font-weight: 600; letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 8px; color: var(--ink);
}
.cip-insight-panel .cip-eyebrow {
  font-size: 10px; font-weight: 600; color: var(--muted-2);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.cip-insight-panel .cip-actions { display: flex; gap: 4px; align-items: center; }
.cip-insight-panel .cip-card-body { padding: var(--pad-card-y) var(--pad-card); }
.cip-insight-panel .cip-card.brand-tint {
  background: linear-gradient(180deg, var(--brand-tint) 0%, var(--surface) 70%);
  border-color: var(--brand-tint-2);
}

.cip-insight-panel .cip-section-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
  margin: 0 0 6px 0;
}

/* === Tags === */
.cip-insight-panel .cip-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-xs); font-weight: 500;
  padding: 2px 8px; border-radius: 999px;
  background: var(--bg-cool); color: var(--ink-2);
  border: 1px solid var(--border);
}
.cip-insight-panel .cip-tag.danger { background: var(--danger-tint); color: var(--danger); border-color: #f3c8c8; }
.cip-insight-panel .cip-tag.warn { background: var(--warn-tint); color: var(--warn); border-color: #f3d8a3; }
.cip-insight-panel .cip-tag.success { background: var(--success-tint); color: var(--success); border-color: #c5e6cc; }
.cip-insight-panel .cip-tag.info { background: var(--info-tint); color: var(--brand-deep); border-color: var(--brand-tint-2); }

/* === Key-value + bullet lists === */
.cip-insight-panel .cip-kv-list { display: grid; gap: var(--gap-row); }
.cip-insight-panel .cip-kv-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: start; }
.cip-insight-panel .cip-kv-row .k { color: var(--muted); font-size: var(--text-sm); padding-top: 1px; }
.cip-insight-panel .cip-kv-row .v { color: var(--ink); font-size: var(--text-base); }

.cip-insight-panel .cip-bullet-list { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.cip-insight-panel .cip-bullet-list li { position: relative; padding-left: 16px; font-size: var(--text-base); color: var(--ink-2); }
.cip-insight-panel .cip-bullet-list li::before {
  content: ""; position: absolute; left: 4px; top: 8px;
  width: 4px; height: 4px; border-radius: 999px; background: var(--brand);
}

/* Visit-brief / coding expandable bullets */
.cip-insight-panel .cip-vb-bullets { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.cip-insight-panel .cip-vb-bullets li {
  position: relative; padding-left: 18px;
  font-size: 13.5px; color: var(--ink-2); line-height: 1.5;
}
.cip-insight-panel .cip-vb-bullets li::before {
  content: ""; position: absolute; left: 4px; top: 8px;
  width: 6px; height: 6px; border-radius: 999px; background: var(--bullet-color, var(--brand));
}

/* === Compliance ring (conic gradient) === */
.cip-insight-panel .cip-ring {
  --pct: 60; --size: 76px;
  width: var(--size); height: var(--size);
  border-radius: 999px;
  display: grid; place-items: center;
  background: conic-gradient(var(--ring-color, var(--warn)) calc(var(--pct)*1%), var(--bg-cool) 0);
  position: relative; flex-shrink: 0;
}
.cip-insight-panel .cip-ring::after {
  content: ""; position: absolute; inset: 7px;
  background: var(--surface); border-radius: 999px;
}
.cip-insight-panel .cip-ring-inner { position: relative; z-index: 1; text-align: center; line-height: 1; }
.cip-insight-panel .cip-ring .pct { font-size: 20px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cip-insight-panel .cip-ring .pct .small { font-size: 11px; color: var(--muted); font-weight: 500; }
.cip-insight-panel .cip-ring .lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 3px; }

/* === Timeline === */
.cip-insight-panel .cip-timeline { position: relative; padding-left: 18px; }
.cip-insight-panel .cip-timeline::before {
  content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px;
  width: 1px; background: var(--border);
}
.cip-insight-panel .cip-tl-item { position: relative; padding: 4px 0 14px 0; }
.cip-insight-panel .cip-tl-item:last-child { padding-bottom: 0; }
.cip-insight-panel .cip-tl-item::before {
  content: ""; position: absolute; left: -18px; top: 7px;
  width: 9px; height: 9px; border-radius: 999px;
  background: var(--surface); border: 2px solid var(--brand);
}
.cip-insight-panel .cip-tl-item.current::before { background: var(--brand); }
.cip-insight-panel .cip-tl-item.outcome-bad::before { border-color: var(--warn); }
.cip-insight-panel .cip-tl-title { font-size: var(--text-sm); font-weight: 500; color: var(--ink); }
.cip-insight-panel .cip-tl-date { font-size: var(--text-xs); color: var(--muted); margin-top: 1px; }
.cip-insight-panel .cip-tl-outcome { font-size: var(--text-xs); margin-top: 3px; }

/* === Hero / cockpit grid row === */
.cip-insight-panel .cip-hero {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: calc(var(--gap-grid) / 2);
  align-items: stretch;
}
.cip-insight-panel .cip-hero + .cip-hero { margin-top: var(--gap-grid); }
.cip-insight-panel .cip-hero > * {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  margin: 0;
  min-width: 0;
}
.cip-insight-panel .cip-hero .cip-card {
  overflow: visible;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.cip-insight-panel .cip-hero .cip-card .cip-card-body { flex: 1; }
.cip-insight-panel .cip-hero > .cip-right {
  background: transparent;
  border: 0;
  padding: 0;
}
.cip-insight-panel .cip-hero > .cip-right > .cip-card { height: 100%; display: flex; flex-direction: column; }

/* Col-1 stack (R2): Patient Context + the inline live transcript beneath it. Transparent grid
   child (like .cip-right) so each stacked card supplies its own surface. */
.cip-insight-panel .cip-hero > .cip-ctx-stack {
  background: transparent; border: 0; padding: 0;
  display: flex; flex-direction: column; gap: calc(var(--gap-grid) / 2); min-width: 0;
}
/* While recording, col 1 grows with the transcript — keep cols 2–3 top-aligned, not stretched. */
.cip-insight-panel .cip-hero.recording { align-items: start; }

.cip-insight-panel .cip-ctx {
  flex: 1; padding: 14px 16px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.cip-insight-panel .cip-left {
  padding: 16px 18px;
  background: linear-gradient(180deg, var(--brand-tint) 0%, var(--surface) 80%);
  border-color: var(--brand-tint-2);
}
.cip-insight-panel .cip-ctx-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cip-insight-panel .cip-ctx-photo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-tint), var(--accent-tint));
  display: grid; place-items: center;
  color: var(--brand-deep); font-weight: 600; font-size: 14px;
  border: 1px solid var(--border); flex-shrink: 0;
}
.cip-insight-panel .cip-ctx-name { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; line-height: 1.2; }
.cip-insight-panel .cip-ctx-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* responsive collapse (handoff is desktop-first ≥1280px) */
@media (max-width: 1024px) {
  .cip-insight-panel .cip-hero { grid-template-columns: 1fr; }
}

/* === Expandable section (Visit Brief / Visit Work) === */
.cip-insight-panel .cip-exp {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden;
}
.cip-insight-panel .cip-exp-head { cursor: pointer; padding: 9px 11px; background: transparent; }
.cip-insight-panel .cip-exp-head.open { background: var(--surface-2); }
.cip-insight-panel .cip-exp-label {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.cip-insight-panel .cip-exp-dot { width: 6px; height: 6px; border-radius: 999px; }
.cip-insight-panel .cip-exp-status { font-size: 12.5px; font-weight: 600; }
.cip-insight-panel .cip-exp-preview { display: flex; gap: 8px; margin-top: 4px; align-items: flex-start; }
.cip-insight-panel .cip-exp-preview .bdot { width: 4px; height: 4px; border-radius: 999px; flex-shrink: 0; margin-top: 7px; }
.cip-insight-panel .cip-exp-preview .ptext { font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.cip-insight-panel .cip-exp-body { padding: 4px 11px 11px; }
.cip-insight-panel .cip-chev { transition: transform 160ms ease; color: var(--muted); display: inline-flex; }
.cip-insight-panel .cip-chev.open { transform: rotate(90deg); }

/* === Scribe block (in Patient Context) === */
.cip-insight-panel .cip-scribe-block { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.cip-insight-panel .cip-scribe-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 6px; }
.cip-insight-panel .cip-scribe-col { min-width: 0; }
.cip-insight-panel .cip-scribe-label { font-size: 11px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.cip-insight-panel .cip-radio-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); cursor: pointer; position: relative; }
.cip-insight-panel .cip-radio-pill input { position: absolute; opacity: 0; pointer-events: none; }
.cip-insight-panel .cip-radio-pill .dot-r {
  width: 14px; height: 14px; border-radius: 999px;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  display: inline-block; position: relative; flex-shrink: 0;
}
.cip-insight-panel .cip-radio-pill.on .dot-r { border-color: var(--accent); }
.cip-insight-panel .cip-radio-pill.on .dot-r::after { content: ""; position: absolute; inset: 2px; border-radius: 999px; background: var(--accent); }
.cip-insight-panel .cip-radio-pill.on { color: var(--ink); font-weight: 500; }
.cip-insight-panel .cip-device-select {
  width: 100%; box-sizing: border-box; height: 34px;
  padding: 0 28px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235E6F82' stroke-width='2' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>")
    right 8px center / 14px no-repeat;
  font-size: 12px; font-weight: 500; color: var(--ink); font-family: inherit;
  appearance: none; margin-top: 6px; cursor: pointer; line-height: 32px;
}
.cip-insight-panel .cip-device-select:focus { outline: 2px solid var(--brand-tint-2); outline-offset: -1px; }
.cip-insight-panel .cip-scribe-actions { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 6px; margin-top: 12px; align-items: stretch; }
.cip-insight-panel .cip-scribe-actions .cip-btn { height: 34px; box-sizing: border-box; justify-content: center; white-space: nowrap; min-width: 0; }
.cip-insight-panel .cip-consent-off { color: var(--danger); border-color: #f3c8c8; background: var(--surface); }
.cip-insight-panel .cip-consent-off:hover { background: var(--danger-tint); }
.cip-insight-panel .cip-consent-on { color: var(--success); border-color: #c5e6cc; background: var(--surface); }
.cip-insight-panel .cip-consent-on:hover { background: var(--success-tint); }
.cip-insight-panel .cip-scribe-btn.recording { background: var(--danger); border-color: var(--danger); color: #fff; animation: cip-pulse 1.8s ease infinite; }

/* === Quality / billing score bars === */
.cip-insight-panel .cip-qs-bar-row { display: grid; grid-template-columns: minmax(60px,auto) minmax(0,1fr) 32px; gap: 8px; align-items: center; }
.cip-insight-panel .cip-qs-bar-label { font-size: 11px; color: var(--ink-2); }
.cip-insight-panel .cip-qs-bar { height: 5px; background: var(--bg-cool); border-radius: 999px; position: relative; overflow: hidden; }
.cip-insight-panel .cip-qs-bar-fill { position: absolute; inset: 0; border-radius: 999px; }

/* === Risk profile rows === */
.cip-insight-panel .cip-risk-row { border-bottom: 1px dashed var(--divider); padding-bottom: 6px; }
.cip-insight-panel .cip-risk-head { display: flex; justify-content: space-between; cursor: pointer; padding: 4px 0; align-items: center; }
.cip-insight-panel .cip-risk-name { font-size: var(--text-sm); font-weight: 500; }
.cip-insight-panel .cip-risk-level { font-size: 10px; font-weight: 600; }
.cip-insight-panel .cip-risk-track { width: 50px; height: 4px; background: var(--bg-cool); border-radius: 999px; position: relative; }
.cip-insight-panel .cip-risk-fill { position: absolute; inset: 0; border-radius: 999px; }
.cip-insight-panel .cip-risk-score { font-size: 11px; color: var(--muted); width: 22px; text-align: right; }

/* === Trends legend === */
.cip-insight-panel .cip-trend-legend { display: flex; gap: 12px; font-size: var(--text-xs); color: var(--muted); }
.cip-insight-panel .cip-trend-legend .sw { width: 10px; height: 2px; display: inline-block; margin-right: 4px; vertical-align: middle; }

/* === Evidence / dashed list rows === */
.cip-insight-panel .cip-dash-row { padding: 6px 0; border-bottom: 1px dashed var(--divider); }
.cip-insight-panel .cip-dash-row:last-child { border-bottom: 0; }

/* === Inline live-transcript panel (R1 — replaces the floating window) === */
.cip-insight-panel .cip-scribe-live {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; overflow: visible; /* visible so the note-type menu can escape the card */
}
.cip-insight-panel .cip-scribe-live.recording { border-color: var(--brand-tint-2); box-shadow: 0 0 0 2px var(--brand-tint), var(--shadow-card); }
.cip-insight-panel .cip-scribe-live .csl-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--divider); background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0; /* card is overflow:visible now — round the corners here */
}
.cip-insight-panel .cip-scribe-live .csl-head h3 {
  margin: 0; font-size: var(--text-md); font-weight: 600; letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 8px; color: var(--ink);
}
.cip-insight-panel .cip-scribe-live .csl-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; color: var(--muted); flex: none; }
.cip-insight-panel .cip-scribe-live .csl-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--muted-2); flex: none; }
.cip-insight-panel .cip-scribe-live .csl-dot.live { background: var(--danger); animation: cip-pulse-dot 1.4s ease infinite; }
.cip-insight-panel .cip-scribe-live .csl-dot.error { background: var(--danger); }
.cip-insight-panel .cip-scribe-live .csl-body {
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
  max-height: 240px; overflow-y: auto;
}
.cip-insight-panel .cip-scribe-live .csl-empty { padding: 8px 2px; font-size: 12.5px; }
.cip-insight-panel .cip-scribe-live .csl-listening { display: inline-flex; align-items: center; gap: 8px; color: var(--brand-deep); font-weight: 500; }
.cip-insight-panel .cip-scribe-live .csl-err-text { color: var(--danger); font-weight: 500; }
.cip-insight-panel .cip-scribe-live .tr-line { display: grid; gap: 2px; }
.cip-insight-panel .cip-scribe-live .tr-speaker { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.cip-insight-panel .cip-scribe-live .tr-line.doctor .tr-speaker { color: var(--brand); }
.cip-insight-panel .cip-scribe-live .tr-line.patient .tr-speaker { color: var(--accent); }
.cip-insight-panel .cip-scribe-live .tr-text { font-size: 12.5px; line-height: 1.5; color: var(--ink); padding: 6px 10px; background: var(--surface-2); border-radius: 8px; border-left: 2px solid transparent; }
.cip-insight-panel .cip-scribe-live .tr-line.doctor .tr-text { border-left-color: var(--brand); }
.cip-insight-panel .cip-scribe-live .tr-line.patient .tr-text { border-left-color: var(--accent); }
.cip-insight-panel .cip-scribe-live .csl-foot {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--divider); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Custom note-type dropdown (replaces the native <select> whose open list can't be themed) */
.cip-insight-panel .cip-scribe-live .csl-nt { position: relative; }
.cip-insight-panel .cip-scribe-live .csl-nt-btn {
  width: 100%; height: 32px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 8px 0 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--ink); cursor: pointer; text-align: left; transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.cip-insight-panel .cip-scribe-live .csl-nt-btn:hover { border-color: var(--brand-tint-2); }
.cip-insight-panel .cip-scribe-live .csl-nt.open .csl-nt-btn { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.cip-insight-panel .cip-scribe-live .csl-nt-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cip-insight-panel .cip-scribe-live .csl-nt-chev { display: inline-flex; flex: none; color: var(--muted); transition: transform 0.15s ease; }
.cip-insight-panel .cip-scribe-live .csl-nt.open .csl-nt-chev { transform: rotate(180deg); }
.cip-insight-panel .cip-scribe-live .csl-nt-backdrop { position: fixed; inset: 0; z-index: 60; }
.cip-insight-panel .cip-scribe-live .csl-nt-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 61; margin: 0; padding: 5px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 14px 34px rgba(15,23,42,0.18);
  max-height: 264px; overflow-y: auto; animation: cip-nt-pop 0.13s ease;
}
.cip-insight-panel .cip-scribe-live .csl-nt-menu li {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  font-size: 12.5px; color: var(--ink-2); cursor: pointer; transition: background 0.1s ease, color 0.1s ease;
}
.cip-insight-panel .cip-scribe-live .csl-nt-menu li:hover { background: var(--brand-tint); color: var(--brand-deep); }
.cip-insight-panel .cip-scribe-live .csl-nt-menu li.on { color: var(--brand-deep); font-weight: 600; }
.cip-insight-panel .cip-scribe-live .csl-nt-check { width: 12px; height: 12px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.cip-insight-panel .cip-scribe-live .csl-nt-opt { flex: 1; min-width: 0; }
.cip-insight-panel .cip-scribe-live .csl-foot-actions { display: flex; align-items: center; gap: 6px; }
.cip-insight-panel .cip-scribe-live .csl-privacy { font-size: 10px; color: var(--muted-2); display: inline-flex; align-items: center; gap: 5px; margin-right: auto; }
.cip-insight-panel .cip-scribe-live .cip-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Note Studio view === */
/* Fill the viewport from the first frame so the note streams into a stable full-height card
   (head pinned top, body fills + scrolls, chat bar pinned bottom) instead of the card growing
   as the note is written. ~150px = banner above (~79) + footer + margins below. */
.cip-insight-panel .cip-note-top { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); display: flex; flex-direction: column; height: calc(100vh - 150px); min-height: 420px; }
.cip-insight-panel .cip-note-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--divider); background: var(--surface-2); flex-wrap: wrap; gap: 8px;
}
.cip-insight-panel .cip-note-tabs { display: inline-flex; background: var(--bg-cool); border-radius: 8px; padding: 3px; gap: 2px; }
.cip-insight-panel .cip-note-tabs button {
  padding: 5px 10px; border: 0; background: transparent; font: inherit; font-size: 12px; font-weight: 500;
  color: var(--muted); cursor: pointer; border-radius: 6px; display: inline-flex; align-items: center; gap: 5px;
}
.cip-insight-panel .cip-note-tabs button.on { background: var(--surface); color: var(--brand-deep); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.cip-insight-panel .cip-note-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px;
  border-bottom: 1px solid var(--divider); background: var(--surface-2); flex-wrap: wrap;
}
.cip-insight-panel .cip-note-action {
  height: 40px; padding: 0 16px; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff; border: 1px solid var(--brand); border-radius: 8px;
  font-family: inherit; cursor: pointer;
}
.cip-insight-panel .cip-note-action:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.cip-insight-panel .cip-note-action.subtle { background: var(--surface); color: var(--ink-2); border-color: var(--border-strong); }
.cip-insight-panel .cip-note-action.subtle:hover { background: var(--bg-cool); }
.cip-insight-panel .cip-note-action.send { background: var(--brand-deep); border-color: var(--brand-deep); }
.cip-insight-panel .cip-note-action.on { background: var(--brand-deep); border-color: var(--brand-deep); box-shadow: inset 0 1px 3px rgba(0,0,0,0.25); }
.cip-insight-panel .cip-note-body {
  padding: 18px 22px; flex: 1 1 auto; min-height: 0; overflow-y: auto;
  font-size: 13.5px; line-height: 1.6; color: var(--ink);
}
.cip-insight-panel .cip-note-body:focus { outline: none; }
.cip-insight-panel .cip-note-body h3 { font-size: 18px; margin: 0 0 12px; letter-spacing: -0.01em; }
.cip-insight-panel .cip-note-body h4 {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--brand-deep); margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--divider);
}
.cip-insight-panel .cip-note-body p { margin: 6px 0; }
.cip-insight-panel .cip-note-body ul, .cip-insight-panel .cip-note-body ol { padding-left: 22px; margin: 6px 0; }
.cip-insight-panel .cip-note-body li { margin-bottom: 4px; }
.cip-insight-panel .cip-note-chat-bar { padding: 12px 16px; background: linear-gradient(180deg, var(--brand-tint) 0%, var(--surface) 100%); border-bottom: 1px solid var(--brand-tint-2); }
.cip-insight-panel .cip-note-chat-eyebrow { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; color: var(--brand-deep); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.cip-insight-panel .cip-note-chat-wrap { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--brand-tint-2); border-radius: 999px; padding: 4px 4px 4px 16px; box-shadow: 0 2px 6px rgba(15,98,181,0.08); }
.cip-insight-panel .cip-note-chat-input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 13px; color: var(--ink); padding: 6px 8px; }
.cip-insight-panel .cip-note-chat-mic, .cip-insight-panel .cip-note-chat-send { width: 32px; height: 32px; border-radius: 999px; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; margin-left: 4px; }
.cip-insight-panel .cip-note-chat-send { background: var(--brand-deep); }

/* === AI reasoning prose (reused AiResponseGenerator output, scoped restyle only) === */
/* Cap the live block so variable-length model output keeps cards compact and the grid balanced. */
.cip-insight-panel .cip-ai-zone { max-height: 240px; overflow-y: auto; padding-right: 2px; }
.cip-insight-panel .cip-ai-zone::-webkit-scrollbar { width: 6px; }
.cip-insight-panel .cip-ai-zone::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.cip-insight-panel .cip-ai-zone table { width: 100%; border-collapse: collapse; font-size: 11px; margin: 4px 0; }
.cip-insight-panel .cip-ai-zone th, .cip-insight-panel .cip-ai-zone td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--divider); vertical-align: top; color: var(--ink-2); }
.cip-insight-panel .cip-ai-zone th { color: var(--muted); font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.cip-insight-panel .cip-ai-zone .content-zone { padding: 0; }
.cip-insight-panel .cip-ai-zone .ai-response-content,
.cip-insight-panel .cip-ai-zone p.small { font-size: 12.5px !important; color: var(--ink-2); line-height: 1.55; margin: 0; }
.cip-insight-panel .cip-ai-zone .ai-response-content h1,
.cip-insight-panel .cip-ai-zone .ai-response-content h2,
.cip-insight-panel .cip-ai-zone .ai-response-content h3,
.cip-insight-panel .cip-ai-zone .ai-response-content h4,
.cip-insight-panel .cip-ai-zone .ai-response-content h5,
.cip-insight-panel .cip-ai-zone .ai-response-content h6 { font-size: 12px !important; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 10px 0 4px; }
.cip-insight-panel .cip-ai-zone .ai-response-content ul { padding-left: 18px; margin: 4px 0; }
.cip-insight-panel .cip-ai-zone .ai-response-content li { font-size: 12.5px; color: var(--ink-2); margin-bottom: 3px; }
/* === Live-AI loading indicator (CLX-767 E1) ===
   AiResponseGenerator (shared, unedited) renders a bare <span>Generating response...</span>
   as the ONLY child of .ai-response-content while the ClinicalGpt call is in flight; post-load
   that span is gone (content becomes Markdig block HTML). We key on that loading-only span to
   show a breathing brand-blue dot + "cliexaAI is analyzing…" — page-scoped, no shared-component
   edit. Covers all live-AI zones on this route (the 3 dashboard cards + Note Studio note-gen). */
.cip-insight-panel .cip-ai-zone .ai-response-content > span:only-child {
	display: inline-flex; align-items: center; gap: 8px; font-size: 0; /* hide the default text */
}
.cip-insight-panel .cip-ai-zone .ai-response-content > span:only-child::before {
	content: ""; width: 8px; height: 8px; border-radius: 999px; flex: none;
	background: var(--brand); animation: cip-pulse-dot 1.4s ease infinite; /* keyframe already defined below */
}
.cip-insight-panel .cip-ai-zone .ai-response-content > span:only-child::after {
	content: "cliexaAI is analyzing\2026"; font-size: 13px; font-weight: 500; color: var(--muted);
}

/* === Live indicator dot (Documentation Quality "Live") === */
.cip-insight-panel .cip-rec-live { width: 8px; height: 8px; border-radius: 999px; background: var(--success); display: inline-block; animation: cip-pulse-dot 2.4s ease infinite; }

/* === Streaming caret (blinks at the end of the note while it is being written) === */
.cip-insight-panel .cip-stream-caret { display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: text-bottom; background: var(--brand); border-radius: 1px; animation: cip-blink 1.05s step-end infinite; }

/* === "cliexaAI is writing…" breathing indicator (shown before the first token streams in) === */
.cip-insight-panel .cip-note-writing { display: flex; align-items: center; gap: 13px; padding: 30px 4px; }
.cip-insight-panel .cip-note-writing-orb { width: 14px; height: 14px; border-radius: 999px; flex: none; background: var(--brand); animation: cip-breathe 1.8s ease-in-out infinite; }
.cip-insight-panel .cip-note-writing-text { font-size: 14px; font-weight: 500; letter-spacing: -0.01em; color: var(--brand-deep); animation: cip-breathe-text 1.8s ease-in-out infinite; }

/* === Footer === */
.cip-insight-panel .cip-foot { padding: 14px 4px; font-size: var(--text-xs); color: var(--muted); display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); margin-top: var(--gap-grid); }

/* === Animations === */
@keyframes cip-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(15,98,181,0.4); } 50% { box-shadow: 0 0 0 8px rgba(15,98,181,0); } }
@keyframes cip-pulse-dot { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.8); } }
@keyframes cip-blink { 50% { opacity: 0; } }
@keyframes cip-spin { to { transform: rotate(360deg); } }
/* Breathing loader: orb scales + emits a soft expanding glow ring; text gently fades. */
@keyframes cip-breathe {
  0%, 100% { transform: scale(0.82); opacity: 0.7; box-shadow: 0 0 0 0 rgba(15,98,181,0.35); }
  50% { transform: scale(1.18); opacity: 1; box-shadow: 0 0 0 11px rgba(15,98,181,0); }
}
@keyframes cip-breathe-text { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes cip-nt-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Visit Toolkit (Phase 3, CLX-767) — Clinical Workflow launcher + output drawer ─────────── */
/* Launcher: responsive grid of tool buttons inside the "Clinical Workflow" cip-card. */
.cip-insight-panel .cip-wf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}
.cip-insight-panel .cip-wf-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--ink);
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.cip-insight-panel .cip-wf-btn:hover {
  background: var(--brand-tint); border-color: var(--brand-tint-2);
  box-shadow: var(--shadow-card);
}
.cip-insight-panel .cip-wf-ico {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-tint);
}
.cip-insight-panel .cip-wf-text { display: flex; flex-direction: column; min-width: 0; }
.cip-insight-panel .cip-wf-label { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.cip-insight-panel .cip-wf-sub {
  font-size: 11px; color: var(--muted); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Output drawer: right-side panel over a dimmed backdrop; hosts ONE AiResponseGenerator. */
.cip-insight-panel .cip-drawer-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(11, 27, 46, 0.32);
  animation: cip-fade-in .14s ease;
}
.cip-insight-panel .cip-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 91;
  height: 100dvh; width: min(580px, 94vw); max-width: 96vw;
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  animation: cip-drawer-in .2s cubic-bezier(.22, .61, .36, 1);
}
/* Left-edge drag handle: widen/narrow the drawer; double-click resets (insightPanelDrawer.js). */
.cip-insight-panel .cip-drawer-resize {
  position: absolute; top: 0; left: -4px; width: 9px; height: 100%;
  cursor: ew-resize; z-index: 2; touch-action: none;
}
.cip-insight-panel .cip-drawer-resize::before {
  content: ""; position: absolute; top: 50%; left: 4px;
  width: 3px; height: 44px; transform: translateY(-50%);
  border-radius: 999px; background: var(--border);
  transition: background .15s ease, height .15s ease;
}
.cip-insight-panel .cip-drawer-resize:hover::before,
.cip-insight-panel .cip-drawer-resize:active::before {
  background: var(--brand); height: 72px;
}
.cip-insight-panel .cip-drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border); flex: none;
}
.cip-insight-panel .cip-drawer-title { font-size: 15px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.cip-insight-panel .cip-drawer-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; }
/* In the full-height drawer the AI document fills the whole panel — override the dashboard card's
   compact 240px scroll box (.cip-ai-zone) so long output uses the full height instead of a tiny window. */
.cip-insight-panel .cip-drawer-body .cip-ai-zone { flex: 1 1 auto; max-height: none; overflow: visible; padding-right: 0; }
@keyframes cip-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cip-drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
