  /* ============================================================
     TYPOGRAPHY DESIGN TOKENS — single source of truth for the EMR.
     Every font-size below references one of these steps so the whole
     app shares one professional, readable scale.
     ============================================================ */
  :root {
    --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    /* Type scale (px shown for reference) */
    --fs-2xs: 0.6875rem;  /* 11px */
    --fs-xs:  0.75rem;    /* 12px */
    --fs-sm:  0.8125rem;  /* 13px */
    --fs-base:0.875rem;   /* 14px */
    --fs-md:  0.9375rem;  /* 15px */
    --fs-lg:  1.125rem;   /* 18px */
    --fs-xl:  1.25rem;    /* 20px */
    /* Line-heights */
    --lh-tight: 1.25;
    --lh-snug:  1.4;
    --lh-normal:1.55;
    /* Letter-spacing */
    --ls-caps:  0.05em;   /* uppercase eyebrow labels */
    --ls-tight: -0.01em;  /* large headings */
    /* Weights */
    --fw-normal: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* ---- Surface / border / elevation tokens ----
       Companion to the type scale: one source of truth for chrome, so cards,
       rails, popovers and the palette all sit on the same neutral ramp. */
    --c-surface:      #FFFFFF;
    --c-surface-2:    #FBFCFD;  /* header bands, inset rows */
    --c-canvas:       #F4F6F9;  /* app background behind cards */
    --c-border:       #E2E8F0;
    --c-border-strong:#CBD5E1;
    --c-text:         #0F172A;
    --c-text-muted:   #64748B;
    --c-text-subtle:  #94A3B8;
    --c-brand:        #2563EB;
    --c-brand-strong: #1D4ED8;
    --c-brand-soft:   #EFF6FF;
    /* Clinical semantics — reserved for meaning, never decoration */
    --c-ok:           #059669;
    --c-warn:         #D97706;
    --c-critical:     #DC2626;

    --shadow-sm: 0 1px 2px rgba(15,23,42,0.04), 0 1px 1px rgba(15,23,42,0.03);
    --shadow-md: 0 4px 12px rgba(15,23,42,0.08), 0 1px 3px rgba(15,23,42,0.04);
    --shadow-lg: 0 12px 32px rgba(15,23,42,0.12), 0 2px 8px rgba(15,23,42,0.06);
    --shadow-xl: 0 24px 64px rgba(15,23,42,0.20), 0 8px 16px rgba(15,23,42,0.08);

    /* Sidebar rail width — read by the layout and the fullscreen card overlay */
    --rail-w: 76px;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  }
  body {
    font-family: var(--font-sans);
    background-color: #F3F4F6;
    color: #1F2937;
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    letter-spacing: -0.006em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Proportional by default; numeric fields opt into tabular below. */
    font-feature-settings: 'cv11', 'ss01';
  }
  /* Clinical data reads in aligned, equal-width figures (vitals, doses, labs, IDs). */
  input, textarea, select, .vital-input, .tabular-nums,
  [id^="v"][class*="vital"], .nh-chip, .badge, .rag-insight, table {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum', 'cv11', 'ss01';
  }
  /* Uppercase eyebrow labels share one consistent tracking. */
  .uppercase, [class*="uppercase"] { letter-spacing: var(--ls-caps); }
  html, body { overflow-x: hidden; }
  /* Sidebar removed; make content full width */
  .content-area { width: 100%; overflow-x: hidden; }
  .vital-badge {
    border-radius: 8px; border: 1px solid #E5E7EB;
    display: flex; align-items: center;
    transition: border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.2s ease, transform 0.2s ease;
  }
  .vital-badge:hover { box-shadow: 0 3px 10px rgba(2,6,23,0.08); transform: translateY(-1px); }
  .summary-badge-card { transition: box-shadow 0.2s ease, transform 0.2s ease; }
  .summary-badge-card:hover { box-shadow: 0 4px 14px rgba(2,6,23,0.08); transform: translateY(-2px); }
  .vital-input {
    background: transparent; border: none; padding: 0;
    font-weight: 700; font-size: var(--fs-md); color: #111827;
    flex: 1 1 auto; width: 100%; min-width: 0;
  }
  .vital-input:focus { outline: none; background: #f3f4f6; border-radius: 4px; }
  .patient-demographic-input {
    min-width: 0; border: none; border-radius: 4px; padding: 0 2px;
    background: transparent; color: inherit;
    transition: background-color 0.15s ease;
  }
  .patient-demographic-input:hover { background: #f9fafb; }
  .patient-demographic-input:focus { outline: none; background: #f3f4f6; }
  .patient-demographic-input::placeholder { color: #9CA3AF; font-style: italic; font-weight: 400; }

  /* Improve vitals alignment */
  .vital-badge .flex-1 { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
  .vital-badge .flex.items-baseline { align-items: center; }
  .vital-badge .flex.items-baseline > span { flex-shrink: 0; white-space: nowrap; }
  .vital-badge > .w-8, .vital-badge .vital-status-tooltip { flex-shrink: 0; }

  /* Snap the two hard-coded arbitrary sizes onto the scale (11px floor for legibility). */
  .text-\[10px\], .text-\[11px\] {
    font-size: var(--fs-2xs) !important;
    line-height: 1rem;
    letter-spacing: var(--ls-caps);
  }
  /* Inputs/textareas read at the body base size everywhere (no per-card bump). */
  .section-card input, .section-card textarea, .section-card .minimal-input,
  input, textarea, select { font-size: var(--fs-base); }
  textarea.minimal-input {
    resize: none; background: transparent; border: none;
    width: 100%; font-size: var(--fs-base); padding: 0; color: #374151;
  }
  textarea.minimal-input:focus { outline: none; }
  textarea.minimal-input::placeholder { color: #9CA3AF; font-style: italic; }

  /* Voice Panel — shares the same dark CDSS Analysis chrome (.ai-panel-header / .ai-panel-body) */
  #voiceModal {
    display: none;
    position: fixed;
    bottom: 9rem;
    right: 1.5rem;
    z-index: 1000;
    width: min(100%, 340px);
    flex-direction: column;
    border-radius: 1.1rem;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(2,6,23,0.45);
    pointer-events: none;
    transition: box-shadow 0.25s ease;
  }
  #voiceModal.active {
    display: flex;
    pointer-events: auto;
    animation: panel-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15);
  }
  /* Live "listening" glow while actively recording */
  #voiceModal.is-recording {
    box-shadow: 0 25px 60px rgba(2,6,23,0.45), 0 0 0 2px rgba(239,68,68,0.45), 0 0 24px rgba(239,68,68,0.35);
  }
  @keyframes panel-in {
    from { opacity: 0; transform: translateY(18px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  #voiceModal .ai-panel-body { text-align: center; }
  #voiceModal .ai-panel-body p { color: #94A3B8; margin-bottom: 0.75rem; }
  #voiceModal .ai-panel-body #recordingStatus { margin-bottom: 0.5rem; }
  #voiceModal .ai-panel-body #statusText { color: #E2E8F0; }
  #voiceModal .ai-panel-body #recordingTimer { color: #CBD5E1; }
  #voiceModal .ai-panel-body #liveTranscript,
  #voiceModal .ai-panel-body #textInputWrapper {
    margin-bottom: 0.75rem;
    background: rgba(255,255,255,0.04) !important;
    border: 1px solid rgba(255,255,255,0.08);
    transition: border-color 0.15s, background 0.15s;
  }
  #voiceModal .ai-panel-body #liveTranscript:hover,
  #voiceModal .ai-panel-body #textInputWrapper:hover {
    border-color: rgba(124,58,237,0.4);
    background: rgba(255,255,255,0.06) !important;
  }
  #voiceModal .ai-panel-body #liveTranscriptText { color: #CBD5E1; }
  #voiceModal .ai-panel-body textarea {
    min-height: 4.25rem;
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.14) !important;
    color: #E2E8F0;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  #voiceModal .ai-panel-body textarea:focus {
    outline: none;
    border-color: rgba(124,58,237,0.7) !important;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.25);
  }
  #voiceModal .ai-panel-body textarea::placeholder { color: #CBD5E1; }
  #voiceModal .ai-panel-body .flex.space-x-2 { gap: 0.5rem; }
  #voiceModal .ai-panel-body .btn-ghost {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.14);
    color: #E2E8F0;
  }
  #voiceModal .ai-panel-body .btn-ghost:hover {
    background: rgba(255,255,255,0.12);
    transform: translateY(-1px);
  }
  #voiceModal .ai-panel-body .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37,99,235,0.4);
  }
  #voiceModal .ai-panel-body .btn-primary:active,
  #voiceModal .ai-panel-body .btn-ghost:active {
    transform: scale(0.96);
  }
  #voiceModal .ai-panel-body .btn {
    transition: transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1.3), box-shadow 0.15s, background 0.15s;
  }
  .voice-icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 18px; height: 18px;
    color: #94A3B8;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s, transform 0.15s;
  }
  .voice-icon-btn:hover { color: #C4B5FD; background: rgba(124,58,237,0.18); transform: scale(1.1); }
  .voice-icon-btn:active { transform: scale(0.92); }
  /* Gentle invite-to-click pulse on the idle status text */
  #voiceModal:not(.is-recording) #statusText {
    animation: voice-status-breathe 2.6s ease-in-out infinite;
  }
  @keyframes voice-status-breathe {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 1; }
  }
  /* CDSS Analysis floating panel — dark theme, no full-page backdrop */
  #ragPanel {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 100px;
    top: 130px;
    width: min(620px, calc(100vw - 130px));
    max-height: 70vh;
    flex-direction: column;
    border-radius: 0.85rem;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(2,6,23,0.45);
  }
  #ragPanel.active { display: flex; }
  #ragPanel.active { animation: panel-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15); }
  #ragPanel.rag-panel-maximized {
    left: 100px !important; right: 20px !important; top: 20px !important; bottom: 20px !important;
    width: calc(100vw - 120px) !important;
    height: calc(100vh - 40px) !important;
    max-height: none !important;
  }
  .ai-panel-header {
    background: #0F172A;
    color: #ffffff;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1rem;
    flex: none;
  }
  .ai-panel-header .rag-icon {
    animation: rag-icon-breathe 2.4s ease-in-out infinite;
  }
  .ai-panel-header-title {
    display: flex; align-items: center; gap: 0.5rem;
    font-weight: 700; font-size: var(--fs-md);
  }
  .ai-panel-header-actions { display: flex; align-items: center; gap: 0.35rem; }
  .ai-panel-header-actions button {
    color: #9CA3AF; padding: 4px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s, transform 0.15s;
  }
  .ai-panel-header-actions button:hover { background: rgba(255,255,255,0.08); color: #ffffff; transform: scale(1.1); }
  .ai-panel-header-actions button:active { transform: scale(0.92); }
  .ai-panel-header-actions button:focus-visible { outline: 2px solid #60A5FA; outline-offset: 1px; }
  .ai-panel-body {
    background: #1E293B;
    color: #E2E8F0;
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.1rem 1.25rem;
  }
  .rag-loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2.5rem 1rem;
    gap: 0.9rem;
  }
  .rag-loading .rag-icon-big {
    width: 64px; height: 64px;
    color: #60A5FA;
    filter: drop-shadow(0 0 14px rgba(96,165,250,0.55));
  }
  .rag-loading-text { color: #CBD5E1; font-size: var(--fs-base); font-weight: 500; }
  .rag-section { margin-top: 1.1rem; }
  .rag-section:first-child { margin-top: 0; }
  .rag-section h4 {
    font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase;
    color: #94A3B8; letter-spacing: 0.04em; margin-bottom: 0.5rem;
  }
  .rag-diagnosis-item { margin-bottom: 0.85rem; }
  .rag-diagnosis-item .rag-diagnosis-name {
    color: #F1F5F9; font-weight: 700; font-size: var(--fs-base); margin-bottom: 0.25rem;
  }
  .rag-diagnosis-item .rag-diagnosis-name .rag-prob-high { color: #F87171; }
  .rag-diagnosis-item .rag-diagnosis-name .rag-prob-medium { color: #FBBF24; }
  .rag-diagnosis-item .rag-diagnosis-name .rag-prob-low { color: #94A3B8; }
  .rag-diagnosis-item ul { margin: 0; padding-left: 1.1rem; }
  .rag-diagnosis-item li { color: #CBD5E1; font-size: var(--fs-sm); line-height: 1.45; }
  .rag-list { color: #CBD5E1; font-size: var(--fs-base); list-style: disc; padding-left: 1.1rem; }
  .rag-list li { margin-bottom: 0.3rem; line-height: 1.45; }
  .rag-evidence-card {
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 0.5rem; padding: 0.5rem 0.65rem; margin-bottom: 0.4rem; font-size: var(--fs-xs);
  }
  .rag-evidence-card .font-semibold { color: #F1F5F9; }
  .rag-evidence-card p { color: #94A3B8; }
  #ragPatientSummary { color: #E2E8F0; font-size: var(--fs-base); }
  #ragDisclaimer { color: #CBD5E1; }

  /* Field-specific insight cards (deterministic checks) */
  .rag-insight {
    border: 1px solid rgba(255,255,255,0.08); border-left-width: 3px;
    border-radius: 0.5rem; padding: 0.5rem 0.65rem; margin-bottom: 0.45rem;
    background: rgba(255,255,255,0.04); font-size: var(--fs-xs); color: #CBD5E1;
  }
  .rag-insight .ri-head { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.2rem; }
  .rag-insight .ri-badge {
    font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
    padding: 0.08rem 0.4rem; border-radius: 9999px;
  }
  .rag-insight .ri-field { font-size: var(--fs-2xs); color: #94A3B8; text-transform: uppercase; letter-spacing: 0.03em; }
  .rag-insight .ri-msg { color: #E2E8F0; line-height: 1.4; }
  .rag-insight .ri-src { color: #94A3B8; font-size: var(--fs-2xs); margin-top: 0.2rem; font-style: italic; }
  .rag-insight.sev-critical { border-left-color: #F87171; }
  .rag-insight.sev-critical .ri-badge { background: rgba(248,113,113,0.18); color: #FCA5A5; }
  .rag-insight.sev-warning  { border-left-color: #FBBF24; }
  .rag-insight.sev-warning  .ri-badge { background: rgba(251,191,36,0.18); color: #FCD34D; }
  .rag-insight.sev-advice   { border-left-color: #60A5FA; }
  .rag-insight.sev-advice   .ri-badge { background: rgba(96,165,250,0.18); color: #93C5FD; }
  .rag-insight.sev-info     { border-left-color: #64748B; }
  .rag-insight.sev-info     .ri-badge { background: rgba(148,163,184,0.18); color: #CBD5E1; }
  .rag-gating {
    border: 1px solid rgba(251,191,36,0.35); background: rgba(251,191,36,0.08);
    border-radius: 0.5rem; padding: 0.55rem 0.7rem; margin-top: 0.9rem;
    color: #FCD34D; font-size: var(--fs-xs); line-height: 1.45;
  }
  .rag-completeness {
    margin-top: 1rem; padding-top: 0.6rem; border-top: 1px solid rgba(255,255,255,0.08);
    color: #94A3B8; font-size: var(--fs-2xs); line-height: 1.5;
  }
  .rag-completeness .rc-skip { color: #CBD5E1; }
  .pulse-ring {
    animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
  }
  @keyframes pulse-ring {
    0% { transform: scale(0.8); opacity: 1; }
    80%, 100% { transform: scale(1.6); opacity: 0; }
  }
  .recording-waves span {
    display: inline-block; width: 4px; background: #3B82F6;
    border-radius: 2px; margin: 0 2px;
    animation: wave 1.2s ease-in-out infinite;
  }
  /* Waveform picks up the illustration palette */
  .recording-waves span:nth-child(1) { background: #8FB0F4; }
  .recording-waves span:nth-child(2) { background: #B18AF8; animation-delay: 0.1s; }
  .recording-waves span:nth-child(3) { background: #F8A013; animation-delay: 0.2s; }
  .recording-waves span:nth-child(4) { background: #F584A6; animation-delay: 0.3s; }
  .recording-waves span:nth-child(5) { background: #FFC53D; animation-delay: 0.4s; }
  @keyframes wave {
    0%, 100% { height: 8px; }
    50% { height: 28px; }
  }

  /* Drag and drop + per-section accent colors.
     Enterprise chrome: neutral surface + neutral border, with the section hue
     carried only by a 3px left rail, the status dot and the expand affordance.
     Saturated header bands read as consumer/demo software — the rail keeps the
     colour-coded wayfinding without tinting clinical content. */
  .section-card {
    cursor: grab; position: relative; transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
    border: 1px solid var(--c-border, #E2E8F0);
    border-left: 3px solid var(--accent, #CBD5E1);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: var(--shadow-sm);
  }
  .section-card:active { cursor: grabbing; }
  .section-card:hover:not(.dragging):not(.fullscreen) {
    box-shadow: var(--shadow-md);
    border-color: var(--c-border-strong, #CBD5E1);
    transform: translateY(-1px);
  }
  .status-dot {
    width: 7px; height: 7px; border-radius: 9999px;
    background: var(--accent, #94A3B8); flex: none;
  }
  /* Neutral header band; the accent lives in the rail and the dot */
  .section-card > .p-3 {
    background: var(--c-surface-2, #FBFCFD);
    border-bottom-color: var(--c-border, #EEF2F6);
  }
  .section-card > .p-3 h3 {
    color: var(--c-text, #0F172A);
    font-weight: var(--fw-semibold); font-size: var(--fs-base);
    letter-spacing: -0.006em;
  }
  /* Expand arrow sits next to the title, tinted with the accent */
  .section-card > .p-3 .fullscreen-btn { color: var(--accent, #9CA3AF); }
  /* 13 sections, 13 clearly distinct hues */
  .section-card[data-section="diagnosis"]           { --accent: #DC2626; } /* red */
  .section-card[data-section="local-exam"]          { --accent: #F97316; } /* orange */
  .section-card[data-section="development-history"] { --accent: #F59E0B; } /* amber */
  .section-card[data-section="birth-history"]       { --accent: #84CC16; } /* lime */
  .section-card[data-section="history"]             { --accent: #16A34A; } /* green */
  .section-card[data-section="family-history"]      { --accent: #0D9488; } /* teal */
  .section-card[data-section="clinical-info"]       { --accent: #06B6D4; } /* cyan */
  .section-card[data-section="cns-examination"]     { --accent: #2563EB; } /* blue */
  .section-card[data-section="chief-complaints"]    { --accent: #4F46E5; } /* indigo */
  .section-card[data-section="investigations"]      { --accent: #9333EA; } /* purple */
  .section-card[data-section="follow-up"]           { --accent: #C026D3; } /* fuchsia */
  .section-card[data-section="general-exam"]        { --accent: #EC4899; } /* pink */
  .section-card[data-section="medications"]         { --accent: #A0522D; } /* brown */
  /* Card spacing: ~20px body padding, slightly tighter header */
  .section-card > .p-3 { padding: 12px 20px; }
  .section-card > .p-4 { padding: 20px; }

  /* Pills / chips */
  .pill {
    border-radius: 9999px;
    padding: 6px 14px;
    border: 1px solid #D1D5DB;
    background: #ffffff;
    color: #1F2937;
    font-size: var(--fs-xs);
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .pill:hover { background: #F9FAFB; }
  .pill.selected {
    background: var(--accent, #3B82F6);
    border-color: var(--accent, #3B82F6);
    color: #ffffff;
  }

  /* Structured pediatric-neuro-history controls injected into history cards */
  .nh-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
  .nh-field { display: flex; flex-direction: column; gap: 5px; }
  .nh-label { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: #6B7280; }
  .nh-opts { display: flex; flex-wrap: wrap; gap: 6px; }
  .nh-chip {
    border-radius: 9999px; padding: 4px 11px; border: 1px solid #D1D5DB;
    background: #fff; color: #374151; font-size: var(--fs-xs); line-height: 1.1; cursor: pointer;
    transition: background .15s, color .15s, border-color .15s; user-select: none;
  }
  .nh-chip:hover { background: #F9FAFB; }
  .nh-chip.selected { background: var(--accent, #3B82F6); border-color: var(--accent, #3B82F6); color: #fff; }
  .nh-inline { display: inline-flex; align-items: center; gap: 6px; }
  .nh-input {
    border: 1px solid #D1D5DB; border-radius: 6px; padding: 3px 8px; font-size: var(--fs-xs);
    color: #111827; background: #fff; max-width: 100%;
  }
  .nh-input:focus { outline: none; border-color: var(--accent, #3B82F6); }
  .nh-input.nh-num { width: 68px; }
  .nh-input.nh-text { width: 100%; }
  .nh-group { border: 1px solid #E5E7EB; border-radius: 8px; padding: 8px 10px; }
  .nh-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .nh-group-title { font-size: var(--fs-xs); font-weight: 700; color: #374151; }
  .nh-group-body { margin-top: 8px; display: flex; flex-direction: column; gap: 9px; }
  .nh-group[data-open="false"] .nh-group-body { display: none; }
  .nh-toggle {
    font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    border: 1px solid #D1D5DB; border-radius: 9999px; padding: 3px 10px; cursor: pointer; color: #6B7280; background: #fff;
  }
  .nh-group[data-open="true"] .nh-toggle { background: var(--accent, #3B82F6); border-color: var(--accent, #3B82F6); color: #fff; }
  .nh-hidden { display: none !important; }

  /* + add button in card header: white bordered square (per design) */
  .card-add-btn {
    cursor: pointer;
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 7px;
    color: #374151;
    background: #ffffff;
    border: 1px solid #E5E7EB;
    transition: background 0.15s, transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1.3), box-shadow 0.15s;
    margin-left: 2px;
  }
  .card-add-btn:hover { background: #F9FAFB; transform: scale(1.12); box-shadow: 0 2px 6px rgba(2,6,23,0.12); }
  .card-add-btn:active { transform: scale(0.92); }

  /* RAG clinical decision support FAB trigger button */
  .rag-fab-wrap {
    display: flex;
    align-items: center;
  }
  .rag-fab {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    background: #7C3AED;
    color: #ffffff;
    /* White ring separates the floating action from the card it overlaps */
    box-shadow: 0 0 0 4px rgba(255,255,255,0.92), 0 6px 16px rgba(124, 58, 237, 0.35);
    border: none;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.3), box-shadow 0.2s;
  }
  .rag-fab:hover {
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 0 0 4px rgba(255,255,255,0.95), 0 10px 22px rgba(124, 58, 237, 0.45);
  }
  .rag-fab:active {
    transform: scale(0.94);
  }
  .rag-fab-ring {
    position: absolute;
    left: 0; bottom: 0;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: rgba(124, 58, 237, 0.35);
    animation: rag-fab-pulse 2.2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    pointer-events: none;
  }
  @keyframes rag-fab-pulse {
    0% { transform: scale(0.85); opacity: 0.6; }
    80%, 100% { transform: scale(1.5); opacity: 0; }
  }
  .rag-icon {
    transform-box: view-box;
    transform-origin: 12px 12px;
    animation: rag-icon-breathe 2.4s ease-in-out infinite;
  }
  @keyframes rag-icon-breathe {
    0%, 100% { transform: scale(1); opacity: 0.92; }
    50% { transform: scale(1.12); opacity: 1; }
  }
  .rag-fab:hover .rag-icon {
    animation-play-state: paused;
    transform: scale(1.18) rotate(-6deg);
    transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  }

  /* Buttons — 3 tiers */
  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: var(--fs-sm); font-weight: 500; line-height: 1.2;
    padding: 8px 14px; border-radius: 9px;
    border: 1px solid transparent; cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s,
                transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1.3), box-shadow 0.15s;
  }
  .btn:hover { transform: translateY(-1px); }
  .btn:active { transform: scale(0.96); }
  .btn:disabled, .btn-split .btn-main:disabled {
    opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important;
  }
  /* Tier 1: primary solid blue */
  .btn-primary { background: #2563EB; border-color: #2563EB; color: #ffffff; }
  .btn-primary:hover { background: #1D4ED8; border-color: #1D4ED8; box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
  /* Tier 2: ghost/outline */
  .btn-ghost { background: #ffffff; border-color: #D1D5DB; color: #374151; }
  .btn-ghost:hover { background: #F9FAFB; box-shadow: 0 2px 8px rgba(2,6,23,0.08); }
  /* Compact variant for in-card / navbar buttons */
  .btn-sm { font-size: var(--fs-xs); padding: 5px 10px; border-radius: 8px; }
  /* Tier 3: split button sharing the blue fill */
  .btn-split { display: inline-flex; align-items: stretch; position: relative; }
  .btn-split .btn-main,
  .btn-split .btn-caret {
    background: #2563EB; color: #ffffff; border: none;
    font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
    transition: background 0.15s;
    display: flex; align-items: center;
  }
  .btn-split .btn-main { padding: 8px 14px; border-radius: 9px 0 0 9px; }
  .btn-split .btn-caret {
    padding: 8px 8px; border-radius: 0 9px 9px 0;
    border-left: 1px solid rgba(255,255,255,0.35);
  }
  .btn-split .btn-caret svg { transition: transform 0.2s ease; }
  .btn-split .btn-caret.open svg { transform: rotate(180deg); }
  .btn-split .btn-main:hover,
  .btn-split .btn-caret:hover { background: #1D4ED8; }

  .section-card.dragging {
    opacity: 0.4; transform: scale(0.98);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  }
  .section-card.drag-over {
    box-shadow: 0 0 0 2px #3B82F6;
    transform: scale(1.01);
  }
  .drag-handle {
    cursor: grab; color: #9CA3AF; padding: 2px 4px;
    border-radius: 4px; transition: color 0.15s, background 0.15s, transform 0.15s;
    display: flex; align-items: center;
  }
  .drag-handle:hover { color: #6B7280; background: #F3F4F6; transform: scale(1.15); }
  /* Hint draggability as soon as the card itself is hovered, not just the handle */
  .section-card:hover:not(.dragging):not(.fullscreen) .drag-handle { color: #6B7280; }

  /* Card Collapse */
  .section-card.collapsed > div:not(:first-child) {
    display: none !important;
  }
  .section-card.collapsed {
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
    height: auto !important;
    overflow: hidden;
  }
  .section-card.collapsed > .p-4 {
    min-height: 0 !important;
  }
  .minimize-btn {
    cursor: pointer; color: #9CA3AF; padding: 2px 4px;
    border-radius: 4px; transition: color 0.15s, background 0.15s, transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1.3);
    display: flex; align-items: center; width: 20px; height: 20px;
    justify-content: center; font-size: var(--fs-xs);
    margin-left: 2px;
  }
  .minimize-btn:hover { color: #6B7280; background: #F3F4F6; transform: scale(1.12); }
  .minimize-btn:active { transform: scale(0.92); }
  .minimize-btn.minimized { color: #3B82F6; }
  .minimize-btn.minimized:hover { background: #EFF6FF; }

  /* AI Fill Highlight */
  .ai-filled { animation: ai-fill-flash 1s ease-out; }
  @keyframes ai-fill-flash {
    0% { background: #EFF6FF; }
    100% { background: transparent; }
  }
  .vital-ai-filled input { animation: vital-flash 1s ease-out; }
  @keyframes vital-flash {
    0% { background: #DBEAFE; border-radius: 4px; }
    100% { background: transparent; }
  }

  /* Toast */
  #toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(80px) scale(0.92);
    opacity: 0;
    background: #1E293B; color: white; padding: 10px 20px; border-radius: 8px;
    font-size: var(--fs-sm); z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3), opacity 0.25s ease;
    display: flex; align-items: center; gap: 8px; pointer-events: none;
  }
  #toast.show { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }

  /* Transcript Panel removed */

  /* Status Badge */
  .status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: var(--fs-2xs); padding: 2px 8px; border-radius: 12px;
    font-weight: 600; text-transform: uppercase;
  }

  .vital-status-tooltip {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    cursor: default;
  }
  .vital-status-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    opacity: 0;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.95);
    color: #fff;
    font-size: var(--fs-2xs);
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 6px;
    transition: opacity 0.08s ease, transform 0.08s ease;
    z-index: 50;
  }
  .vital-status-tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  .vital-status-tooltip[data-tooltip='']::after {
    display: none;
  }
  /* Interactive vital status indicators */
  .vital-status-tooltip > div {
    transition: transform 0.15s ease, box-shadow 0.2s ease;
  }
  .vital-status-tooltip:hover > div { transform: scale(1.3); }
  .vital-status-tooltip > span { transition: color 0.2s ease; }
  /* Springy pop when a status is set/changes */
  .status-pop { animation: status-pop 0.4s cubic-bezier(0.3, 1.6, 0.5, 1); }
  @keyframes status-pop {
    0%   { transform: scale(0.3); }
    70%  { transform: scale(1.3); }
    100% { transform: scale(1); }
  }
  /* Abnormal: continuous red sonar pulse */
  .status-abnormal-pulse { animation: abnormal-pulse 1.5s ease-out infinite; }
  @keyframes abnormal-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.50); }
    70%  { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
    100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
  }
  /* Normal: one soft green glow ring on arrival */
  .status-normal-glow { animation: normal-glow 0.9s ease-out 1; }
  @keyframes normal-glow {
    0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.50); }
    100% { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  }
  /* The whole vital pill tints with the status (transition lives on the base .vital-badge rule) */
  .vital-badge.status-ok  { border-color: #BBF7D0; background-color: #FAFFFB; }
  .vital-badge.status-bad { border-color: #FECACA; background-color: #FFFAFA; }

  /* Column headers with drag zones */
  .emr-column { display: flex; flex-direction: column; gap: 16px; }

  /* Ensure main grid uses full width */
  #mainGrid { width: 100%; box-sizing: border-box; }
  .content-area > .overflow-y-auto { padding-right: 1rem; }

  /* Scrollbar hide */
  .no-scrollbar::-webkit-scrollbar { display: none; }
  .no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

  /* Speech-to-text button: flat illustrated mic + speech bubbles (per design) */
  .voice-orb {
    border: 1px solid #E5E7EB; cursor: pointer;
    background: #ffffff;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.25s ease, background 0.2s ease;
    animation: orb-breathe 3.5s ease-in-out infinite;
  }
  .voice-orb svg { width: 78%; height: 78%; pointer-events: none; }

  /* ---- Voice symbol: duotone mic + side bars that track the real input level.
     `--lvl` (0…1) is written by the analyser loop while recording; when idle
     the bars fall back to a slow breathing keyframe. ---- */
  .voice-orb { --lvl: 0; }
  .voice-orb .sym-capsule { fill: var(--c-brand, #2563EB); }
  .voice-orb .sym-arc     { stroke: #1E293B; }
  .voice-orb .sym-base    { fill: #1E293B; }
  .voice-orb .sym-bar     { fill: #93B4FC; }
  .voice-orb .sym-mic, .voice-orb .sym-bar {
    transform-box: fill-box; transform-origin: center;
  }
  .voice-orb .sym-bar {
    animation: sym-idle 1.6s ease-in-out infinite;
    transition: fill 0.2s ease;
  }
  .voice-orb .sym-b1 { animation-delay: 0s; }
  .voice-orb .sym-b2 { animation-delay: 0.16s; }
  .voice-orb .sym-b3 { animation-delay: 0.32s; }
  @keyframes sym-idle {
    0%, 100% { transform: scaleY(0.55); opacity: 0.7; }
    50%      { transform: scaleY(1.15); opacity: 1; }
  }
  .voice-orb .sym-mic { animation: sym-mic-breathe 3s ease-in-out infinite; }
  @keyframes sym-mic-breathe {
    0%, 100% { transform: translateY(0) scale(1); }
    50%      { transform: translateY(-1px) scale(1.03); }
  }
  /* Hover: bars fan out, mic leans in — the symbol answers the pointer */
  .voice-orb:hover .sym-bar { animation-duration: 0.8s; fill: #2563EB; }
  .voice-orb:hover .sym-mic { transform: scale(1.06); animation-play-state: paused; }

  /* Recording: amplitude drives every bar directly — no faked loop */
  .voice-orb.recording .sym-bar {
    animation: none;
    fill: #EF4444;
    opacity: calc(0.5 + var(--lvl) * 0.5);
    transition: transform 0.07s linear, opacity 0.07s linear;
  }
  .voice-orb.recording .sym-b1 { transform: scaleY(calc(0.35 + var(--lvl) * 1.5)); }
  .voice-orb.recording .sym-b2 { transform: scaleY(calc(0.35 + var(--lvl) * 1.9)); }
  .voice-orb.recording .sym-b3 { transform: scaleY(calc(0.35 + var(--lvl) * 2.3)); }
  .voice-orb.recording .sym-capsule { fill: #EF4444; }
  .voice-orb.recording .sym-mic { animation: none; }

  /* Small AI marker on the floating trigger */
  #micBtn { position: fixed; }
  .orb-badge {
    position: absolute; top: -2px; right: -2px;
    width: 22px; height: 22px; border-radius: 999px;
    background: #7C3AED; color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(15,23,42,0.25);
    transition: transform 0.2s var(--ease-out);
  }
  .orb-badge svg { width: 12px !important; height: 12px !important; }
  #micBtn:hover .orb-badge { transform: scale(1.15) rotate(8deg); }
  #micBtn.recording .orb-badge { background: #EF4444; }
  /* Idle breathing: soft indigo glow swells and fades */
  @keyframes orb-breathe {
    0%, 100% {
      box-shadow:
        0 0 0 5px rgba(148,163,184,0.12),
        0 0 16px 3px rgba(99,102,241,0.25),
        0 8px 22px rgba(2,6,23,0.18);
    }
    50% {
      box-shadow:
        0 0 0 7px rgba(148,163,184,0.18),
        0 0 26px 8px rgba(99,102,241,0.40),
        0 8px 22px rgba(2,6,23,0.18);
    }
  }
  .voice-orb:hover { transform: scale(1.10); }
  .voice-orb:active { transform: scale(0.94); }
  /* Recording: red tint, pulse, and expanding ripple rings */
  .voice-orb.recording {
    background: #FEF2F2 !important;
    border-color: #FECACA;
    animation: orb-pulse 1.4s ease-in-out infinite;
  }
  .voice-orb.recording::after {
    content: ''; position: absolute; inset: 0; border-radius: 9999px;
    border: 2px solid rgba(239,68,68,0.6);
    animation: orb-ripple 1.4s ease-out infinite;
    pointer-events: none;
  }
  @keyframes orb-pulse {
    0%, 100% {
      box-shadow:
        0 0 0 5px rgba(239,68,68,0.15),
        0 0 18px 5px rgba(239,68,68,0.40),
        0 8px 22px rgba(2,6,23,0.18);
    }
    50% {
      box-shadow:
        0 0 0 8px rgba(239,68,68,0.25),
        0 0 30px 10px rgba(239,68,68,0.60),
        0 8px 22px rgba(2,6,23,0.18);
    }
  }
  @keyframes orb-ripple {
    0%   { transform: scale(1);   opacity: 0.9; }
    100% { transform: scale(2.1); opacity: 0; }
  }

  /* Uniform card sizing: ensure consistent card body heights and layout */
  /* Uniform card sizing: force identical card width/height and make content scrollable */
  .section-card { width: 100%; height: 260px; flex: none; display: flex; flex-direction: column; }
  /* Keep fullscreen cards unaffected */
  .section-card.fullscreen { height: auto; }
  .section-card > .p-4 { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: flex-start; min-height: 0 !important; overflow: auto; }
  .section-card > .p-4.min-h\[128px\] { min-height: 0 !important; }
  .section-card .minimal-input.h-full { height: 100%; }
  .section-card .p-3 { flex: 0 0 auto; }
  /* Fullscreen card overlay — leaves the section sidebar visible on the left */
  .section-card.fullscreen {
    position: fixed !important;
    top: 12px !important; right: 12px !important; bottom: 12px !important;
    left: calc(var(--rail-w) + 12px) !important;
    transition: left 0.24s var(--ease-out) !important;
    width: auto !important;
    height: calc(100% - 24px) !important;
    z-index: 60 !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 60px rgba(2,6,23,0.4) !important;
    overflow: auto !important;
    background: white !important;
  }
  body.card-fullscreen-open { overflow: hidden; }

  .fullscreen-btn {
    cursor: pointer; color: #9CA3AF; padding: 2px 4px;
    border-radius: 4px; transition: color 0.15s, background 0.15s, transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1.3);
    display: flex; align-items: center; width: 20px; height: 20px;
    justify-content: center; font-size: var(--fs-xs); margin-left: 2px;
    margin-right: 2px;
  }
  .fullscreen-btn:hover { background: #F3F4F6; transform: scale(1.12); }
  .fullscreen-btn:active { transform: scale(0.92); }
  .fullscreen-btn.active { color: #3B82F6; }

  .card-controls { display: flex; gap: 4px; align-items: center; }
  .card-controls .fullscreen-btn { margin-left: 0; margin-right: 0; }

  /* Section sidebar — click an icon to open that section in the existing fullscreen card view */
  .section-sidebar {
    width: var(--rail-w);
    height: 100%;
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    overflow-y: auto; overflow-x: hidden;
    padding: 6px 0;
    transition: width 0.24s var(--ease-out);
  }
  .sidebar-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 10px 4px;
    background: none; border: none; cursor: pointer;
    color: var(--c-text-muted);
    border-left: 3px solid transparent;
    position: relative;
    transition: background 0.2s ease, color 0.2s ease, border-left-color 0.2s ease;
  }
  /* Two-line wrap instead of an ellipsis: "Chief Com…" is not an acceptable
     label in a clinical nav — every section must be readable at a glance. */
  .sidebar-item span {
    font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
    line-height: 1.2; text-align: center;
    max-width: 68px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; hyphens: auto;
  }
  .sidebar-item svg { transition: transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1.3); flex: none; }
  .sidebar-item:hover { background: var(--c-surface-2); color: var(--c-text); }
  .sidebar-item:hover svg { transform: scale(1.12); }
  .sidebar-item.active { background: var(--c-brand-soft); color: var(--c-brand); border-left-color: var(--c-brand); }
  .sidebar-item.active svg { stroke-width: 2.2; }
  .sidebar-item:focus-visible {
    outline: 2px solid var(--c-brand); outline-offset: -2px;
    background: var(--c-brand-soft);
  }
  /* Full label on hover, so the collapsed rail is never ambiguous */
  .sidebar-item::after {
    content: attr(title);
    position: absolute; left: calc(100% + 8px); top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: rgba(15,23,42,0.94); color: #fff;
    font-size: var(--fs-2xs); font-weight: var(--fw-medium);
    padding: 5px 9px; border-radius: 6px; white-space: nowrap;
    opacity: 0; pointer-events: none; z-index: 80;
    box-shadow: var(--shadow-md);
    transition: opacity 0.15s ease, transform 0.15s var(--ease-out);
  }
  .sidebar-item:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }

  /* ---- Expanded rail (toggled by the header menu button) ---- */
  body.sidebar-expanded { --rail-w: 212px; }
  body.sidebar-expanded .sidebar-item {
    flex-direction: row; justify-content: flex-start;
    gap: 10px; padding: 9px 14px;
  }
  body.sidebar-expanded .sidebar-item span {
    max-width: none; text-align: left;
    -webkit-line-clamp: 1; font-size: var(--fs-xs);
  }
  body.sidebar-expanded .sidebar-item::after { display: none; }
  #sidebarToggle svg { transition: transform 0.24s var(--ease-out); }
  body.sidebar-expanded #sidebarToggle { color: var(--c-brand); }
  /* ============================================================
     ENTERPRISE CHROME LAYER
     Adds the affordances a clinical product is judged on: visible
     focus, save state, progress, keyboard surface, and calm
     neutral surfaces. Everything here is additive — no existing
     behaviour or element id is changed.
     ============================================================ */

  /* ---- Global focus visibility (keyboard + accessibility) ---- */
  :where(button, a, input, textarea, select, [tabindex]):focus-visible {
    outline: 2px solid var(--c-brand);
    outline-offset: 2px;
    border-radius: 6px;
  }

  /* ---- Quiet scrollbars: chrome shouldn't compete with data ---- */
  * { scrollbar-width: thin; scrollbar-color: #CBD5E1 transparent; }
  *::-webkit-scrollbar { width: 9px; height: 9px; }
  *::-webkit-scrollbar-track { background: transparent; }
  *::-webkit-scrollbar-thumb {
    background: #D8DEE7; border-radius: 99px;
    border: 2px solid transparent; background-clip: content-box;
  }
  *::-webkit-scrollbar-thumb:hover { background: #B6C0CE; background-clip: content-box; }

  /* ---- Icon-only button ---- */
  .icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px;
    color: var(--c-text-muted); background: transparent;
    border: 1px solid transparent; cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }
  .icon-btn:hover { background: var(--c-surface-2); color: var(--c-text); border-color: var(--c-border); }
  .icon-btn:active { transform: scale(0.94); }

  /* ---- Keycap hints ---- */
  kbd, .btn-kbd, .search-kbd {
    font-family: var(--font-sans); font-size: 10px; font-weight: var(--fw-semibold);
    line-height: 1; color: var(--c-text-subtle);
    background: var(--c-surface-2); border: 1px solid var(--c-border);
    border-bottom-width: 2px; border-radius: 5px;
    padding: 3px 5px; white-space: nowrap;
  }
  .btn-kbd { margin-left: 4px; }
  .search-kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    pointer-events: none; transition: opacity 0.15s;
  }
  .global-search:focus + .search-kbd { opacity: 0; }

  /* ---- Global search ---- */
  .global-search {
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    color: var(--c-text);
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  }
  .global-search::placeholder { color: var(--c-text-subtle); }
  .global-search:hover { border-color: var(--c-border-strong); }
  .global-search:focus {
    outline: none; background: var(--c-surface);
    border-color: var(--c-brand);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  }
  #searchResults {
    border: 1px solid var(--c-border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
  }

  /* ---- Save-state chip ---- */
  .dirty-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
    padding: 4px 10px; border-radius: 99px;
    border: 1px solid var(--c-border); background: var(--c-surface-2);
    color: var(--c-text-muted); letter-spacing: 0;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
  }
  .dirty-dot {
    width: 6px; height: 6px; border-radius: 99px; background: currentColor; flex: none;
  }
  .dirty-chip.is-clean { color: var(--c-ok); border-color: #A7F3D0; background: #ECFDF5; }
  .dirty-chip.is-dirty { color: var(--c-warn); border-color: #FDE68A; background: #FFFBEB; }
  .dirty-chip.is-dirty .dirty-dot { animation: dirtyPulse 1.8s ease-in-out infinite; }
  .dirty-chip.is-saving { color: var(--c-brand); border-color: #BFDBFE; background: var(--c-brand-soft); }
  @keyframes dirtyPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.35; transform: scale(0.8); }
  }

  /* ---- Chart completeness meter ---- */
  .completeness { min-width: 190px; }
  .completeness-track {
    height: 6px; border-radius: 99px; background: #E8EDF3; overflow: hidden;
  }
  .completeness-fill {
    height: 100%; width: 0%; border-radius: 99px;
    background: linear-gradient(90deg, #3B82F6, #06B6D4);
    transition: width 0.6s var(--ease-out), background 0.4s ease;
  }
  .completeness-fill.is-high { background: linear-gradient(90deg, #059669, #10B981); }
  .completeness-fill.is-low  { background: linear-gradient(90deg, #F59E0B, #FBBF24); }

  /* ---- Vitals: make the empty state look intentional, not broken ---- */
  .vital-badge { background: var(--c-surface); }
  .vital-badge.is-empty { border-style: dashed; border-color: #DDE3EB; }
  .vital-badge.is-empty .vital-input::placeholder { color: #CBD5E1; }
  .vital-badge:focus-within {
    border-color: var(--c-brand);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    border-style: solid;
  }

  /* ---- Save button busy state (applies to .btn and the split .btn-main) ---- */
  .spinner {
    width: 13px; height: 13px; border-radius: 99px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    animation: spin 0.7s linear infinite;
    display: none; flex: none;
  }
  .is-busy .spinner { display: block; }
  .is-busy .btn-label { opacity: 0.85; }
  .btn-split .btn-main { justify-content: center; gap: 7px; }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ---- Command palette ---- */
  .cmdk-backdrop {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(15,23,42,0.38);
    backdrop-filter: blur(3px);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 12vh;
    opacity: 0; pointer-events: none;
    transition: opacity 0.16s ease;
  }
  .cmdk-backdrop.open { opacity: 1; pointer-events: auto; }
  .cmdk-panel {
    width: min(620px, 92vw);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 14px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transform: translateY(-8px) scale(0.985);
    transition: transform 0.18s var(--ease-out);
  }
  .cmdk-backdrop.open .cmdk-panel { transform: translateY(0) scale(1); }
  .cmdk-input-row {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; border-bottom: 1px solid var(--c-border);
  }
  .cmdk-input {
    flex: 1; border: none; outline: none; background: transparent;
    font-size: var(--fs-md); color: var(--c-text);
  }
  .cmdk-input::placeholder { color: var(--c-text-subtle); }
  .cmdk-input:focus-visible { outline: none; }
  .cmdk-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
  .cmdk-group-label {
    font-size: var(--fs-2xs); font-weight: var(--fw-bold);
    text-transform: uppercase; letter-spacing: var(--ls-caps);
    color: var(--c-text-subtle); padding: 10px 10px 5px;
  }
  .cmdk-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 8px; cursor: pointer;
    font-size: var(--fs-base); color: #334155;
    border-left: 3px solid transparent;
  }
  .cmdk-item .cmdk-icon { color: var(--c-text-subtle); flex: none; display: flex; }
  .cmdk-item .cmdk-hint { margin-left: auto; font-size: var(--fs-2xs); color: var(--c-text-subtle); }
  .cmdk-item.selected {
    background: var(--c-brand-soft); color: var(--c-brand-strong);
    border-left-color: var(--c-brand);
  }
  .cmdk-item.selected .cmdk-icon { color: var(--c-brand); }
  .cmdk-empty { padding: 28px 16px; text-align: center; color: var(--c-text-subtle); font-size: var(--fs-sm); }
  .cmdk-footer {
    display: flex; align-items: center; gap: 14px;
    padding: 9px 14px; border-top: 1px solid var(--c-border);
    background: var(--c-surface-2);
    font-size: var(--fs-2xs); color: var(--c-text-subtle);
  }
  .cmdk-footer span { display: inline-flex; align-items: center; gap: 5px; }

  /* ---- Scroll affordance on fixed-height card bodies ----
     Cards are a uniform 260px, so longer sections silently clip. These
     pure-CSS scroll shadows appear only when there is actually more
     content in that direction — no JS, no layout cost. */
  .section-card > .p-4 {
    background:
      linear-gradient(#fff 30%, rgba(255,255,255,0)) center top,
      linear-gradient(rgba(255,255,255,0), #fff 70%) center bottom,
      radial-gradient(farthest-side at 50% 0, rgba(15,23,42,0.13), rgba(15,23,42,0)) center top,
      radial-gradient(farthest-side at 50% 100%, rgba(15,23,42,0.13), rgba(15,23,42,0)) center bottom;
    background-repeat: no-repeat;
    background-size: 100% 30px, 100% 30px, 100% 9px, 100% 9px;
    background-attachment: local, local, scroll, scroll;
  }
  .section-card.fullscreen > .p-4 { background: #fff; }

  /* ============================================================
     VOICE TO EMR PANEL — enterprise capture console
     ============================================================ */
  #voiceModal { width: min(100%, 420px); }
  #voiceModal .ai-panel-body { text-align: center; padding: 16px 18px 14px; }
  #voiceModal .ai-panel-body p { margin-bottom: 0; }

  /* State chip in the panel header */
  .v-chip {
    display: inline-flex; align-items: center; gap: 5px;
    margin-left: 8px; padding: 3px 9px; border-radius: 99px;
    font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: 0;
    border: 1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.06);
    color: #CBD5E1;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
  }
  .v-chip-dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; flex: none; }
  .v-chip.is-ready { color: #94A3B8; }
  .v-chip.is-live {
    color: #FCA5A5; border-color: rgba(239,68,68,0.45); background: rgba(239,68,68,0.16);
  }
  .v-chip.is-live .v-chip-dot { animation: dirtyPulse 1.2s ease-in-out infinite; }
  .v-chip.is-working {
    color: #93C5FD; border-color: rgba(59,130,246,0.45); background: rgba(59,130,246,0.16);
  }
  .v-chip.is-done { color: #6EE7B7; border-color: rgba(16,185,129,0.45); background: rgba(16,185,129,0.16); }

  /* Pipeline stepper */
  .v-steps {
    display: flex; align-items: center; justify-content: space-between;
    gap: 4px; margin-bottom: 14px; padding: 0 2px;
  }
  .v-step {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    flex: 1; position: relative;
    font-size: 10px; font-weight: var(--fw-semibold);
    color: #64748B; letter-spacing: 0.02em;
    transition: color 0.25s ease;
  }
  .v-step::before {
    content: ''; position: absolute; top: 4px; left: calc(-50% + 9px); right: calc(50% + 9px);
    height: 2px; background: rgba(255,255,255,0.10); border-radius: 2px;
    transition: background 0.3s ease;
  }
  .v-step:first-child::before { display: none; }
  .v-step-dot {
    width: 9px; height: 9px; border-radius: 99px;
    background: rgba(255,255,255,0.16); flex: none;
    transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
  }
  .v-step.is-done { color: #94A3B8; }
  .v-step.is-done .v-step-dot { background: #10B981; }
  .v-step.is-done::before { background: rgba(16,185,129,0.5); }
  .v-step.is-active { color: #E2E8F0; }
  .v-step.is-active .v-step-dot {
    background: #60A5FA; transform: scale(1.25);
    box-shadow: 0 0 0 4px rgba(96,165,250,0.22);
  }

  /* Capture stage */
  .v-stage {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 16px 14px 12px;
    margin-bottom: 12px;
    transition: border-color 0.25s ease, background 0.25s ease;
  }
  #voiceModal.is-recording .v-stage {
    border-color: rgba(239,68,68,0.35);
    background: rgba(239,68,68,0.06);
  }
  /* Halo breathes with the live input level */
  .v-halo {
    position: absolute; width: 72px; height: 72px; border-radius: 999px;
    background: radial-gradient(circle, rgba(239,68,68,0.35) 0%, rgba(239,68,68,0) 70%);
    opacity: 0; pointer-events: none;
    transform: scale(calc(1 + var(--lvl, 0) * 1.1));
    transition: opacity 0.2s ease, transform 0.08s linear;
  }
  #voiceModal.is-recording .v-halo { opacity: 1; }

  /* Id-scoped so these beat the older #voiceModal .ai-panel-body #id colour rules */
  .v-readout { margin-top: 12px; }
  #voiceModal .ai-panel-body #recordingTimer {
    font-size: 30px; font-weight: var(--fw-bold);
    font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
    color: #F1F5F9; line-height: 1.1; margin-bottom: 0;
  }
  #voiceModal.is-recording .ai-panel-body #recordingTimer { color: #FCA5A5; }
  #voiceModal .ai-panel-body #statusText {
    font-size: var(--fs-sm); color: #94A3B8; margin-top: 2px; margin-bottom: 0;
  }
  #voiceModal.is-recording .ai-panel-body #statusText { color: #FCA5A5; }
  #voiceModal .ai-panel-body #liveTranscriptText { font-size: var(--fs-xs); color: #CBD5E1; }

  /* Live input meter — 16 bars, each driven by its own frequency bin */
  .recording-waves {
    display: flex; align-items: center; justify-content: center;
    gap: 3px; height: 34px; margin-top: 12px;
  }
  .recording-waves.hidden { display: none; }
  .recording-waves span {
    width: 4px; height: 100%; border-radius: 99px;
    background: #EF4444 !important;
    transform: scaleY(var(--b, 0.12));
    transform-origin: center;
    animation: none !important;
    transition: transform 0.07s linear;
    opacity: 0.9;
  }

  /* Device / permission readout */
  .v-device {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 10px;
    font-size: var(--fs-2xs); color: #64748B;
  }
  .v-device-dot {
    width: 6px; height: 6px; border-radius: 99px; background: #475569; flex: none;
    transition: background 0.2s;
  }
  .v-device.is-ok .v-device-dot { background: #10B981; }
  .v-device.is-ok { color: #94A3B8; }
  .v-device.is-blocked .v-device-dot { background: #EF4444; }
  .v-device.is-blocked { color: #FCA5A5; }

  .v-actions { display: flex; gap: 8px; margin-bottom: 12px; }

  /* Transcript */
  .v-eyebrow {
    display: flex; align-items: center; gap: 6px;
    font-size: var(--fs-2xs); font-weight: var(--fw-bold);
    text-transform: uppercase; letter-spacing: var(--ls-caps);
    color: #94A3B8 !important;
  }
  .v-live-dot {
    width: 6px; height: 6px; border-radius: 99px; background: #EF4444; flex: none;
    animation: dirtyPulse 1.2s ease-in-out infinite;
  }

  /* Collapsible manual-text path */
  .v-disclosure {
    display: flex; align-items: center; gap: 6px;
    background: none; border: none; cursor: pointer; padding: 0;
    font-size: var(--fs-2xs); font-weight: var(--fw-bold);
    text-transform: uppercase; letter-spacing: var(--ls-caps);
    color: #94A3B8;
    transition: color 0.15s;
  }
  .v-disclosure:hover { color: #C4B5FD; }
  .v-chevron { transition: transform 0.22s var(--ease-out); flex: none; }
  #textInputWrapper:not(.is-collapsed) .v-chevron { transform: rotate(90deg); }
  /* Single grid child is required — a second child lands in an implicit
     auto-sized row and defeats the 1fr→0fr collapse. */
  .v-collapsible {
    display: grid; grid-template-rows: 1fr;
    transition: grid-template-rows 0.25s var(--ease-out), opacity 0.2s ease, margin-top 0.25s;
    margin-top: 8px; opacity: 1;
  }
  .v-collapsible-inner { min-height: 0; overflow: hidden; }
  #textInputWrapper.is-collapsed .v-collapsible {
    grid-template-rows: 0fr; opacity: 0; margin-top: 0;
  }

  /* Processing */
  .v-processing { color: #93C5FD; margin-bottom: 10px; }
  .v-progress {
    height: 3px; border-radius: 99px; margin-top: 9px;
    background: rgba(255,255,255,0.08); overflow: hidden;
  }
  .v-progress-bar {
    height: 100%; width: 35%; border-radius: 99px;
    background: linear-gradient(90deg, #3B82F6, #A78BFA);
    animation: v-indeterminate 1.25s ease-in-out infinite;
  }
  @keyframes v-indeterminate {
    0%   { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
  }

  /* Footer hints */
  .v-hints {
    display: flex; align-items: center; gap: 12px;
    padding-top: 10px; margin-top: 2px;
    border-top: 1px solid rgba(255,255,255,0.07);
    font-size: var(--fs-2xs); color: #64748B;
  }
  .v-hints span { display: inline-flex; align-items: center; gap: 5px; }
  .v-hints kbd {
    background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.14);
    color: #CBD5E1;
  }
  .v-hints-note { margin-left: auto; font-style: italic; }

  /* ============================================================
     CDSS ANALYSIS PANEL — enterprise decision-support console
     ============================================================ */
  #ragPanel .ai-panel-header { cursor: grab; user-select: none; }
  #ragPanel.is-dragging .ai-panel-header { cursor: grabbing; }
  #ragPanel.is-dragging { transition: none !important; }

  .c-steps { margin-bottom: 14px; }
  .c-steps.hidden { display: none; }

  /* Triage bar — severity counts double as jump links */
  .c-triage {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
    padding: 9px 10px; margin-bottom: 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    position: sticky; top: -1.1rem; z-index: 5;
    backdrop-filter: blur(8px);
  }
  .c-triage.hidden { display: none; }
  .c-pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 9px; border-radius: 99px;
    font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
    border: 1px solid transparent; cursor: pointer;
    background: rgba(255,255,255,0.06); color: #CBD5E1;
    transition: transform 0.15s var(--ease-out), background 0.15s, border-color 0.15s;
  }
  .c-pill:hover { transform: translateY(-1px); background: rgba(255,255,255,0.12); }
  .c-pill:active { transform: scale(0.96); }
  .c-pill-count { font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); }
  .c-pill.sev-critical { background: rgba(248,113,113,0.16); color: #FCA5A5; border-color: rgba(248,113,113,0.35); }
  .c-pill.sev-warning  { background: rgba(251,191,36,0.16);  color: #FCD34D; border-color: rgba(251,191,36,0.35); }
  .c-pill.sev-advice   { background: rgba(96,165,250,0.16);  color: #93C5FD; border-color: rgba(96,165,250,0.35); }
  .c-pill.is-muted { opacity: 0.45; }
  .c-pill-spacer { margin-left: auto; }

  /* Section headers become collapse toggles */
  #ragPanel .rag-section h4 {
    display: flex; align-items: center; gap: 6px;
    cursor: pointer; border-radius: 6px;
    transition: color 0.15s;
  }
  #ragPanel .rag-section h4:hover { color: #C4B5FD; }
  .c-caret {
    width: 12px; height: 12px; flex: none;
    transition: transform 0.22s var(--ease-out);
  }
  .rag-section.is-collapsed .c-caret { transform: rotate(-90deg); }
  .rag-section.is-collapsed > *:not(h4) { display: none; }
  .c-count-badge {
    margin-left: auto; font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
    color: #64748B; background: rgba(255,255,255,0.06);
    padding: 1px 7px; border-radius: 99px;
    font-variant-numeric: tabular-nums;
  }

  /* Diagnosis confidence meters */
  .c-prob {
    height: 4px; border-radius: 99px; margin-top: 6px;
    background: rgba(255,255,255,0.08); overflow: hidden;
  }
  .c-prob-bar {
    height: 100%; border-radius: 99px; width: 0;
    transition: width 0.7s var(--ease-out);
  }
  .c-prob-bar.p-high   { width: 88%; background: linear-gradient(90deg, #EF4444, #F87171); }
  .c-prob-bar.p-medium { width: 55%; background: linear-gradient(90deg, #D97706, #FBBF24); }
  .c-prob-bar.p-low    { width: 24%; background: linear-gradient(90deg, #475569, #94A3B8); }
  #ragPanel .rag-diagnosis-item {
    padding: 10px 12px; border-radius: 9px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    transition: background 0.18s, border-color 0.18s, transform 0.18s;
  }
  #ragPanel .rag-diagnosis-item:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(148,163,184,0.28);
    transform: translateX(2px);
  }

  /* Insight cards react to the pointer */
  #ragPanel .rag-insight {
    transition: background 0.18s, transform 0.18s, box-shadow 0.18s;
  }
  #ragPanel .rag-insight:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 14px rgba(2,6,23,0.35);
  }
  #ragPanel .rag-insight.is-flash {
    animation: c-flash 1.1s ease-out;
  }
  @keyframes c-flash {
    0%   { box-shadow: 0 0 0 0 rgba(96,165,250,0.55); }
    100% { box-shadow: 0 0 0 14px rgba(96,165,250,0); }
  }

  /* Evidence cards */
  #ragPanel .rag-evidence-card {
    padding: 9px 11px; border-radius: 9px; margin-bottom: 7px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-left: 3px solid #7C3AED;
    font-size: var(--fs-sm); line-height: 1.45;
    transition: background 0.18s, transform 0.18s;
  }
  #ragPanel .rag-evidence-card:hover { background: rgba(124,58,237,0.10); transform: translateX(2px); }

  /* Loading skeleton */
  .c-skeleton { margin-top: 16px; display: flex; flex-direction: column; gap: 9px; }
  .c-sk-line, .c-sk-card {
    border-radius: 7px;
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.11) 37%, rgba(255,255,255,0.05) 63%);
    background-size: 400% 100%;
    animation: c-shimmer 1.5s ease-in-out infinite;
  }
  .c-sk-line { height: 11px; }
  .c-sk-card { height: 58px; }
  .c-sk-line.w-40 { width: 40%; } .c-sk-line.w-70 { width: 70%; }
  .c-sk-line.w-90 { width: 90%; } .c-sk-line.w-100 { width: 100%; }
  @keyframes c-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
  }

  /* Empty / error state */
  .c-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 34px 20px; gap: 4px; color: #CBD5E1;
  }
  .c-empty.hidden { display: none; }
  .c-empty-icon { width: 40px; height: 40px; color: #475569; margin-bottom: 6px; }
  .c-empty-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: #E2E8F0; }
  .c-empty-sub { font-size: var(--fs-sm); color: #94A3B8; max-width: 42ch; line-height: 1.5; }
  .c-empty .btn { margin-top: 12px; }
  .c-empty.is-error .c-empty-icon { color: #F87171; }

  /* Footer meta */
  .c-meta {
    margin-top: 18px; padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex; flex-direction: column; gap: 5px;
  }
  .c-meta-row {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: var(--fs-2xs); color: #64748B;
    font-variant-numeric: tabular-nums;
  }
  #ragPanel #ragDisclaimer { color: #64748B; margin: 0; }

  /* ---- Respect reduced-motion preferences ---- */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.001ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001ms !important;
    }
    .section-card:hover:not(.dragging):not(.fullscreen) { transform: none; }
    .btn:hover { transform: none; }
  }
