/* CliOS - Advitam NYC */

:root {
  --bg: #f0f2f5;
  /* Left nav — match page canvas (Linear-style) */
  --sidebar-bg: #f0f2f5;
  /* Rounded main column panel */
  --main-shell-bg: #fcfcfd;
  --field-bg: #f7f8fa;
  /* Patients kanban columns + Tasks Care Board cells behind cards */
  --kanban-column-bg: #e8eaef;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --border: #e2e6eb;
  --border-strong: #c8cdd4;
  --text: #1a1d21;
  --text-muted: #5c636a;
  --text-faint: #8b9299;
  /* Neutral-leaning purple: lower chroma than pure electric violet */
  --primary: #4a45a8;
  --primary-hover: #3c388f;
  --primary-light: #ebeaf5;
  --primary-light-hover: #f3f2f8;
  --accent: #5550a0;
  /* Inline @mentions — same purple as links / primary UI */
  --mention-text: var(--primary);
  --danger: #c53030;
  --danger-bg: #fef2f2;
  --warning-bg: #fffbeb;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  /* Typography scale */
  --text-2xs: 0.6875rem;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1rem;
  --text-xl: 1.375rem;
  --font-page-title: var(--text-lg);
  --font-section-title: var(--text-md);
  --font-body: var(--text-base);
  --font-body-reading: var(--text-md);
  --btn-radius: var(--radius);
  --assistant-dock-width: 380px;
  --patient-picker-dock-width: 320px;
  /* Status, Assignee, Date, workflow filters — one size everywhere */
  --workflow-control-height: 2rem;
  --workflow-control-padding-x: 0.5rem;
  --workflow-control-font-size: var(--text-base);
  --workflow-control-radius: 999px;
  --scrollbar-size: 10px;
  --scrollbar-thumb: color-mix(in srgb, var(--text) 28%, transparent);
  --scrollbar-thumb-hover: color-mix(in srgb, var(--text) 42%, transparent);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: var(--font-body-reading);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

#app {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: 1fr;
}

/* Left sidebar — same canvas as page; active items use pill highlight */
.sidebar {
  grid-column: 1;
  grid-row: 1 / -1;
  width: 200px;
  min-height: 0;
  align-self: stretch;
  background: var(--sidebar-bg);
  border-right: none;
  /* Match .main top gutter so logo aligns with rounded main shell */
  padding: 0.75rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  overflow: hidden;
  box-sizing: border-box;
  --sidebar-shell-width: 200px;
  --sidebar-nav-gutter-x: 0.75rem;
  --sidebar-pill-padding-x: 0.5rem;
  --sidebar-content-width: calc(var(--sidebar-shell-width) - (2 * var(--sidebar-nav-gutter-x)));
  --sidebar-hover-bg: rgba(0, 0, 0, 0.045);
  --sidebar-icon-slot: 1.5rem;
  --sidebar-icon-text-gap: 0.5rem;
}

/* Fixed shell width + equal horizontal inset — immune to Firefox scrollbar shrinking the scrollport */
.sidebar-logo-row,
.sidebar-clinic-wrap,
.sidebar-demo-footer {
  width: var(--sidebar-shell-width);
  box-sizing: border-box;
  padding-inline: var(--sidebar-nav-gutter-x);
}

.sidebar-logo-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  width: var(--sidebar-shell-width);
  box-sizing: border-box;
  padding-inline: var(--sidebar-nav-gutter-x);
}

.sidebar-logo-row .sidebar-logo {
  padding: 0;
  margin-top: 0;
  flex: 0 1 auto;
  min-width: 0;
}

.sidebar-logo-actions {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  flex-shrink: 0;
  margin-left: auto;
}

.sidebar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background-color 0.12s ease, color 0.12s ease;
}

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

.sidebar-icon-btn--primary {
  color: var(--primary);
}

.sidebar-icon-btn--primary:hover {
  background: var(--sidebar-hover-bg);
  color: var(--primary);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
  margin-top: 0;
  font-weight: 600;
  font-size: calc(0.9375rem * 0.8);
  color: var(--primary);
  text-decoration: none;
}

.sidebar-logo:hover {
  color: var(--primary-hover);
}

.sidebar-clinic-wrap {
  position: relative;
  margin-bottom: 0;
  width: var(--sidebar-shell-width);
  padding-inline: var(--sidebar-nav-gutter-x);
  box-sizing: border-box;
}

.sidebar-clinic {
  display: grid;
  grid-template-columns: var(--sidebar-icon-slot) minmax(0, 1fr);
  column-gap: var(--sidebar-icon-text-gap);
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  border: none;
  padding: 0.5rem var(--sidebar-pill-padding-x);
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-md);
  transition: background-color 0.12s ease;
}

.sidebar-clinic:hover {
  background: var(--sidebar-hover-bg);
}

/* All dropdowns: ensure expanded content appears below the trigger */
.sidebar-flyout,
.wearables-actions-flyout,
.manage-users-actions-flyout,
.workflow-row-actions-flyout,
.workflow-date-popover,
.workflow-status-popover,
.workflow-assignee-popover,
.workflow-filter-popover,
.add-note-patient-list {
  bottom: auto !important;
  animation: dissolveIn 0.2s ease;
}

.sidebar-flyout {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.75rem;
  z-index: 100;
}

.sidebar-flyout[hidden] {
  display: none;
}

.sidebar-flyout-name {
  margin: 0 0 0.15rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.sidebar-flyout-team {
  margin: 0 0 0.75rem 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.sidebar-flyout-link {
  display: block;
  padding: 0.4rem 0;
  font-size: 0.9375rem;
  color: var(--primary);
  text-decoration: none;
}

.sidebar-flyout-link:hover {
  text-decoration: underline;
}

.sidebar-avatar {
  grid-column: 1;
  justify-self: center;
  align-self: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.6875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 0 0 1px #fff;
}

.sidebar-avatar--photo .sidebar-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-clinic-name {
  grid-column: 2;
  min-width: 0;
  position: relative;
  z-index: 1;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  margin-top: 0.125rem;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  width: var(--sidebar-shell-width);
  box-sizing: border-box;
  scrollbar-width: none !important;
  scrollbar-gutter: auto;
  scrollbar-color: transparent transparent !important;
  -ms-overflow-style: none;
}

.sidebar-nav-inner {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  box-sizing: border-box;
  padding-inline: var(--sidebar-nav-gutter-x);
}

.sidebar .sidebar-nav {
  scrollbar-width: none !important;
  scrollbar-color: transparent transparent !important;
}

.sidebar .sidebar-nav::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none;
}

.sidebar-nav-inner > .sidebar-group:first-child {
  margin-top: 0;
}

.sidebar-nav-bottom {
  margin-top: auto;
  padding-top: 0.5rem;
}

.sidebar-link.sidebar-link--with-icon {
  display: grid;
  grid-template-columns: var(--sidebar-icon-slot) minmax(0, 1fr);
  column-gap: var(--sidebar-icon-text-gap);
  align-items: center;
}

.sidebar-link-icon {
  position: relative;
  z-index: 1;
  grid-column: 1;
  justify-self: center;
  align-self: center;
  flex-shrink: 0;
  width: var(--sidebar-icon-slot);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  color: inherit;
  opacity: 1;
}

.sidebar-link.sidebar-link--with-icon.sidebar-link--truncate {
  overflow: visible;
}

.sidebar-link.sidebar-link--with-icon.sidebar-link--truncate > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-link[data-route="patients"] .sidebar-link-icon {
  font-size: 1.0714em;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  border: none;
  padding: 0.5rem var(--sidebar-pill-padding-x);
  margin-inline: 0;
  color: var(--text);
  text-decoration: none;
  font-weight: 400;
  font-size: 0.875rem;
  background: transparent;
  transition: color 0.12s ease;
}

.sidebar-link > span {
  grid-column: 2;
  min-width: 0;
  position: relative;
  z-index: 1;
  text-align: left;
}

.sidebar-link::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: var(--radius-md);
  background: transparent;
  pointer-events: none;
  transition: background-color 0.12s ease;
}

.sidebar-link--truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-link:hover {
  color: var(--text);
}

.sidebar-link:hover::before {
  background-color: var(--sidebar-hover-bg);
}

.sidebar-link.active {
  color: var(--primary);
  font-weight: 600;
}

.sidebar-link.active::before {
  background-color: var(--surface);
}

.sidebar-link.active .sidebar-link-icon {
  color: var(--primary);
}

/* Favorites (pinned patients): full-width row hover + remove (×) */
#sidebar-pinned-patients {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  width: 100%;
}

.sidebar-pinned-item {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-shrink: 0;
  width: 100%;
  margin-inline: 0;
  box-sizing: border-box;
  border: none;
  background: transparent;
  transition: color 0.12s ease;
}

.sidebar-pinned-item::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: var(--radius-md);
  background: transparent;
  pointer-events: none;
  transition: background-color 0.12s ease;
}

.sidebar-pinned-item:hover::before,
.sidebar-pinned-item:focus-within::before {
  background-color: var(--sidebar-hover-bg);
}

.sidebar-pinned-item:has(.sidebar-pinned-link.active)::before {
  background-color: var(--surface);
}

.sidebar-pinned-item:has(.sidebar-pinned-link.active):hover::before,
.sidebar-pinned-item:has(.sidebar-pinned-link.active):focus-within::before {
  background-color: var(--surface);
}

.sidebar-pinned-item .sidebar-pinned-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  max-width: 100%;
  position: relative;
  z-index: 1;
  border-left: none;
  border-inline: none;
  margin-inline: 0;
  padding: 0.5rem var(--sidebar-pill-padding-x);
  border-radius: var(--radius-md);
  font-weight: 400;
  color: var(--text);
  box-sizing: border-box;
  overflow: hidden;
}

.sidebar-pinned-item .sidebar-pinned-link .sidebar-avatar {
  grid-column: unset;
  justify-self: unset;
  align-self: unset;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  font-size: 0.5625rem;
  box-shadow: none;
}

.sidebar-pinned-item .sidebar-pinned-name {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  grid-column: unset;
  text-align: left;
}

.sidebar-pinned-item .sidebar-pinned-link::before {
  display: none;
}

.sidebar-pinned-item .sidebar-pinned-link.active {
  background: transparent;
  color: var(--primary);
  font-weight: 600;
}

.sidebar-pinned-item:hover .sidebar-pinned-link:not(.active),
.sidebar-pinned-item:focus-within .sidebar-pinned-link:not(.active) {
  color: var(--text);
  background: transparent;
}

.sidebar-pinned-unpin {
  flex-shrink: 0;
  align-self: center;
  width: 1.625rem;
  height: 1.625rem;
  margin-right: var(--sidebar-pill-padding-x);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  position: relative;
  z-index: 1;
  transition: opacity 0.12s ease, color 0.12s ease, background-color 0.12s ease;
}

.sidebar-pinned-item:hover .sidebar-pinned-unpin,
.sidebar-pinned-item:focus-within .sidebar-pinned-unpin,
.sidebar-pinned-unpin:focus-visible {
  opacity: 1;
}

.sidebar-pinned-unpin:hover {
  color: var(--text);
  background: var(--sidebar-hover-bg);
}

.sidebar-pinned-unpin:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-light);
}

@media (hover: none) {
  .sidebar-pinned-unpin {
    opacity: 0.55;
  }
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-top: 1rem;
  width: 100%;
  flex-shrink: 0;
  align-items: stretch;
}

.sidebar-group-title-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  width: 100%;
  margin-inline: 0;
  box-sizing: border-box;
  border: none;
  padding: 0.5rem 0 0.25rem;
}

.sidebar-group-title {
  flex: 1;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0.05em;
}

.sidebar-add-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1;
  font-weight: 400;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.sidebar-add-btn:hover {
  color: var(--text);
  background: var(--sidebar-hover-bg);
}

.sidebar-demo-footer {
  margin-top: auto;
  padding: 0.75rem var(--sidebar-nav-gutter-x) 0 calc(var(--sidebar-nav-gutter-x) + var(--sidebar-pill-padding-x));
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.sidebar-demo-help {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.375rem;
  height: 1.375rem;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1;
}

.sidebar-demo-help i {
  line-height: 1;
  display: block;
}

.sidebar-demo-help:hover {
  color: var(--primary);
  background: rgba(0, 0, 0, 0.05);
}

.sidebar-demo-help:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.sidebar-demo-text {
  margin: 0;
  line-height: 1.25;
}

.main {
  grid-column: 2;
  grid-row: 1;
  min-height: 0;
  /* Firefox: default min-width:auto on grid items can prevent shrinking and clip flex descendants */
  min-width: 0;
  overflow: hidden;
  padding: 0.75rem 1rem 1rem 0;
  max-width: 1200px;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.75rem;
  box-sizing: border-box;
  position: relative;
}

.main.assistant-open {
  max-width: none;
}

.main.patient-picker-open {
  max-width: none;
}

.main.assistant-open .main-content-shell,
.main.patient-picker-open .main-content-shell {
  flex: 1 1 0;
  min-width: 0;
}

/* Rounded main column (Linear-style); scroll inside shell */
.main-content-shell {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--main-shell-bg);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  padding: 1.5rem;
  overflow: hidden;
}

/* Shell fills main; each route view uses a fixed header + inner scroll (see #patient-view) */
.main-content-shell > .view.view-scroll-layout:not(.hidden) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.main-content-shell > .view.assistant-page-view:not(.hidden) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.view-scroll-layout .view-fixed-header {
  flex-shrink: 0;
  background-color: var(--main-shell-bg);
}

.view-scroll-layout .view-scroll-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1.5rem;
  /* block by default so tables/lists grow with content and this region scrolls */
}

/* Kanban: column flex so .patients-kanban-scroll can flex-fill and scroll horizontally */

/* Tasks: list table grows → outer body scrolls; Care Board subview fills height → inner .care-board scrolls */
#home-view .view-scroll-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Must hide inactive subviews — .hidden alone is not enough (only .view.hidden is global). */
.home-workflows-subview.hidden {
  display: none !important;
}

#home-view .view-scroll-body #home-workflows-patient-subview.home-workflows-subview:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#home-view .view-scroll-body #home-workflows-care-board-subview.home-workflows-subview:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
}

#home-view .view-scroll-body #home-workflows-operations-subview.home-workflows-subview:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Inbox: outer shell does not scroll; list + detail columns scroll internally */
.view-scroll-layout .view-scroll-body--messages {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Inset so + New clears shell overflow + radius; padding on #messages-view avoids Firefox clipping inside overflow:hidden flex child */
#messages-view .view-scroll-body--messages {
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  /* Inbox scrolls internally; avoid double FAB padding */
  padding-bottom: 0;
}

.main.main--content-full-width {
  max-width: none;
}

/* Patient record: fill shell; body scrolls inside .patient-view-scroll-body so header never overlaps content */
/* Do not use overflow:hidden here — it clips .patient-view-sticky-header when margin-top pulls it into shell padding */
#patient-view:not(.hidden) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* Patient view: header + tabs stay fixed above the scroll region (not position:sticky — scroll is inner only) */
.patient-view-sticky-header {
  flex-shrink: 0;
  /* Opaque fill — same as .main-content-shell canvas */
  background-color: var(--main-shell-bg);
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  /* Pull up into .main-content-shell top padding — tight gap above breadcrumbs */
  margin-top: -1.5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  padding-top: 0.5rem;
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--main-shell-bg);
  box-shadow: none;
}

.patient-view-scroll-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1.5rem;
}

/*
 * Auto-hide scrollbars app-wide: fixed thin track, transparent thumb when idle,
 * visible thumb while scrolling (.is-scrolling from app.js).
 * scrollbar-width stays thin always so Firefox never reflows when the thumb appears.
 */
body * {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

/* Sidebar nav: never reserve a scrollbar track — it shrinks link rows in Firefox */
.sidebar .sidebar-nav {
  scrollbar-width: none !important;
  scrollbar-color: transparent transparent !important;
}

body *.is-scrolling {
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

body *::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

body *::-webkit-scrollbar-track {
  background: transparent;
}

body *::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background-color 0.2s ease;
}

body *.is-scrolling::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  background-clip: content-box;
  border: 2px solid transparent;
}

body *.is-scrolling::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

#patient-view .patient-view-sticky-header .page-header--record {
  margin-top: 0;
  margin-bottom: 0.5rem;
  padding-top: 0;
  background-color: var(--main-shell-bg);
}

#patient-view .patient-view-sticky-header .patient-record-top-row {
  margin-bottom: 0.5rem;
}

#patient-view .patient-view-sticky-header .patient-subnav {
  margin-bottom: 0;
}

#patient-view .patient-view-sticky-header .back-link {
  margin-bottom: 0.5rem;
}

/* Space below patient sub-nav (Overview, Details, Progress, etc.) — keep moderate; details use + card/wrapper inset */
.patient-view-scroll-body > .patient-panel {
  padding-top: 1rem;
}

#patient-view #patient-profile-panel {
  width: 100%;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
  padding-top: 0;
}

/* Match Patient Details: first headings sit below tabs + same inset as .record-card padding (1.25rem) */
#patient-view #patient-progress-panel .progress-content,
#patient-view #patient-wearables-panel .wearables-content {
  padding-top: 1.25rem;
}

/* Patient view: section blocks sit on main shell */
#patient-view #patient-overview-panel .record-card--plan,
#patient-view #patient-overview-panel .record-card--plan-timeline,
#patient-view #patient-workflow-panel .record-card,
#patient-view #patient-notes-panel .record-card {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  border: none;
  margin: 0;
}

#patient-view #patient-profile-panel .record-card {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  border: none;
  margin: 0;
}

#patient-view #patient-profile-panel .record-card--profile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  box-sizing: border-box;
  width: 100%;
  max-width: none;
}

#patient-view #patient-profile-panel.patient-record {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: none;
  gap: 0;
}

.profile-demographics-layout {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 1.25rem;
  width: 100%;
  max-width: none;
  min-width: 0;
  align-items: stretch;
  overflow: visible;
}

.profile-page-wrap {
  width: 100%;
  max-width: none;
  min-width: 0;
}

.profile-page-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0;
  margin: 0;
  border-bottom: none;
}

.record-card--profile-hero {
  padding: 1.25rem;
}

.profile-patient-section-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

.profile-page-hero .patient-profile-photo-wrap {
  width: 80px;
  height: 80px;
}

.profile-page-hero .patient-profile-avatar {
  width: 80px;
  height: 80px;
  font-size: 1.5rem;
}

.profile-page-hero-meta {
  min-width: 0;
  flex: 1;
}

.profile-page-hero-name {
  margin: 0 0 0.35rem;
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

.profile-page-hero-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  font-size: 0.875rem;
}

.profile-page-hero-registered {
  color: var(--text-muted);
}

.profile-page-hero-status-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-page-hero-status-label {
  color: var(--text-muted);
}

.profile-page-hero-status-host {
  display: inline-flex;
  align-items: center;
}

.profile-page-hero-status-host .patient-record-status-dropdown .workflow-status-trigger {
  font-size: 0.875rem;
}

.profile-demographics-subnav-column {
  padding: 0;
  box-sizing: border-box;
  min-width: 0;
  align-self: stretch;
  overflow: visible;
}

.profile-demographics-subnav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 2;
  padding-top: 1rem;
  box-sizing: border-box;
}

.profile-demographics-subnav-btn {
  display: block;
  width: 100%;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: var(--font-section-title);
  text-align: left;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  line-height: 1.35;
}

.profile-demographics-subnav-btn:hover {
  background: var(--bg);
}

.profile-demographics-subnav-btn.is-selected {
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
}

.profile-demographics-main-column {
  min-width: 0;
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-top: 1rem;
  box-sizing: border-box;
}

.profile-demographics-section {
  scroll-margin-top: 1rem;
  width: 100%;
  max-width: none;
  min-width: 0;
}

#patient-view #patient-profile-panel .record-card--wearables > h2.wearables-tile-title {
  margin: 0;
  padding-bottom: 0;
}

#patient-view #patient-profile-panel .record-card--wearables .wearables-table-wrap {
  margin-top: 0.75rem;
  padding-top: 0;
}

/* Patient Details: field grid inside each white section card */
#patient-view #patient-profile-panel .record-card--profile .profile-fields-grid {
  padding: 0;
  box-sizing: border-box;
  background: transparent;
  border: none;
  border-radius: 0;
}

#patient-view #patient-profile-panel .record-card--profile > h2 {
  margin: 0 0 1rem 0;
  padding-bottom: 0;
}

#patient-view #patient-profile-panel .profile-fields-list > .profile-field-row--split,
#patient-view #patient-profile-panel .record-card--payment .profile-fields-list > .profile-field-row--split {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  column-gap: 0.75rem;
  row-gap: 0.5rem;
  align-items: center;
  justify-content: initial;
  flex-direction: initial;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: inherit;
}

#patient-view #patient-profile-panel .profile-fields-list > .profile-field-row--split:last-child,
#patient-view #patient-profile-panel .record-card--payment .profile-fields-list > .profile-field-row--split:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

#patient-view #patient-profile-panel .profile-fields-list > .profile-field-row--split:first-child,
#patient-view #patient-profile-panel .record-card--payment .profile-fields-list > .profile-field-row--split:first-child {
  padding-top: 0;
}

#patient-view #patient-profile-panel .profile-field-label-cell {
  padding-right: 0;
}

#patient-view #patient-progress-panel .progress-tile {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

#patient-view #patient-communications-panel .patient-messages-layout {
  border: none;
  box-shadow: var(--shadow);
}

/* Patient view: table blocks match Tasks (.table-wrap) — border, 8px radius, clip; no second shadow inside .record-card */
#patient-view .plan-table-wrap,
#patient-view .progress-tests-wrap,
#patient-view .wearables-table-wrap,
#patient-view .record-card--workflow .plan-table-wrap--workflow-patient {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: none;
  min-width: 0;
}

#patient-view .plan-table-wrap,
#patient-view .progress-tests-wrap,
#patient-view .wearables-table-wrap {
  overflow: visible;
}

#patient-view .record-card--workflow .plan-table-wrap--workflow-patient {
  overflow: visible;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

/* Overview (Program + Treatment) & Workflow: flat table chrome — no outer stroke/shadow on wrap */
#patient-view #patient-overview-panel .record-card--plan .plan-table-wrap,
#patient-view #patient-overview-panel .record-card--plan-timeline .plan-table-wrap,
#patient-view #patient-overview-panel .patient-program-table-wrap,
#patient-view #patient-workflow-panel .record-card--workflow .plan-table-wrap--workflow-patient,
#patient-view #patient-notes-panel .record-card--workflow .plan-table-wrap--workflow-patient {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

#patient-view #patient-overview-panel .patient-overview-section-divider {
  grid-column: 1 / -1;
  width: 100%;
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 1.25rem;
}

/* Horizontal rules only (no column strokes), like Tasks */
#patient-view .plan-table th,
#patient-view .plan-table td,
#patient-view .plan-timeline-table th,
#patient-view .plan-timeline-table td,
#patient-view .progress-tests-table th,
#patient-view .progress-tests-table td,
#patient-view .wearables-table th,
#patient-view .wearables-table td,
#patient-view .record-card--workflow .workflow-table--patient th,
#patient-view .record-card--workflow .workflow-table--patient td {
  border-left: none;
  border-right: none;
}

.view {
  animation: fadeIn 0.2s ease;
}

.view.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes dissolveIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Page header */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header--main:has(+ .dashboard-toolbar) {
  margin-bottom: 0.75rem;
}

.page-header--record {
  margin-bottom: 1rem;
}

/* Patient identity row: same encapsulated treatment as Treatment Plan (.record-card) */
.page-header--record .patient-record-header-card.record-card {
  margin-top: 0;
  margin-bottom: 0;
}

.page-header--record .patient-record-header-card .patient-header-row {
  margin-top: 0;
}

.page-header h1 {
  margin: 0 0 0.25rem 0;
  font-size: var(--font-page-title);
  font-weight: 600;
  color: var(--text);
}

.page-header-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.page-header-title-row h1 {
  margin: 0;
}

.page-header--main h1 {
  font-size: var(--font-page-title);
  font-weight: 600;
}

.patient-record-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.75rem;
  margin-bottom: 0.5rem;
}

.patient-record-top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.patient-record-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0;
  font-size: 0.875rem;
  line-height: 1.3;
  flex: 1 1 auto;
  min-width: 0;
}

.patient-breadcrumb-link {
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}

.patient-breadcrumb-link:hover {
  text-decoration: underline;
}

.patient-breadcrumb-link[aria-expanded="true"] {
  text-decoration: underline;
}

.patient-breadcrumb-sep {
  color: var(--text-faint);
}

.patient-breadcrumb-current {
  color: var(--text-muted);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-back-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.patient-back-row .back-link {
  margin-bottom: 0;
}

.subtitle {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.back-link:hover {
  text-decoration: underline;
}

/* Patient header with profile photo */
.patient-header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.25rem;
}

.patient-profile-photo-wrap {
  position: relative;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
}

.patient-profile-photo-wrap--readonly .patient-profile-avatar {
  cursor: default;
}

.patient-profile-photo-wrap--readonly .patient-profile-avatar:hover {
  background: var(--primary);
}

.patient-profile-photo-wrap--readonly .patient-profile-avatar--photo:hover {
  background: var(--border);
}

.patient-profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s;
}

.patient-profile-avatar:hover {
  background: var(--primary-hover);
}

.patient-profile-avatar--photo {
  padding: 0;
  background: var(--border);
  box-sizing: border-box;
}

.patient-profile-avatar--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.patient-profile-photo-camera-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.patient-profile-photo-camera-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.patient-profile-photo-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.patient-header-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.patient-header-title-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  max-width: 100%;
  width: 100%;
}

.patient-header-meta--title-row {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.patient-header-status-row {
  margin: 0.625rem 0 0;
  width: 100%;
}

.patient-header-inline-status {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  min-width: 0;
}

.patient-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
  align-self: center;
}

.patient-header-actions-tools {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.patient-header-name-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
}

.patient-pin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0;
  transition: color 0.12s ease;
}

.patient-pin-icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  display: block;
}

.patient-pin-btn .patient-pin-icon--filled {
  display: none;
}

.patient-pin-btn:hover {
  color: var(--primary);
  background: transparent;
}

.patient-pin-btn[aria-pressed="true"] {
  color: var(--primary);
  background: transparent;
}

.patient-pin-btn[aria-pressed="true"] .patient-pin-icon--outline {
  display: none;
}

.patient-pin-btn[aria-pressed="true"] .patient-pin-icon--filled {
  display: block;
}

.patient-pin-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.page-header--record #patient-record-title,
#patient-view .patient-header-title-line #patient-record-title {
  font-size: var(--text-xl);
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
}

#patient-record-subtitle,
.patient-header-meta {
  font-size: var(--text-base);
  line-height: 1.45;
}

#patient-record-subtitle.patient-header-meta--title-row,
.patient-header-meta.patient-header-meta--title-row {
  margin: 0;
}

.patient-header-meta-sep {
  color: var(--text-muted);
  margin: 0 0.15rem;
  user-select: none;
}

.patient-header-meta-icon {
  font-size: 0.875rem;
  vertical-align: -0.1em;
  margin-right: 0.2rem;
  color: var(--text-muted);
}

.patient-record-contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  max-width: 100%;
}

.patient-record-contact-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-record-contact-link:hover {
  text-decoration: underline;
}

.patient-record-contact-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 2px;
}

.patient-header-inline-status .patient-header-checklist-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.45;
  color: var(--text);
}

.patient-header-status-display {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.45;
  color: var(--text);
  margin-right: 0.15rem;
}

.patient-header-status-display .workflow-status-bullet {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.patient-header-status-display--active .workflow-status-bullet {
  background: var(--success, #059669);
}

.patient-header-status-display--new .workflow-status-bullet {
  background: var(--info, #2563eb);
}

.patient-header-status-display--inactive .workflow-status-bullet {
  background: var(--error, #dc2626);
}

.patient-header-status-display--unset .workflow-status-bullet {
  background: var(--text-faint);
}

.patient-header-inline-status .patient-header-checklist-item .workflow-status-bullet--task-chip {
  width: 0.75rem;
  height: 0.75rem;
}

.patient-header-inline-status .patient-record-status-dropdown {
  margin: 0 0.25rem;
}

.patient-header-inline-status .patient-record-status-dropdown .workflow-status-trigger {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.125rem 0.5rem;
  min-height: 0;
  height: auto;
  line-height: 1.2;
  border: 1px solid var(--border);
  border-radius: var(--workflow-control-radius);
  background: var(--surface);
  color: var(--text);
}

.patient-header-inline-status.patient-header-status--active .patient-record-status-dropdown .workflow-status-trigger {
  background: var(--success-bg, #ecfdf5);
  border-color: var(--success, #059669);
  color: var(--success-dark, #047857);
}

.patient-header-inline-status.patient-header-status--new .patient-record-status-dropdown .workflow-status-trigger {
  background: var(--info-bg, #eff6ff);
  border-color: var(--info, #2563eb);
  color: var(--info-dark, #1d4ed8);
}

.patient-header-inline-status.patient-header-status--inactive .patient-record-status-dropdown .workflow-status-trigger {
  background: var(--error-bg, #fef2f2);
  border-color: var(--error, #dc2626);
  color: var(--error-dark, #b91c1c);
}

.patient-header-actions .patient-presence-avatars {
  display: flex;
  align-items: center;
  flex-direction: row;
  flex-shrink: 0;
}

.patient-header-actions .patient-presence-avatars[hidden] {
  display: none;
}

.patient-header-actions .patient-presence-avatar .workflow-assignee-avatar {
  width: 2rem;
  height: 2rem;
  font-size: 0.75rem;
}

.patient-header-actions .patient-presence-avatar--more {
  width: 2rem;
  height: 2rem;
  font-size: 0.75rem;
}

.patient-header-actions .patient-pin-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  box-sizing: border-box;
  transition: color 0.15s ease, background 0.15s ease;
}

.patient-header-actions .patient-pin-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.patient-header-actions .patient-pin-btn[aria-pressed="true"] {
  color: var(--primary);
  background: var(--primary-light);
}

.patient-header-actions .patient-pin-btn .patient-pin-icon {
  width: 1.125rem;
  height: 1.125rem;
}

.patient-header-actions .patient-presence-avatar {
  box-shadow: 0 0 0 2px var(--surface);
}

.patient-header-checklist-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.45;
  color: var(--text);
}

.patient-header-checklist-item .workflow-status-bullet--task-chip {
  width: 0.75rem;
  height: 0.75rem;
}

.app-working-indicator {
  position: fixed;
  inset: 0;
  z-index: 12050;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.app-working-indicator[hidden] {
  display: none !important;
  pointer-events: none;
}
.app-working-indicator:not([hidden]) {
  pointer-events: auto;
}
.app-working-indicator--page-load {
  background: color-mix(in srgb, var(--text, #1a1d21) 12%, transparent);
}
.app-working-indicator-card {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1rem;
  min-width: 7.5rem;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: var(--radius-md, 10px);
  box-shadow:
    0 10px 28px rgba(15, 23, 42, 0.14),
    0 2px 8px rgba(15, 23, 42, 0.08);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  pointer-events: auto;
}
.app-working-indicator-spinner {
  flex: 0 0 auto;
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid color-mix(in srgb, var(--text, #1a1d21) 14%, transparent);
  border-top-color: var(--text, #1a1d21);
  border-radius: 50%;
  animation: app-working-indicator-spin 0.7s linear infinite;
}
.app-working-indicator-label {
  white-space: nowrap;
}
@keyframes app-working-indicator-spin {
  to {
    transform: rotate(360deg);
  }
}

.patient-header-status {
  margin-left: auto;
  flex-shrink: 0;
}

/* Message icon + patient status dropdown (matches workflow task header row) */
.patient-record-header-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.patient-presence-avatars {
  display: flex;
  align-items: center;
  flex-direction: row;
  flex-shrink: 0;
}

.patient-presence-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-left: -0.4rem;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--main-shell-bg, var(--surface));
}

.main-header-trailing {
  position: absolute;
  z-index: 4;
  top: 1.5rem;
  right: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

#patient-view:not(.hidden) .patient-record-top-actions .main-header-trailing {
  position: static;
  top: auto;
  right: auto;
  z-index: auto;
}

.main-header-trailing .patient-presence-avatars[hidden] {
  display: none;
}

.main-header-trailing .patient-presence-avatars:not([hidden]) {
  display: flex;
}

.patient-presence-avatar:first-child {
  margin-left: 0;
}

.patient-presence-avatar .workflow-assignee-avatar {
  width: 2rem;
  height: 2rem;
  font-size: 0.75rem;
}

.patient-presence-avatar--more {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--bg, #f0f2f5);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 0 0 2px var(--surface);
}

.patient-record-messages-overlay {
  z-index: 1000;
}

.patient-record-status-popover-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
}

.patient-record-status-popover-actions {
  display: flex;
  flex-direction: column;
  padding: 0.15rem 0 0.25rem;
}

.patient-record-status-action {
  display: block;
  width: 100%;
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.patient-record-status-action:hover {
  background: var(--bg);
}

.patient-record-status-action-delete:hover {
  color: var(--danger, #dc2626);
}

.patient-header-status-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  height: var(--workflow-control-height);
  padding: 0 var(--workflow-control-padding-x);
  line-height: 1.25;
  box-sizing: border-box;
  font: inherit;
  font-size: var(--workflow-control-font-size);
  border: 1px solid var(--border);
  border-radius: var(--workflow-control-radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 0;
  width: auto;
}

.patient-header-status--active .patient-header-status-select,
.patient-header-status--active .patient-header-status-label,
.patient-header-status--active .patient-record-status-dropdown .workflow-status-trigger {
  background: var(--success-bg, #ecfdf5);
  border-color: var(--success, #059669);
  color: var(--success-dark, #047857);
}
.patient-header-status--new .patient-header-status-select,
.patient-header-status--new .patient-header-status-label,
.patient-header-status--new .patient-record-status-dropdown .workflow-status-trigger {
  background: var(--info-bg, #eff6ff);
  border-color: var(--info, #2563eb);
  color: var(--info-dark, #1d4ed8);
}
.patient-header-status--inactive .patient-header-status-select,
.patient-header-status--inactive .patient-header-status-label,
.patient-header-status--inactive .patient-record-status-dropdown .workflow-status-trigger {
  background: var(--error-bg, #fef2f2);
  border-color: var(--error, #dc2626);
  color: var(--error-dark, #b91c1c);
}

.patients-table .patients-table-status-wrap {
  margin-left: 0;
  display: inline-block;
  position: relative;
  z-index: 1;
}

/* Payment Status column - matches Program table Payment styling */
.patients-payment-label {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--workflow-control-padding-x);
  height: var(--workflow-control-height);
  box-sizing: border-box;
  font-size: var(--workflow-control-font-size);
  border: 1px solid var(--border);
  border-radius: var(--workflow-control-radius);
  background: var(--surface);
  color: var(--text);
}
.patients-payment--up-to-date {
  background: var(--success-bg, #ecfdf5);
  border-color: var(--success, #059669);
  color: var(--success-dark, #047857);
}
.patients-payment--outstanding {
  background: var(--error-bg, #fef2f2);
  border-color: var(--error, #dc2626);
  color: var(--error-dark, #b91c1c);
}

/* Patient Status labels - match Patient view Active dropdown styling */
.patients-table .patient-header-status-label {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--workflow-control-padding-x);
  height: var(--workflow-control-height);
  box-sizing: border-box;
  border-radius: var(--workflow-control-radius);
}

.patient-header-status-label {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.patient-header-info h1 {
  margin: 0 0 0.25rem 0;
  font-size: calc(2em - 6px);
}

/* Patient sub-pages */
.patient-subnav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.patient-subnav-link {
  padding: 0.5rem 1rem;
  font-size: var(--font-section-title);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.patient-subnav-link:hover {
  color: var(--text);
}

.patient-subnav-link.active,
.patient-subnav-link.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.patient-panel {
  margin-top: 0;
}

.patient-panel.hidden {
  display: none !important;
}

/* Inventory → Medications (wide catalog table) */
.inventory-medication-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.inventory-med-count {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted, var(--text));
}

.inventory-med-add-btn {
  flex-shrink: 0;
  font-size: 0.875rem;
}

.inventory-med-empty-hint {
  margin: 0 0 0.5rem;
}

.inventory-medication-table-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.inventory-medication-table {
  min-width: 88rem;
  font-size: 0.8125rem;
}

.inventory-medication-table th {
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--main-shell-bg, var(--surface));
  box-shadow: 0 1px 0 var(--border);
}

.inventory-medication-table th:first-child,
.inventory-medication-table td:first-child,
.inventory-medication-table td[data-column="medication"] {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
  min-width: 17.5rem;
}

.inventory-medication-table td[data-column="medication"] .inventory-med-cell-input {
  min-width: 17.5rem;
  max-width: 20rem;
}

.inventory-medication-table thead th:first-child {
  z-index: 3;
}

.inventory-medication-table td {
  vertical-align: top;
  white-space: nowrap;
}

.inventory-medication-table td.inventory-med-td--wrap {
  white-space: normal;
  min-width: 14rem;
  max-width: 18rem;
  word-break: break-word;
}

.inventory-medication-table .inventory-med-cell-input,
.inventory-medication-table .inventory-med-cell-select,
.inventory-medication-table .inventory-med-cell-textarea {
  display: block;
  width: 100%;
  min-width: 6rem;
  max-width: 14rem;
  min-height: var(--workflow-control-height, 2rem);
  padding: 0.2rem 0.35rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
}

.inventory-medication-table .inventory-med-cell-textarea {
  min-width: 14rem;
  max-width: 18rem;
  min-height: 3.5rem;
  resize: none;
}

.inventory-medication-table td[data-column="shippingCost"],
.inventory-medication-table td[data-column="clinicCost"],
.inventory-medication-table td[data-column="patientCost"] {
  min-width: 0;
  max-width: 6.5rem;
}

.inventory-med-currency-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  max-width: 6rem;
}

.inventory-medication-table.patients-table td select.inventory-med-cell-select {
  appearance: auto;
  -webkit-appearance: menulist;
  -moz-appearance: menulist;
  background-image: none;
  cursor: pointer;
  padding-right: 1.25rem;
}

.inventory-medication-table .inventory-med-cell-select {
  cursor: pointer;
}

.inventory-medication-table td[data-column="volumeUnits"] .inventory-med-cell-select,
.inventory-medication-table td[data-column="doseUnits"] .inventory-med-cell-select {
  min-width: 7.5rem;
  max-width: 9.5rem;
}

.inventory-medication-table td[data-column="frequency"] .inventory-med-cell-select {
  min-width: 9rem;
  max-width: 12rem;
}

.inventory-med-currency-wrap .inventory-med-cell-input {
  display: inline-block;
  width: auto;
  flex: 1 1 auto;
}

.inventory-med-currency-prefix {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.inventory-medication-table .inventory-med-currency-input {
  min-width: 3rem;
  max-width: 4.5rem;
  text-align: right;
}

.inventory-medication-table td[data-column="margin"] {
  min-width: 5rem;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.inventory-med-margin-value {
  display: inline-flex;
  align-items: center;
  min-width: 3.5rem;
  min-height: var(--workflow-control-height, 2rem);
  margin-top: 0.05rem;
  font-size: 0.8125rem;
  line-height: 1.25;
}

.inventory-medication-table th.inventory-med-actions-header,
.inventory-medication-table td.inventory-med-actions-cell {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: -1px 0 0 var(--border);
  width: 2.5rem;
  min-width: 2.5rem;
}

.inventory-medication-table thead th.inventory-med-actions-header {
  z-index: 4;
}

/* Progress page */
.progress-content {
  max-width: 100%;
}

.progress-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.progress-tile:last-child {
  margin-bottom: 0;
}

.progress-tile-title {
  margin: 0 0 1rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #000;
  text-transform: capitalize;
  letter-spacing: -0.01em;
}

.progress-vitals-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.progress-vitals-header .progress-tile-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-vitals-updated {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-faint);
}

.progress-health-profile-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.progress-health-profile-header .progress-tile-title {
  margin: 0;
}

.progress-health-profile-ts {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-faint);
}

#patient-view .progress-profile-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 1.25rem 0;
}

#patient-view .progress-section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.progress-vitals-time-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-vitals-body {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.progress-vitals-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 10rem;
  flex-shrink: 0;
}

.progress-vital-list-btn {
  display: block;
  width: 100%;
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.progress-vital-list-btn:hover {
  background: var(--bg);
}

.progress-vital-list-btn.is-selected {
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
}

.progress-vitals-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.progress-vitals-control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.progress-vitals-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.progress-vitals-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  min-width: 0;
  width: auto;
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  line-height: 1.25;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.progress-vitals-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.progress-vitals-chart-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 280px;
}

.progress-vitals-chart-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.progress-vitals-body .progress-vitals-chart {
  flex: 1;
  min-width: 0;
  min-height: 200px;
  width: 100%;
}

.progress-empty {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-faint);
  font-style: italic;
}

.progress-tests-wrap {
  overflow: visible;
  margin-top: 0.5rem;
}

.progress-tests-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.progress-tests-table th,
.progress-tests-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.progress-tests-table th {
  font-weight: 600;
  color: #000;
  background: var(--bg);
  font-size: 0.8125rem;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
}

.progress-tests-table td {
  color: var(--text);
}

.progress-tests-table tbody tr:hover {
  background: var(--primary-light-hover);
}

.progress-tests-table tbody tr:last-child td {
  border-bottom: none;
}

.progress-test-link {
  display: inline-flex;
  align-items: center;
  color: var(--primary);
  text-decoration: none;
}

.progress-test-link:hover {
  text-decoration: underline;
}

.progress-intake-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem 1.5rem;
}

.progress-intake-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.progress-intake-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.progress-intake-value {
  font-size: 0.9375rem;
  color: var(--text);
}

/* Communications page */
.communications-content {
  max-width: 100%;
}

/* Patient Messages: sub-nav (left) + main panel (conversation thread or placeholders) */
.communications-content--messages-two-col {
  max-width: 100%;
}

.patient-messages-layout {
  display: flex;
  align-items: stretch;
  min-height: 28rem;
  height: calc(100vh - 10.5rem);
  max-height: 52rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.patient-messages-subnav-column {
  width: 24%;
  min-width: 11rem;
  max-width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: transparent;
  padding: 0.75rem 0.5rem;
  box-sizing: border-box;
}

.patient-messages-subnav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.patient-messages-subnav-btn {
  display: block;
  width: 100%;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  line-height: 1.35;
}

.patient-messages-subnav-btn:hover {
  background: var(--surface);
}

.patient-messages-subnav-btn.is-selected {
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
}

.patient-messages-main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.patient-messages-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.patient-messages-panel[hidden] {
  display: none !important;
}

.patient-messages-panel--placeholder {
  padding: 1.5rem 1.75rem;
  overflow: auto;
  background: var(--surface);
  justify-content: flex-start;
}

.patient-messages-placeholder {
  margin: 0;
  max-width: 36rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.patient-messages-thread-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.patient-messages-thread-column .inbox-detail-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.patient-messages-thread-column .inbox-detail-thread {
  flex: 1;
  min-height: 0;
}

.communications-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.communications-tile-title {
  margin: 0 0 1rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #000;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  padding-bottom: 0.5rem;
}

.communications-tile-title:has(+ .communications-tile-desc) {
  margin-bottom: 0.35rem;
}

.communications-tile-desc {
  margin: 0 0 1rem 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.45;
  padding-bottom: 1rem;
}

.communications-cols {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

.communications-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.communications-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.communications-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.communications-pdf-link {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  line-height: 1.25;
  box-sizing: border-box;
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.communications-pdf-link:hover {
  border-color: var(--border-strong);
  background: var(--bg);
  color: var(--primary);
}

.communications-no-pdf {
  font-size: 0.875rem;
  color: var(--text-faint);
}

.communications-file-input {
  font-size: 0.8125rem;
  max-width: 100%;
}

.communications-file-hint {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.communications-cadence-select {
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  max-width: 100%;
}

@media (max-width: 768px) {
  .communications-cols {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .communications-cols {
    grid-template-columns: 1fr;
  }
}

.communications-tile--table {
  margin-top: 1.25rem;
}
.communications-tile--table .communications-tile-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.communications-table-wrap {
  overflow: visible;
  margin-top: 0.5rem;
}

.table-wrap.messages-table-wrap {
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.communications-table {
  table-layout: auto;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.communications-table th,
.communications-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  vertical-align: top;
}

.communications-table th {
  font-weight: 600;
  color: #000;
  background: var(--bg);
  font-size: 0.8125rem;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
}

.communications-table td {
  color: var(--text);
}

.communications-table tbody tr:hover {
  background: var(--primary-light-hover);
}

.communications-table th:nth-child(1),
.communications-table td:nth-child(1) {
  min-width: 5rem;
}

.communications-table th:nth-child(2),
.communications-table td:nth-child(2) {
  min-width: 5rem;
}

.communications-table.messages-table th:nth-child(3),
.communications-table.messages-table td:nth-child(3) {
  min-width: 8rem;
}

.communications-table th:nth-child(4),
.communications-table td:nth-child(4) {
  min-width: 5rem;
}

.communications-table th:nth-child(5),
.communications-table td:nth-child(5),
.communications-table th:nth-child(6),
.communications-table td:nth-child(6) {
  min-width: 5rem;
}

.communications-table th:nth-child(7),
.communications-table td:nth-child(7) {
  min-width: 3rem;
  text-align: center;
}

/* Inbox messages table: ensure Message column wraps */
.messages-table .name-cell,
.messages-table td:nth-child(1) {
  min-width: 6rem;
}

.messages-table td:nth-child(4) {
  max-width: 100%;
  min-width: 0;
}

.messages-table .messages-from-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
}

.messages-table .messages-patient-link {
  color: var(--primary);
  text-decoration: none;
}

.messages-table .messages-patient-link:hover {
  text-decoration: underline;
}

/* Patient Messages table: From (avatar), Date, Attachment columns should not wrap */
.patient-messages-table th:nth-child(1),
.patient-messages-table td:nth-child(1),
.patient-messages-table th:nth-child(2),
.patient-messages-table td:nth-child(2),
.patient-messages-table th:nth-child(4),
.patient-messages-table td:nth-child(4) {
  white-space: nowrap;
}

.patient-messages-table .patient-messages-from-cell {
  width: 3rem;
  min-width: 3rem;
  text-align: center;
  vertical-align: top;
}

.patient-messages-from-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
}

.communications-table-empty {
  color: var(--text-faint);
  font-style: italic;
  text-align: center;
  padding: 1.5rem !important;
}

/* Wearables page */
.wearables-content {
  max-width: 100%;
}

.wearables-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.wearables-tile-title {
  margin: 0 0 1rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #000;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  padding-bottom: 0.5rem;
}

.wearables-tile-title:has(+ .wearables-tile-desc) {
  margin-bottom: 0.35rem;
}

.wearables-tile-title--with-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.wearables-tile-desc {
  margin: 0 0 1rem 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.45;
  padding-bottom: 1rem;
}

.wearables-table-wrap {
  overflow: visible;
  margin-top: 0.5rem;
}

.wearables-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.wearables-table th,
.wearables-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.wearables-table th {
  font-weight: 600;
  color: #000;
  background: var(--bg);
  font-size: 0.8125rem;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
}

.wearables-table td {
  color: var(--text);
}

.wearables-table tbody tr:hover {
  background: var(--primary-light-hover);
}

.wearables-table-empty {
  color: var(--text-faint);
  font-style: italic;
  text-align: center;
  padding: 1.5rem !important;
}

.wearables-table-actions {
  text-align: center !important;
  width: 1%;
  white-space: nowrap;
}

.wearables-actions-wrap {
  position: relative;
  display: inline-block;
}

.wearables-connection-actions-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.wearables-connection-actions-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.wearables-actions-flyout {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.15rem;
  min-width: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 20;
  padding: 0.25rem 0;
}

.wearables-actions-flyout[hidden] {
  display: none;
}

.wearables-connection-delete {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.wearables-connection-delete:hover {
  background: var(--bg);
  color: var(--danger);
}

/* Manage Users table actions */
.manage-users-table-actions {
  text-align: center !important;
  width: 1%;
  white-space: nowrap;
}

.manage-users-actions-wrap {
  position: relative;
  display: inline-block;
}

.manage-users-actions-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.manage-users-actions-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.manage-users-actions-flyout {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.15rem;
  min-width: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 20;
  padding: 0.25rem 0;
}

.manage-users-actions-flyout[hidden] {
  display: none;
}

.manage-users-delete {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.manage-users-delete:hover {
  background: var(--bg);
  color: var(--danger);
}

.manage-user-team-select {
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-width: 8rem;
}

.manage-users-toolbar {
  justify-content: space-between;
}

/* Admin Teams page */
.teams-section,
.teams-users-section {
  margin-bottom: 1.5rem;
}
.teams-section:last-child,
.teams-users-section:last-child {
  margin-bottom: 0;
}
.teams-section h2,
.teams-users-section h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.teams-section-actions {
  margin-left: auto;
}
.teams-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}
.teams-list-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.teams-list-name {
  font-size: 0.875rem;
}
.teams-list-name-editable {
  min-width: 4rem;
  outline: none;
}
.teams-list-name-editable:focus {
  background: var(--surface);
  border-radius: 2px;
  padding: 0 2px;
  margin: 0 -2px;
}
.teams-item-actions-wrap {
  position: relative;
  display: inline-flex;
}
.teams-item-actions-btn {
  padding: 0.2rem 0.35rem;
  font-size: 1rem;
  line-height: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.teams-item-actions-btn:hover {
  color: var(--text);
  background: var(--primary-light);
}
.teams-item-actions-flyout {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.15rem;
  min-width: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 20;
  padding: 0.25rem 0;
}
.teams-item-actions-flyout[hidden] {
  display: none;
}
.teams-item-delete-btn {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.teams-item-delete-btn:hover {
  background: var(--bg);
  color: var(--danger, #dc2626);
}
.teams-members-by-team {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.teams-members-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.teams-members-group-title {
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.teams-members-group .table-wrap {
  margin: 0;
  border-radius: 0;
}
.teams-members-group .table-wrap table {
  margin: 0;
}
.teams-group-empty {
  padding: 1rem !important;
  margin: 0 !important;
}

/* Dashboard toolbar */
.dashboard-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.dashboard-toolbar--patients {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.dashboard-toolbar-row--patients-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dashboard-toolbar-row--patients-filter .workflow-filters {
  margin-bottom: 0;
  flex-wrap: wrap;
}

/* Patients & Tasks: filters aligned with search on one row */
.patients-dashboard-filters-row,
.home-dashboard-filters-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  width: 100%;
}

/* Workflows → Patient: native hidden + legacy .hidden (only .view.hidden is global elsewhere) */
.home-dashboard-filters-row[hidden],
.home-dashboard-filters-row.hidden {
  display: none !important;
}

.patients-dashboard-filters-inner,
.home-dashboard-filters-inner {
  flex: 1;
  min-width: 0;
}

.patients-dashboard-filters-inner .workflow-filters,
.home-dashboard-filters-inner .workflow-filters {
  margin-bottom: 0;
}

.patients-dashboard-filters-row .patients-dashboard-search,
.home-dashboard-filters-row .home-dashboard-search {
  flex-shrink: 0;
  width: auto;
  min-width: 240px;
  max-width: 28rem;
}

/* Patient status trigger: label + count in a small circle (page-bg fill) */
.patients-kanban-status-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  text-align: left;
}

.patients-kanban-status-trigger-label {
  font-weight: 500;
}

.patients-kanban-status-trigger-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 0.3rem;
  box-sizing: border-box;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  background: var(--bg);
  color: var(--text-muted);
}

/* Patients page — Kanban by program */
.patients-dashboard {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: transparent;
}

.patients-dashboard-header,
.home-dashboard-header {
  flex-shrink: 0;
  margin-bottom: 1rem;
}

.patients-dashboard-title-row,
.home-dashboard-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.patients-dashboard-title,
.home-dashboard-title {
  margin: 0;
  font-size: var(--font-page-title);
  font-weight: 600;
  color: var(--text);
}

.patients-dashboard-right-actions,
.home-dashboard-right-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.patients-dashboard-search input[type="search"],
.home-dashboard-search input[type="search"] {
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .patients-dashboard-title-row,
  .home-dashboard-title-row {
    flex-direction: column;
    align-items: stretch;
  }
  .patients-dashboard-right-actions,
  .home-dashboard-right-actions {
    align-items: center;
    justify-content: flex-end;
  }
  .patients-dashboard-filters-row,
  .home-dashboard-filters-row {
    flex-direction: column;
    align-items: stretch;
  }
  .patients-dashboard-filters-row .patients-dashboard-search,
  .home-dashboard-filters-row .home-dashboard-search {
    max-width: none;
    width: 100%;
  }
}

.patients-dashboard .dashboard-toolbar--patients {
  flex-shrink: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  border-bottom: none;
}

/* Tasks page: List / Care Board subnav */
#home-view:not(.hidden) {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#home-view .patient-subnav {
  margin-bottom: 1rem;
  padding: 0;
}

/* Operations (embedded under Workflows) — layout aligned with main shell */
#home-workflows-operations-subview:not(.hidden) {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.home-operations-embedded {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  gap: 0.75rem;
}

.home-operations-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.home-operations-toolbar .operations-filters-placeholder,
.home-operations-toolbar #operations-filters-row {
  flex: 1 1 auto;
  min-width: 0;
}

.home-operations-search {
  flex: 0 1 14rem;
  max-width: 100%;
}

.home-operations-table-wrap {
  min-width: 0;
  overflow-x: auto;
}

.operations-filters-placeholder {
  min-height: 0;
  min-width: 0;
}

#home-workflows-operations-subview .home-table.workflow-table th:nth-child(3),
#home-workflows-operations-subview .home-table.workflow-table td:nth-child(3) {
  min-width: 7rem;
}

#home-workflows-operations-subview .home-table.workflow-table th,
#home-workflows-operations-subview .home-table.workflow-table td {
  vertical-align: middle;
}

.home-operations-embedded-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.02em;
}

.operations-task-modal-field {
  margin-bottom: 1rem;
}

.operations-task-modal-field:last-of-type {
  margin-bottom: 0;
}

.operations-task-modal-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

textarea.operations-task-modal-notes.record-input {
  width: 100%;
  min-height: 6rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--text);
  resize: none;
  box-sizing: border-box;
  text-align: left;
}

.operations-task-category-wrap .workflow-filter-trigger {
  width: 100%;
  justify-content: space-between;
}

.operations-task-cell {
  max-width: 24rem;
}

.operations-task-cell-btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  font: inherit;
  font-size: inherit;
  text-align: left;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.operations-task-cell-btn:hover {
  color: var(--primary-hover);
}

.home-tasks-subview {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.home-tasks-subview.hidden {
  display: none !important;
}

.home-tasks-subview .care-board {
  flex: 1;
}

.patients-subview {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.patients-subview.hidden {
  display: none !important;
}

.patients-subview--programs .patients-dashboard-filters-row {
  flex-shrink: 0;
}

.patients-subview--programs .patients-kanban-scroll {
  flex: 1;
  min-height: 0;
}

.patients-subview--timeline {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.patients-timeline-root {
  padding: 0 0 1.25rem;
}

.patients-timeline-intro {
  margin-bottom: 1rem;
}

.patients-timeline-intro-text {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.patients-timeline-layout {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

.patients-timeline-sidebar {
  flex: 0 0 220px;
  position: sticky;
  top: 0;
  padding: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.patients-timeline-mini-head {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.patients-timeline-mini-wday {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.15rem;
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 0.35rem;
}

.patients-timeline-mini-grid .patients-timeline-week--mini {
  gap: 0.15rem;
}

.patients-timeline-mini-grid .patients-timeline-cell--mini[data-day-key] {
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.patients-timeline-mini-grid .patients-timeline-cell--mini[data-day-key]:hover {
  background: var(--bg);
}

.patients-timeline-mini-grid .patients-timeline-cell--mini.patients-timeline-cell--has-events {
  background: rgba(59, 130, 246, 0.18); /* subtle primary tint */
}

.patients-timeline-mini-grid .patients-timeline-cell--mini.patients-timeline-cell--has-events:hover {
  background: rgba(59, 130, 246, 0.26);
}

.patients-timeline-main {
  flex: 1;
  min-width: 0;
}

.patients-timeline-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.patients-timeline-month-label {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.patients-timeline-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.patients-timeline-wday,
.patients-timeline-mini-wday {
  user-select: none;
}

.patients-timeline-wday {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 0.35rem;
}

.patients-timeline-grid .patients-timeline-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.patients-timeline-mini-grid .patients-timeline-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.patients-timeline-cell {
  min-height: 5.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.35rem 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.patients-timeline-cell--pad {
  min-height: 0;
  border: none;
  background: transparent;
  padding: 0;
}

.patients-timeline-cell--mini {
  min-height: 2.25rem;
  padding: 0.15rem 0.2rem;
  font-size: var(--text-2xs);
}

.patients-timeline-cell--mini .patients-timeline-daynum {
  font-size: var(--text-2xs);
}

.patients-timeline-cell--mini .patients-timeline-chip {
  font-size: var(--text-2xs);
  padding: 0.1rem 0.2rem;
}

.patients-timeline-daynum {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.patients-timeline-chips {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 0;
}

.patients-timeline-chip {
  display: block;
  font-size: 0.6875rem;
  line-height: 1.25;
  color: var(--primary);
  text-decoration: none;
  padding: 0.2rem 0.35rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
}

.patients-timeline-chip:hover {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}

.patients-timeline-chip-sub {
  display: block;
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.05rem;
}

.patients-timeline-more {
  font-size: 0.625rem;
  color: var(--text-muted);
  padding: 0 0.2rem;
}

@media (max-width: 900px) {
  .patients-timeline-layout {
    flex-direction: column;
  }

  .patients-timeline-sidebar {
    flex: none;
    width: 100%;
    position: static;
  }
}

/* Care Board — swimlane grid (task type × date band) */
.care-board {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -1.5rem;
  padding: 0 1.5rem 1.25rem;
}

.care-board-grid {
  display: grid;
  grid-template-columns: 5.75rem repeat(5, minmax(200px, 1fr));
  gap: 0.75rem;
  align-items: stretch;
  width: 100%;
  min-width: 880px;
}

.care-board-corner {
  min-height: 2.5rem;
}

/* Column headers — title + count (no program dots) */
.care-board-col-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.3rem 0.35rem 0.5rem;
  background: var(--kanban-column-bg);
  border-radius: var(--radius-sm);
  border: none;
  box-shadow: none;
  min-height: 2.5rem;
  box-sizing: border-box;
}

.care-board-row-label {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.35rem 0.35rem 0.5rem 0;
}

.care-board-cell {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 4.5rem;
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem 0.75rem;
  background: var(--kanban-column-bg);
  border: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Tasks > Care Board: canvas behind headers/cards (#F0F2F5) */
#home-workflows-care-board-subview .care-board-col-head,
#home-workflows-care-board-subview .care-board-cell {
  background: var(--bg);
}

/* Card chrome comes from shared .patients-kanban-card-link rules */
.care-board-card.patients-kanban-card {
  margin: 0;
}

.care-board-card .care-board-card-top.patients-kanban-card-top {
  justify-content: space-between;
  align-items: center;
}

.care-board-card .care-board-card-top .patients-kanban-card-name {
  margin: 0;
  min-width: 0;
  flex: 1;
}

.care-board-card .care-board-card-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.care-board-card .care-board-card-id-mrn {
  margin: 0;
  text-align: right;
  max-width: 12rem;
}

/* Task / date / status chips — Patients pill shell + Care Board semantics */
.patients-kanban-meta-pill.care-board-pill--asap {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(197, 48, 48, 0.45);
  font-weight: 600;
}

.patients-kanban-meta-pill.care-board-pill--date {
  background: var(--field-bg);
  color: var(--text-muted);
  border-color: var(--border);
}

.patients-kanban-meta-pill.care-board-pill--urgent {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(197, 48, 48, 0.45);
  font-weight: 600;
}

.patients-kanban-meta-pill.care-board-pill--status-todo {
  background: #fef9c3;
  border: 1px solid #fde047;
  color: var(--text);
  font-weight: 600;
}

.patients-kanban-meta-pill.care-board-pill--status-in-progress {
  background: #f5e6d3;
  border: 1px solid #d4a574;
  color: var(--text);
  font-weight: 600;
}

.patients-kanban-meta-pill.care-board-pill--status-on-hold {
  background: #ffedd5;
  border: 1px solid #fdba74;
  color: var(--text);
  font-weight: 600;
}

.patients-kanban-meta-pill.care-board-pill--status-canceled {
  background: var(--field-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-decoration: line-through;
}

.patients-kanban-meta-pill.care-board-pill--status-done {
  background: var(--field-bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.patients-kanban-meta-pill.care-board-pill--status-muted {
  background: var(--field-bg);
  color: var(--text-muted);
  border-color: var(--border);
}

.patients-kanban-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin: 0 -1.5rem;
  padding: 0 1.5rem 1.5rem;
}

.patients-kanban-scroll.patients-kanban-scroll--flat {
  overflow-x: hidden;
  overflow-y: auto;
}

.patients-kanban-board {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-height: min(70vh, 720px);
  padding-bottom: 0.5rem;
}

.patients-kanban-board.patients-kanban-board--flat {
  /* Masonry-style columns to avoid large row gaps with variable-height cards */
  display: block;
  column-width: 280px;
  column-gap: 0.75rem;
}

.patients-kanban-board.patients-kanban-board--flat .patients-kanban-card {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 0.75rem 0;
}

.patients-kanban-column {
  flex: 0 0 280px;
  width: 280px;
  max-width: 85vw;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 11.5rem);
  min-height: 200px;
  box-sizing: border-box;
  padding: 0.5rem 0.65rem 0.75rem;
  background: var(--kanban-column-bg);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.patients-kanban-column-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.25rem 0 0.65rem;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--kanban-column-bg);
  border-radius: var(--radius-sm);
}

.patients-kanban-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.patients-kanban-dot--0 {
  background: #f59e0b;
}
.patients-kanban-dot--1 {
  background: #3b82f6;
}
.patients-kanban-dot--2 {
  background: #eab308;
}
.patients-kanban-dot--3 {
  background: #22c55e;
}
.patients-kanban-dot--4 {
  background: #8b5cf6;
}
.patients-kanban-dot--5 {
  background: #ec4899;
}
.patients-kanban-dot--6 {
  background: #14b8a6;
}
.patients-kanban-dot--7 {
  background: #64748b;
}

.patients-kanban-column-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: calc(0.8125rem + 2px);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.patients-kanban-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.patients-kanban-column-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0 0 0.25rem;
}

.patients-kanban-empty {
  margin: 0;
  padding: 1rem 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

.patients-kanban-empty--board {
  padding: 2.5rem 1rem;
  max-width: 22rem;
  margin: 0 auto;
}

.patients-kanban-card {
  margin: 0;
  position: relative;
  border-radius: 10px;
}

/* Programs board: full-card hit target under content so the Messages control can sit beside the name */
.patients-kanban-card-hit {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 10px;
}

.patients-kanban-card-hit:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.patients-kanban-card-body {
  --patients-kanban-pill-h: 1.5rem;
  position: relative;
  z-index: 1;
  pointer-events: none;
  display: block;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.patients-kanban-card:hover .patients-kanban-card-body {
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

/* Care Board / shared: single link wraps the whole card */
.patients-kanban-card-link {
  display: block;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.patients-kanban-card-link:hover {
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.patients-kanban-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.patients-kanban-card-id-line {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.patients-kanban-card-id {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.patients-kanban-card-avatar {
  width: calc(26px * 1.2);
  height: calc(26px * 1.2);
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: calc(0.625rem * 1.2);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.patients-kanban-card-avatar--photo img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.patients-kanban-card-name-row {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
  min-width: 0;
}

/* Name only uses the width it needs so the message control sits flush beside it */
.patients-kanban-card-name-row .patients-kanban-card-name {
  margin-bottom: 0;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patients-kanban-card-messages-btn {
  flex-shrink: 0;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: var(--patients-kanban-pill-h);
  height: var(--patients-kanban-pill-h);
  min-width: var(--patients-kanban-pill-h);
  padding: 0;
  font-size: 0.75rem;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--field-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.patients-kanban-card-messages-btn:hover {
  background: var(--bg);
  color: var(--primary);
  border-color: var(--border-strong);
}

.patients-kanban-card-messages-btn.is-active,
.patients-kanban-card-messages-btn[aria-expanded="true"] {
  color: var(--primary);
  background: var(--primary-light);
  border-color: var(--primary-light);
}

.patients-kanban-card-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.35rem;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: -0.02em;
}

.patients-kanban-name-status-dot--active {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--success, #059669);
  box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.2);
}

.patients-kanban-card-session {
  margin: 0 0 0.6rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.patients-kanban-card-meta-label {
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 0.15rem;
}

/* Kanban meta row: demographics, payment + intake icons, optional status */
.patients-kanban-card-pills {
  --patients-kanban-pill-h: 1.5rem;
  --patients-kanban-pill-radius: 999px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.patients-kanban-card-pills-left,
.patients-kanban-card-pills-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.patients-kanban-card-pills-right {
  margin-left: auto;
  justify-content: flex-end;
}

.patients-kanban-meta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: var(--patients-kanban-pill-h);
  height: var(--patients-kanban-pill-h);
  padding: 0 0.5rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text);
  background: var(--field-bg, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--border);
  border-radius: var(--patients-kanban-pill-radius);
  line-height: 1.2;
}

.patients-kanban-meta-pill--payment {
  font-weight: 500;
  min-width: calc(var(--patients-kanban-pill-h) + 0.25rem);
  padding: 0 0.45rem;
}

.patients-kanban-meta-pill--payment i.ti {
  font-size: 0.75rem;
  line-height: 1;
}

/* Circular payment + intake icon chips (Programs kanban) */
.patients-kanban-meta-pill--payment-round {
  width: var(--patients-kanban-pill-h);
  min-width: var(--patients-kanban-pill-h);
  padding: 0;
  border-radius: 50%;
}

.patients-kanban-meta-pill--payment-round i.ti {
  font-size: var(--text-2xs);
  line-height: 1;
}

.patients-kanban-meta-pill--intake {
  width: var(--patients-kanban-pill-h);
  min-width: var(--patients-kanban-pill-h);
  padding: 0;
  border-radius: 50%;
  font-size: 0.8125rem;
}

.patients-kanban-meta-pill--intake-open {
  background: #fef9c3;
  border-color: #eab308;
  color: #a16207;
}

.patients-kanban-meta-pill--intake-overdue {
  background: var(--danger-bg, #fef2f2);
  border-color: var(--danger, #c53030);
  color: var(--danger, #c53030);
}

.patients-kanban-meta-pill--intake-complete {
  background: var(--success-bg, #ecfdf5);
  border-color: var(--success, #059669);
  color: var(--success-dark, #047857);
}

/* Icon-only message thread status (matches age pill height) */
.patients-kanban-meta-pill--message {
  min-width: calc(var(--patients-kanban-pill-h) + 0.25rem);
  padding: 0 0.45rem;
  font-weight: 500;
}

.patients-kanban-meta-pill--message i.ti {
  font-size: 0.75rem;
  line-height: 1;
}

/* State 1: unread (patient message not marked read) */
.patients-kanban-meta-pill--message-unread {
  background: var(--warning-bg, #fffbeb);
  border-color: #fbbf24;
  color: #b45309;
}

/* State 2: all caught up / read — same treatment as age & other neutral meta pills */
.patients-kanban-meta-pill--message-caught-up {
  background: var(--field-bg, rgba(0, 0, 0, 0.04));
  border-color: var(--border);
  color: var(--text);
}

.patients-kanban-meta-pill--payment.patients-payment--up-to-date {
  background: var(--success-bg, #ecfdf5);
  border-color: var(--success, #059669);
  color: var(--success-dark, #047857);
}

.patients-kanban-meta-pill--payment.patients-payment--outstanding {
  background: var(--error-bg, #fef2f2);
  border-color: var(--error, #dc2626);
  color: var(--error-dark, #b91c1c);
}

.patients-kanban-card-pills .patients-kanban-status-pill.patient-header-status {
  margin-left: 0;
}

.patients-kanban-card .patients-kanban-status-pill .patient-header-status-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: var(--patients-kanban-pill-h);
  height: var(--patients-kanban-pill-h);
  padding: 0 0.5rem;
  font-size: 0.6875rem;
  border-radius: var(--patients-kanban-pill-radius);
}

.tests-labs-toolbar {
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.tests-labs-toolbar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.tests-labs-toolbar-row .search-wrap {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.tests-labs-toolbar-row .tests-labs-new-btn {
  margin-left: auto;
}

.home-dashboard-filters-inner .workflow-filters {
  flex-wrap: wrap;
}

.home-filter-control {
  display: flex;
  align-items: center;
}

.home-hide-completed-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  margin-left: auto;
}

.home-hide-completed-label input {
  margin: 0;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 1rem;
  pointer-events: none;
}

.search-wrap input,
.app-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  font: inherit;
  font-size: var(--text-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.search-wrap input::placeholder {
  color: var(--text-faint);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.patient-count {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Inbox - Linear-style two-column layout */
.inbox-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 6rem);
  min-height: 24rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.inbox-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

/* Match shell canvas; horizontal inset is on #messages-view (Firefox: avoids clip inside overflow:hidden flex child) */
#messages-view .inbox-page-header {
  background: var(--main-shell-bg);
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.inbox-page-title {
  margin: 0;
  font-size: var(--font-page-title);
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}

.inbox-page-header .btn {
  flex-shrink: 0;
}

.inbox-columns {
  display: flex;
  flex-direction: row;
  flex: 1 1 auto;
  align-items: stretch;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.inbox-list-column {
  /* Do not shrink — default flex-shrink:1 was narrowing the column and clipping dates/dots */
  flex: 0 0 320px;
  width: 320px;
  min-width: 280px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg);
}

.inbox-list-search-wrap {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.inbox-list-search-wrap .search-wrap {
  max-width: 100%;
}

.inbox-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.inbox-list-empty {
  padding: 2rem 1.25rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-align: center;
}

.inbox-list-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border: none;
  width: 100%;
  text-align: left;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.inbox-list-item--active {
  background: var(--surface);
}

.inbox-list-item-avatar {
  flex-shrink: 0;
}

.inbox-list-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
}

.inbox-list-avatar--photo {
  padding: 0;
  overflow: hidden;
}

.inbox-list-avatar--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.inbox-list-item-content {
  flex: 1;
  min-width: 0;
}

.inbox-list-item-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  min-width: 0;
}

.inbox-list-item-name {
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-list-item-name:hover {
  text-decoration: underline;
}

.inbox-list-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.inbox-list-item-date {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.inbox-list-item-unread {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.inbox-list-item-preview {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.inbox-detail-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.inbox-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-muted);
}

.inbox-detail-empty.hidden {
  display: none;
}

.inbox-detail-empty-icon {
  font-size: 2.75rem;
  line-height: 1;
  margin-bottom: 1rem;
  opacity: 0.45;
  color: var(--text-muted);
}

.inbox-detail-empty-text {
  margin: 0;
  font-size: 0.9375rem;
}

.inbox-detail-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.inbox-detail-content.hidden {
  display: none;
}

.inbox-detail-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.inbox-detail-patient-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.inbox-detail-thread {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.inbox-detail-no-messages {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.inbox-detail-message {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.inbox-detail-message:last-child {
  margin-bottom: 0;
}

.inbox-detail-message-avatar {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Match patients table (patient) vs notes/from staff (user) avatar styling */
.inbox-detail-message-avatar--patient {
  background: var(--primary);
  color: #fff;
}

.inbox-detail-message-avatar--user {
  background: var(--primary-light);
  color: var(--primary);
}

.inbox-detail-message-body {
  flex: 1;
  min-width: 0;
}

.inbox-detail-message-date {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.inbox-detail-message-text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.inbox-detail-reply-wrap {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.inbox-detail-reply-compose {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.inbox-compose-mode-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  width: 100%;
}

.inbox-compose-mode-descriptions {
  flex: 1;
  min-width: 12rem;
  display: flex;
  align-items: center;
}

.inbox-compose-mode-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}

.inbox-compose-mode-btn {
  padding: 0.4rem 0.95rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  margin: 0;
  transition: background 0.15s, color 0.15s;
}

.inbox-compose-mode-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.inbox-compose-mode-btn.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: inset 0 1px 0 var(--border);
}

.inbox-compose-mode-description {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted);
  max-width: none;
}

/* Ensure [hidden] works (author display:flex must not override UA hidden) */
.inbox-compose-mode-description[hidden] {
  display: none !important;
}

.inbox-compose-mode-description.inbox-compose-mode-description--call {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.inbox-compose-call-phone-text {
  font-variant-numeric: tabular-nums;
}

.inbox-compose-call-canned-dropdown {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.inbox-compose-call-canned-dropdown .workflow-filter-trigger {
  min-width: 10rem;
  max-width: min(100%, 22rem);
}

.inbox-detail-attach-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.inbox-detail-reply-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  width: 75%;
  max-width: 75%;
  box-sizing: border-box;
  align-self: flex-start;
}

/* Exactly one primary action: Message → Reply only; Call → Save only */
.inbox-detail-reply-compose[data-compose-mode="message"] .inbox-compose-save-call-btn {
  display: none !important;
}
.inbox-detail-reply-compose[data-compose-mode="call"] .inbox-compose-reply-btn {
  display: none !important;
}
.inbox-detail-reply-compose[data-compose-mode="message"] .inbox-compose-reply-btn {
  display: inline-flex;
}
.inbox-detail-reply-compose[data-compose-mode="call"] .inbox-compose-save-call-btn {
  display: inline-flex;
}

.inbox-detail-reply-attach {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.inbox-detail-reply-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.inbox-detail-attach-filename {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-detail-reply-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  resize: none;
  min-height: 4rem;
}

/* Narrower compose field + left-aligned actions — keeps Reply clear of Assistant FAB */
.inbox-compose-panel--message,
.inbox-compose-panel--call {
  width: 75%;
  max-width: 75%;
  box-sizing: border-box;
  align-self: flex-start;
}

.inbox-detail-reply-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

#messages-view {
  box-sizing: border-box;
  min-width: 0;
  /* Match shell horizontal inset; keeps + New inside rounded shell in Firefox (flex min-width:auto overflow) */
  padding: 0 2rem 0 0;
  /* Pull into shell top padding — tightens gap above Inbox; safe vs .inbox-layout margin (does not escape view-scroll-body) */
  margin-top: -1rem;
}

#messages-view .inbox-layout {
  /* Override .inbox-layout height: calc(100vh - 6rem) — fill messages column, not viewport */
  height: auto;
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  max-height: none;
  /* No negative margin-top: -1.5rem would pull the header above .view-scroll-body--messages (overflow:hidden) and clip the + New button */
  margin: 0;
  border-radius: 0;
  border: none;
  /* No top border — avoids double line above the Inbox header vs shell */
  /* Base .inbox-layout overflow:hidden clips the 320px list column when the row is squeezed */
  overflow: visible;
}

/* Same row height so the border under search aligns with the border under patient name */
#messages-view .inbox-list-search-wrap,
#messages-view .inbox-detail-header {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 3.75rem;
}

#messages-view .inbox-list-search-wrap {
  padding: 0 1rem;
}

#messages-view .inbox-detail-header {
  padding: 0 1.5rem;
}

#messages-view .inbox-list-search-wrap .search-wrap {
  flex: 1;
  min-width: 0;
}

.dashboard-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.dashboard-status-filter {
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: var(--workflow-control-font-size);
  border: 1px solid var(--border);
  border-radius: var(--workflow-control-radius);
  background: var(--surface);
  color: var(--text);
  min-width: 7rem;
  cursor: pointer;
}

.patients-new-btn,
.home-add-btn,
.notes-add-btn,
.patient-notes-add-btn {
  margin-left: auto;
}

/* Table */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  /* Must stay overflow:visible — any overflow:auto on this box traps position:sticky (Chrome/Safari) */
  overflow: visible;
  min-width: 0;
  box-shadow: var(--shadow);
}

.table-wrap.home-table-wrap {
  min-width: 0;
}

/* Sticky header row — scroll container is .view-scroll-body / .patient-view-scroll-body */
.main-content-shell .view-scroll-body table thead th,
#patient-view .patient-view-scroll-body table thead th {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg);
  box-shadow: 0 1px 0 var(--border);
}

.home-table {
  width: 100%;
}

table th,
table td {
  vertical-align: top;
}

.patients-table {
  width: 100%;
  /* collapse breaks position:sticky on thead in Chrome — separate + 0 spacing keeps borders aligned */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9375rem;
}

.patients-table th,
.patients-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.patients-table th {
  font-weight: 600;
  color: #000;
  background: var(--bg);
  font-size: 0.8125rem;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
}

.patients-table tbody tr:hover {
  background: var(--primary-light-hover);
}

.patients-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table data dropdowns: no chevron, rounded, width hugs content, consistent height/padding */
.patients-table td select,
.patients-table th select,
.workflow-table td select,
.workflow-table th select,
.plan-table td select,
.plan-table th select,
.plan-timeline-table td select,
.plan-timeline-table th select,
.notes-table td select,
.notes-table th select,
.patient-notes-table td select,
.patient-notes-table th select,
.communications-table td select,
.communications-table th select,
.tests-labs-table td select,
.tests-labs-table th select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  border-radius: var(--radius);
  width: auto;
  min-width: 0;
  max-width: 100%;
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  line-height: 1.25;
  box-sizing: border-box;
  font-size: 0.875rem;
}

.patients-table .name-cell {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.patients-table .patients-name-link {
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.patients-table .patients-name-link:hover {
  text-decoration: underline;
}

.patients-table th:nth-child(3),
.patients-table td:nth-child(3),
.patients-table th:nth-child(5),
.patients-table td:nth-child(5) {
  white-space: nowrap;
}

.dashboard-patients-table th:nth-child(1),
.dashboard-patients-table td:nth-child(1),
.dashboard-patients-table th:nth-child(2),
.dashboard-patients-table td:nth-child(2),
.dashboard-patients-table th:nth-child(3),
.dashboard-patients-table td:nth-child(3),
.dashboard-patients-table th:nth-child(4),
.dashboard-patients-table td:nth-child(4),
.dashboard-patients-table th:nth-child(5),
.dashboard-patients-table td:nth-child(5),
.dashboard-patients-table th:nth-child(7),
.dashboard-patients-table td:nth-child(7),
.dashboard-patients-table th:nth-child(8),
.dashboard-patients-table td:nth-child(8) {
  width: 1%;
  white-space: nowrap;
}

/* Next Task column takes all remaining space */
.dashboard-patients-table th:nth-child(6),
.dashboard-patients-table td:nth-child(6) {
  width: auto;
  min-width: 12rem;
}

.dashboard-patients-table th,
.dashboard-patients-table td {
  vertical-align: middle;
}

.patients-table-name-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Patient avatars: inverted (filled) to distinguish from user/staff avatars */
.patients-table-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.patients-table-avatar--photo {
  padding: 0;
  background: var(--border);
  overflow: hidden;
  box-sizing: border-box;
}

.patients-table-avatar--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Top-level Notes page: table fits container, Note column wraps */
.notes-table {
  table-layout: fixed;
  width: 100%;
}

.notes-table th,
.notes-table td {
  vertical-align: top;
}

.notes-table th:nth-child(1),
.notes-table td:nth-child(1) {
  width: 10rem;
  min-width: 8rem;
}

.notes-table th:nth-child(2),
.notes-table td:nth-child(2) {
  width: 3rem;
  min-width: 3rem;
  text-align: center;
}

.notes-table .notes-from-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
}

.notes-table .notes-note-cell {
  max-width: 28rem;
  white-space: normal;
  line-height: 1.4;
  word-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

/* Inline @mentions: same flow as body text, default purple — no chip background */
.note-mention {
  display: inline;
  padding: 0;
  border-radius: 0;
  font-weight: inherit;
  font-size: inherit;
  line-height: inherit;
  background: transparent;
  /* Explicit purple: wins over inherited td/body color (some tables set color on cells) */
  color: var(--primary) !important;
  -webkit-text-fill-color: var(--primary);
  white-space: normal;
}

.note-mention--unknown {
  background: transparent;
  color: var(--text-muted) !important;
  -webkit-text-fill-color: var(--text-muted);
  font-weight: inherit;
}

.notes-note-cell .note-mention,
.workflow-note-body .note-mention {
  white-space: normal;
}

/* Patient Workflow note rows: paragraph flow + @mentions (td is normally flex for tasks; reset for notes) */
.record-card--workflow .workflow-table--patient tbody tr.workflow-note-row td.workflow-note-cell.workflow-encounter-cell {
  display: table-cell;
  vertical-align: middle !important;
  height: auto !important;
  min-height: 2.75rem !important;
  max-height: none !important;
  overflow: visible !important;
}

.record-card--workflow .workflow-table--patient .workflow-note-body {
  display: block;
  line-height: 1.45;
  word-wrap: break-word;
  word-break: break-word;
  min-width: 0;
  color: var(--text);
}

.record-card--workflow .workflow-table--patient .workflow-note-body .note-mention:not(.note-mention--unknown) {
  color: var(--primary) !important;
  -webkit-text-fill-color: var(--primary);
}

.record-card--workflow .workflow-table--patient .workflow-note-body .note-mention--unknown {
  color: var(--text-muted) !important;
  -webkit-text-fill-color: var(--text-muted);
}

#notes-view .notes-table td.notes-note-cell .note-mention:not(.note-mention--unknown) {
  color: var(--primary) !important;
  -webkit-text-fill-color: var(--primary);
}

.notes-table th:nth-child(3),
.notes-table td:nth-child(3) {
  width: auto;
  min-width: 0;
  white-space: normal;
}

.notes-table th:nth-child(4),
.notes-table td:nth-child(4) {
  width: 11rem;
  min-width: 11rem;
  white-space: nowrap;
}

.notes-table th:nth-child(5),
.notes-table td:nth-child(5) {
  width: 8rem;
  min-width: 8rem;
  white-space: nowrap;
}

.notes-table th:nth-child(6),
.notes-table td:nth-child(6) {
  width: 12rem;
  min-width: 12rem;
  white-space: nowrap;
}

.notes-table .notes-name-link {
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}
.notes-table .notes-name-link:hover {
  text-decoration: underline;
}

.notes-table .notes-status-select {
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
  cursor: pointer;
}

.notes-table .workflow-date-combined {
  min-width: 0;
}

.home-table .name-cell .home-patient-cell-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.home-table .workflow-encounter-cell .home-task-cell-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.home-table .home-name-link {
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}
.home-table .home-name-link:hover {
  text-decoration: underline;
}

.home-table.workflow-table {
  table-layout: auto;
}

#home-view .home-table.workflow-table th,
#home-view .home-table.workflow-table td {
  vertical-align: middle;
}

/* Tasks page: task column — use table-cell so row vertical-align centers content (flex on td breaks alignment) */
#home-view .patients-table.home-table.workflow-table tbody td.workflow-encounter-cell {
  display: table-cell;
  vertical-align: middle;
}

/* Tasks list only — fixed column order (Patient | Task | …). Views tables use .view-configurable-task-table + class-based widths. */
#home-view .home-table.workflow-table th:nth-child(1),
#home-view .home-table.workflow-table td:nth-child(1) {
  min-width: 10rem;
  width: 1%;
  white-space: nowrap;
}

#home-view .home-table.workflow-table th:nth-child(2),
#home-view .home-table.workflow-table td:nth-child(2) {
  width: auto;
  min-width: 28rem;
  max-width: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#home-view .home-table.workflow-table th:nth-child(3),
#home-view .home-table.workflow-table td:nth-child(3),
#home-view .home-table.workflow-table th:nth-child(4),
#home-view .home-table.workflow-table td:nth-child(4),
#home-view .home-table.workflow-table th:nth-child(5),
#home-view .home-table.workflow-table td:nth-child(5) {
  width: 1%;
  min-width: 8rem;
  white-space: nowrap;
}

#home-view .home-table.workflow-table th.workflow-row-actions-header,
#home-view .home-table.workflow-table td.workflow-row-actions-cell {
  width: 1%;
  min-width: 2.5rem;
  white-space: nowrap;
}

/* Inherits shared workflow control sizing from :root */
.home-table .workflow-date-trigger,
.home-table .workflow-status-trigger,
.home-table .workflow-assignee-trigger {
  min-width: 0;
}

/* Patient Notes: styled like Patient Messages (communications-tile) */
.notes-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.notes-toolbar .search-wrap {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.notes-toolbar .patient-notes-add-btn {
  margin-left: 0;
}

.notes-title-text {
  margin-right: 0.5rem;
}

.communications-tile .patient-notes-table {
  table-layout: auto;
}

.communications-tile .patient-notes-table th:first-child,
.communications-tile .patient-notes-table td:first-child {
  width: 3rem;
  min-width: 3rem;
  text-align: center;
}

.communications-tile .patient-notes-table .patient-notes-note-cell {
  min-width: 12rem;
}

.communications-tile .patient-notes-table th:nth-child(3),
.communications-tile .patient-notes-table td:nth-child(3) {
  min-width: 8rem;
  white-space: nowrap;
}

.patient-notes-from-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
}

/* —— Patient Notes: Linear-style stacked cards —— */
#patient-view #patient-notes-panel.patient-record {
  display: block;
  width: 100%;
}

#patient-view #patient-notes-panel .patient-notes-panel-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
}

.patient-notes-panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  min-height: 2rem;
  width: 100%;
}

.patient-notes-panel-header h2,
.patient-notes-panel-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.25;
  display: flex;
  align-items: center;
}

.patient-notes-panel-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.patient-notes-search-wrap {
  width: 12rem;
  max-width: 40vw;
}

.patient-notes-feed {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 60%;
  max-width: 60%;
}

.patient-notes-empty {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  width: 60%;
  max-width: 60%;
}

.patient-notes-thread-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem 0.65rem;
  box-sizing: border-box;
  width: 100%;
}

.patient-notes-comment {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.55rem 0.75rem;
  padding: 0.55rem 0;
}

.patient-notes-comment + .patient-notes-comment {
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.patient-notes-comment--reply {
  padding-left: 0;
}

.patient-notes-comment-avatar {
  display: flex;
  justify-content: center;
  padding-top: 0.1rem;
}

.patient-notes-comment-avatar .workflow-assignee-avatar,
.patient-notes-reply-composer-avatar .workflow-assignee-avatar {
  width: 1.75rem;
  height: 1.75rem;
  font-size: 0.625rem;
}

.patient-notes-comment-main {
  min-width: 0;
}

.patient-notes-comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.2rem;
}

.patient-notes-comment-author {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.patient-notes-comment-time {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.patient-notes-pin-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.15rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.6875rem;
  cursor: pointer;
}

.patient-notes-pin-badge:hover {
  color: var(--text);
  border-color: var(--border-strong, var(--border));
}

.patient-notes-card-menu-wrap {
  margin-left: auto;
  position: relative;
}

.patient-notes-card-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.patient-notes-card-menu-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.patient-notes-card-menu-flyout {
  z-index: 1200;
  min-width: 9rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.patient-notes-card-menu-item {
  display: flex;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}

.patient-notes-card-menu-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.patient-notes-card-menu-item--danger:hover {
  background: color-mix(in srgb, #dc2626 12%, transparent);
  color: #b91c1c;
}

.patient-notes-comment-body {
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.patient-notes-comment-edit-input,
.patient-notes-compose-input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.patient-notes-comment-edit-input {
  min-height: 4.5rem;
  padding: 0.5rem 0.65rem;
  resize: vertical;
}

.patient-notes-comment-edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.patient-notes-reply-composer {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.55rem 0.75rem;
  align-items: center;
  min-height: 1.75rem;
  margin-top: 0.35rem;
  padding: 0.55rem 0 0.15rem;
  border: none;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow: none;
  outline: none;
}

.patient-notes-reply-composer-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 0;
  height: 1.75rem;
}

.patient-notes-reply-composer-shell {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
}

.patient-notes-reply-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 1.75rem;
  min-height: 1.75rem;
  max-height: 1.75rem;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.75rem;
  color: var(--text);
}

#patient-view .patient-notes-reply-composer .patient-notes-reply-input {
  display: block;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  margin-top: 0;
  padding: 0;
  min-height: 1.75rem;
  height: 1.75rem;
  max-height: 1.75rem;
  line-height: 1.75rem;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  box-shadow: none;
  resize: none;
  overflow: hidden;
}

#patient-view .patient-notes-reply-composer .patient-notes-reply-input:focus,
#patient-view .patient-notes-reply-composer .patient-notes-reply-input:focus-visible {
  outline: none;
  border: 0;
  box-shadow: none;
}

.patient-notes-composer-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
  height: 1.75rem;
}

.patient-notes-attach-btn,
.patient-notes-post-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.patient-notes-attach-btn:hover,
.patient-notes-post-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.patient-notes-post-btn {
  color: var(--text);
}

.patient-notes-attach-name {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.patient-notes-compose-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  box-sizing: border-box;
  width: 60%;
  max-width: 60%;
}

.patient-notes-compose-input {
  min-height: 4.5rem;
  padding: 0.55rem 0.65rem;
  border: none;
  resize: none;
  background: transparent;
}

.patient-notes-compose-input:focus {
  outline: none;
}

.patient-notes-compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.patient-notes-pin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.patient-notes-pin-toggle input {
  margin: 0;
}

.patient-notes-compose-footer .patient-notes-composer-actions {
  margin-left: auto;
}

.patient-notes-table .patient-notes-note-cell {
  max-width: 28rem;
  white-space: normal;
  line-height: 1.4;
}

.patient-notes-table th:nth-child(2),
.patient-notes-table td:nth-child(2) {
  width: auto;
  min-width: 0;
  white-space: normal;
  word-wrap: break-word;
  word-break: break-word;
}

.patient-notes-table th:nth-child(3),
.patient-notes-table td:nth-child(3) {
  width: 11rem;
  min-width: 11rem;
  white-space: nowrap;
}

.patient-notes-table th:nth-child(4),
.patient-notes-table td:nth-child(4) {
  width: 8rem;
  min-width: 8rem;
  white-space: nowrap;
}

.patient-notes-table th:nth-child(5),
.patient-notes-table td:nth-child(5) {
  width: 12rem;
  min-width: 12rem;
  white-space: nowrap;
}

/* Patient record → Notes panel: Note (icon+text) | Timestamp | User | Actions (4 columns only — not global Notes page) */
.patient-notes-table.patient-notes-panel-table:not(.notes-global-page-table) td:nth-child(1),
.patient-notes-table.patient-notes-panel-table:not(.notes-global-page-table) th:nth-child(1) {
  width: auto;
  min-width: 0;
  white-space: normal;
  word-wrap: break-word;
}

.patient-notes-table.patient-notes-panel-table:not(.notes-global-page-table) td:nth-child(2),
.patient-notes-table.patient-notes-panel-table:not(.notes-global-page-table) th:nth-child(2) {
  width: 9.5rem;
  min-width: 7rem;
  white-space: nowrap;
}

.patient-notes-table.patient-notes-panel-table:not(.notes-global-page-table) td:nth-child(3),
.patient-notes-table.patient-notes-panel-table:not(.notes-global-page-table) th:nth-child(3) {
  width: 8.75rem;
  min-width: 7rem;
  white-space: nowrap;
}

.patient-notes-table.patient-notes-panel-table:not(.notes-global-page-table) td:nth-child(4),
.patient-notes-table.patient-notes-panel-table:not(.notes-global-page-table) th:nth-child(4) {
  width: 3.25rem;
  min-width: 3.25rem;
  white-space: nowrap;
}

.patient-notes-table .patient-notes-status-select,
.patient-notes-table .patient-notes-date-input,
.patient-notes-table .patient-notes-assignee-select {
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
  width: auto;
  cursor: pointer;
}

.workflow-encounter-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.workflow-table tbody td.workflow-encounter-cell {
  height: 2.75rem;
  max-height: 2.75rem;
  overflow: hidden;
  box-sizing: border-box;
}

.tests-labs-table {
  table-layout: auto;
  width: 100%;
  border-collapse: collapse;
}

.tests-labs-table th,
.tests-labs-table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

.tests-labs-table tbody tr {
  height: 2.75rem;
  border-bottom: 1px solid var(--border);
}

.tests-labs-table tbody tr:last-child {
  border-bottom: none;
}

.tests-labs-table tbody td {
  height: 2.75rem;
  min-height: 2.75rem;
  max-height: 2.75rem;
  border-bottom: none;
  box-sizing: border-box;
}

.tests-labs-table th:nth-child(3),
.tests-labs-table td:nth-child(3),
.tests-labs-table th:nth-child(4),
.tests-labs-table td:nth-child(4) {
  min-width: 12rem;
}

.date-selector-wrap {
  position: relative;
  display: inline-block;
  width: max-content;
  max-width: 13ch;
  min-width: 6ch;
  min-height: 2.25rem;
  cursor: pointer;
  flex: 0 0 auto;
}
.date-selector-wrap .date-selector-display {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 13ch;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}
.date-selector-wrap input[type="date"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  min-height: 2.25rem;
  opacity: 0;
  cursor: pointer;
  font-size: 1rem;
  box-sizing: border-box;
}

.workflow-date-combined {
  position: relative;
  display: inline-block;
}

/* Shared pill controls: Date, Status, Assignee, toolbar filters */
.workflow-date-trigger,
.workflow-filter-trigger,
.workflow-status-trigger,
.workflow-assignee-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: auto;
  min-width: 0;
  height: var(--workflow-control-height);
  padding: 0 var(--workflow-control-padding-x);
  box-sizing: border-box;
  font: inherit;
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  border: 1px solid var(--border);
  border-radius: var(--workflow-control-radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.workflow-date-trigger:hover,
.workflow-filter-trigger:hover,
.workflow-status-trigger:hover,
.workflow-assignee-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

/* Completed: timestamp replaces date dropdown — match control height */
.workflow-date-completed-at {
  display: inline-flex;
  align-items: center;
  min-height: var(--workflow-control-height);
  padding: 0 var(--workflow-control-padding-x);
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  color: var(--text);
  vertical-align: middle;
  border-radius: var(--workflow-control-radius);
}

.workflow-filter-combined {
  position: relative;
  display: inline-block;
}

.workflow-filter-popover {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 0.15rem;
  min-width: 10rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 1100;
  overscroll-behavior: contain;
}

.workflow-filter-options {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.workflow-filter-option-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.8125rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  gap: 0.5rem;
}

.workflow-filter-option-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.workflow-status-combined,
.workflow-assignee-combined {
  position: relative;
  display: inline-block;
  z-index: 1;
}

.workflow-assignee-trigger {
  min-width: 4rem;
  pointer-events: auto;
}

.workflow-status-popover,
.workflow-assignee-popover {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 0.15rem;
  min-width: 10rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 1100;
  overscroll-behavior: contain;
}

.workflow-assignee-search {
  width: 100%;
  padding: 0.35rem 0.5rem;
  margin-bottom: 0.35rem;
  font: inherit;
  font-size: 0.8125rem;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-sizing: border-box;
}

.workflow-assignee-search:focus {
  outline: none;
  border-bottom-color: var(--primary);
}

.workflow-assignee-section {
  margin-top: 0.5rem;
}

.workflow-assignee-section:first-of-type {
  margin-top: 0.25rem;
}

.workflow-assignee-section-header {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  padding: 0 0.25rem;
}

.workflow-status-options,
.workflow-assignee-options {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.workflow-status-option-btn,
.workflow-assignee-option-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.8125rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  gap: 0.5rem;
}

.workflow-status-option-btn:hover,
.workflow-assignee-option-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Add Note @-mention popover (fixed to viewport; appended to body while open) */
.add-note-mention-popover.workflow-assignee-popover {
  z-index: 1102;
  max-height: min(320px, 45vh);
  overflow-y: auto;
  min-width: 17.5rem;
}

.workflow-assignee-option-btn.add-note-mention-option.is-active {
  background: var(--bg, #f0f2f5);
  color: var(--text);
}

.workflow-assignee-avatar {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.625rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.workflow-assignee-avatar--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.workflow-assignee-option-icon {
  flex-shrink: 0;
  width: 1rem;
  opacity: 0.8;
  text-align: center;
}

.workflow-assignee-top-options {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.25rem;
}

.workflow-option-checkmark {
  flex-shrink: 0;
  margin-left: auto;
  color: var(--primary);
}

.workflow-status-option-btn .workflow-option-checkmark,
.workflow-assignee-option-btn .workflow-option-checkmark,
.workflow-filter-option-btn .workflow-option-checkmark,
.workflow-date-preset-btn .workflow-option-checkmark {
  opacity: 0;
}

.workflow-status-option-btn.is-selected .workflow-option-checkmark,
.workflow-assignee-option-btn.is-selected .workflow-option-checkmark,
.workflow-filter-option-btn.is-selected .workflow-option-checkmark,
.workflow-date-preset-btn.is-selected .workflow-option-checkmark {
  opacity: 1;
}

.workflow-status-bullet {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--text-faint);
}

.workflow-status-option-btn[data-value="Backlog"] .workflow-status-bullet {
  background: transparent;
  border: 1px dashed #38bdf8;
  box-sizing: border-box;
}

.workflow-status-option-btn[data-value="On Hold"] .workflow-status-bullet {
  background: transparent;
  border: 2px solid #fb923c;
  box-sizing: border-box;
}

.workflow-status-option-btn[data-value="Todo"] .workflow-status-bullet,
.workflow-status-option-btn[data-value="To do"] .workflow-status-bullet {
  background: transparent;
  border: 2px solid #9ca3af;
  box-sizing: border-box;
}

.workflow-status-option-btn[data-value="In Progress"] .workflow-status-bullet {
  background: linear-gradient(90deg, #fde047 50%, rgba(253, 224, 71, 0.15) 50%);
  border: 1px solid #ca8a04;
  box-sizing: border-box;
}

.workflow-status-option-btn[data-value="Completed"] .workflow-status-bullet {
  background: #22c55e;
  border: none;
}

.workflow-status-option-btn[data-value="Canceled"] .workflow-status-bullet {
  background: #6b7280;
  border: none;
}

.workflow-status-option-btn[data-value="Overdue"] .workflow-status-bullet {
  background: #fca5a5;
}

/* Patient record header status (same popover pattern as workflow status) */
.workflow-status-option-btn[data-value="Active"] .workflow-status-bullet {
  background: var(--success, #059669);
}
.workflow-status-option-btn[data-value="New"] .workflow-status-bullet,
.workflow-status-option-btn[data-value="New-Consult"] .workflow-status-bullet {
  background: var(--info, #2563eb);
}
.workflow-status-option-btn[data-value="Inactive"] .workflow-status-bullet {
  background: var(--error, #dc2626);
}
.workflow-status-option-btn[data-value=""] .workflow-status-bullet {
  background: var(--text-faint);
}

/* Task column: status bullets beside category chip (same look as status dropdown options) */
.workflow-status-bullet--task-chip[data-status="Backlog"] {
  background: transparent;
  border: 1px dashed #38bdf8;
  box-sizing: border-box;
}

.workflow-status-bullet--task-chip[data-status="On Hold"] {
  background: transparent;
  border: 2px solid #fb923c;
  box-sizing: border-box;
}

.workflow-status-bullet--task-chip[data-status="Todo"],
.workflow-status-bullet--task-chip[data-status="To do"] {
  background: transparent;
  border: 2px solid #9ca3af;
  box-sizing: border-box;
}

.workflow-status-bullet--task-chip[data-status="In Progress"] {
  background: linear-gradient(90deg, #fde047 50%, rgba(253, 224, 71, 0.15) 50%);
  border: 1px solid #ca8a04;
  box-sizing: border-box;
}

.workflow-status-bullet--task-chip[data-status="Completed"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #22c55e;
  border: none;
  color: #fff;
}
.workflow-status-bullet--task-chip[data-status="Completed"] .workflow-status-bullet-check {
  display: block;
  width: 70%;
  height: 70%;
  flex-shrink: 0;
}

.workflow-status-bullet--task-chip[data-status="Canceled"] {
  background: #6b7280;
  border: none;
}

.workflow-status-bullet--task-chip[data-status="Overdue"] {
  background: #fca5a5;
}

.workflow-status-bullet--task-chip[data-status="all"] {
  background: var(--text-faint);
  border: none;
}

.workflow-filter-trigger--patient-wf-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.workflow-filter-option-btn--with-status-bullet {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
}

.workflow-filter-option-btn--with-status-bullet .workflow-option-checkmark {
  margin-left: auto;
  flex-shrink: 0;
}

.workflow-filter-option-btn--with-status-bullet .workflow-filter-option-label {
  min-width: 0;
}

.workflow-task-cell-fallback {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.35rem;
  min-width: 0;
}

.workflow-assignee-individual-row {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.workflow-assignee-individual-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.workflow-assignee-individual-input {
  width: 100%;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}

.workflow-date-popover {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 0.15rem;
  min-width: 12rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 1100;
  overscroll-behavior: contain;
}

.workflow-date-presets {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
}

.workflow-date-preset-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.8125rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  gap: 0.5rem;
}

.workflow-date-preset-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.workflow-date-specific {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.workflow-date-specific-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.workflow-date-popover .workflow-date-input {
  width: 100%;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}

.workflow-table {
  table-layout: auto;
  width: 100%;
}

.workflow-table th,
.workflow-table td {
  padding: 0.4rem 0.5rem;
  vertical-align: top;
}

.home-table.workflow-table th,
.home-table.workflow-table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

.home-table.workflow-table {
  border-collapse: collapse;
}

.home-table.workflow-table tbody tr {
  height: 2.75rem;
  border-bottom: 1px solid var(--border);
}

.home-table.workflow-table tbody tr:last-child {
  border-bottom: none;
}

.home-table.workflow-table tbody td {
  height: 2.75rem;
  min-height: 2.75rem;
  max-height: 2.75rem;
  vertical-align: middle;
  box-sizing: border-box;
  border-bottom: none;
}

.home-table.workflow-table tbody td.workflow-encounter-cell {
  vertical-align: middle;
}

.workflow-table tbody td {
  height: 2.75rem;
  box-sizing: border-box;
}

/* Patient Workflow tile: uniform row height, middle alignment, and aligned row dividers */
.record-card--workflow .workflow-table:not(.workflow-table--patient) {
  border-collapse: collapse;
}
.record-card--workflow .workflow-table tbody tr {
  height: 2.75rem;
  border-bottom: 1px solid var(--border);
}
.record-card--workflow .workflow-table tbody tr:last-child {
  border-bottom: none;
}
.record-card--workflow .workflow-table:not(.workflow-table--patient) tbody td {
  height: 2.75rem;
  min-height: 2.75rem;
  max-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  vertical-align: top;
  overflow: hidden;
  border-bottom: none;
  box-sizing: border-box;
}
.record-card--workflow .workflow-table tbody tr.workflow-section-header-row {
  height: auto !important;
}
.record-card--workflow .workflow-table tbody tr.workflow-section-header-row td {
  overflow: visible !important;
  max-height: none !important;
}
.record-card--workflow .workflow-table:not(.workflow-table--patient) tbody td.workflow-encounter-cell {
  vertical-align: top;
  min-width: 6rem;
}

.workflow-task-cell-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
  min-width: 0;
}

.workflow-task-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-task-trigger {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.workflow-task-trigger:hover {
  text-decoration: underline;
  color: var(--primary);
}

.workflow-type-icon {
  display: inline-block;
  margin-right: 0.35rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.workflow-task-trigger:hover .workflow-type-icon {
  color: var(--primary);
}

.record-card--workflow .workflow-table:not(.workflow-table--patient) thead th {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
/* Patient Workflow (5 col legacy layout): exclude 6-col .workflow-table--patient */
.record-card--workflow .workflow-table:not(.workflow-table--patient) th:nth-child(1),
.record-card--workflow .workflow-table:not(.workflow-table--patient) td:nth-child(1) {
  width: 1%;
  min-width: 8rem;
}
.record-card--workflow .workflow-table:not(.workflow-table--patient) th:nth-child(2),
.record-card--workflow .workflow-table:not(.workflow-table--patient) td:nth-child(2) {
  width: auto;
  min-width: 10rem;
}
.record-card--workflow .workflow-table:not(.workflow-table--patient) th:nth-child(3),
.record-card--workflow .workflow-table:not(.workflow-table--patient) td:nth-child(3) {
  width: 1%;
  min-width: 8rem;
}
.record-card--workflow .workflow-table:not(.workflow-table--patient) th:nth-child(4),
.record-card--workflow .workflow-table:not(.workflow-table--patient) td:nth-child(4),
.record-card--workflow .workflow-table:not(.workflow-table--patient) .workflow-assignee-cell {
  width: 1%;
  min-width: 9rem;
}
.record-card--workflow .workflow-table .workflow-assignee-cell,
.workflow-table .workflow-assignee-cell {
  overflow: visible;
  position: relative;
  z-index: 2;
}
.record-card--workflow .workflow-table th.workflow-row-actions-header,
.record-card--workflow .workflow-table td.workflow-row-actions-cell {
  width: 1%;
  min-width: 2.5rem;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
  text-align: center;
  vertical-align: top;
}

/* Patient view tables — match Tasks list (.patients-table.home-table.workflow-table) */
#patient-overview-panel .plan-table,
#patient-overview-panel .plan-timeline-table,
#patient-overview-panel .plan-treatment-readonly-table,
#patient-progress-panel .progress-tests-table,
#patient-wearables-panel .wearables-table,
#patient-profile-panel .wearables-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9375rem;
}

#patient-overview-panel .plan-table th,
#patient-overview-panel .plan-table td,
#patient-overview-panel .plan-timeline-table th,
#patient-overview-panel .plan-timeline-table td,
#patient-overview-panel .plan-treatment-readonly-table th,
#patient-overview-panel .plan-treatment-readonly-table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

#patient-overview-panel .plan-table thead th,
#patient-overview-panel .plan-timeline-table thead th,
#patient-overview-panel .plan-treatment-readonly-table thead th {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  border-radius: 0;
}

#patient-overview-panel .plan-table tbody tr:last-child td,
#patient-overview-panel .plan-timeline-table tbody tr:last-child td,
#patient-overview-panel .plan-treatment-readonly-table tbody tr:last-child td {
  border-bottom: none;
}

#patient-overview-panel .plan-program-name-link {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--link, var(--primary));
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
  text-align: left;
}

#patient-overview-panel .plan-program-name-link:hover {
  color: var(--link-hover, var(--primary));
}

/* No separator between program row and its note — the note reads as continuation of the same block */
#patient-overview-panel .plan-table tbody tr:has(+ tr.plan-program-note-row) td {
  border-bottom: none;
}

#patient-overview-panel .plan-program-note-row td {
  vertical-align: top;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom: 1px solid var(--border);
}

#patient-overview-panel .plan-program-note-display {
  display: block;
  margin: 0;
  padding-bottom: 0;
  font-size: 0.9375rem;
  line-height: 1.35;
  white-space: pre-wrap;
  color: var(--foreground, inherit);
}

/* Program page → Program table: Program column uses remaining width; ~20px gutters (10px + 10px) */
#patient-overview-panel #program .plan-table.plan-program-table {
  table-layout: fixed;
  width: 100%;
}
#patient-overview-panel #program .plan-table.plan-program-table col.plan-col-status {
  width: 5.75rem;
}
#patient-overview-panel #program .plan-table.plan-program-table col.plan-col-payment {
  width: 6.75rem;
}
#patient-overview-panel #program .plan-table.plan-program-table col.plan-col-sessions {
  width: 9rem;
}
#patient-overview-panel #program .plan-table.plan-program-table col.plan-col-session-cost {
  width: 8rem;
}
#patient-overview-panel #program .plan-table.plan-program-table col.plan-col-additional {
  width: 10rem;
}
#patient-overview-panel #program .plan-table.plan-program-table col.plan-col-discount {
  width: 4.25rem;
}
#patient-overview-panel #program .plan-table.plan-program-table col.plan-col-total {
  width: 6rem;
}
#patient-overview-panel #program .plan-table.plan-program-table col.plan-col-actions {
  width: 2.75rem;
}
/* .plan-col-program: no width — absorbs remainder */
#patient-overview-panel #program .plan-table.plan-program-table thead th,
#patient-overview-panel #program .plan-table.plan-program-table tbody td {
  padding-top: 0.75rem !important;
  padding-bottom: 0.75rem !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
}
#patient-overview-panel #program .plan-table.plan-program-table thead th {
  white-space: normal;
  line-height: 1.3;
}
#patient-overview-panel #program .plan-table.plan-program-table thead th:nth-child(5) {
  white-space: nowrap;
}
#patient-overview-panel #program .plan-table.plan-program-table tbody tr.plan-program-note-row td {
  padding-top: 0.35rem !important;
  padding-bottom: 0 !important;
}
#patient-overview-panel #program .plan-table.plan-program-table tbody tr.plan-program-note-row + tr td {
  padding-top: 0.5rem !important;
}

#patient-progress-panel .progress-tests-table th,
#patient-progress-panel .progress-tests-table td,
#patient-wearables-panel .wearables-table th,
#patient-wearables-panel .wearables-table td,
#patient-profile-panel .wearables-table th,
#patient-profile-panel .wearables-table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

#patient-progress-panel .progress-tests-table thead th,
#patient-wearables-panel .wearables-table thead th,
#patient-profile-panel .wearables-table thead th {
  background: var(--bg);
  border-bottom: none;
  box-shadow: none;
  border-radius: 0;
}

.record-card--workflow .workflow-table--patient thead th {
  background: var(--bg);
  border-bottom: none;
  box-shadow: none;
  border-radius: 0;
}

.record-card--workflow .workflow-table--patient thead th:not(:last-child) {
  border-right: none;
  box-shadow: none;
}

/* Patient Workflow only: #, Date, Task, Status, Assignee, Actions — scroll horizontally if narrow */
.record-card--workflow .plan-table-wrap--workflow-patient {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.record-card--workflow .workflow-table--patient {
  width: 100%;
  min-width: 56rem;
  max-width: none;
  table-layout: fixed;
  /* collapse keeps one straight rule across all columns (separate + per-td borders stepped visually) */
  border-collapse: collapse;
  border-spacing: 0;
}

/* Unified Patient Workflow table: use page width; no horizontal scroll */
#patient-view .record-card--workflow .plan-table-wrap--workflow-patient.patient-wf-table-wrap {
  overflow-x: hidden;
  overflow-y: visible;
  max-width: 100%;
  box-sizing: border-box;
}
#patient-view .record-card--workflow .plan-table-wrap--workflow-patient {
  overflow-x: hidden;
  max-width: 100%;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient {
  --patient-wf-tree-inset: 12px;
  --patient-wf-tree-marker: 1.125rem;
  --patient-wf-tree-text-gap: 0.15rem;
  --patient-wf-header-title-count-gap: 0.5rem;
  --patient-wf-thread-arm: 24px;
  --patient-wf-tree-line-x: calc(var(--patient-wf-tree-inset) + var(--patient-wf-tree-marker) / 2);
  --patient-wf-thread-task-padding-y: 0.35rem;
  --patient-wf-thread-bridge: calc(var(--patient-wf-thread-task-padding-y) + 0.3rem);
  --patient-wf-thread-seam-overlap: 1px;
  --patient-wf-thread-curve-offset: 4px;
  --patient-wf-thread-branch-half: 8px;
  --patient-wf-thread-bullet-gap: 5px;
  --patient-wf-category-block-gap: 2.5rem;
  --patient-wf-category-block-spacer-height: calc(var(--patient-wf-category-block-gap) * 0.5);
  --patient-wf-dot-size: 10px;
  --patient-wf-status-bullet-size: 0.625rem;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  overflow-x: hidden;
  overflow-y: visible;
}
/* Fixed layout: legacy split pills column (non-task rows only) */
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr:not(.patient-wf-task-row) td.patient-wf-td-workflow-pills {
  max-width: 0;
  overflow: visible !important;
  text-align: right;
  white-space: nowrap;
}

/* Task rows: single colspan cell spans main + pills columns */
#patient-view .patient-wf-td-task-body {
  width: auto;
  min-width: 0;
  max-width: none;
  overflow: visible;
  padding-right: 2px !important;
}
#patient-view .patient-wf-task-row-inner {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
#patient-view .patient-wf-task-row-inner > .patient-wf-task-main {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  max-width: none;
}
#patient-view .patient-wf-task-row-inner > .patient-wf-workflow-pills {
  flex: 0 0 auto;
  margin-left: 0;
  margin-right: calc(-2 * var(--patient-wf-actions-slot-size, 1.75rem) - var(--patient-wf-actions-rail-gap, 0.15rem));
}

/* Patient Workflow tasks table: no row divider lines (see also override after .plan-table { }) */
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) th,
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody td {
  border: 0 !important;
}

/* Message rows open the Patient Messages drawer (same as header Messages control) */
#patient-view .record-card--workflow .patient-wf-table tbody tr.patient-wf-message-row {
  cursor: pointer;
}
#patient-view .record-card--workflow .patient-wf-table tbody tr.patient-wf-message-row td.workflow-row-actions-cell {
  cursor: default;
}

/* Patient Workflow tasks: task main (dot, id, type, title, details) | pills | actions */
/* Main column (.patient-wf-col-main) has no width — in fixed layout it receives all space left after fixed sibling cols */
#patient-view .patient-wf-table:not(.patient-notes-table) col.patient-wf-col-workflow-pills {
  width: 21rem;
  min-width: 0;
}
#patient-view .patient-wf-table col.patient-wf-col-actions {
  width: 3.25rem;
}
#patient-view .patient-wf-table:not(.patient-notes-table) col.patient-wf-col-actions {
  /* 3 fixed slots: subcategory | add | ⋯ */
  width: 6rem;
}
/* No width on .patient-wf-col-main — in fixed layout it receives the remainder */
.record-card--workflow .workflow-table--patient col.workflow-col-idx {
  width: 2.35rem;
}
.record-card--workflow .workflow-table--patient col.workflow-col-date {
  width: 8.25rem;
}
/* Tighter than before — content (pills/dropdowns) is narrower than old 8rem/10rem, reducing dead space to Assignee */
.record-card--workflow .workflow-table--patient col.workflow-col-status {
  width: 6.75rem;
}
.record-card--workflow .workflow-table--patient col.workflow-col-assignee {
  width: 8.5rem;
}
.record-card--workflow .workflow-table--patient col.workflow-col-actions {
  width: 2.75rem;
}
/* Task: width auto + min-width — in fixed layout this column expands to fill space after fixed cols */
.record-card--workflow .workflow-table--patient col.workflow-col-task {
  width: auto;
  min-width: 12rem;
}
/* Vertically center row contents (headers + data rows) */
.record-card--workflow .workflow-table--patient thead th {
  vertical-align: middle !important;
}
.record-card--workflow .workflow-table--patient tbody tr:not(.workflow-section-header-row) td {
  vertical-align: middle !important;
}
/* Must be table-cell — base .workflow-encounter-cell uses flex and breaks row border collapse (double line under Task) */
.record-card--workflow .workflow-table--patient tbody td.workflow-encounter-cell {
  display: table-cell;
  vertical-align: middle !important;
}

/* Row dividers: inherit .plan-table td border-bottom; last row flush with card (see #patient-view .patient-wf-table rule below) */
.record-card--workflow .workflow-table--patient th.workflow-row-actions-header,
.record-card--workflow .workflow-table--patient td.workflow-row-actions-cell {
  vertical-align: middle !important;
}

#patient-view .record-card--workflow .workflow-table th.workflow-row-actions-header,
#patient-view .record-card--workflow .workflow-table td.workflow-row-actions-cell {
  padding: 0.75rem 1rem;
}
#patient-view .record-card--workflow .patient-wf-table th.workflow-row-actions-header,
#patient-view .record-card--workflow .patient-wf-table td.workflow-row-actions-cell {
  padding-left: 12px;
  padding-right: 12px;
  text-align: right;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row td.workflow-row-actions-cell {
  padding-left: 12px !important;
  padding-right: 12px !important;
}

/* Cell alignment — widths come from <colgroup> */
.record-card--workflow .workflow-table--patient thead th:nth-child(1),
.record-card--workflow .workflow-table--patient tbody tr:not(.workflow-section-header-row) td:nth-child(1) {
  text-align: center;
}
.record-card--workflow .workflow-table--patient thead th:nth-child(2),
.record-card--workflow .workflow-table--patient tbody tr:not(.workflow-section-header-row) td:nth-child(2) {
  white-space: nowrap;
}
/* Task column width comes from colgroup (flex column); avoid min-width:0 on td — it was shrinking the column */
.record-card--workflow .workflow-table--patient thead th.workflow-col-task {
  width: auto;
}
/* Override .plan-table td { white-space: nowrap } so Task / note text can wrap */
.record-card--workflow .workflow-table.plan-table tbody td.workflow-encounter-cell {
  white-space: normal;
}
.record-card--workflow .workflow-table.plan-table tbody td:nth-child(2) {
  white-space: nowrap;
}
/* Patient Workflow: cell padding (tighter on category / subcategory / task rows) */
#patient-view .record-card--workflow .workflow-table--patient.plan-table thead th,
#patient-view .record-card--workflow .workflow-table--patient.plan-table tbody tr:not(.workflow-section-header-row) td {
  padding: 0.75rem 1rem;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-group-header-row td,
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-subcategory-header-row td,
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row td {
  padding-top: 0.2rem !important;
  padding-bottom: 0.2rem !important;
}
#patient-view .record-card--workflow .workflow-table--patient.plan-table:not(.patient-notes-table) thead th:nth-child(2),
#patient-view .record-card--workflow .workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr:not(.workflow-section-header-row) td:nth-child(2),
#patient-view .record-card--workflow .workflow-table--patient.plan-table:not(.patient-notes-table) thead th:nth-child(3),
#patient-view .record-card--workflow .workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr:not(.workflow-section-header-row) td:nth-child(3) {
  white-space: nowrap;
  overflow: visible !important;
}

/* Patient Workflow task table: main column left-aligned */
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row td.patient-wf-td-main--task,
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-group-header-row td.patient-wf-group-header-cell,
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-subcategory-header-row td.patient-wf-subcategory-header-cell {
  text-align: left;
  padding-left: 12px !important;
  padding-right: 12px !important;
}

/* Patient Workflow task row: status + assignee + date pills (one column, right-aligned) */
#patient-view .patient-wf-workflow-pills {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  width: auto;
  max-width: none;
  margin-left: auto;
  vertical-align: middle;
}
#patient-view .patient-wf-workflow-pills .task-type-modal-pill {
  flex: 0 0 auto;
  display: inline-flex;
  max-width: none;
  min-width: 0;
}
#patient-view .patient-wf-workflow-pills .workflow-status-combined,
#patient-view .patient-wf-workflow-pills .workflow-assignee-combined,
#patient-view .patient-wf-workflow-pills .workflow-date-combined {
  display: inline-block;
  max-width: none;
  vertical-align: middle;
}
#patient-view .patient-wf-workflow-pills .workflow-status-trigger,
#patient-view .patient-wf-workflow-pills .workflow-assignee-trigger,
#patient-view .patient-wf-workflow-pills .workflow-date-trigger,
#patient-view .patient-wf-workflow-pills .workflow-date-completed-at {
  width: auto;
  max-width: none;
  overflow: visible;
  white-space: nowrap;
  box-sizing: border-box;
}
#patient-view .patient-wf-workflow-pills .workflow-status-trigger,
#patient-view .patient-wf-workflow-pills .workflow-assignee-trigger,
#patient-view .patient-wf-workflow-pills .workflow-date-trigger {
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font-size: var(--workflow-control-font-size);
  font-weight: 500;
  background: var(--field-bg);
}
#patient-view .patient-wf-workflow-pills .workflow-assignee-trigger.workflow-assignee-trigger--avatar-only {
  padding: 0;
  border: none;
  background: transparent;
  min-width: 0;
  height: auto;
  border-radius: 50%;
}
#patient-view .patient-wf-workflow-pills .workflow-assignee-trigger.workflow-assignee-trigger--avatar-only .workflow-assignee-avatar {
  width: 28px;
  height: 28px;
  font-size: 0.6875rem;
}
#patient-view .patient-wf-workflow-pills .workflow-assignee-trigger:not(.workflow-assignee-trigger--avatar-only) .workflow-assignee-avatar {
  margin-right: 0.35rem;
}
#patient-view .patient-wf-workflow-pills .workflow-date-completed-at {
  padding: 0.35rem 0.65rem;
}
#patient-view .patient-wf-status-icon-cell {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  min-width: 0;
}
#patient-view .patient-wf-status-bullet-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
/* All task status dots share the same x anchor as subcategory-threaded tasks */
#patient-view .patient-wf-task-row .patient-wf-status-bullet-slot {
  position: relative;
  z-index: 1;
  margin-left: calc(
    var(--patient-wf-tree-line-x) + 10px + var(--patient-wf-thread-bullet-gap) - var(--patient-wf-tree-inset)
  );
}
#patient-view .patient-wf-td-main--task {
  vertical-align: middle;
  min-width: 0;
  text-align: left;
  white-space: normal;
  overflow-x: visible;
  overflow-y: visible;
}
#patient-view .patient-wf-task-main {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem 0.5rem;
  width: 100%;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
  text-align: left;
}
#patient-workflow-panel .patient-wf-task-row:not(.patient-wf-task-row--locked) .patient-wf-task-main {
  cursor: default;
}
#patient-workflow-panel .patient-wf-task-row:not(.patient-wf-task-row--locked) .patient-wf-meta-cells--task {
  cursor: pointer;
  border-radius: var(--workflow-control-radius);
  transition: background-color 0.12s ease;
}
#patient-workflow-panel .patient-wf-task-row:not(.patient-wf-task-row--locked) .patient-wf-meta-cells--task:hover {
  background: #e8eaef;
}
#patient-workflow-panel .patient-wf-task-row.patient-wf-task-row--inbox-highlight:not(.patient-wf-task-row--locked) .patient-wf-meta-cells--task {
  background: #e8eaef;
}
#patient-workflow-panel .patient-wf-task-row:not(.patient-wf-task-row--locked) .patient-wf-meta-cells--task:active,
#patient-workflow-panel .patient-wf-task-row:not(.patient-wf-task-row--locked).patient-wf-task-row--content-active .patient-wf-meta-cells--task {
  background: var(--surface, #fff);
}
#patient-view .patient-wf-task-main .patient-wf-status-icon-cell {
  flex: 0 0 auto;
}
#patient-view .patient-wf-task-main-id {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
#patient-view .patient-wf-task-main-id .patient-wf-task-id-link {
  font-variant-numeric: tabular-nums;
}
/* Task meta: fixed leading chips/title, then description fills remainder of main column */
#patient-view .patient-wf-task-main .patient-wf-meta-cells.patient-wf-meta-cells--task {
  display: flex;
  flex: 1 1 auto;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  min-width: 0;
  width: auto;
  max-width: none;
  overflow: hidden;
}
#patient-view .patient-wf-task-main .patient-wf-meta-cells--task-left {
  display: flex;
  flex: 1 1 auto;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  min-width: 0;
  width: auto;
  max-width: none;
  overflow: hidden;
}
#patient-view .patient-wf-meta-cells--task-leading {
  display: inline-flex;
  flex: 0 0 auto;
  flex-shrink: 0;
  align-items: center;
  gap: 0.35rem 0.5rem;
  min-width: 0;
}
#patient-view .patient-wf-meta-cells--task-desc {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  width: auto;
  max-width: none;
  overflow: hidden;
}
#patient-view .patient-wf-task-main .workflow-task-chip,
#patient-view .patient-wf-task-main .patient-wf-label-chip,
#patient-view .patient-wf-task-main .patient-wf-decision-option {
  flex: 0 0 auto;
}
#patient-view .patient-wf-task-main .patient-wf-task-title-group {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  flex: 0 0 auto;
  min-width: 0;
}
#patient-view .patient-wf-task-main .patient-wf-task-title {
  flex: 0 0 auto;
  white-space: nowrap;
}
#patient-view .patient-wf-task-main .patient-wf-task-title-sep {
  flex: 0 0 auto;
  font-weight: 400;
  color: var(--text-muted);
  white-space: pre;
}
#patient-view .patient-wf-task-main .patient-wf-task-desc {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
  color: var(--text-muted);
}
#patient-view .patient-wf-task-main .patient-wf-task-title-with-decision {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}
#patient-view .patient-wf-task-main .patient-wf-task-title-with-decision .patient-wf-task-title {
  flex: 0 1 auto;
}
/* Subcategory → tasks: Linear-style continuous thread (flush rows, muted stroke, rounded elbows) */
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-subcategory-header-row td {
  padding-bottom: 0 !important;
}
#patient-view .patient-wf-table.workflow-table--patient tbody tr.patient-wf-task-row--under-subcategory {
  overflow: visible;
}
#patient-view .patient-wf-task-row--under-subcategory .patient-wf-td-task-body {
  overflow: visible;
  vertical-align: middle;
  position: relative;
}
#patient-view .patient-wf-status-icon-cell--threaded {
  position: static;
  display: flex;
  align-items: center;
  min-height: 1.65rem;
}
#patient-view .patient-wf-status-bullet-slot .workflow-status-bullet--task-chip {
  width: var(--patient-wf-status-bullet-size);
  height: var(--patient-wf-status-bullet-size);
}
#patient-view .patient-wf-status-bullet-slot .workflow-status-bullet--task-chip[data-status="Completed"] {
  width: calc(var(--patient-wf-status-bullet-size) + 2px);
  height: calc(var(--patient-wf-status-bullet-size) + 2px);
}
/* Position vs .patient-wf-td-main--task so spine matches subcategory dot x */
#patient-view .patient-wf-task-thread-gutter {
  position: absolute;
  left: calc(var(--patient-wf-tree-line-x) - var(--patient-wf-thread-arm) / 2);
  top: 0;
  bottom: 0;
  width: var(--patient-wf-thread-arm);
  margin: 0;
  color: var(--text, #1a1d21);
  overflow: visible;
  pointer-events: none;
}
/* Vertical spine stops above the curve; SVG draws the elbow + branch only */
#patient-view .patient-wf-task-thread-gutter::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: calc(50% + var(--patient-wf-thread-branch-half));
  width: 1.15px;
  transform: translateX(-50%);
  background: currentColor;
  pointer-events: none;
}
#patient-view .patient-wf-task-thread-gutter--first::before,
#patient-view .patient-wf-task-thread-gutter--only::before,
#patient-view .patient-wf-task-thread-gutter--middle::before,
#patient-view .patient-wf-task-thread-gutter--last::before {
  top: calc(-1 * var(--patient-wf-thread-bridge) - var(--patient-wf-thread-seam-overlap));
}
#patient-view .patient-wf-task-thread-gutter--first:not(.patient-wf-task-thread-gutter--last)::after,
#patient-view .patient-wf-task-thread-gutter--middle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(50% + var(--patient-wf-thread-curve-offset));
  bottom: calc(-1 * var(--patient-wf-thread-bridge) - var(--patient-wf-thread-seam-overlap));
  width: 1.15px;
  transform: translateX(-50%);
  background: currentColor;
  pointer-events: none;
}
/* Curved elbow at row center → task dot (fixed aspect, not stretched) */
#patient-view .patient-wf-task-thread-branch {
  position: absolute;
  left: 0;
  top: 50%;
  width: var(--patient-wf-thread-arm);
  height: 16px;
  transform: translateY(-50%);
  display: block;
  overflow: visible;
}

/* Workflow task inline notes — match Patient Notes thread cards */
#patient-workflow-panel .patient-wf-task-note-btn {
  display: none;
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 1.65rem;
  height: 1.65rem;
  margin-left: 0.35rem;
  padding: 0;
  border: none;
  border-radius: var(--radius, 6px);
  background: transparent;
  color: var(--text-muted, #64748b);
  cursor: pointer;
}
#patient-workflow-panel .patient-wf-task-note-btn--has-count {
  width: auto;
  min-width: 1.65rem;
  padding: 0 0.4rem 0 0.35rem;
}
#patient-workflow-panel .patient-wf-task-note-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: inherit;
  line-height: 1;
}
#patient-workflow-panel .patient-wf-task-row--has-notes .patient-wf-task-note-btn,
#patient-workflow-panel .patient-wf-task-row:hover .patient-wf-task-note-btn,
#patient-workflow-panel .patient-wf-task-row:focus-within .patient-wf-task-note-btn,
#patient-workflow-panel .patient-wf-task-note-btn--active {
  display: inline-flex;
}
@media (hover: none) {
  #patient-workflow-panel .patient-wf-task-row:not(.patient-wf-task-row--locked) .patient-wf-task-note-btn {
    display: inline-flex;
  }
}
#patient-workflow-panel .patient-wf-task-note-btn:hover,
#patient-workflow-panel .patient-wf-task-note-btn--active {
  background: var(--field-bg, rgba(0, 0, 0, 0.06));
  color: var(--text, #1a1d21);
}
#patient-view .patient-wf-td-main--task-notes {
  vertical-align: top;
  white-space: normal !important;
  overflow: visible !important;
  border-top: none !important;
}
#patient-view .patient-wf-task-notes-row .patient-wf-td-task-body {
  position: relative;
  overflow: visible;
}
#patient-view .patient-wf-task-notes-row td {
  border-top: none !important;
  overflow: visible !important;
}
#patient-view .patient-wf-task-row + .patient-wf-task-notes-row td {
  padding-top: 0 !important;
}
#patient-view .patient-wf-task-notes-row-inner {
  display: block;
  overflow: visible;
}
/* Same containing block + left offset as .patient-wf-task-thread-gutter on task rows */
#patient-view .patient-wf-task-notes-thread-gutter {
  position: absolute;
  left: calc(var(--patient-wf-tree-line-x) - var(--patient-wf-thread-arm) / 2);
  top: 0;
  bottom: 0;
  width: var(--patient-wf-thread-arm);
  margin: 0;
  color: var(--text, #1a1d21);
  overflow: visible;
  pointer-events: none;
}
#patient-view .patient-wf-task-notes-thread-gutter::before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(-1 * var(--patient-wf-thread-bridge) - var(--patient-wf-thread-seam-overlap));
  bottom: 0;
  width: 1.15px;
  transform: translateX(-50%);
  background: currentColor;
  pointer-events: none;
}
#patient-view .patient-wf-task-notes-row--under-subcategory.patient-wf-task-notes-row--thread-continue .patient-wf-task-notes-thread-gutter::before,
#patient-view .patient-wf-task-row--under-subcategory + .patient-wf-task-notes-row.patient-wf-task-notes-row--thread-continue .patient-wf-task-notes-thread-gutter::before {
  bottom: calc(-1 * var(--patient-wf-thread-bridge) - var(--patient-wf-thread-seam-overlap));
}
/* Ungrouped tasks: continue from status-dot x (no subcategory spine on the task row) */
#patient-view .patient-wf-task-row:not(.patient-wf-task-row--under-subcategory) + .patient-wf-task-notes-row .patient-wf-task-notes-thread-gutter {
  left: calc(
    var(--patient-wf-tree-line-x) + 10px + var(--patient-wf-thread-bullet-gap) - var(--patient-wf-thread-arm) / 2 +
      var(--patient-wf-status-bullet-size) / 2
  );
}
/* Subcategory-threaded tasks: spine must match task gutter x exactly */
#patient-view .patient-wf-task-row--under-subcategory + .patient-wf-task-notes-row .patient-wf-task-notes-thread-gutter {
  left: calc(var(--patient-wf-tree-line-x) - var(--patient-wf-thread-arm) / 2);
}
#patient-view .patient-wf-task-row--under-subcategory.patient-wf-task-row--notes-expanded .patient-wf-task-thread-gutter--first:not(.patient-wf-task-thread-gutter--last)::after,
#patient-view .patient-wf-task-row--under-subcategory.patient-wf-task-row--notes-expanded .patient-wf-task-thread-gutter--middle::after {
  display: none;
}
#patient-view .patient-wf-task-notes-block {
  position: relative;
  min-width: 0;
  padding: 0;
  margin-left: calc(
    var(--patient-wf-tree-line-x) + 10px + var(--patient-wf-thread-bullet-gap) - var(--patient-wf-tree-inset) +
      var(--patient-wf-status-bullet-size) + 0.5rem
  );
  box-sizing: border-box;
}
#patient-view .patient-wf-task-notes-thread-card {
  width: 80%;
  max-width: 80%;
  margin-bottom: 0.35rem;
  padding: 0.45rem 0.85rem 0.5rem;
  box-sizing: border-box;
}
#patient-view .patient-wf-task-notes-thread-card:last-child {
  margin-bottom: 0;
}
#patient-view .patient-wf-task-notes-thread-card .patient-notes-comment {
  padding-top: 0.25rem;
  padding-bottom: 0.35rem;
}
#patient-view .patient-wf-task-notes-thread-card .patient-notes-comment:first-child {
  padding-top: 0.1rem;
}
#patient-view .patient-wf-task-notes-thread-card .patient-notes-comment-body,
#patient-view .patient-wf-task-notes-thread-card .patient-notes-comment-main {
  text-align: left;
}
#patient-view .patient-wf-task-notes-thread-card .patient-notes-reply-composer {
  margin-top: 0.2rem;
  padding-top: 0.35rem;
}
#patient-view .patient-wf-task-notes-thread-card--compose {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}
#patient-view .patient-wf-task-notes-thread-card--compose .patient-notes-reply-composer {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-notes-row td.patient-wf-td-main--task-notes {
  padding-top: 0 !important;
  padding-bottom: 0.35rem !important;
  padding-left: 12px !important;
  padding-right: 2px !important;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-notes-row {
  overflow: visible;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-notes-row td {
  white-space: normal !important;
  overflow: visible !important;
}

#patient-view .record-card--workflow .plan-table-wrap--workflow-patient.patient-wf-table-wrap {
  overflow-y: visible;
}

#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-data-row td:nth-child(2) {
  text-align: left;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-panel-table) tbody tr.patient-wf-note-row td:nth-child(2),
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-panel-table) tbody tr.patient-wf-message-row td:nth-child(2),
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-panel-table) tbody tr.patient-wf-pinned-row td:nth-child(2) {
  white-space: normal !important;
}
/* Patient Notes panel: column 1 = note body (icon + text), column 2 = date */
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table thead th:nth-child(1),
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table tbody tr:not(.workflow-section-header-row) td:nth-child(1) {
  text-align: left;
}
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-note-row td:nth-child(1),
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-pinned-row td:nth-child(1) {
  white-space: normal !important;
}
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-note-row:not(.patient-wf-note-thread-row):has(+ tr.patient-wf-note-thread-row) td,
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-pinned-row:has(+ tr.patient-wf-note-thread-row) td,
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-note-thread-row td {
  border-bottom: none;
}
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-note-row:has(+ tr.patient-notes-thread-divider) td,
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-note-thread-row:has(+ tr.patient-notes-thread-divider) td,
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-pinned-row:has(+ tr.patient-notes-thread-divider) td {
  border-bottom: none;
}
/* Task row actions cell (col 2 after combined body colspan) */
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row td:nth-child(2) {
  white-space: normal !important;
  overflow-x: hidden !important;
}

/* Workflows → Patient: no elevated card surface behind toolbar + table */
#home-view .home-global-workflow-card.record-card {
  background: transparent;
  box-shadow: none;
  padding: 0;
}

/* Workflows → Patient: all-patients unified table (same structure as patient workflow + Patient column) */
#home-view .home-global-workflow-card .plan-table-wrap--workflow-patient.patient-wf-table-wrap {
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
}
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border-spacing: 0;
}
/* Match Patient record → Workflow → Patient Workflow spacing and cell typography */
#home-view .home-global-workflow-card .patient-wf-toolbar {
  flex-wrap: wrap;
  gap: 0.5rem 0.35rem;
}
/* Workflows → Patient: summary left; filter + search right */
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell.workflow-filters--linear {
  justify-content: flex-start;
  width: 100%;
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  width: 100%;
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-summary {
  flex: 1 1 auto;
  min-width: min(240px, 100%);
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text-muted, #64748b);
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-summary-inner {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-summary-up-to-date {
  font-weight: 500;
  color: var(--text, #0f172a);
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-summary-sep {
  color: var(--border-strong, var(--border, #cbd5e1));
  font-weight: 400;
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-summary-item {
  font-weight: 400;
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-summary-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text, #111);
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-summary-item--overdue .home-global-wf-summary-num,
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-summary-item--overdue {
  color: var(--danger, #c53030);
  font-weight: 600;
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex: 0 1 auto;
  margin-left: auto;
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-controls .linear-filter-toolbar {
  flex-shrink: 0;
}
#home-view .home-global-workflow-card #home-global-wf-toolbar.home-global-wf-toolbar-shell .home-global-wf-controls .workflow-notes-toolbar {
  margin-left: 0;
}
#home-view .home-global-workflow-card .patient-wf-table-wrap {
  margin-top: 0.75rem;
}

/* Patient column: avatar + name (markup matches Tasks list but table is .home-global-wf-table, not .home-table) */
#home-view .home-global-workflow-card .patient-wf-td-patient.name-cell .home-patient-cell-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  min-width: 0;
}

/* All table links: same typography as task action tail (e.g. “Complete authorization”) — plain body text, no underline */
#home-view .home-global-workflow-card .patient-wf-table a:not(.btn) {
  font-size: var(--workflow-control-font-size);
  font-weight: 400;
  line-height: 1.25;
  color: var(--text);
  text-decoration: none;
}
#home-view .home-global-workflow-card .patient-wf-table a:not(.btn):not(.home-name-link):hover {
  color: var(--text);
  text-decoration: none;
}
#home-view .home-global-workflow-card .patient-wf-td-patient.name-cell .home-name-link:hover {
  color: var(--primary);
  text-decoration: underline;
}
#home-view .home-global-workflow-card .patient-wf-table a:not(.btn):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Message / Notes row icons — match Patient record → Workflow → Patient Workflow */
#home-view .home-global-workflow-card .patient-wf-row-type-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}
#home-view .home-global-workflow-card .patient-wf-row-type-icon.patient-wf-msg-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--border);
  border: none;
  box-sizing: border-box;
  margin-top: 0;
  color: var(--text, #0a0a0a);
}
#home-view .home-global-workflow-card .patient-wf-msg-icon .patient-wf-row-msg-icon-svg {
  display: block;
  flex-shrink: 0;
  width: 0.75rem;
  height: 0.75rem;
  color: inherit;
}
#home-view .home-global-workflow-card .patient-wf-row-type-icon.patient-wf-row-note-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--text);
  border: none;
  box-sizing: border-box;
  margin-top: 0;
  color: var(--border);
}
#home-view .home-global-workflow-card .patient-wf-row-note-icon .patient-wf-note-row-svg {
  display: block;
  flex-shrink: 0;
  width: 0.78rem;
  height: 0.78rem;
  color: inherit;
}
/* Threaded note reply: L-connector + corner-down-right icon (same badge as note) */
#home-view .home-global-workflow-card .patient-wf-body-with-icon--note-reply {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.35rem;
  min-width: 0;
  padding-left: 5px;
}
#home-view .home-global-workflow-card .patient-wf-note-thread-connector {
  flex-shrink: 0;
  width: 0.875rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-top: 0.12rem;
  color: var(--border, #e5e5e5);
}
#home-view .home-global-workflow-card .patient-wf-note-thread-connector-svg {
  display: block;
  width: 0.875rem;
  height: 1.35rem;
  color: inherit;
}
#home-view .home-global-workflow-card .patient-wf-row-type-icon.patient-wf-row-note-icon--reply {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--text);
  border: none;
  box-sizing: border-box;
  margin-top: 0;
  color: var(--border);
}
#home-view .home-global-workflow-card .patient-wf-row-note-icon--reply .patient-wf-note-reply-glyph {
  font-size: var(--text-2xs);
  line-height: 1;
}
#home-view .home-global-workflow-card .patient-wf-table tbody tr.patient-wf-note-thread-row {
  background: transparent;
}
#home-view .home-global-workflow-card .patient-wf-table tbody tr.patient-wf-note-thread-row td {
  background: transparent;
}

#home-view .home-global-workflow-card .patient-wf-table tbody td {
  vertical-align: middle;
  font-size: 0.875rem;
}
#home-view .home-global-workflow-card .patient-wf-table .patient-wf-td-date {
  text-align: left;
  vertical-align: top;
  min-width: 9.5rem;
}
#home-view .home-global-workflow-card .patient-wf-table .patient-wf-td-meta--task,
#home-view .home-global-workflow-card .patient-wf-table .patient-wf-td-body {
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
#home-view .home-global-workflow-card .patient-wf-table tbody tr.patient-wf-task-row .patient-wf-td-meta--task {
  white-space: normal;
  overflow-x: hidden;
  overflow: hidden;
}
#home-view .home-global-workflow-card .patient-wf-meta-cells.patient-wf-meta-cells--task {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
}
#home-view .home-global-workflow-card .patient-wf-meta-cells--task-left {
  display: flex;
  flex: 1 1 auto;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem 0.5rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
#home-view .home-global-workflow-card .patient-wf-meta-cells--task-leading {
  display: inline-flex;
  flex: 0 0 auto;
  flex-shrink: 0;
  align-items: center;
  gap: 0.35rem 0.5rem;
  min-width: 0;
}
#home-view .home-global-workflow-card .patient-wf-meta-cells--task-desc {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

#home-view .home-global-workflow-card .patient-wf-task-title {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  flex: 0 0 auto;
  white-space: nowrap;
}

#home-view .home-global-workflow-card .patient-wf-task-title-sep {
  flex: 0 0 auto;
  color: var(--text-muted);
}

#home-view .home-global-workflow-card .patient-wf-task-desc {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
  color: var(--text-muted);
}

#home-view .home-global-workflow-card .patient-wf-task-title--empty {
  color: var(--text-muted);
  font-weight: 400;
}
#home-view .home-global-workflow-card .patient-wf-body-with-icon {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
}
#home-view .home-global-workflow-card .patient-wf-body-with-icon .workflow-note-body,
#home-view .home-global-workflow-card .patient-wf-body-with-icon .patient-wf-message-body {
  min-width: 0;
  flex: 1;
}
#home-view .home-global-workflow-card .patient-wf-td-type-label {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

#home-view .home-global-workflow-card button.workflow-task-trigger.patient-wf-task-id-link,
#home-view .home-global-workflow-card button.workflow-task-trigger.workflow-task-id-link {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--primary, var(--text));
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex: 0 0 auto;
}
#home-view .home-global-workflow-card button.workflow-task-trigger.patient-wf-task-id-link:hover,
#home-view .home-global-workflow-card button.workflow-task-trigger.workflow-task-id-link:hover {
  text-decoration: underline;
}

.workflow-task-meta-row--table {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.workflow-task-meta-row--table .patient-wf-task-desc {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
  color: var(--text-muted);
}

.workflow-task-meta-row--table .patient-wf-task-title-sep {
  flex: 0 0 auto;
  color: var(--text-muted);
}

.workflow-task-meta-row--table .workflow-task-trigger.patient-wf-task-id-link,
.workflow-task-meta-row--table .workflow-task-trigger.workflow-task-id-link {
  flex: 0 0 auto;
}
#home-view .home-table.workflow-table .workflow-task-meta-row--table button.workflow-task-trigger.patient-wf-task-id-link,
#home-view .home-table.workflow-table .workflow-task-meta-row--table button.workflow-task-trigger.workflow-task-id-link {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--primary, var(--text));
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}
#home-view .home-table.workflow-table .workflow-task-meta-row--table button.workflow-task-trigger.patient-wf-task-id-link:hover,
#home-view .home-table.workflow-table .workflow-task-meta-row--table button.workflow-task-trigger.workflow-task-id-link:hover {
  text-decoration: underline;
}
/* Fluid columns — table stays within the shell (no horizontal page scroll) */
#home-view .home-global-workflow-card .patient-wf-table col.patient-wf-col-patient {
  width: 14%;
}
#home-view .home-global-workflow-card .patient-wf-table col.patient-wf-col-date {
  width: 10%;
}
#home-view .home-global-workflow-card .patient-wf-table col.patient-wf-col-status-icon {
  width: 2.75rem;
}
/* Align with Patient record → Workflow: status icon | task ID | status | meta | … */
#home-view .home-global-workflow-card .patient-wf-table col.patient-wf-col-task-id {
  width: 3.25rem;
}
#home-view .home-global-workflow-card .patient-wf-table col.patient-wf-col-status {
  width: 11%;
  min-width: 9.25rem;
}
/* Main column absorbs remaining width (matches single-patient workflow table) */
#home-view .home-global-workflow-card .patient-wf-table col.patient-wf-col-main {
  width: auto;
}
#home-view .home-global-workflow-card .patient-wf-table col.patient-wf-col-assignee {
  width: 17%;
}
#home-view .home-global-workflow-card .patient-wf-table col.patient-wf-col-actions {
  width: 5%;
}
/* 8-column row: Patient | Status icon | Task ID | Status | Details | Assignee | Date | Actions */
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-data-row td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-data-row td:nth-child(1) {
  text-align: left;
  padding: 0.75rem 1rem;
}
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-data-row td:nth-child(2) {
  text-align: left;
}
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-note-row td:nth-child(4),
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-message-row td:nth-child(4),
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-pinned-row td:nth-child(4) {
  white-space: normal !important;
}
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-task-row td:nth-child(4) {
  white-space: normal !important;
  overflow-x: hidden !important;
}
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-task-row td:nth-child(5),
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-task-row td:nth-child(7) {
  white-space: nowrap;
  overflow: visible !important;
}
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr.patient-wf-task-row td.patient-wf-td-status--dropdown .workflow-filter-trigger {
  white-space: nowrap;
}
#home-view .home-global-workflow-card .patient-wf-table th.workflow-row-actions-header,
#home-view .home-global-workflow-card .patient-wf-table td.workflow-row-actions-cell {
  padding: 0.75rem 1rem;
  padding-left: 0.5rem;
  padding-right: 1.35rem;
  text-align: center !important;
  vertical-align: middle !important;
}
#home-view .home-global-workflow-card .plan-table tbody td:nth-child(7).workflow-row-actions-cell {
  text-align: center !important;
}
#home-view .home-global-workflow-card .patient-wf-table .patient-wf-td-task-id {
  text-align: center;
  vertical-align: middle;
}
#home-view .home-global-workflow-card .patient-wf-table .patient-wf-td-task-id .patient-wf-task-id-link {
  font-variant-numeric: tabular-nums;
}
#home-view .home-global-workflow-card .patient-wf-table.workflow-table--patient.plan-table tbody tr:last-child td {
  border-bottom: none;
}
#home-view .home-global-workflow-card .patient-wf-table tbody tr.patient-wf-message-row {
  cursor: pointer;
}
#home-view .home-global-workflow-card .patient-wf-table tbody tr.patient-wf-message-row td.workflow-row-actions-cell {
  cursor: default;
}

/* Workflows → Patient: same pinned / replied / note hover (Edit & Reply) as Patient record → Workflow */
#home-view .home-global-workflow-card .patient-wf-meta-cells:not(.patient-wf-meta-cells--task) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}
#home-view .home-global-workflow-card .patient-wf-pinned-row {
  background: var(--primary-light);
}
#home-view .home-global-workflow-card .patient-wf-pinned-row td {
  background: transparent;
}
#home-view .home-global-workflow-card .patient-wf-table tbody tr.patient-wf-replied-row:not(.patient-wf-pinned-row) {
  background: rgba(22, 163, 74, 0.07);
}
#home-view .home-global-workflow-card .patient-wf-table tbody tr.patient-wf-replied-row:not(.patient-wf-pinned-row) td {
  background: transparent;
}
#home-view .home-global-workflow-card .patient-wf-note-row-shell {
  position: relative;
  padding-top: 0.1rem;
}
#home-view .home-global-workflow-card .patient-wf-note-row-shell:not(.patient-wf-note-row-shell--editing) .patient-wf-body-with-icon {
  padding-right: 7.5rem;
}
#home-view .home-global-workflow-card .patient-wf-note-row-actions {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
#home-view .home-global-workflow-card .patient-wf-note-reply-btn,
#home-view .home-global-workflow-card .patient-wf-note-edit-btn {
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
}
#home-view .home-global-workflow-card .patient-wf-note-row:hover .patient-wf-note-row-actions,
#home-view .home-global-workflow-card .patient-wf-pinned-row:hover .patient-wf-note-row-actions,
#home-view .home-global-workflow-card .patient-wf-note-row-shell:focus-within .patient-wf-note-row-actions {
  opacity: 1;
  pointer-events: auto;
}
#home-view .home-global-workflow-card .patient-wf-note-row-shell--editing .patient-wf-note-row-actions {
  display: none;
}
@media (hover: none) {
  #home-view .home-global-workflow-card .patient-wf-note-row-actions {
    opacity: 1;
    pointer-events: auto;
  }
}
#home-view .home-global-workflow-card .patient-wf-note-edit-inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
#home-view .home-global-workflow-card .patient-wf-body-with-icon .patient-wf-note-textarea {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}
#home-view .home-global-workflow-card .patient-wf-note-reply-draft-row td {
  background: var(--bg);
  border-top: 1px dashed var(--border-strong);
  vertical-align: top;
}

/* Notes page (#/notes): no elevated card behind toolbar + table (match Workflows → Patient) */
#notes-view #notes-global-notes-card.record-card,
#notes-view .notes-global-card.record-card {
  background: transparent;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
}
#notes-view .notes-global-card .plan-table-wrap--workflow-patient.patient-wf-table-wrap {
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
  background: transparent;
  padding: 0;
  margin-top: 0.75rem;
}
#notes-view .notes-global-card .notes-global-page-table.workflow-table--patient {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* Notes page (#/notes): toolbar + Patient column + note column = Patient record → Notes structure */
#notes-view .notes-global-card .patient-wf-toolbar {
  flex-wrap: wrap;
  gap: 0.5rem 0.35rem;
}
#notes-view .notes-global-card .patient-wf-toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  width: 100%;
}
#notes-view .notes-global-card .patient-notes-count {
  flex: 1 1 auto;
  min-width: min(240px, 100%);
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text-muted, #64748b);
}
#notes-view .notes-global-card .patient-wf-toolbar-filters-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex: 0 1 auto;
  margin-left: auto;
}
#notes-view .notes-global-card .patient-wf-toolbar-filters-cluster .workflow-notes-toolbar {
  margin-left: 0;
}
#notes-view .notes-global-card .patient-wf-td-patient.name-cell .home-patient-cell-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  min-width: 0;
}
#notes-view .notes-global-card .patient-wf-table a:not(.btn) {
  font-size: var(--workflow-control-font-size);
  font-weight: 400;
  line-height: 1.25;
  color: var(--text);
  text-decoration: none;
}
#notes-view .notes-global-card .patient-wf-table a:not(.btn):not(.home-name-link):hover {
  color: var(--text);
  text-decoration: none;
}
#notes-view .notes-global-card .patient-wf-td-patient.name-cell .home-name-link:hover {
  color: var(--primary);
  text-decoration: underline;
}
#notes-view .notes-global-card .patient-wf-table a:not(.btn):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
#notes-view .notes-global-card .notes-global-page-table col.patient-wf-col-patient {
  width: 14%;
  min-width: 9rem;
}
#notes-view .notes-global-card .notes-global-page-table col.notes-global-col-note-body {
  width: auto;
}
#notes-view .notes-global-card .notes-global-page-table col.patient-notes-col-date {
  width: 9.5rem;
  min-width: 7rem;
}
#notes-view .notes-global-card .notes-global-page-table col.patient-notes-col-user {
  width: 8.75rem;
  min-width: 7rem;
}
#notes-view .notes-global-card .notes-global-page-table col.patient-notes-col-actions {
  width: 3.25rem;
  min-width: 3.25rem;
}
#notes-view .notes-global-card .notes-global-page-table.workflow-table--patient.plan-table tbody tr.patient-wf-data-row td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}
#notes-view .notes-global-card .patient-wf-table tbody tr.patient-wf-note-row .patient-wf-td-body,
#notes-view .notes-global-card .patient-wf-table tbody tr.patient-wf-pinned-row .patient-wf-td-body {
  white-space: normal;
}
#notes-view .notes-global-card .notes-global-page-table tbody tr.patient-wf-data-row td:nth-child(1) {
  text-align: left;
  vertical-align: top;
}
#notes-view .notes-global-card .notes-global-page-table tbody tr.patient-wf-data-row td:nth-child(2) {
  text-align: left;
  vertical-align: top;
  white-space: normal !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
#notes-view .notes-global-card .notes-global-page-table tbody tr.patient-wf-data-row td:nth-child(3),
#notes-view .notes-global-card .notes-global-page-table tbody tr.patient-wf-data-row td:nth-child(4) {
  white-space: nowrap;
}

/*
 * Notes table borders (`border-collapse: collapse`):
 * Use `hidden` at thread seams — `none` can still merge into a visible line above the reply row.
 * Parent → reply: hide bottom on parent/predecessor and top on reply; also use direct sibling as fallback for :has quirks.
 */
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-wf-note-thread-row > td {
  border-top: hidden !important;
}
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-wf-note-row:not(.patient-wf-note-thread-row) + tr.patient-wf-note-thread-row > td,
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-wf-pinned-row + tr.patient-wf-note-thread-row > td,
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-wf-note-thread-row + tr.patient-wf-note-thread-row > td {
  border-top: hidden !important;
}
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table tbody tr.patient-wf-note-row:not(.patient-wf-note-thread-row):has(+ tr.patient-wf-note-thread-row) > td,
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table tbody tr.patient-wf-pinned-row:has(+ tr.patient-wf-note-thread-row) > td,
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table tbody tr.patient-wf-note-thread-row:has(+ tr.patient-wf-note-thread-row) > td {
  border-bottom: hidden !important;
}
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr:has(+ tr.patient-notes-thread-divider):not(.patient-notes-thread-divider) > td {
  border-bottom: 1px solid var(--border) !important;
}
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-notes-thread-divider td,
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-notes-thread-divider .patient-notes-thread-divider-cell {
  border-top: none !important;
}

/* Reply rows: blank patient column (avatar/name only on thread root / pinned) */
#notes-view .notes-global-card .patient-wf-table tbody tr.patient-wf-note-thread-row td.patient-wf-td-patient--notes-reply-span,
#notes-view .notes-global-card .patient-wf-table tbody tr:not(.patient-wf-note-thread-row) td.patient-wf-td-patient--notes-reply-span {
  vertical-align: top;
  padding: 0.75rem 0.35rem !important;
}

/* Connector + note body layout (Patient record → Notes row icons omitted on Notes page) */
#notes-view .notes-global-card .patient-wf-body-with-icon {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
}
#notes-view .notes-global-card .patient-wf-body-with-icon .workflow-note-body {
  min-width: 0;
  flex: 1;
}
#notes-view .notes-global-card .patient-wf-body-with-icon--note-reply {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.35rem;
  min-width: 0;
  padding-left: 5px;
}
#notes-view .notes-global-card .patient-wf-note-thread-connector {
  flex-shrink: 0;
  width: 0.875rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-top: 0.12rem;
  color: var(--border, #e5e5e5);
}
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table .patient-wf-note-thread-connector {
  color: var(--text-muted, rgba(15, 23, 42, 0.55));
}
#notes-view .notes-global-card .patient-wf-note-thread-connector-svg {
  display: block;
  width: 0.875rem;
  height: 1.35rem;
  color: inherit;
}

#notes-view .notes-global-card .patient-wf-table tbody tr.patient-wf-note-thread-row {
  background: transparent;
}
#notes-view .notes-global-card .patient-wf-table tbody tr.patient-wf-note-thread-row td {
  background: transparent;
}
#notes-view .notes-global-card .patient-wf-note-edit-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  flex: 1;
}
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table tbody tr.patient-wf-note-row > td,
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table tbody tr.patient-wf-pinned-row > td,
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table tbody tr.patient-wf-note-reply-draft-row > td {
  vertical-align: top;
}
#notes-view .notes-global-card .notes-global-page-table th.workflow-row-actions-header,
#notes-view .notes-global-card .notes-global-page-table td.workflow-row-actions-cell {
  padding: 0.75rem 1rem;
  padding-left: 0.5rem;
  padding-right: 1.35rem;
  text-align: center !important;
  vertical-align: middle !important;
}
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table tbody tr.patient-wf-note-row td.workflow-row-actions-cell,
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table tbody tr.patient-wf-pinned-row td.workflow-row-actions-cell {
  vertical-align: top !important;
}
#notes-view .notes-global-card .notes-global-page-table.workflow-table--patient.plan-table tbody tr:last-child td {
  border-bottom: none;
}
#notes-view .notes-global-card .patient-wf-pinned-row {
  background: var(--primary-light);
}
#notes-view .notes-global-card .patient-wf-pinned-row td {
  background: transparent;
}
#notes-view .notes-global-card .patient-wf-note-row-shell {
  position: relative;
  padding-top: 0.1rem;
}
#notes-view .notes-global-card .patient-wf-note-row-shell:not(.patient-wf-note-row-shell--editing) .patient-wf-body-with-icon {
  padding-right: 7.5rem;
}
#notes-view .notes-global-card .patient-wf-note-row-actions {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
#notes-view .notes-global-card .patient-wf-note-reply-btn,
#notes-view .notes-global-card .patient-wf-note-edit-btn {
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
}
#notes-view .notes-global-card .patient-wf-note-row:hover .patient-wf-note-row-actions,
#notes-view .notes-global-card .patient-wf-pinned-row:hover .patient-wf-note-row-actions,
#notes-view .notes-global-card .patient-wf-note-row-shell:focus-within .patient-wf-note-row-actions {
  opacity: 1;
  pointer-events: auto;
}
#notes-view .notes-global-card .patient-wf-note-row-shell--editing .patient-wf-note-row-actions {
  display: none;
}
@media (hover: none) {
  #notes-view .notes-global-card .patient-wf-note-row-actions {
    opacity: 1;
    pointer-events: auto;
  }
}
#notes-view .notes-global-card .patient-wf-note-edit-inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0;
}
#notes-view .notes-global-card .patient-wf-body-with-icon .patient-wf-note-textarea {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}
#notes-view .notes-global-card .patient-wf-note-reply-draft-row td {
  background: var(--bg);
  border-top: 1px dashed var(--border-strong);
  vertical-align: top;
}
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-notes-thread-divider {
  height: 0;
  line-height: 0;
  font-size: 0;
}
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-notes-thread-divider td {
  padding: 0 !important;
  border-top: none !important;
  border-left: none;
  border-right: none;
  border-bottom: none;
  vertical-align: middle;
  height: 0 !important;
  line-height: 0 !important;
  font-size: 0 !important;
}
#notes-view .notes-global-card .notes-global-page-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-notes-thread-divider .patient-notes-thread-divider-cell {
  padding: 0 !important;
  margin: 0;
  border-top: none !important;
  border-bottom: none !important;
  height: 0 !important;
  line-height: 0 !important;
  font-size: 0 !important;
  overflow: hidden;
}
#notes-view .notes-global-card .patient-wf-row-type-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

/* Messages page (#/messages): table opens same slide-out drawer as patient header message icon */
#messages-view .view-scroll-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#messages-view #messages-global-messages-card.record-card,
#messages-view .messages-global-card.record-card {
  background: transparent;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
}

#messages-view .messages-global-card .plan-table-wrap--workflow-patient.patient-wf-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  box-sizing: border-box;
  background: transparent;
  padding: 0;
  margin-top: 0.75rem;
}

#messages-view .messages-global-card .messages-global-page-table.workflow-table--patient {
  table-layout: fixed;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

#messages-view .messages-global-card .patient-wf-toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  width: 100%;
}

#messages-view .messages-global-card .patient-notes-count {
  flex: 1 1 auto;
  min-width: min(240px, 100%);
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text-muted, #64748b);
}

#messages-view .messages-global-card .patient-wf-toolbar-filters-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex: 0 1 auto;
  margin-left: auto;
}

/* Patient / Message columns: match Notes page (#/notes) — same colgroup + cell rules */
#messages-view .messages-global-card .messages-global-page-table col.patient-wf-col-patient {
  width: 14%;
  min-width: 9rem;
}

#messages-view .messages-global-card .messages-global-page-table col.messages-global-col-body {
  width: auto;
}

#messages-view .messages-global-card .messages-global-page-table col.patient-notes-col-date {
  width: 9.5rem;
  min-width: 7rem;
}

#messages-view .messages-global-card .messages-global-page-table col.patient-notes-col-user {
  width: 8.75rem;
  min-width: 7rem;
}

#messages-view .messages-global-card .messages-global-page-table col.patient-notes-col-actions {
  width: 3.25rem;
  min-width: 3.25rem;
}

#messages-view .messages-global-card .patient-wf-td-patient.name-cell .home-patient-cell-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  min-width: 0;
}

#messages-view .messages-global-card .patient-wf-table a:not(.btn) {
  font-size: var(--workflow-control-font-size);
  font-weight: 400;
  line-height: 1.25;
  color: var(--text);
  text-decoration: none;
}

#messages-view .messages-global-card .patient-wf-table a:not(.btn):not(.home-name-link):hover {
  color: var(--text);
  text-decoration: none;
}

#messages-view .messages-global-card .patient-wf-td-patient.name-cell .home-name-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

#messages-view .messages-global-card .patient-wf-table a:not(.btn):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

#messages-view .messages-global-card .messages-global-page-table.workflow-table--patient.plan-table tbody tr.patient-wf-data-row td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

#messages-view .messages-global-card .messages-global-page-table tbody tr.patient-wf-data-row td:nth-child(1) {
  text-align: left;
  vertical-align: top;
}

/*
 * Undo .record-card--workflow .workflow-table.plan-table tbody td:nth-child(2) { white-space: nowrap },
 * which forces single-line message previews (ellipsis).
 */
#messages-view .messages-global-card .messages-global-page-table tbody tr.patient-wf-data-row td:nth-child(2) {
  text-align: left;
  vertical-align: top;
  white-space: normal !important;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#messages-view .messages-global-card .messages-global-page-table tbody tr.patient-wf-data-row td:nth-child(3),
#messages-view .messages-global-card .messages-global-page-table tbody tr.patient-wf-data-row td:nth-child(4) {
  white-space: nowrap;
}

#messages-view .messages-global-card .messages-global-page-table tbody tr.patient-wf-message-row td.patient-wf-td-patient {
  vertical-align: top;
}

#messages-view .messages-global-card .messages-global-page-table tbody tr.patient-wf-message-row td.messages-global-msg-cell {
  vertical-align: top;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
}

#messages-view .messages-global-msg-preview {
  cursor: pointer;
  text-align: left;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
}

#messages-view .messages-global-msg-preview:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

#messages-view .messages-global-msg-preview .workflow-note-body--messages-page {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
  font-size: 0.875rem;
  overflow: visible;
  text-overflow: clip;
}

#messages-view .messages-global-card .messages-global-page-table tbody tr.patient-wf-message-row td.workflow-row-actions-cell {
  cursor: default;
  vertical-align: top;
}

#messages-view .messages-global-card .messages-global-page-table tbody tr.patient-wf-message-row td.patient-wf-td-date,
#messages-view .messages-global-card .messages-global-page-table tbody tr.patient-wf-message-row td.patient-wf-td-assignee {
  vertical-align: top;
  white-space: nowrap;
}

#patient-view .record-card--workflow .workflow-table--patient.plan-table thead th:nth-child(1),
#patient-view .record-card--workflow .workflow-table--patient.plan-table tbody tr:not(.workflow-section-header-row):not(.patient-wf-data-row) td:nth-child(1) {
  padding: 0.75rem 0.3rem 0.75rem 1rem;
}

#patient-view .record-card--workflow .workflow-table--patient.plan-table thead th:nth-child(2),
#patient-view .record-card--workflow .workflow-table--patient.plan-table tbody tr:not(.workflow-section-header-row):not(.patient-wf-data-row) td:nth-child(2) {
  padding: 0.75rem 1rem 0.75rem 0.3rem;
  text-align: left;
}
/*
 * Section header: NEVER use display:flex on <td> — it breaks table layout and colspan spanning.
 * Flex lives on .workflow-section-header-inner instead.
 */
.record-card--workflow .workflow-table--patient .workflow-section-header-row td[colspan="6"].workflow-section-header-cell,
.record-card--workflow .workflow-table--patient .workflow-section-header-row td[colspan="5"].workflow-section-header-cell {
  display: table-cell !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  box-sizing: border-box;
  white-space: normal !important;
  vertical-align: middle !important;
}
.record-card--workflow .workflow-table.plan-table .workflow-section-header-row td {
  white-space: normal !important;
}
.workflow-section-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.workflow-section-header-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}
.workflow-section-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
}
.workflow-section-toggle:hover {
  background: rgba(255, 255, 255, 0.55);
}
.workflow-section-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.workflow-section-toggle-icon {
  font-size: var(--text-2xs);
  transition: transform 0.2s ease;
}
.workflow-section-header-row.is-collapsed .workflow-section-toggle-icon {
  transform: rotate(-90deg);
}
.workflow-section-header-sep {
  color: var(--text-muted);
  font-weight: 400;
  padding: 0 0.5em;
}
.workflow-section-header-count {
  font-weight: 600;
  color: var(--text-muted);
}
.record-card--workflow .workflow-table--patient tbody tr.workflow-section-row--collapsed {
  display: none !important;
}
/* Transparent cell + margined inner = a few px “air” above/below section bar */
.record-card--workflow .workflow-table--patient tbody tr.workflow-section-header-row td {
  background: transparent !important;
  border-radius: 0;
  border-bottom: none !important;
  padding: 0 !important;
  min-height: 0 !important;
  vertical-align: middle !important;
}
.record-card--workflow .workflow-table--patient .workflow-section-header-inner {
  margin: 0;
  min-height: 0;
  padding: 0.5rem 0.75rem;
  box-sizing: border-box;
  background: transparent;
  border-radius: 0;
  border-bottom: none;
}
.record-card--workflow .workflow-table--patient .workflow-section-toggle:hover {
  background: transparent;
}
.record-card--workflow .workflow-table--patient .workflow-section-actions-btn:hover {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.record-card--workflow .workflow-table--patient .workflow-section-toggle {
  width: 1.5rem;
  height: 1.5rem;
}
.record-card--workflow .workflow-table--patient .workflow-section-header-title {
  font-size: 0.8125rem;
}
/* Let task rows grow with wrapped task text (fixed 2.75rem td height was stacking lines) */
.record-card--workflow .workflow-table--patient tbody tr.workflow-task-row td {
  height: auto !important;
  min-height: 2.75rem !important;
  max-height: none !important;
  overflow: visible !important;
}
.record-card--workflow .workflow-table--patient tbody tr.workflow-task-row td.workflow-encounter-cell {
  overflow: visible !important;
  max-height: none !important;
}
.record-card--workflow .workflow-table tbody tr.workflow-task-row {
  height: auto !important;
}
.record-card--workflow .workflow-table--patient .workflow-task-cell-wrap {
  overflow: visible;
}
.record-card--workflow .workflow-table--patient .workflow-task-trigger {
  gap: 0.35rem;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  white-space: normal;
  height: auto;
  overflow: visible;
  text-overflow: clip;
}

.record-card--workflow .workflow-table--patient .workflow-task-trigger.patient-wf-task-id-link,
.record-card--workflow .workflow-table--patient .workflow-task-trigger.workflow-task-id-link {
  flex: 0 0 auto;
  min-width: 0;
}

/* Chip layout: icon + pills + action text stay on one row */
.record-card--workflow .workflow-table--patient .workflow-task-trigger:has(.workflow-task-chips) {
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* Patient Workflow Task column: Type / Subtype chips + plain action (Tasks-style mockup) */
.record-card--workflow .workflow-table--patient .workflow-task-chips {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.35rem 0.45rem;
  min-width: 0;
  text-align: left;
}

.record-card--workflow .workflow-table--patient .workflow-task-chip {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  min-height: var(--workflow-control-height);
  height: var(--workflow-control-height);
  padding: 0 var(--workflow-control-padding-x);
  box-sizing: border-box;
  font-size: var(--workflow-control-font-size);
  font-weight: 500;
  line-height: 1.25;
  border-radius: var(--workflow-control-radius);
  flex-shrink: 0;
  max-width: 100%;
}

.record-card--workflow .workflow-table--patient .workflow-task-chip--outline {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  gap: 0.15rem;
}

.record-card--workflow .workflow-table--patient .workflow-task-chip--fill {
  background: var(--border);
  border: 1px solid transparent;
  color: var(--text);
}

.record-card--workflow .workflow-table--patient button.workflow-task-trigger.workflow-task-chip {
  margin: 0;
  font: inherit;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
}

.record-card--workflow .workflow-table--patient button.workflow-task-trigger.workflow-task-chip:hover {
  text-decoration: none;
  color: var(--text);
}

.record-card--workflow .workflow-table--patient button.workflow-task-trigger.workflow-task-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.record-card--workflow .workflow-table--patient .workflow-task-chip--outline .workflow-type-icon--chips {
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1;
}

.record-card--workflow .workflow-table--patient .workflow-task-chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-card--workflow .workflow-table--patient .workflow-task-chip-tail {
  font-size: var(--workflow-control-font-size);
  font-weight: 400;
  color: var(--text);
  line-height: 1.25;
  min-width: 0;
  flex: 0 1 auto;
  white-space: nowrap;
}

/* Inactive workflow status tabs — same token as task # badges */
.record-card--workflow .workflow-table--patient .workflow-task-circle-num {
  background: var(--border);
}

.record-card--workflow .workflow-table--patient .workflow-encounter-cell .workflow-task-text {
  flex: 1 1 auto;
  min-width: 6rem;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  word-break: break-word;
}

/* Tasks list + Views: Task column chips match Patient Workflow */
#home-view .home-table.workflow-table .workflow-task-cell-wrap,
.view-configurable-task-table .workflow-task-cell-wrap {
  overflow: visible;
}
#home-view .home-table.workflow-table .workflow-task-trigger,
.view-configurable-task-table .workflow-task-trigger {
  gap: 0.35rem;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  white-space: normal;
  height: auto;
  overflow: visible;
  text-overflow: clip;
}
#home-view .home-table.workflow-table .workflow-task-trigger:has(.workflow-task-chips),
.view-configurable-task-table .workflow-task-trigger:has(.workflow-task-chips) {
  flex-wrap: nowrap;
  white-space: nowrap;
}
#home-view .home-table.workflow-table .workflow-task-chips,
.view-configurable-task-table .workflow-task-chips {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.35rem 0.45rem;
  min-width: 0;
  text-align: left;
}
#home-view .home-table.workflow-table .workflow-task-chip,
.view-configurable-task-table .workflow-task-chip {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  min-height: var(--workflow-control-height);
  height: var(--workflow-control-height);
  padding: 0 var(--workflow-control-padding-x);
  box-sizing: border-box;
  font-size: var(--workflow-control-font-size);
  font-weight: 500;
  line-height: 1.25;
  border-radius: var(--workflow-control-radius);
  flex-shrink: 0;
  max-width: 100%;
}
#home-view .home-table.workflow-table .workflow-task-chip--outline,
.view-configurable-task-table .workflow-task-chip--outline {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  gap: 0.15rem;
}
#home-view .home-table.workflow-table .workflow-task-chip--fill,
.view-configurable-task-table .workflow-task-chip--fill {
  background: var(--border);
  border: 1px solid transparent;
  color: var(--text);
}

#home-view .home-table.workflow-table button.workflow-task-trigger.workflow-task-chip,
.view-configurable-task-table button.workflow-task-trigger.workflow-task-chip {
  margin: 0;
  font: inherit;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
}

#home-view .home-table.workflow-table button.workflow-task-trigger.workflow-task-chip:hover,
.view-configurable-task-table button.workflow-task-trigger.workflow-task-chip:hover {
  text-decoration: none;
  color: var(--text);
}

#home-view .home-table.workflow-table button.workflow-task-trigger.workflow-task-chip:focus-visible,
.view-configurable-task-table button.workflow-task-trigger.workflow-task-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
#home-view .home-table.workflow-table .workflow-task-chip--outline .workflow-type-icon--chips,
.view-configurable-task-table .workflow-task-chip--outline .workflow-type-icon--chips {
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1;
}
#home-view .home-table.workflow-table .workflow-task-chip-text,
.view-configurable-task-table .workflow-task-chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#home-view .home-table.workflow-table .workflow-task-chip-tail,
.view-configurable-task-table .workflow-task-chip-tail {
  font-size: var(--workflow-control-font-size);
  font-weight: 400;
  color: var(--text);
  line-height: 1.25;
  min-width: 0;
  flex: 0 1 auto;
  white-space: nowrap;
}
#home-view .home-table.workflow-table .workflow-encounter-cell .workflow-task-text,
.view-configurable-task-table .workflow-encounter-cell .workflow-task-text {
  flex: 1 1 auto;
  min-width: 6rem;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  word-break: break-word;
}

.workflow-card-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}
.workflow-card-title-row h2 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 8rem;
}
/* Override .record-card h2 padding/margin/flex so title aligns with action buttons */
.record-card--workflow .workflow-card-title-row h2 {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  align-self: center;
  line-height: 1.25;
  min-height: 2rem;
  box-sizing: border-box;
  flex-wrap: nowrap;
  gap: 0;
}
.record-card--workflow .workflow-card-title-row .workflow-btns {
  align-self: center;
  flex-shrink: 0;
}
#patient-view #patient-workflow-panel .record-card--workflow > .workflow-card-title-row .patient-wf-title-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 0.65rem;
  margin-left: auto;
  flex: 1 1 auto;
  min-width: 0;
}

.patient-wf-header-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  flex: 0 1 auto;
  min-width: 0;
}

#patient-view #patient-workflow-panel .patient-wf-header-filter .workflow-filter-trigger {
  font-size: var(--workflow-control-font-size, 0.8125rem);
  font-weight: 400;
}

#patient-view #patient-workflow-panel .record-card--workflow > .workflow-card-title-row .patient-wf-toolbar-filters-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0;
}
#patient-view #patient-workflow-panel .record-card--workflow > .workflow-card-title-row .patient-wf-title-toolbar .workflow-btns {
  margin-left: 0;
}
.record-card--workflow .workflow-card-title-row {
  margin-bottom: calc(0.5rem + 10px);
}
/* Task subpage: title row flush to task-type sticky header (override generic workflow title-row margin) */
#patient-view #patient-workflow-panel .patient-wf-task-subpage.record-card--workflow > .patient-wf-task-subpage-sticky > .workflow-card-title-row.patient-wf-task-subpage-title-row {
  margin-bottom: 0;
}

/* Patient Workflow: task ID subpage (breadcrumb + Automate/Save; task body below) */
.patient-wf-task-subpage-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--patient-wf-task-subpage-crumb-gap, 0.5rem);
  flex: 1 1 auto;
  min-width: 0;
  min-height: 2rem;
  box-sizing: border-box;
  font-size: 0.95rem;
}
.patient-wf-breadcrumb-link {
  color: var(--link-color, var(--accent, #2563eb));
  text-decoration: none;
  font-weight: 500;
}
.patient-wf-breadcrumb-link:hover {
  text-decoration: underline;
}
.patient-wf-breadcrumb-sep {
  color: var(--muted-foreground, #64748b);
  font-weight: 400;
}
.patient-wf-breadcrumb-current {
  font-weight: 600;
  color: var(--foreground, inherit);
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-breadcrumb .patient-wf-task-subpage-task-id {
  font-weight: 400;
}
.patient-wf-task-subpage-title-row .patient-wf-task-subpage-btns {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-self: center;
  flex-shrink: 0;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-btns .workflow-row-actions-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  min-width: 1.75rem;
  min-height: 1.75rem;
  padding: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-move-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.patient-wf-task-subpage {
  /* Right column sticky offset — set from JS from measured sticky block height */
  --patient-wf-task-subpage-sticky-toolbar-height: 4.75rem;
  --patient-wf-task-subpage-crumb-gap: 0.5rem;
}
.patient-wf-task-subpage-embed-host {
  margin-top: 0.75rem;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}
.patient-wf-task-subpage-missing {
  margin: 0 0 0.75rem;
}

/* Task subpage: sticky toolbar (breadcrumb + actions) + task type header — no ruled line directly under Automate/Save */
#patient-view #patient-workflow-panel .patient-wf-task-subpage-sticky {
  position: sticky;
  top: 0;
  z-index: 8;
  background: var(--main-shell-bg, var(--surface, #fff));
  padding-top: 0.2rem;
  margin-top: -0.15rem;
  margin-bottom: 0;
  border-bottom: none;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-task-head {
  padding: 0.5rem 0 0;
  box-sizing: border-box;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-header {
  margin: 0;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-header-main {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-width: 0;
  width: 100%;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-header-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 1 1 auto;
  width: auto;
  max-width: 100%;
  min-width: 0;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-header-main > .patient-wf-task-subpage-last-updated {
  margin: 0 0 0 auto;
  flex: 0 0 auto;
  align-self: center;
  max-width: min(18rem, 42vw);
  min-width: 0;
  padding-top: 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--text-muted, #64748b);
  text-align: right;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-header-main > .patient-wf-task-subpage-last-updated .patient-wf-task-subpage-last-updated-line {
  color: var(--text, #111);
  font-weight: 400;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-category-slot {
  flex-shrink: 0;
  padding-top: 0.1rem;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-category-slot .workflow-task-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--workflow-control-height);
  height: var(--workflow-control-height);
  padding: 0 var(--workflow-control-padding-x);
  box-sizing: border-box;
  font-size: var(--workflow-control-font-size);
  font-weight: 500;
  line-height: 1.25;
  border-radius: var(--workflow-control-radius);
  max-width: 100%;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-category-slot .workflow-task-chip--outline {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-head-text {
  flex: 0 1 auto;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.0625rem;
  padding-top: 0.25rem;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-title-prefix {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--patient-wf-task-subpage-crumb-gap, 0.5rem);
  max-width: 100%;
  min-width: 0;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-title-sep {
  color: var(--text-muted, #64748b);
  font-weight: 400;
  flex-shrink: 0;
  user-select: none;
  margin: 0;
  padding: 0;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-title-seg {
  flex-shrink: 0;
}
/* Override .record-card h2 space-between — crumbs stay left with even gaps */
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-title {
  margin: 0;
  padding: 0;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  align-self: flex-start;
  flex: none;
  gap: var(--patient-wf-task-subpage-crumb-gap, 0.5rem);
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  font-size: calc(1.125rem - 2px);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text, #111);
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-title-input {
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: inherit;
  font-weight: 500;
  line-height: inherit;
  letter-spacing: inherit;
  color: var(--text, #111);
  min-width: 0;
  max-width: 100%;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-select-wrap {
  display: inline-flex;
  flex-shrink: 0;
  vertical-align: middle;
  max-width: 100%;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-pills {
  width: auto;
  gap: 0;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-dropdown {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  vertical-align: middle;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-dropdown .workflow-filter-trigger {
  width: auto;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: inherit;
  font-weight: 500;
  line-height: inherit;
  background: var(--field-bg);
  border: 1px solid var(--border);
  color: var(--text, #111);
  justify-content: flex-start;
  text-align: left;
  white-space: nowrap;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-dropdown .workflow-filter-trigger--with-icon {
  gap: 0.5rem;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-dropdown .workflow-filter-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg, #f8fafc);
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-dropdown .workflow-filter-trigger:focus-visible {
  outline: 2px solid var(--primary-light, #ebeaf5);
  outline-offset: 1px;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-title-input {
  flex: 1 1 8rem;
  min-width: 6rem;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-title-input::placeholder {
  color: var(--text-muted, #64748b);
  font-weight: 500;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-title-input:focus {
  outline: none;
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-desc {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text-muted, #64748b);
}
#patient-view #patient-workflow-panel .patient-wf-task-subpage-type-rule {
  border: none;
  border-top: 1px solid var(--border, #e5e7eb);
  margin: 0.65rem 0 0;
}
/* Two-column task body (embedded modal) */
.task-type-modal--workflow-subpage .patient-wf-task-subpage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 22rem);
  gap: 1.5rem 2rem;
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 900px) {
  .task-type-modal--workflow-subpage .patient-wf-task-subpage-layout {
    grid-template-columns: 1fr;
  }
  .task-type-modal--workflow-subpage .patient-wf-task-subpage-col--right {
    position: static;
    top: auto;
    z-index: auto;
  }
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-col--left {
  min-width: 0;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-col--right {
  min-width: 0;
  position: sticky;
  align-self: start;
  top: var(--patient-wf-task-subpage-sticky-toolbar-height, 4.75rem);
  z-index: 6;
}
/* Dividers moved inside .form-sheet; hide lead + footer hr so the card has clean top/bottom edges */
.task-type-modal--workflow-subpage .patient-wf-task-subpage-col--left > .task-type-modal-divider {
  display: none;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-form-sheet > hr.task-type-modal-divider:first-of-type:not(.task-type-modal-divider--before-footer) {
  display: none !important;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-form-sheet > .task-type-modal-divider--before-footer {
  display: none !important;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-control-hidden {
  display: none !important;
}
/* Left column: free-form task details (structured fields archived off-screen) */
.task-type-modal--workflow-subpage .patient-wf-task-subpage-body-editor {
  display: flex;
  flex-direction: column;
  min-height: 18rem;
  width: 100%;
  box-sizing: border-box;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-body-input {
  display: block;
  width: 100%;
  min-height: 18rem;
  flex: 1 1 auto;
  margin: 0;
  padding: 0.15rem 0 0.35rem;
  box-sizing: border-box;
  border: none;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: calc(1.25rem - 4px);
  font-weight: 400;
  line-height: 1.5;
  color: var(--text, #111);
  resize: none;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-body-input::placeholder {
  color: var(--text-muted, #64748b);
  font-weight: 400;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-body-input:focus {
  outline: none;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-fields-archive {
  display: none !important;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-col--right > .task-type-modal-meta {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-col--right .task-type-modal-meta-row--primary {
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-composer {
  margin-top: 1rem;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-thread {
  margin: 0 0 0.65rem;
  padding: 0.65rem 0.75rem;
  min-height: 2.5rem;
  max-height: 14rem;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text, #111);
  background: color-mix(in srgb, var(--field-bg, #f1f5f9) 85%, transparent);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-thread:empty {
  display: none;
}
/* Single bordered field: text area + icons inside bottom-right (matches comment composer pattern) */
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-input-shell {
  position: relative;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: var(--surface, #fff);
  overflow: hidden;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-draft {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  border: none;
  outline: none;
  resize: none;
  min-height: 5.5rem;
  padding: 0.65rem 0.75rem 2.35rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text, #111);
  background: transparent;
  box-shadow: none;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-draft::placeholder {
  color: var(--text-muted, #94a3b8);
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-draft:focus {
  outline: none;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-input-actions {
  position: absolute;
  right: 0.25rem;
  bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.1rem;
  pointer-events: auto;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-attach-btn,
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-send-btn {
  color: var(--text-muted, #64748b);
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-attach-btn:hover,
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-send-btn:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text, #334155);
}
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-send-btn:focus-visible,
.task-type-modal--workflow-subpage .patient-wf-task-subpage-note-attach-btn:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 1px;
}

.workflow-notes-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.workflow-notes-search-wrap input {
  max-width: 14rem;
}

.workflow-section-header-row td {
  height: auto !important;
  min-height: 2.5rem !important;
  max-height: none !important;
  padding: 0.65rem 0.75rem !important;
  vertical-align: middle !important;
  border-bottom: 1px solid var(--border);
  background: var(--field-bg, #e8eaed);
}
.workflow-section-header-cell {
  /* table-cell only — flex is on .workflow-section-header-inner */
  box-sizing: border-box;
}
.workflow-section-header-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workflow-section-actions-wrap {
  position: relative;
  flex-shrink: 0;
}
.workflow-section-actions-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.875rem;
  min-height: 1.875rem;
  padding: 0.2rem 0.35rem;
  font-size: 1rem;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.workflow-section-actions-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.workflow-section-actions-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.workflow-section-actions-icon {
  pointer-events: none;
  font-size: 0.95rem;
}
.workflow-section-actions-flyout {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 30;
  padding: 0.25rem 0;
}
.workflow-section-delete {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--danger, #c53030);
  cursor: pointer;
}
.workflow-section-delete:hover {
  background: var(--danger-bg, #fef2f2);
}

.workflow-task-circle-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.375rem;
  height: 1.375rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--bg, #f0f2f5);
  border: none;
  box-shadow: none;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}

/* Note rows: sticky icon in # column (same footprint as task number badge) */
.workflow-note-idx-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 999px;
  background: var(--bg, #f0f2f5);
  color: var(--text-muted);
  font-size: var(--text-2xs);
  line-height: 1;
  vertical-align: middle;
}
.workflow-note-idx-icon i {
  line-height: 1;
}

.workflow-primary-add-wrap {
  position: relative;
  display: inline-block;
}
.workflow-add-block-wrap {
  position: relative;
  display: inline-block;
}
.workflow-add-flyout {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 10rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 40;
  padding: 0.25rem 0;
}
.workflow-add-block-flyout {
  position: absolute;
  left: 0;
  right: auto;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 12rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 40;
  padding: 0.25rem 0;
}
.workflow-add-flyout[hidden],
.workflow-add-block-flyout[hidden] {
  display: none !important;
}
.workflow-add-flyout-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.workflow-add-block-flyout-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.workflow-add-flyout-item:hover,
.workflow-add-block-flyout-item:hover {
  background: var(--bg);
}
.record-card--workflow .workflow-table--patient .workflow-note-row td {
  height: auto !important;
  min-height: 2.75rem !important;
  max-height: none !important;
  white-space: normal !important;
  overflow: visible !important;
}
/* Patient Workflow row actions: ellipsis button and flyout */
.workflow-row-actions-wrap {
  position: relative;
  display: inline-block;
}
.workflow-row-actions-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.35rem;
  font-size: 1.1rem;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.workflow-row-actions-icon {
  pointer-events: none;
  font-size: 0.95rem;
}
.workflow-row-actions-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.workflow-row-actions-flyout {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.15rem;
  width: max-content;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 20;
  padding: 0.25rem 0;
}
.workflow-row-actions-flyout[hidden] {
  display: none;
}
.workflow-row-delete {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.workflow-row-delete:hover {
  background: var(--bg);
  color: var(--danger);
}
.workflow-row-pin-toggle {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.workflow-row-pin-toggle:hover {
  background: var(--bg);
  color: var(--primary);
}
.workflow-row-replied-toggle {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.workflow-row-replied-toggle:hover {
  background: var(--bg);
  color: var(--primary);
}
.workflow-row-actions-flyout > button:not(:first-child):not(.patient-wf-task-reorder-btn) {
  border-top: 1px solid var(--border);
}
.patient-wf-task-reorder-btn + .patient-wf-task-reorder-btn {
  border-top: none;
}

/* Do not apply legacy 4-col widths to 6-col Patient Workflow table (breaks colspan headers + Task column) */
.workflow-table:not(.workflow-table--patient) th:nth-child(1),
.workflow-table:not(.workflow-table--patient) td:nth-child(1),
.workflow-table:not(.workflow-table--patient) th:nth-child(3),
.workflow-table:not(.workflow-table--patient) td:nth-child(3),
.workflow-table:not(.workflow-table--patient) th:nth-child(4),
.workflow-table:not(.workflow-table--patient) td:nth-child(4) {
  width: 1%;
  white-space: nowrap;
}

.workflow-table:not(.workflow-table--patient) th:nth-child(2),
.workflow-table:not(.workflow-table--patient) td:nth-child(2) {
  min-width: 6rem;
}


.assignee-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.assignee-wrap .assignee-individual-name {
  display: none;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-width: 8rem;
  max-width: 12rem;
}
.assignee-wrap.is-individual .assignee-individual-name {
  display: inline-block;
}

.patients-table .link-cell {
  white-space: nowrap;
}

.view-record-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  background: var(--primary);
  color: white;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
}

.view-record-btn:hover {
  background: var(--primary-hover);
  color: white;
  border-color: var(--primary-hover);
}

/* Patient record layout – 2 rows of 2 tiles */
.patient-record {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(2, 1fr);
}

.record-card {
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* Top 4 tiles: same padding as other record cards */
.record-card--tile {
  min-width: 0;
  padding: 1.25rem;
}

.record-card--tile h2 {
  margin: 0 0 0.05rem 0;
  padding-bottom: 0.1rem;
}

.record-card--tile ul {
  margin-top: 0;
}
.record-card--tile li:not(.profile-field-row--split) {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.1rem 0;
  font-size: 0.875rem;
}
.record-card--tile li:first-child:not(.profile-field-row--split) {
  padding-top: 0;
}

.record-card--tile .label {
  flex-shrink: 0;
}

.record-card--tile .record-input,
.record-card--tile .record-dob-wrap {
  flex: 1;
  min-width: 0;
  text-align: right;
}

.record-card--tile .record-input--select {
  width: auto;
  min-width: 0;
}

.record-card--tile li.record-row--top {
  align-items: flex-start;
}

.record-card--tile li.record-row--top .record-input {
  text-align: right;
}

.record-card--tile .record-input {
  padding: 0.2rem 0.35rem;
  font-size: 0.875rem;
}

.record-card--tile .record-input--multiline {
  min-height: 1.85em;
  resize: none;
  text-align: left;
}

.record-input--multiline {
  display: block;
  width: 100%;
  min-height: 2.25em;
  resize: none;
  text-align: left;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.record-card h2 {
  margin: 0 0 1rem 0;
  font-size: var(--font-section-title);
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
  letter-spacing: -0.01em;
  padding-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Profile page: Intake-style layout and field outlines */
.record-card--profile .profile-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.record-card--profile .profile-fields-grid--patient {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.record-card--profile .profile-fields-grid--cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record-card--profile .profile-fields-grid--contact-single {
  grid-template-columns: 1fr;
}

.record-card--profile .profile-field-row--span-2 {
  grid-column: span 2;
}

.record-card--profile .profile-field-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0;
}

.record-card--profile .profile-fields-list,
.record-card--payment .profile-fields-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.record-card--profile .profile-field-row--split,
.record-card--payment .profile-field-row--split {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  column-gap: 0.75rem;
  row-gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.record-card--profile .profile-field-row--split:last-child,
.record-card--payment .profile-field-row--split:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.record-card--profile .profile-field-row--split:first-child,
.record-card--payment .profile-field-row--split:first-child {
  padding-top: 0;
}

.record-card--profile .profile-field-row--split.profile-field-row--top,
.record-card--payment .profile-field-row--split.profile-field-row--top {
  align-items: start;
}

.profile-field-label-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.profile-field-icon {
  flex-shrink: 0;
  font-size: 1.125rem;
  color: var(--text-muted);
  line-height: 1;
}

.profile-field-value-cell {
  min-width: 0;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

#patient-view #patient-profile-panel .profile-field-row--split .profile-asap-dropdown,
#patient-view #patient-profile-panel .record-card--payment .profile-field-row--split .profile-asap-dropdown {
  width: auto;
  max-width: 100%;
  display: inline-block;
}

#patient-view #patient-profile-panel .profile-asap-dropdown .workflow-filter-trigger {
  width: auto;
  min-width: 4.5rem;
  max-width: 100%;
}

.record-card--profile .profile-field-row--split .profile-asap-dropdown,
.record-card--payment .profile-field-row--split .profile-asap-dropdown {
  width: auto;
  max-width: 100%;
}

.profile-mailing-address-fields.profile-inline-fields-row,
.profile-emergency-contact-fields.profile-inline-fields-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  width: auto;
  max-width: 100%;
}

.profile-inline-field-slot {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}

.profile-inline-field-slot--state .workflow-filter-trigger {
  min-width: 3.5rem;
}

.profile-inline-field-slot--relationship .workflow-filter-trigger {
  min-width: 6.5rem;
}

.record-card--profile .profile-inline-fields-row .profile-field-input {
  min-height: 2rem;
  height: 2rem;
  line-height: 1.25;
  padding-top: 0;
  padding-bottom: 0;
}

.record-card--profile .profile-field-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  text-align: left;
}

.record-card--profile .profile-field-input,
.record-card--payment .profile-field-input {
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  box-sizing: border-box;
  width: 100%;
  text-align: left;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.record-card--profile .profile-field-input.profile-field-input--autosize,
.record-card--payment .profile-field-input.profile-field-input--autosize {
  width: auto;
  min-width: 6ch;
  max-width: 100%;
  field-sizing: content;
}

.record-card--profile .profile-inline-fields-row .profile-field-input {
  min-height: 2rem;
  height: 2rem;
  line-height: 1.25;
  padding-top: 0;
  padding-bottom: 0;
}

.record-card--profile .profile-field-input.profile-field-input--street {
  min-width: 12ch;
}

.record-card--profile .profile-field-input.profile-field-input--phone {
  min-width: 14ch;
}

.record-card--profile .profile-field-input:focus,
.record-card--payment .profile-field-input:focus {
  outline: none;
  background: var(--field-bg);
  box-shadow: 0 0 0 1px var(--primary);
}

.record-card--profile .profile-field-input-wrap.record-dob-wrap,
.record-card--profile .profile-dob-field-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-start;
  width: 100%;
}

.record-card--profile .profile-field-input-wrap .record-age,
.record-card--profile .profile-dob-field-wrap .record-age {
  flex-shrink: 0;
  margin-left: 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  font-weight: 500;
}

.record-card--profile .profile-field-input-wrap .date-selector-wrap,
.record-card--profile .profile-dob-field-wrap .date-selector-wrap {
  flex: 0 1 auto;
  width: auto;
  min-width: 8.5rem;
  max-width: 100%;
}

.record-card--profile .profile-field-input-wrap .date-selector-display {
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  box-sizing: border-box;
  width: 100%;
  text-align: left;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.record-card--profile .profile-field-input-wrap .date-selector-wrap:focus-within .date-selector-display {
  background: var(--field-bg);
  box-shadow: 0 0 0 1px var(--primary);
}

.record-card--profile .profile-field-input.record-input--multiline,
.record-card--payment .profile-field-input.record-input--multiline {
  min-height: 4rem;
  resize: none;
  text-align: left;
}

.record-card--profile .profile-field-input.record-input--select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
}

.record-card--profile .profile-field-row--top .profile-field-input {
  min-height: 4rem;
}

.record-card--profile .profile-field-row--full,
.record-card--payment .profile-field-row--full {
  grid-column: 1 / -1;
}

.record-card--profile .profile-asap-dropdown,
.record-card--payment .profile-asap-dropdown {
  flex: 1;
  min-width: 0;
  display: block;
}

.record-card--profile .profile-asap-dropdown .workflow-filter-trigger,
.record-card--payment .profile-asap-dropdown .workflow-filter-trigger {
  width: 100%;
  min-width: 0;
  text-align: left;
  justify-content: flex-start;
  border: none;
  background: transparent;
  font-size: 0.9375rem;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.record-card--profile .profile-asap-dropdown .workflow-filter-trigger:hover,
.record-card--payment .profile-asap-dropdown .workflow-filter-trigger:hover {
  background: transparent;
}

.record-card--profile .profile-asap-dropdown .workflow-filter-trigger:focus,
.record-card--profile .profile-asap-dropdown .workflow-filter-trigger[aria-expanded="true"],
.record-card--payment .profile-asap-dropdown .workflow-filter-trigger:focus,
.record-card--payment .profile-asap-dropdown .workflow-filter-trigger[aria-expanded="true"] {
  background: var(--field-bg);
  box-shadow: 0 0 0 1px var(--primary);
  outline: none;
}

/* Payment card – reveal toggle */
.record-card--payment h2 {
  flex-wrap: wrap;
}

.payment-reveal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: -4px -4px -4px 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.payment-reveal-btn:hover {
  background: var(--bg);
  color: var(--primary);
}

.payment-reveal-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.payment-reveal-icon {
  display: block;
}

.payment-reveal-icon--hide {
  display: none;
}

.payment-reveal-btn[data-revealed="true"] .payment-reveal-icon--show {
  display: none;
}

.payment-reveal-btn[data-revealed="true"] .payment-reveal-icon--hide {
  display: block;
}

.record-card--payment .payment-value--card {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.02em;
}

.record-card--payment .profile-field-input-wrap.payment-field-with-copy {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.record-card--payment .profile-field-input-wrap.payment-field-with-copy .profile-field-input {
  flex: 1;
  min-width: 0;
}

.payment-field-with-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.payment-field-with-copy .record-input {
  flex: 1;
  min-width: 0;
}

.payment-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.payment-copy-btn:hover {
  background: var(--bg);
  color: var(--primary);
}

.payment-copy-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.payment-input-copied {
  color: var(--primary) !important;
  font-weight: 500;
}

.record-card ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.record-card li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

.record-card li:last-child {
  border-bottom: none;
}

.record-card.record-card--profile li,
.record-card.record-card--payment li {
  border-bottom: none;
}

.record-card .label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.record-card .value {
  color: var(--text);
  text-align: right;
  font-weight: 500;
}

.record-card .value--danger {
  color: var(--danger);
  font-weight: 600;
}

.record-card .value--muted {
  color: var(--text-muted);
  margin: 0;
}

.record-card .value--empty {
  color: var(--text-faint);
  font-style: italic;
  font-weight: 400;
}

/* Editable record inputs */
.record-input {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  background: var(--field-bg);
  border: none;
  border-radius: var(--radius-sm);
  text-align: right;
  transition: background-color 0.15s ease, box-shadow 0.15s;
}

.record-input:hover,
.record-input:focus,
.record-input:focus-visible {
  background: var(--surface);
}

.record-input:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--primary);
}

.record-input::placeholder {
  color: var(--text-faint);
}

/* Grey-background inputs/textareas/selects: white on hover/focus for readability */
:where(
  .profile-field-input,
  .inventory-med-cell-input,
  .inventory-med-cell-textarea,
  .inventory-med-cell-select,
  .add-note-input,
  .new-patient-input,
  .new-patient-textarea,
  textarea.operations-task-modal-notes.record-input,
  .patient-memo-card .record-input--memo,
  .program-session-edit-table input,
  .program-session-edit-table select,
  .create-task-patient-autocomplete .add-note-input,
  .add-new-item-rail .add-note-patient-autocomplete .add-note-input,
  .add-new-item-header-strip .add-note-patient-autocomplete .add-note-input,
  .new-patient-inline-fields .profile-field-input,
  #new-patient-modal .modal-body--new-patient .profile-field-input,
  .patient-program-cost-fee-input,
  .patient-program-cost-fee-label-input,
  .patient-program-cost-discount-percent-input,
  .patient-program-cost-discount-dollar-input
):not(:disabled):is(:hover, :focus, :focus-visible) {
  background: var(--surface);
}

.record-card--profile .profile-field-input-wrap .date-selector-display:hover,
.record-card--profile .profile-field-input-wrap .date-selector-wrap:focus-within .date-selector-display {
  background: var(--surface);
}

.record-input--select {
  cursor: pointer;
  appearance: auto;
  padding-right: 1.5rem;
}

.record-input--full {
  text-align: left;
  width: 100%;
}

.record-card--list-field .record-input--block {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  text-align: left;
}

/* Combined Allergies & Conditions tile – label beside field */
.record-card--allergies-conditions .allergies-conditions-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
  font-size: 0.875rem;
}

.record-card--allergies-conditions .allergies-conditions-row:first-of-type {
  margin-top: 0;
}

.allergies-conditions-label {
  flex-shrink: 0;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 0;
}

.record-card--allergies-conditions .record-input--block {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  text-align: right;
}

.record-input--textarea {
  display: block;
  width: 100%;
  min-height: 100px;
  resize: none;
  text-align: left;
  margin-top: 0.25rem;
}

.record-card:not(.record-card--tile) li {
  align-items: center;
}

.record-dob-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.record-age {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.record-input--card {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.02em;
}

/* Allergies / alerts */
.allergies-list,
.conditions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.allergies-list li,
.conditions-list li {
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  display: inline-flex;
}

.allergies-list li {
  background: var(--danger-bg);
  color: var(--danger);
}

.conditions-list li {
  background: var(--primary-light);
  color: var(--primary);
}

.record-card .notes-block {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text);
  border: 1px solid #fde68a;
}

/* Full-width card */
.record-card--full {
  grid-column: 1 / -1;
}

/* Settings page */
.settings-card h2 {
  margin: 0 0 0.25rem 0;
}

.settings-card .value--muted {
  margin: 0;
}

.settings-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.settings-card-header-left {
  flex: 1;
  min-width: 0;
}

.settings-profile-section {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.settings-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 60px;
  height: 60px;
}

.settings-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.settings-avatar--photo {
  padding: 0;
  background: var(--border);
  border: 2px solid var(--primary);
  box-sizing: border-box;
}

.settings-avatar--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-avatar-upload-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.settings-avatar-upload-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.settings-profile-form {
  flex: 1;
  min-width: 240px;
  max-width: 360px;
}

.settings-form-row {
  margin-bottom: 1rem;
}

.settings-form-row label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}

.settings-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}

.settings-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.settings-input[readonly] {
  background: var(--bg);
  color: var(--text-muted);
  cursor: default;
}

.settings-field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.settings-readonly-value {
  margin: 0;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text);
}

.settings-form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.settings-save-status {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Patient memo (Overview): idle "+ Add memo" or expanded tile; saved state has purple stroke */
.patient-memo {
  grid-column: 1 / -1;
}

#patient-view #patient-overview-panel .patient-memo {
  width: 75%;
  max-width: 75%;
  justify-self: start;
  box-sizing: border-box;
}

.patient-memo--idle {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.patient-memo--saved .patient-memo-card {
  border: 1px solid var(--primary);
  box-sizing: border-box;
}

.record-card--memo-wrap {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.record-card--memo-editor-row {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 0.75rem;
  width: 100%;
}
.record-card--memo-editor-row .record-input--memo {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  max-width: 100%;
}
.record-card--memo-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  gap: 0;
}
.record-card--memo-meta-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  margin-top: 0.5rem;
  text-align: right;
}
.record-card--memo-meta-ts {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.3;
}
.record-card--memo-meta-by {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.3;
}
.record-card--memo-meta-line {
  display: inline-block;
  width: 1px;
  height: 0.85em;
  background: var(--border);
  flex-shrink: 0;
}
.record-card--memo-actions {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  flex-shrink: 0;
  gap: 0.5rem;
  padding-top: 0.125rem;
}
.patient-memo-card .record-input--memo {
  display: block;
  width: 100%;
  min-height: 5rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--text);
  resize: none;
  box-sizing: border-box;
  text-align: left;
  box-shadow: none;
}
.patient-memo-card .record-input--memo:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.patient-memo-card .record-input--memo::placeholder {
  color: var(--text-muted);
}

/* Plan section header: title + circular add — same vertical center as .btn (min-height 2rem) */
.record-card--plan > h2 {
  align-items: center;
  min-height: 2rem;
}
.record-card--plan > h2 .plan-card-heading-text {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  line-height: 1.25;
}

/* Plan section table */
.record-card--plan .plan-empty,
.record-card--plan-timeline .plan-empty,
.record-card--workflow .plan-empty {
  margin: 0;
  padding: 0.5rem 0;
}

.workflow-status-cell-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status-completed-at {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Status dropdown color tinting */
tr[data-status="Backlog"] .workflow-status-trigger,
tr[data-status="Backlog"] .workflow-status-select,
.plan-timeline-status--backlog .workflow-status-trigger,
.plan-timeline-status--backlog .plan-timeline-status-select {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

tr[data-status="On Hold"] .workflow-status-trigger,
tr[data-status="On Hold"] .workflow-status-select,
.plan-timeline-status--on-hold .workflow-status-trigger,
.plan-timeline-status--on-hold .plan-timeline-status-select {
  background: #ffedd5;
  border-color: #fdba74;
}

tr[data-status="Todo"] .workflow-status-trigger,
tr[data-status="Todo"] .workflow-status-select,
tr[data-status="To do"] .workflow-status-trigger,
tr[data-status="To do"] .workflow-status-select,
.plan-timeline-status--to-do .workflow-status-trigger,
.plan-timeline-status--to-do .plan-timeline-status-select {
  background: #f3f4f6;
  border-color: #d1d5db;
}

tr[data-status="In Progress"] .workflow-status-trigger,
tr[data-status="In Progress"] .workflow-status-select,
.plan-timeline-status--in-progress .workflow-status-trigger,
.plan-timeline-status--in-progress .plan-timeline-status-select {
  background: #f5e6d3;
  border-color: #d4a574;
}

tr[data-status="Completed"] .workflow-status-trigger,
tr[data-status="Completed"] .workflow-status-select,
.plan-timeline-status--completed .workflow-status-trigger,
.plan-timeline-status--completed .plan-timeline-status-select {
  background: #dcfce7;
  border-color: #86efac;
}

tr[data-status="Canceled"] .workflow-status-trigger,
tr[data-status="Canceled"] .workflow-status-select,
.plan-timeline-status--canceled .workflow-status-trigger,
.plan-timeline-status--canceled .plan-timeline-status-select {
  background: #f3f4f6;
  border-color: #9ca3af;
}

tr[data-status="Overdue"] .workflow-status-trigger,
tr[data-status="Overdue"] .workflow-status-select,
.plan-timeline-status--overdue .workflow-status-trigger,
.plan-timeline-status--overdue .plan-timeline-status-select {
  background: #fee2e2;
  border-color: #fca5a5;
}

.plan-table .plan-table-select,
.plan-payment-select {
  height: var(--workflow-control-height);
  padding: 0 var(--workflow-control-padding-x);
  font: inherit;
  font-size: var(--workflow-control-font-size);
  border: 1px solid var(--border);
  border-radius: var(--workflow-control-radius);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
  cursor: pointer;
  box-sizing: border-box;
}

.record-card--workflow h2 {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.workflow-btns {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.patient-wf-new-group-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.patient-wf-new-group-popover {
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.35rem;
  min-width: 11rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.patient-wf-new-group-popover[hidden] {
  display: none !important;
}

.patient-wf-new-group-pathway-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.65rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.patient-wf-new-group-pathway-opt:hover {
  background: var(--bg, #f0f2f5);
}

.patient-wf-new-group-pathway-opt--custom {
  margin-top: 0.15rem;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  color: var(--text-muted);
}

.patient-wf-new-group-empty {
  padding: 0.45rem 0.65rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Patient Program pathway panel (mirrors Workflow category tree patterns) */
#patient-view #patient-overview-panel .patient-programs-panel {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.patient-programs-panel--flat {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

/* Patient Progress history list */
.patient-progress-panel--flat {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

#patient-view #patient-progress-panel .patient-progress-panel .workflow-card-title-row,
#patient-view #patient-progress-panel .patient-progress-panel .patient-wf-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: calc(0.5rem + 10px);
}

#patient-view #patient-progress-panel .patient-progress-panel .workflow-card-title-row h2 {
  margin: 0;
  padding: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #000;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  align-self: center;
  line-height: 1.25;
  min-height: 2rem;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-width: 8rem;
}

.patient-progress-title-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 0.65rem;
  margin-left: auto;
  flex: 1 1 auto;
  min-width: 0;
}

.patient-progress-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0;
}

#patient-view #patient-progress-panel .patient-progress-panel .patient-wf-title-toolbar .workflow-btns {
  margin-left: 0;
}

#patient-view #patient-progress-panel .workflow-notes-search-wrap input {
  max-width: 14rem;
}

.progress-type-multiselect-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.4rem 0.5rem 0.5rem;
  border-top: 1px solid var(--border);
}

.progress-type-clear-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.progress-type-clear-btn:hover:not(:disabled) {
  color: var(--text);
  background: var(--field-bg, #f1f5f9);
}

.progress-type-clear-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.progress-type-filter-empty {
  display: block;
  padding: 0.55rem 0.65rem;
  font-size: 0.8125rem;
  color: var(--text-faint);
  font-style: italic;
}

.progress-type-multiselect .progress-type-option-btn.is-selected {
  font-weight: 500;
}

#patient-view #patient-progress-panel .progress-history-table-wrap {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

#patient-view #patient-progress-panel .progress-history-table {
  --patient-wf-tree-inset: 12px;
  --patient-wf-tree-marker: 1.125rem;
  --patient-wf-tree-text-gap: 0.15rem;
  --patient-wf-header-title-count-gap: 0.5rem;
  --patient-wf-thread-arm: 24px;
  --patient-wf-tree-line-x: calc(var(--patient-wf-tree-inset) + var(--patient-wf-tree-marker) / 2);
  --patient-wf-thread-task-padding-y: 0.35rem;
  --patient-wf-thread-bridge: calc(var(--patient-wf-thread-task-padding-y) + 0.3rem);
  --patient-wf-thread-seam-overlap: 1px;
  --patient-wf-thread-curve-offset: 4px;
  --patient-wf-thread-branch-half: 8px;
  --patient-wf-thread-bullet-gap: 5px;
  --patient-wf-category-block-gap: 2rem;
  --patient-wf-category-block-spacer-height: calc(var(--patient-wf-category-block-gap) * 0.5);
  --patient-wf-dot-size: 10px;
  --patient-wf-status-bullet-size: 0.625rem;
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  background: transparent;
  overflow-x: hidden;
  overflow-y: visible;
}

#patient-view #patient-progress-panel .progress-history-table th,
#patient-view #patient-progress-panel .progress-history-table td {
  border: 0 !important;
}

#patient-view #patient-progress-panel .progress-history-subcategory-header-row td {
  padding: 0;
  border: 0 !important;
  background: transparent !important;
}

#patient-view #patient-progress-panel .progress-history-subcategory-header-row .patient-wf-subcategory-header-cell {
  padding-top: 0.35rem;
  padding-bottom: 0.15rem;
}

#patient-view #patient-progress-panel .progress-history-subcategory-header-row:first-child .patient-wf-subcategory-header-cell {
  padding-top: 0;
}

#patient-view #patient-progress-panel .progress-history-table tbody tr.patient-wf-task-row--under-subcategory {
  overflow: visible;
}

#patient-view #patient-progress-panel .progress-history-td-main {
  overflow: visible;
  vertical-align: middle;
  position: relative;
  padding-top: var(--patient-wf-thread-task-padding-y);
  padding-bottom: var(--patient-wf-thread-task-padding-y);
}

#patient-view #patient-progress-panel .progress-history-row-inner {
  width: 100%;
  min-width: 0;
}

#patient-view #patient-progress-panel .progress-history-task-main {
  cursor: default;
}

#patient-view #patient-progress-panel .progress-history-task-main .patient-wf-meta-cells--task-left {
  gap: 0.35rem;
}

#patient-view #patient-progress-panel .progress-history-group-spacer-row td {
  padding: 0;
  border: 0 !important;
  height: var(--patient-wf-category-block-spacer-height);
}

#patient-view #patient-progress-panel .progress-history-table td {
  background: transparent;
  vertical-align: middle;
  padding: 0.55rem 0.65rem;
  font-size: 0.875rem;
}

#patient-view #patient-progress-panel .progress-history-td-main {
  padding-top: var(--patient-wf-thread-task-padding-y);
  padding-bottom: var(--patient-wf-thread-task-padding-y);
  padding-right: 2px !important;
}

#patient-view #patient-progress-panel .progress-history-actions-cell {
  width: 2.75rem;
  text-align: right;
}

.progress-history-empty {
  padding: 1.25rem 0.65rem !important;
  color: var(--text-faint);
  font-style: italic;
}

.progress-history-actions-placeholder {
  display: inline-block;
  width: 1.75rem;
  height: 1.75rem;
}

.progress-history-modal[hidden] {
  display: none !important;
}

.progress-history-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.progress-history-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}

.progress-history-modal-card {
  position: relative;
  z-index: 1;
  width: min(24rem, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  padding: 1.25rem 1.35rem;
}

.progress-history-modal-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}

.progress-history-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.progress-history-input {
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field-bg, var(--surface));
}

.progress-history-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Progress page — timeline / calendar / trends */
.progress-header-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.progress-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 0.65rem;
  margin-left: auto;
}

.progress-toolbar-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  margin-left: auto;
}

.progress-view-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: var(--field-bg, #f1f5f9);
  border: 1px solid var(--border);
}

.progress-view-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.2;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}

.progress-view-tab.is-active {
  background: #111;
  color: #fff;
}

.progress-callouts-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.progress-callouts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 1 1 auto;
}

.progress-callout {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
}

.progress-callout--info {
  background: #e8f0fe;
  color: #1e40af;
}

.progress-callout--warning {
  background: #fef3c7;
  color: #92400e;
}

.progress-callout--danger {
  background: #fee2e2;
  color: #991b1b;
}

.progress-callout-dismiss {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.1rem;
  cursor: pointer;
  opacity: 0.7;
}

.progress-callout-dismiss:hover {
  opacity: 1;
}

.progress-callout-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.progress-callout-add-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--field-bg, #f1f5f9);
}

.progress-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  margin-bottom: 0.75rem;
}

.progress-search-wrap input {
  max-width: 14rem;
}

.progress-toolbar .asap-dropdown .workflow-filter-trigger {
  font-size: 0.8125rem;
  padding: 0.4rem 0.65rem;
  min-height: 2rem;
}

.progress-filter-vitals.is-disabled .workflow-filter-trigger {
  opacity: 0.55;
  cursor: not-allowed;
}

.progress-filter-abnormal {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.progress-timeline-wrap {
  overflow: auto;
}

.progress-timeline-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.progress-timeline-col-date {
  width: 7.5rem;
}

.progress-timeline-col-item {
  width: 16%;
}

.progress-timeline-col-source {
  width: 14%;
}

/* Data column: no width — receives all remaining space */

.plan-table.progress-timeline-table th,
.plan-table.progress-timeline-table td {
  white-space: normal;
  vertical-align: middle;
  word-break: break-word;
  overflow-wrap: break-word;
}

.plan-table.progress-timeline-table th {
  white-space: nowrap;
}

.progress-timeline-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.progress-timeline-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.progress-timeline-table td.progress-timeline-data {
  min-width: 0;
}

.progress-timeline-row--abnormal {
  background: #fef2f2;
}

.progress-timeline-date {
  color: var(--text-muted);
  white-space: nowrap;
}

.progress-timeline-table th:first-child,
.progress-timeline-table td.progress-timeline-date {
  width: 7.5rem;
}

.progress-timeline-item {
  min-width: 0;
}

.progress-timeline-item-inner {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.progress-timeline-data {
  min-width: 0;
}

.progress-timeline-view-btn {
  display: inline;
  margin-left: 0.35rem;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: inherit;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}

.progress-timeline-view-btn:hover {
  color: var(--primary-hover);
}

.progress-timeline-view-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.patient-note-transcript-overlay {
  z-index: 1000;
}

.patient-note-transcript-column {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.patient-note-transcript-meta {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.patient-note-transcript-meta-label {
  font-weight: 600;
  color: var(--text);
}

.patient-note-transcript-summary,
.patient-note-transcript-body {
  padding: 0.75rem 1rem;
  overflow-y: auto;
}

.patient-note-transcript-summary {
  flex-shrink: 0;
  background: var(--field-bg);
  border-bottom: 1px solid var(--border);
}

.patient-note-transcript-summary-title,
.patient-note-transcript-body-title {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.patient-note-transcript-summary p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.patient-note-transcript-body {
  flex: 1 1 auto;
  min-height: 0;
}

.patient-note-transcript-note {
  font-size: 0.875rem;
  line-height: 1.5;
}

.patient-note-transcript-empty {
  padding: 1rem;
  color: var(--text-muted);
}

.patient-note-transcript-drawer-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.patient-note-transcript-drawer-panel > .patient-note-transcript-column {
  flex: 1 1 auto;
  min-height: 0;
}

.progress-timeline-icon {
  display: block;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  flex-shrink: 0;
}

.progress-timeline-title {
  font-weight: 500;
  min-width: 0;
  line-height: 1.35;
}

.progress-timeline-ref {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-left: 0.35rem;
}

.progress-timeline-status {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.progress-timeline-source {
  color: var(--text);
  font-size: inherit;
  min-width: 0;
}

.progress-timeline-actions {
  float: right;
}

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

/* Calendar view: fill available viewport (Google Calendar–style month grid) */
.main-content-shell > #patient-view:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
}

#patient-view.patient-view--progress-calendar .patient-view-scroll-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}

#patient-view.patient-view--progress-calendar #patient-progress-panel:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.patient-progress-panel--calendar {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.patient-progress-panel--calendar .progress-header-row,
.patient-progress-panel--calendar .progress-callouts-row,
.patient-progress-panel--calendar .progress-toolbar {
  flex-shrink: 0;
}

.patient-progress-panel--calendar .progress-view-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.progress-calendar {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.progress-calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.progress-calendar-month {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.progress-calendar-nav {
  display: flex;
  gap: 0.35rem;
}

.progress-calendar-wday {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
  background: var(--field-bg, #f8fafc);
}

.progress-calendar-wday span {
  padding: 0.45rem 0.25rem;
  border-right: 1px solid var(--border);
}

.progress-calendar-wday span:last-child {
  border-right: none;
}

.progress-calendar-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.progress-calendar-week {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.progress-calendar-week:last-child {
  border-bottom: none;
}

.progress-calendar-cell {
  min-height: 0;
  height: 100%;
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 0.35rem 0.4rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.progress-calendar-cell:last-child {
  border-right: none;
}

.progress-calendar-cell--pad {
  border-color: var(--border);
  background: var(--field-bg, #f8fafc);
}

.progress-calendar-cell--has-events {
  background: #fff;
}

.progress-calendar-daynum {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.progress-calendar-chips {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow-y: auto;
}

.progress-calendar-chip {
  display: block;
  font-size: 0.6875rem;
  line-height: 1.25;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  background: #e8f0fe;
  color: #1e3a8a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-calendar-more {
  flex-shrink: 0;
  font-size: 0.6875rem;
  color: var(--text-muted);
  padding: 0.1rem 0.3rem;
}

.progress-trends-toolbar {
  margin-bottom: 1rem;
}

.progress-trends-toolbar .asap-dropdown .workflow-filter-trigger {
  font-size: 0.8125rem;
  padding: 0.4rem 0.65rem;
  min-height: 2rem;
}

.progress-trend-filter--static .workflow-filter-trigger {
  opacity: 0.55;
  cursor: not-allowed;
}

.progress-trends-chart-card {
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.progress-trends-chart-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 1rem 1.25rem 0.5rem;
}

.progress-trends-chart-title {
  margin: 0;
  font-size: var(--font-section-title);
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.progress-trends-chart-unit {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.progress-trends-chart-wrap {
  padding: 0.25rem 0.75rem 0.5rem;
}

.progress-trends-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.progress-trends-grid-line {
  stroke: #e5e7eb;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.progress-trends-axis-line {
  stroke: #d1d5db;
  stroke-width: 1;
}

.progress-trends-area {
  pointer-events: none;
}

.progress-trends-line {
  stroke: #1a56db;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.progress-trends-dot {
  fill: #1a56db;
  stroke: #fff;
  stroke-width: 2;
}

.progress-trends-axis-label {
  font-size: var(--text-2xs);
  fill: var(--text-muted);
  font-family: inherit;
}

.progress-trends-axis-label--x {
  font-size: var(--text-2xs);
}

.progress-trends-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

.progress-trends-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.progress-trends-stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.progress-trends-stat-value {
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
}

.progress-trends-stat-meta {
  font-size: 0.75rem;
  color: #6b7280;
}

.progress-trends-empty {
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.patient-programs-panel .workflow-card-title-row,
.patient-programs-panel .patient-wf-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: calc(0.5rem + 10px);
}

.patient-programs-panel .program-plan-filter-tabs {
  flex: 0 1 auto;
}

.patient-program-title-toolbar {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
}

.patient-program-new-wrap,
.patient-program-add-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.patient-program-new-popover,
.patient-program-add-popover {
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.35rem;
  min-width: 11rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.patient-program-new-popover[hidden],
.patient-program-add-popover[hidden] {
  display: none !important;
}

.patient-program-pathway-opt,
.patient-program-add-kind-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.65rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.patient-program-pathway-opt:hover,
.patient-program-add-kind-opt:hover {
  background: var(--bg, #f0f2f5);
}

.patient-program-new-empty {
  padding: 0.45rem 0.65rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.patient-program-empty,
.patient-program-items-empty {
  margin: 0;
  padding: 0.75rem 0.5rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* Session-based program containers */
.patient-programs-panel--sessions .patient-programs-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.patient-program-container {
  border: none;
  border-radius: 8px;
  background: transparent;
  overflow: hidden;
}

.patient-program-container-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  flex-wrap: wrap;
  background: var(--border);
  border: 1px solid transparent;
  border-radius: 8px;
  box-sizing: border-box;
}

.patient-program-container:not(.patient-program-container--collapsed) .patient-program-container-header {
  border-radius: 8px 8px 0 0;
}

.patient-program-container-toggle {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.patient-program-container-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

.patient-program-container-name {
  font-weight: 600;
  font-size: var(--font-section-title);
}

.patient-program-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.patient-program-container--edit-mode .patient-program-container-header {
  outline: 1px solid var(--accent, #2563eb);
  outline-offset: -1px;
}

.patient-program-change-superseded {
  text-decoration: line-through;
  color: var(--text-muted);
}

.patient-program-change-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent, #2563eb);
  background: color-mix(in srgb, var(--accent, #2563eb) 12%, transparent);
  border-radius: 4px;
  vertical-align: middle;
}

.patient-program-session-card--removed {
  opacity: 0.85;
}

.patient-program-cost-row--superseded td {
  color: var(--text-muted);
}

.patient-program-status-popover .patient-record-status-popover-divider {
  margin: 0.25rem 0;
}

.patient-record-status-action:disabled,
.patient-program-status-action-edit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.patient-program-session-date-readonly {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.patient-program-container-body {
  padding: 0 0.75rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
}

.patient-program-status-row {
  display: flex;
  align-items: center;
  gap: 0.65rem 1rem;
  flex-shrink: 0;
}

.patient-program-checklist {
  display: flex;
  align-items: center;
  gap: 0.65rem 1rem;
}

.patient-program-checklist-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  white-space: nowrap;
}

.patient-program-checklist-item .workflow-status-bullet--task-chip {
  width: 0.75rem;
  height: 0.75rem;
}

.patient-program-status-combined .workflow-status-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: auto;
  min-width: 0;
  padding-right: 0.65rem;
}

.patient-program-status-combined .workflow-status-trigger-text {
  white-space: nowrap;
}

.workflow-status-bullet--program[data-status="Draft"],
.workflow-status-option-btn[data-value="Draft"] .workflow-status-bullet--program {
  background: transparent;
  border: 2px solid #9ca3af;
  box-sizing: border-box;
}

.workflow-status-bullet--program[data-status="Ready"],
.workflow-status-option-btn[data-value="Ready"] .workflow-status-bullet--program {
  background: transparent;
  border: 2px solid var(--primary, #2563eb);
  box-sizing: border-box;
}

.workflow-status-bullet--program[data-status="In progress"],
.workflow-status-option-btn[data-value="In progress"] .workflow-status-bullet--program {
  background: var(--success, #059669);
  border: none;
}

.workflow-status-bullet--program[data-status="Complete"],
.workflow-status-option-btn[data-value="Complete"] .workflow-status-bullet--program {
  background: var(--success, #059669);
  border: none;
  color: #fff;
}

.patient-program-container--complete .patient-program-session-edit-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.patient-program-container--collapsed .patient-program-container-body {
  display: none;
}

.patient-program-summary-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  font-size: var(--font-section-title);
}

.patient-program-summary-sessions {
  font-weight: 400;
  white-space: nowrap;
}

.patient-program-cost-toggle {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  font-size: var(--font-section-title);
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
}

.patient-program-cost-toggle i {
  color: var(--text-muted);
  font-size: var(--font-section-title);
}

.patient-program-cost-detail {
  padding: 0;
  margin: 0 0 0.75rem 0;
  background: transparent;
  border: none;
  border-radius: 0;
  font-size: var(--text-base);
  min-height: 0;
}

.patient-program-cost-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  font-size: 0.8125rem;
}

.patient-program-cost-detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border-strong);
  font-weight: 600;
  font-size: inherit;
}

.patient-program-cost-detail-footer--empty {
  border-top: none;
  margin-top: 0.25rem;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.patient-program-cost-detail-footer-start {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.patient-program-cost-detail-footer-end {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.patient-program-cost-add-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  font: inherit;
  font-size: inherit;
  font-weight: 500;
  line-height: 1.2;
  padding: 0.15rem 0.35rem;
  margin: 0;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.patient-program-cost-add-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.patient-program-cost-add-combined .patient-program-cost-add-btn.workflow-status-trigger {
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.15rem 0.35rem;
  height: auto;
  min-height: 0;
}

.patient-program-cost-add-combined .patient-program-cost-add-btn.workflow-status-trigger:hover {
  border: none;
  background: var(--bg);
  color: var(--text);
}

.patient-program-cost-table {
  width: 100%;
  table-layout: auto;
}

.patient-program-cost-col-item {
  width: auto;
}

.patient-program-cost-col-qty {
  width: 3.75rem;
}

.patient-program-cost-col-cost {
  width: 4.5rem;
}

.patient-program-cost-col-subtotal {
  width: 4.5rem;
}

.patient-program-cost-col-actions {
  width: 1.5rem;
}

.patient-program-cost-col-metrics {
  width: 0;
}

.patient-program-cost-table tbody td.patient-program-cost-table-actions,
.patient-program-cost-table tfoot td.patient-program-cost-table-actions {
  width: 1.5rem;
  min-width: 1.5rem;
  max-width: 1.5rem;
  box-sizing: border-box;
  text-align: right;
  vertical-align: middle;
  font-weight: 400;
}

.patient-program-cost-actions-col {
  width: 1.5rem;
}

.patient-program-cost-fee-input {
  width: 3.25rem;
  min-width: 3.25rem;
  max-width: 3.25rem;
  flex: 0 0 3.25rem;
  text-align: right;
  font-size: var(--workflow-control-font-size);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}

.patient-program-cost-fee-label-input {
  width: 100%;
  max-width: 100%;
  font-size: inherit;
  font-weight: inherit;
}

.patient-program-cost-table tbody tr.patient-program-cost-fee-row .patient-program-cost-amount--editable {
  text-align: right;
}

.patient-program-cost-remove-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
  cursor: pointer;
  flex-shrink: 0;
}

.patient-program-cost-remove-btn:hover {
  color: var(--danger, #dc2626);
}

.patient-program-cost-unit-prefix {
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  color: var(--text-muted);
  white-space: nowrap;
}

.patient-program-cost-discount-cell {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  font-weight: 400;
  word-break: normal;
  min-width: 0;
}

.patient-program-cost-discount-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
}

.patient-program-cost-discount-footer-row .patient-program-cost-discount-cell {
  font-weight: 400;
}

.patient-program-cost-table tfoot .patient-program-cost-table-qty,
.patient-program-cost-table tfoot .patient-program-cost-table-cost,
.patient-program-cost-table tfoot .patient-program-cost-table-subtotal,
.patient-program-cost-table tfoot .patient-program-cost-footer-totals-cell {
  text-align: right;
}

.patient-program-cost-footer-totals {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  width: 100%;
}

.patient-program-cost-footer-total {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.patient-program-cost-footer-total-label {
  font-weight: 600;
  white-space: nowrap;
}

.patient-program-cost-footer-total--original .patient-program-cost-footer-total-label,
.patient-program-cost-footer-total--original .patient-program-cost-amount {
  font-weight: 400;
}

.patient-program-cost-footer-total--original .patient-program-cost-amount {
  text-decoration: line-through;
  color: var(--text-muted);
}

.patient-program-cost-footer-total--new .patient-program-cost-footer-total-label,
.patient-program-cost-footer-total--new .patient-program-cost-amount {
  font-weight: 600;
}

.patient-program-cost-table tfoot .patient-program-cost-footer-totals-cell--original {
  font-weight: 400;
}

.patient-program-cost-table tfoot .patient-program-cost-footer-totals-cell--new {
  font-weight: 600;
}

.patient-program-cost-footer-totals-cell {
  text-align: right;
}

.patient-program-cost-discount-label {
  font-weight: 400;
  min-width: 4.5rem;
}

.patient-program-cost-discount-type {
  font: inherit;
  font-size: inherit;
  font-weight: 400;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field-bg, var(--surface));
}

.patient-program-cost-discount-value-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}

.patient-program-cost-discount-percent-input {
  width: 2.5rem;
  min-width: 2.5rem;
  max-width: 2.5rem;
  text-align: center;
  font-size: var(--workflow-control-font-size);
}

.patient-program-cost-discount-dollar-input {
  width: 4.5rem;
  min-width: 4.5rem;
  max-width: 4.5rem;
  text-align: right;
  font-size: var(--workflow-control-font-size);
}

.patient-program-cost-detail-per-session {
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.patient-program-sessions-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 960px) {
  .patient-program-sessions-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .patient-program-sessions-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

.patient-program-session-card {
  min-height: 11.5rem;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
  display: flex;
  flex-direction: column;
}

.patient-program-session-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0;
}

.patient-program-session-card-divider {
  display: block;
  width: auto;
  height: 0;
  margin: 0.5rem -0.75rem 0.65rem;
  border: none;
  border-top: 1px solid var(--border);
}

.patient-program-session-card-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

.patient-program-session-card-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.patient-program-session-label {
  font-weight: 600;
  font-size: var(--font-section-title);
  white-space: nowrap;
}

.patient-program-session-date {
  font-size: 0.8125rem;
  min-width: 0;
}

.patient-program-session-edit-btn {
  flex-shrink: 0;
}

.patient-program-session-card--add {
  appearance: none;
  font: inherit;
  cursor: pointer;
  border-style: dashed;
  background: var(--field-bg, #f8fafc);
  color: var(--text-muted);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.patient-program-session-card--add:hover {
  border-color: var(--primary, #2563eb);
  color: var(--primary, #2563eb);
  background: color-mix(in srgb, var(--primary, #2563eb) 6%, white);
}

.patient-program-add-session-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: 100%;
  min-height: 9.5rem;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 500;
}

.patient-program-add-session-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--bg);
  font-size: 1rem;
}

.patient-program-session-items-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.patient-program-session-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}

.patient-program-session-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.patient-program-session-item:first-child {
  padding-top: 0;
}

.patient-program-session-item-name {
  flex: 1 1 0;
  min-width: 0;
  font-weight: 500;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.patient-program-session-item-dosage,
.patient-program-session-item-frequency {
  flex: 0 0 auto;
  white-space: nowrap;
  text-align: right;
}

.patient-program-session-empty {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Program create modal (2-step wizard) */
.modal-dialog--program-create {
  max-width: 48rem;
  width: min(48rem, calc(100vw - 2rem));
}

.modal-header--program-create {
  display: flex;
  align-items: center;
  padding-right: 1.25rem;
}

.program-create-header-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
}

.modal-header--program-create .modal-title {
  margin: 0;
  min-width: 0;
}

.modal-body--program-create {
  display: flex;
  flex-direction: column;
}

.modal-dialog--program-create.program-create-modal--height-locked .modal-body--program-create {
  flex: 1 1 auto;
  min-height: 0;
}

.program-create-step {
  flex: 1 1 auto;
  min-height: 0;
}

.modal-header--program-session-edit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-right: 1.25rem;
}

.modal-header--program-session-edit .modal-title {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.program-session-edit-header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
  margin-left: auto;
}

.program-session-edit-edited-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
}

.program-session-edit-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.program-session-edit-nav-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.program-session-edit-nav-btn:hover:not(:disabled) {
  border-color: var(--primary, #2563eb);
  color: var(--primary, #2563eb);
  background: color-mix(in srgb, var(--primary, #2563eb) 6%, white);
}

.program-session-edit-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.modal-footer--program-create,
.modal-footer--program-session-edit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-footer--program-create .modal-footer-start,
.modal-footer--program-session-edit .modal-footer-start {
  margin-right: auto;
}

.modal-footer--program-create .modal-footer-end,
.modal-footer--program-session-edit .modal-footer-end {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.program-create-pathway-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.75rem;
}

.program-create-pathway-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.5rem;
  min-height: 7.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 1rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.program-create-pathway-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--field-bg, #f1f5f9);
  color: var(--text-muted);
  font-size: 1.35rem;
}

.program-create-pathway-name {
  display: block;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
}

.program-create-pathway-description {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: left;
}

.program-create-pathway-card:hover,
.program-create-session-opt:hover,
.program-create-pathway-card.is-selected,
.program-create-session-opt.is-selected {
  border-color: var(--primary, #2563eb);
  background: var(--field-bg, #eff6ff);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary, #2563eb) 12%, transparent);
}

.program-create-pathway-card.is-selected .program-create-pathway-icon {
  background: color-mix(in srgb, var(--primary, #2563eb) 12%, white);
  color: var(--primary, #2563eb);
}

.program-create-session-opt {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 1rem;
  font: inherit;
  font-size: 0.875rem;
  text-align: center;
  cursor: pointer;
}

.program-create-back-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.125rem;
  line-height: 1;
  padding: 0;
  margin: 0;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.program-create-back-btn:hover {
  color: var(--text);
  background: var(--field-bg, #f1f5f9);
}

.program-create-back-btn[hidden] {
  display: none;
}

.program-create-sessions-heading {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
}

.program-create-session-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.program-create-session-opt-title {
  display: block;
  font-weight: 600;
}

.program-create-session-opt-sub {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.modal-footer--program-create .btn--primary[hidden],
.modal-footer--program-session-edit .btn--primary[hidden] {
  display: none;
}

/* Session edit modal */
.modal-dialog--program-session-edit {
  max-width: 72rem;
  width: min(72rem, calc(100vw - 2rem));
}

.modal-body--program-session-edit {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.program-session-edit-table-wrap {
  overflow-x: auto;
  margin-top: 0;
}

.program-session-edit-table.plan-table {
  width: 100%;
  table-layout: fixed;
  min-width: 36rem;
}

.program-session-edit-table.plan-table thead th {
  background: var(--bg);
  box-shadow: 0 1px 0 var(--border);
}

.program-session-edit-table.plan-table tbody td {
  vertical-align: middle;
}

.program-session-edit-table select,
.program-session-edit-table input {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: inherit;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  transition: background-color 0.15s ease;
}

.program-session-edit-table input[readonly] {
  background: var(--field-bg, #f8fafc);
  color: var(--text-muted);
}

.program-session-edit-actions-col {
  width: 2.5rem;
}

.program-session-edit-actions-cell {
  text-align: center;
  white-space: nowrap;
}

.program-session-edit-row-actions-combined {
  display: inline-flex;
  justify-content: center;
  vertical-align: middle;
}

.program-session-edit-add-row-btn {
  align-self: flex-start;
}

.program-session-edit-table.progress-timeline-table th.program-session-edit-expand-col,
.program-session-edit-table.progress-timeline-table td.program-session-edit-expand-cell {
  width: 1.5rem;
  max-width: 1.5rem;
  text-align: center;
  vertical-align: middle;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  padding-left: 0.35rem;
  padding-right: 0;
}

.program-session-edit-row-toggle {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0.15rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.program-session-edit-row-toggle:hover {
  color: var(--text);
}

.program-session-edit-table.progress-timeline-table th.program-session-edit-item-col,
.program-session-edit-table.progress-timeline-table td.program-session-edit-item-cell {
  text-align: left;
  min-width: 0;
  width: 100%;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  padding-left: 0.25rem;
  padding-right: 0.75rem;
}

.program-session-edit-dosage-col,
.program-session-edit-dosage-cell {
  width: 9rem;
  min-width: 9rem;
  max-width: 9rem;
  white-space: nowrap;
  text-align: right;
}

.program-session-edit-table.progress-timeline-table th.program-session-edit-dosage-col,
.program-session-edit-table.progress-timeline-table td.program-session-edit-dosage-cell {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  padding-left: 0.5rem;
  padding-right: 0.65rem;
}

.program-session-edit-frequency-col,
.program-session-edit-frequency-cell {
  width: 10rem;
  min-width: 10rem;
  max-width: 10rem;
  white-space: nowrap;
  text-align: right;
}

.program-session-edit-table.progress-timeline-table th.program-session-edit-frequency-col,
.program-session-edit-table.progress-timeline-table td.program-session-edit-frequency-cell {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  padding-left: 0.5rem;
  padding-right: 0.65rem;
}

.program-session-edit-dosage-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  width: 100%;
}

.program-session-edit-dosage-wrap .program-session-edit-patient-dosage {
  width: 4.5rem;
  flex: 0 0 auto;
}

.program-session-edit-dose-units {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.program-session-edit-dose-units--empty {
  color: var(--text-muted);
}

.program-session-edit-catalog-combined,
.program-session-edit-frequency-combined {
  display: inline-block;
  width: auto;
  max-width: 100%;
  vertical-align: middle;
}

.program-session-edit-catalog-trigger,
.program-session-edit-frequency-trigger {
  width: auto;
  max-width: 100%;
  text-align: left;
  white-space: nowrap;
}

.program-session-edit-frequency-cell .program-session-edit-frequency-trigger {
  text-align: right;
}

.program-session-edit-detail-row .program-session-edit-detail-cell {
  background: color-mix(in srgb, var(--bg) 88%, var(--surface));
  border-bottom: 1px solid var(--border);
  padding: 1.35rem 1.35rem 1.5rem;
  white-space: normal;
}

.program-session-edit-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.35rem 2rem;
  margin: 0;
  padding: 0.35rem 0.75rem;
}

@media (max-width: 720px) {
  .program-session-edit-detail-grid {
    grid-template-columns: 1fr;
  }
}

.program-session-edit-detail-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.program-session-edit-detail-body {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.program-session-edit-table tbody tr.program-session-edit-detail-row td {
  padding: 0;
}

#program-session-edit-modal .workflow-status-popover,
#program-session-edit-modal .workflow-assignee-popover,
#program-session-edit-modal .program-session-edit-row-popover {
  z-index: 1300;
}

.patient-program-cost-table thead th,
.patient-program-materials-table thead th {
  background: var(--bg);
  box-shadow: 0 1px 0 var(--border);
}

#patient-view .patient-view-scroll-body .patient-program-cost-table thead th,
#patient-view .patient-view-scroll-body .patient-program-materials-table thead th {
  position: static;
  background: var(--bg);
  box-shadow: 0 1px 0 var(--border);
}

.patient-program-cost-table thead th:first-child,
.patient-program-materials-table thead th:first-child,
.patient-program-cost-table .patient-program-cost-table-item,
.patient-program-materials-table .patient-program-materials-table-item {
  text-align: left;
}

/* Tighter numeric columns — must beat #patient-overview-panel .plan-table { padding: 0.75rem 1rem } */
#patient-view #patient-overview-panel .patient-program-cost-table.plan-table th,
#patient-view #patient-overview-panel .patient-program-cost-table.plan-table td,
#patient-view #patient-overview-panel .patient-program-materials-table.plan-table th,
#patient-view #patient-overview-panel .patient-program-materials-table.plan-table td {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

#patient-view #patient-overview-panel .patient-program-cost-table .patient-program-cost-table-item,
#patient-view #patient-overview-panel .patient-program-materials-table .patient-program-materials-table-item {
  padding-left: 0.65rem;
  padding-right: 0.35rem;
}

#patient-view #patient-overview-panel .patient-program-cost-table th.patient-program-cost-table-qty,
#patient-view #patient-overview-panel .patient-program-cost-table td.patient-program-cost-table-qty,
#patient-view #patient-overview-panel .patient-program-cost-table th.patient-program-cost-table-cost,
#patient-view #patient-overview-panel .patient-program-cost-table td.patient-program-cost-table-cost,
#patient-view #patient-overview-panel .patient-program-cost-table th.patient-program-cost-table-subtotal,
#patient-view #patient-overview-panel .patient-program-cost-table td.patient-program-cost-table-subtotal,
#patient-view #patient-overview-panel .patient-program-materials-table th.patient-program-materials-table-status,
#patient-view #patient-overview-panel .patient-program-materials-table td.patient-program-materials-table-status,
#patient-view #patient-overview-panel .patient-program-materials-table th.patient-program-materials-table-date,
#patient-view #patient-overview-panel .patient-program-materials-table td.patient-program-materials-table-date {
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
  padding-left: 0.15rem;
  padding-right: 0.15rem;
}

#patient-view #patient-overview-panel .patient-program-cost-table th.patient-program-cost-table-qty,
#patient-view #patient-overview-panel .patient-program-cost-table td.patient-program-cost-table-qty {
  width: 3.75rem;
  min-width: 3.75rem;
  max-width: 3.75rem;
  padding-right: 0.1rem;
}

#patient-view #patient-overview-panel .patient-program-cost-table th.patient-program-cost-table-cost,
#patient-view #patient-overview-panel .patient-program-cost-table td.patient-program-cost-table-cost,
#patient-view #patient-overview-panel .patient-program-cost-table th.patient-program-cost-table-subtotal,
#patient-view #patient-overview-panel .patient-program-cost-table td.patient-program-cost-table-subtotal {
  width: 4.5rem;
  min-width: 4.5rem;
  max-width: 4.5rem;
}

#patient-view #patient-overview-panel .patient-program-cost-table th.patient-program-cost-actions-col,
#patient-view #patient-overview-panel .patient-program-cost-table td.patient-program-cost-table-actions {
  width: 1.5rem;
  min-width: 1.5rem;
  max-width: 1.5rem;
  padding-left: 0.05rem;
  padding-right: 0.15rem;
}

#patient-view #patient-overview-panel .patient-program-materials-table th.patient-program-materials-table-status,
#patient-view #patient-overview-panel .patient-program-materials-table td.patient-program-materials-table-status {
  width: 5rem;
  min-width: 5rem;
  max-width: 5rem;
  padding-right: 0.1rem;
}

#patient-view #patient-overview-panel .patient-program-materials-table th.patient-program-materials-table-date,
#patient-view #patient-overview-panel .patient-program-materials-table td.patient-program-materials-table-date {
  width: 5.75rem;
  min-width: 5.75rem;
  max-width: 5.75rem;
  padding-left: 0.1rem;
}

#patient-view #patient-overview-panel .patient-program-cost-table col.patient-program-cost-col-qty {
  width: 3.75rem;
}

#patient-view #patient-overview-panel .patient-program-cost-table col.patient-program-cost-col-cost,
#patient-view #patient-overview-panel .patient-program-cost-table col.patient-program-cost-col-subtotal {
  width: 4.5rem;
}

#patient-view #patient-overview-panel .patient-program-cost-table col.patient-program-cost-col-actions {
  width: 1.5rem;
}

#patient-view #patient-overview-panel .patient-program-materials-table col.patient-program-materials-col-status {
  width: 5rem;
}

#patient-view #patient-overview-panel .patient-program-materials-table col.patient-program-materials-col-date {
  width: 5.75rem;
}

.patient-program-cost-table th.patient-program-cost-table-qty,
.patient-program-cost-table td.patient-program-cost-table-qty,
.patient-program-cost-table th.patient-program-cost-table-cost,
.patient-program-cost-table td.patient-program-cost-table-cost,
.patient-program-cost-table th.patient-program-cost-table-subtotal,
.patient-program-cost-table td.patient-program-cost-table-subtotal,
.patient-program-materials-table th.patient-program-materials-table-status,
.patient-program-materials-table td.patient-program-materials-table-status,
.patient-program-materials-table th.patient-program-materials-table-date,
.patient-program-materials-table td.patient-program-materials-table-date {
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

.patient-program-cost-table th.patient-program-cost-table-qty,
.patient-program-cost-table td.patient-program-cost-table-qty {
  width: 3.75rem;
  min-width: 3.75rem;
  max-width: 3.75rem;
}

.patient-program-cost-table th.patient-program-cost-table-cost,
.patient-program-cost-table td.patient-program-cost-table-cost,
.patient-program-cost-table th.patient-program-cost-table-subtotal,
.patient-program-cost-table td.patient-program-cost-table-subtotal {
  width: 4.5rem;
  min-width: 4.5rem;
  max-width: 4.5rem;
}

.patient-program-materials-table th.patient-program-materials-table-status,
.patient-program-materials-table td.patient-program-materials-table-status {
  width: 5rem;
  min-width: 5rem;
  max-width: 5rem;
}

.patient-program-materials-table th.patient-program-materials-table-date,
.patient-program-materials-table td.patient-program-materials-table-date {
  width: 5.75rem;
  min-width: 5.75rem;
  max-width: 5.75rem;
}

.patient-program-cost-table tbody td {
  vertical-align: middle;
}

.patient-program-cost-table tbody tr:last-child td {
  border-bottom: 1px solid var(--border);
}

.patient-program-cost-table tbody tr.patient-program-cost-fee-row td {
  vertical-align: middle;
}

.patient-program-cost-table:has(tfoot) tbody tr:last-child td {
  border-bottom: 1px solid var(--border);
}

.patient-program-cost-table tfoot td {
  vertical-align: middle;
  font-weight: 600;
  border-bottom: none;
}

#patient-view #patient-overview-panel .patient-program-cost-table tfoot td.patient-program-cost-table-qty,
#patient-view #patient-overview-panel .patient-program-cost-table tfoot td.patient-program-cost-table-cost,
#patient-view #patient-overview-panel .patient-program-cost-table tfoot td.patient-program-cost-table-subtotal,
#patient-view #patient-overview-panel .patient-program-cost-table tfoot td.patient-program-cost-table-actions,
#patient-view #patient-overview-panel .patient-program-cost-table tfoot td.patient-program-cost-footer-totals-cell {
  padding-left: 0.15rem;
  padding-right: 0.15rem;
}

#patient-view #patient-overview-panel .patient-program-cost-table tfoot td.patient-program-cost-footer-add {
  padding-left: 0.65rem;
  padding-right: 0.35rem;
}

.patient-program-cost-table tfoot .patient-program-cost-footer-row td,
.patient-program-cost-table tfoot .patient-program-cost-footer-row--highlight td,
.patient-program-cost-table tfoot .patient-program-cost-discount-footer-row td {
  border-top: none;
}

.patient-program-cost-table tfoot .patient-program-cost-footer-row td,
.patient-program-cost-table tfoot .patient-program-cost-footer-row--highlight td {
  background: var(--bg);
  border-top: none;
  border-bottom: none;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.patient-program-cost-table tfoot .patient-program-cost-discount-footer-row td {
  background: var(--bg);
  border-top: none;
  border-bottom: none;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
  font-weight: 400;
  vertical-align: middle;
}

.patient-program-cost-table tfoot .patient-program-cost-discount-footer-row .patient-program-cost-footer-totals-cell {
  vertical-align: middle;
}

.patient-program-cost-table tfoot .patient-program-cost-footer-add {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
  font-weight: 500;
}

.patient-program-materials-summary-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  font-size: var(--font-section-title);
}

.patient-program-materials-toggle {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  font-size: var(--font-section-title);
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
}

.patient-program-materials-toggle i {
  color: var(--text-muted);
  font-size: var(--font-section-title);
}

.patient-program-materials-detail {
  padding: 0;
  margin: 0 0 0.75rem 0;
  background: transparent;
  border: none;
  border-radius: 0;
  font-size: var(--text-base);
  min-height: 0;
}

.patient-program-materials-table {
  width: 100%;
  table-layout: auto;
}

.patient-program-materials-col-item {
  width: auto;
}

.patient-program-materials-row {
  cursor: pointer;
}

.patient-program-materials-row:hover {
  background: color-mix(in srgb, var(--border) 35%, transparent);
}

.patient-program-materials-row:focus-visible {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: -2px;
}

.patient-program-material-name {
  display: block;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  min-width: 0;
}

.patient-program-material-item-meta {
  display: block;
  margin-top: 0.15rem;
  font: inherit;
  font-weight: 400;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.patient-program-materials-col-status {
  width: 5rem;
}

.patient-program-materials-col-date {
  width: 5.75rem;
}

.patient-program-materials-col-metrics {
  width: 0;
}

.patient-program-table-item-inner {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
}

.patient-program-table-item-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--text-muted);
}

.patient-program-table-item-text {
  flex: 1 1 auto;
  min-width: 0;
}

.patient-program-cost-fee-field {
  display: block;
  min-width: 0;
}

.patient-program-cost-fee-field--cost {
  text-align: right;
}

.patient-program-cost-fee-field-display {
  cursor: text;
  font: inherit;
  font-weight: inherit;
  color: inherit;
  text-align: inherit;
  border-radius: var(--radius-sm, 4px);
}

.patient-program-cost-fee-field-display:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.patient-program-cost-fee-field--cost .patient-program-cost-fee-field-display {
  display: block;
  text-align: right;
}

.patient-program-cost-fee-field:not(.is-editing) .patient-program-cost-amount--editable,
.patient-program-cost-fee-field:not(.is-editing) .patient-program-cost-fee-label-input,
.patient-program-cost-fee-field:not(.is-editing) .patient-program-cost-fee-input {
  display: none !important;
}

.patient-program-cost-fee-field.is-editing .patient-program-cost-fee-field-display {
  display: none !important;
}

.patient-program-cost-fee-field.is-editing .patient-program-cost-amount--editable {
  display: block;
}

.patient-program-cost-fee-field.is-editing .patient-program-cost-fee-label-input {
  display: block;
  width: 100%;
}

.patient-program-materials-table-item {
  min-width: 0;
  text-align: left;
  width: auto;
}

.patient-program-material-status-label {
  display: block;
  font: inherit;
  font-weight: 400;
  color: var(--text);
  text-align: right;
}

.patient-program-materials-table-date {
  color: var(--text-muted);
  text-align: right;
}

.patient-program-materials-empty {
  margin: 0.35rem 0;
}

.manage-programs-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 1.5rem;
}

.manage-program-card {
  padding: 1rem 1.15rem;
}

.manage-program-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.manage-program-name-input {
  font-size: 1.0625rem;
  font-weight: 600;
}

.manage-program-description-input {
  min-height: 3.5rem;
  resize: vertical;
}

.manage-program-materials-section {
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
}

.manage-program-materials-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.manage-program-materials-heading {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.manage-program-materials-table td {
  vertical-align: middle;
}

.manage-program-material-preview {
  color: var(--text-muted);
  font-size: 0.8125rem;
  max-width: 28rem;
}

.manage-program-material-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.btn--sm {
  padding: 0.25rem 0.55rem;
  font-size: var(--text-sm);
}

.modal-overlay--top {
  z-index: 1200;
}

.modal-dialog--program-material {
  width: min(48rem, calc(100vw - 2rem));
  max-width: 48rem;
  max-height: min(92vh, 56rem);
  display: flex;
  flex-direction: column;
}

.modal-header--program-material {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.modal-header--program-material .modal-title {
  flex: 1;
  min-width: 0;
  padding-right: 0.5rem;
}

.modal-body--program-material {
  padding-top: 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.modal-footer--program-material {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-footer--program-material .modal-footer-start {
  flex: 1 1 auto;
  min-width: 0;
}

.modal-footer--program-material .modal-footer-end {
  flex: 0 0 auto;
  margin-left: auto;
}

.program-material-edited-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.program-material-body-input {
  width: 100%;
  min-height: 28rem;
  flex: 1 1 auto;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.55;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}

.program-material-body-input:disabled,
.program-material-body-input[readonly] {
  background: var(--field-bg);
  color: var(--text-muted);
}

.patient-program-treatment-plan-summary-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  font-size: var(--font-section-title);
}

.patient-program-treatment-plan-toggle {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  font-size: var(--font-section-title);
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
}

.patient-program-treatment-plan-toggle i {
  color: var(--text-muted);
  font-size: var(--font-section-title);
}

.patient-program-treatment-plan-detail {
  margin-bottom: 0.75rem;
}

.patient-program-treatment-plan-detail .patient-program-sessions-list {
  padding-top: 0.15rem;
}

.patient-program-cost-table-item {
  word-break: break-word;
  text-align: left;
  width: auto;
}

.patient-program-cost-amount {
  display: block;
  text-align: right;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}

.patient-program-cost-amount .patient-program-cost-unit-prefix {
  display: inline;
}

.patient-program-cost-value {
  display: inline;
  text-align: right;
}

.patient-program-cost-amount--editable {
  text-align: right;
}

.patient-program-cost-amount--editable .patient-program-cost-fee-input {
  display: inline-block;
  width: 3.25rem;
  min-width: 3.25rem;
  max-width: 3.25rem;
  vertical-align: middle;
}

.patient-program-created {
  font-weight: 400;
  font-size: 0.8125rem; /* 1 step below .patient-wf-group-title (0.875rem) */
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 0.5rem;
  margin-right: 0.35rem;
  flex-shrink: 0;
}

#patient-view .patient-programs-panel .patient-program-table-wrap {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: visible;
}

#patient-view .patient-programs-panel .patient-program-table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  background: transparent;
}

#patient-view .patient-programs-panel .patient-program-table tbody tr.patient-program-item-row td,
#patient-view .patient-programs-panel .patient-program-table tbody tr.patient-program-items-empty-row td,
#patient-view .patient-programs-panel .patient-program-table tbody tr.patient-program-empty-row td {
  background: transparent;
  padding-top: 0.35rem !important;
  padding-bottom: 0.35rem !important;
}
#patient-view .patient-programs-panel .patient-program-table col.patient-program-col-identity {
  width: 3rem;
}
#patient-view .patient-programs-panel .patient-program-table col.patient-program-col-main {
  width: auto;
}
#patient-view .patient-programs-panel .patient-program-table col.patient-program-col-trailing {
  width: auto;
}

/* Item main row: # · dot | Date | Type | Select | pharmacy | description | dosage */
#patient-view .patient-programs-panel .patient-program-table tbody tr.patient-program-item-row td.patient-program-identity-cell {
  width: 3rem;
  min-width: 3rem;
  max-width: 3rem;
  white-space: nowrap;
  overflow: visible;
  padding-left: 0.35rem !important;
  padding-right: 0.15rem !important;
  vertical-align: middle;
}
#patient-view .patient-programs-panel .patient-program-table tbody tr.patient-program-item-row td.patient-program-main-cell {
  white-space: nowrap;
  padding-left: 0.1rem !important;
  padding-right: 0.25rem !important;
  text-align: left !important;
  overflow: visible;
}
#patient-view .patient-programs-panel .patient-program-item-main {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  min-width: 0;
}
#patient-view .patient-programs-panel .patient-program-leading-date,
#patient-view .patient-programs-panel .patient-program-leading-type,
#patient-view .patient-programs-panel .patient-program-leading-select {
  flex: 0 0 auto;
  min-width: 0;
  position: relative;
  z-index: 2;
}
#patient-view .patient-programs-panel .patient-program-detail-pharmacy,
#patient-view .patient-programs-panel .patient-program-detail-description,
#patient-view .patient-programs-panel .patient-program-dosage-wrap {
  flex: 0 0 auto;
  min-width: 0;
  position: relative;
  z-index: 1;
}
#patient-view .patient-programs-panel .patient-program-leading-type .program-item-type-combined,
#patient-view .patient-programs-panel .patient-program-leading-select .program-item-catalog-combined {
  display: inline-block;
  max-width: 100%;
  vertical-align: middle;
}
#patient-view .patient-programs-panel .patient-program-leading-select .program-item-catalog-trigger {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#patient-view .patient-programs-panel .patient-program-leading-select .patient-program-lab-select {
  width: auto;
  min-width: 8rem;
  max-width: 14rem;
}
#patient-view .patient-programs-panel .patient-program-detail-description {
  flex: 0 1 auto;
  max-width: 14rem;
}
#patient-view .patient-programs-panel .patient-program-dosage-wrap {
  flex: 0 0 auto;
  gap: 0.2rem;
  z-index: 0;
}
#patient-view .patient-programs-panel .patient-program-item-input.patient-program-dosage-input {
  display: inline-block;
  width: 2.75rem !important;
  min-width: 2.75rem !important;
  max-width: 2.75rem !important;
  flex: 0 0 2.75rem !important;
  padding: 0.2rem 0.15rem !important;
  font-variant-numeric: tabular-nums;
  text-align: center;
  box-sizing: border-box;
  position: relative;
  z-index: 0;
}
#patient-view .patient-programs-panel .patient-program-leading-date .workflow-date-combined,
#patient-view .patient-programs-panel .patient-program-leading-type .program-item-type-combined,
#patient-view .patient-programs-panel .patient-program-leading-select .program-item-catalog-combined {
  z-index: 2;
}
/* Trailing controls: Cost | Assignee | Status | ⋯ */
#patient-view .patient-programs-panel .patient-program-table tbody tr.patient-program-item-row td.patient-program-trailing-cell {
  width: 1%;
  white-space: nowrap;
  text-align: right !important;
  padding-left: 0.25rem !important;
  padding-right: 0.35rem !important;
  overflow: visible;
}
#patient-view .patient-programs-panel .patient-program-trailing-controls {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  max-width: 100%;
}
#patient-view .patient-programs-panel .patient-program-trailing-cost,
#patient-view .patient-programs-panel .patient-program-trailing-assignee,
#patient-view .patient-programs-panel .patient-program-trailing-status,
#patient-view .patient-programs-panel .patient-program-trailing-actions {
  flex: 0 0 auto;
  min-width: 0;
}
#patient-view .patient-programs-panel .patient-program-cost-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  flex: 0 0 auto;
}
#patient-view .patient-programs-panel .patient-program-item-input.patient-program-cost-input {
  display: inline-block;
  width: 3.25rem !important;
  min-width: 3.25rem !important;
  max-width: 3.25rem !important;
  flex: 0 0 3.25rem !important;
  padding: 0.2rem 0.2rem !important;
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  text-align: right;
  box-sizing: border-box;
}
#patient-view .patient-programs-panel .patient-program-cost-unit-suffix {
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  color: var(--text-muted);
  white-space: nowrap;
}
#patient-view .patient-programs-panel .workflow-date-popover,
#patient-view .patient-programs-panel .workflow-status-popover,
#patient-view .patient-programs-panel .workflow-assignee-popover,
#patient-view .patient-programs-panel .program-item-type-popover,
#patient-view .patient-programs-panel .program-item-catalog-popover {
  z-index: 1200;
}
#patient-view .patient-programs-panel .patient-program-trailing-assignee .workflow-assignee-combined,
#patient-view .patient-programs-panel .patient-program-trailing-status .workflow-status-combined {
  max-width: 100%;
}
#patient-view .patient-programs-panel .patient-program-trailing-actions .patient-program-item-menu-wrap {
  display: inline-flex;
}

.patient-program-group-header-actions {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
  margin-left: 0.35rem;
}

#patient-view .patient-programs-panel .patient-program-group-header-row td.patient-wf-group-header-cell {
  border-radius: 8px;
}

#patient-view .patient-programs-panel .patient-program-table tbody tr.patient-wf-group-header-row td {
  padding: 0 !important;
  border-bottom: none !important;
}
#patient-view .patient-programs-panel .patient-program-table tbody tr.patient-wf-group-header-row td.patient-wf-group-header-cell {
  background: var(--border);
  border: 1px solid transparent;
  padding: 0.4rem var(--patient-wf-tree-inset, 12px) !important;
  box-sizing: border-box;
}
#patient-view .patient-programs-panel .patient-program-table tbody tr.patient-wf-category-block-spacer-row td {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}
#patient-view .patient-programs-panel .patient-program-table tbody tr.patient-wf-category-block-spacer-row .patient-wf-category-block-spacer-cell {
  padding-top: var(--patient-wf-category-block-spacer-height, 1.25rem) !important;
}

.patient-program-identity-inner {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  width: max-content;
}

.patient-program-item-num {
  flex-shrink: 0;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
  user-select: none;
  min-width: 1.1rem;
  text-align: right;
}

.patient-program-status-dot-slot {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.patient-program-item-type,
.patient-program-lab-select {
  width: 100%;
  max-width: 100%;
  min-height: var(--workflow-control-height, 2rem);
  padding: 0.2rem 0.4rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--field-bg, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.patient-program-detail-pharmacy,
.patient-program-detail-description {
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.patient-program-detail-muted {
  color: var(--text-muted);
}

.patient-program-dosage-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.patient-program-dosage-wrap .patient-program-dosage-input {
  flex: 0 0 auto;
}

.patient-program-dose-units {
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  color: var(--text-muted);
  white-space: nowrap;
}

.patient-program-item-input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  padding: 0.25rem 0.35rem;
  border-radius: var(--radius-sm);
}

.patient-program-item-input.patient-program-dosage-input {
  width: 2.75rem;
  min-width: 2.75rem;
  max-width: 2.75rem;
  flex: 0 0 2.75rem;
  padding: 0.2rem 0.15rem;
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
  text-align: center;
}

.patient-program-cost-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}

.patient-program-item-input.patient-program-cost-input {
  width: 3.25rem;
  min-width: 3.25rem;
  max-width: 3.25rem;
  flex: 0 0 3.25rem;
  padding: 0.2rem 0.2rem;
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
  text-align: right;
}

.patient-program-cost-unit-suffix {
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  color: var(--text-muted);
  white-space: nowrap;
}

.patient-program-item-input:hover,
.patient-program-item-input:focus,
.patient-program-item-input:focus-visible {
  border-color: var(--border);
  background: var(--surface);
  outline: none;
}

.patient-program-item-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.patient-program-item-actions-cell,
.patient-program-trailing-actions {
  text-align: center;
  vertical-align: middle;
}

.patient-program-item-menu-wrap {
  display: inline-flex;
  justify-content: center;
}

.patient-program-menu-flyout {
  z-index: 1200;
}

/* Circular primary “+” button — Workflow / Patient Notes / Program (matches .btn min-height) */
.btn.btn--primary.workflow-add-btn--circle {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  min-height: 2rem;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 1.125rem;
  font-weight: 500;
}
.btn.btn--primary.workflow-add-btn--circle span {
  display: block;
  margin-top: -0.08em;
}

.workflow-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* Linear-style single trigger + drill-down filter menus */
.linear-filter-toolbar {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.linear-filter-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.linear-filter-open-btn:hover {
  background: var(--field-bg);
}
.linear-filter-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  min-width: 280px;
  max-width: min(360px, 92vw);
  padding: 0.5rem 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.linear-filter-dropdown-search-wrap {
  padding: 0 0.65rem 0.5rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.linear-filter-category-search {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: var(--workflow-control-font-size);
  background: var(--field-bg);
}
.linear-filter-drill {
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 420px);
}
.linear-filter-pane--root,
.linear-filter-pane--detail {
  overflow-y: auto;
  padding: 0.25rem 0;
}
.linear-filter-nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: var(--workflow-control-font-size);
  text-align: left;
  cursor: pointer;
}
.linear-filter-nav-item:hover {
  background: var(--field-bg);
}
.linear-filter-nav-icon {
  flex-shrink: 0;
  opacity: 0.85;
  font-size: 1rem;
}
.linear-filter-nav-text {
  flex: 1;
}
.linear-filter-nav-chevron {
  flex-shrink: 0;
  opacity: 0.45;
  font-size: 0.75rem;
}
.linear-filter-back-btn {
  display: block;
  margin: 0 0.65rem 0.5rem;
  padding: 0.35rem 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  cursor: pointer;
}
.linear-filter-detail-mount {
  padding: 0 0.65rem 0.65rem;
}
.linear-filter-detail-mount .workflow-assignee-search {
  margin-bottom: 0.5rem;
}
.linear-filter-detail-mount .workflow-filter-options {
  max-height: 260px;
  overflow-y: auto;
}

/* Linear toolbars: filter control first, row search second; cluster aligned to the right */
.workflow-filters.workflow-filters--linear {
  justify-content: flex-end;
  width: 100%;
}

/* Filter rows: same size as tabs; weight is normal unless tab is active */
.workflow-filters .workflow-filter-trigger {
  font-size: var(--workflow-control-font-size);
  font-weight: 400;
}

.workflow-filters .patients-kanban-status-trigger-label {
  font-weight: 400;
}

/* Patient Workflow: legacy controls on the left; linear variant clusters filter + search on the right */
.record-card--workflow .workflow-filters--patient {
  justify-content: flex-start;
}
.record-card--workflow .workflow-filters--patient.workflow-filters--linear {
  justify-content: stretch;
  width: 100%;
}
.record-card--workflow .workflow-filters--patient .workflow-notes-toolbar {
  margin-left: auto;
}
.record-card--workflow .workflow-filters--patient.workflow-filters--linear .workflow-notes-toolbar {
  margin-left: 0;
}

#patient-view .patient-wf-toolbar {
  flex-wrap: wrap;
  /* Match horizontal spacing between Tasks / Notes / Messages (0.35rem) */
  gap: 0.5rem 0.35rem;
}

#patient-view #patient-workflow-panel .record-card--workflow .patient-wf-toolbar.workflow-filters--linear {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 0;
}

.record-card--workflow .patient-wf-toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  width: 100%;
}
.record-card--workflow .patient-wf-toolbar-filters-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}
.record-card--workflow .patient-notes-count {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  flex: 0 0 auto;
  align-self: center;
  min-width: 0;
  padding-right: 0.5rem;
}
.record-card--workflow .patient-wf-group-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  min-width: 0;
  flex: 1 1 auto;
  font-size: calc(0.8125rem + 2px);
}
.record-card--workflow .patient-wf-group-crumb {
  padding: 0.15rem 0.25rem;
  margin: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.record-card--workflow .patient-wf-group-crumb:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.record-card--workflow .patient-wf-group-crumb--active {
  color: var(--text);
  font-weight: 600;
}
.record-card--workflow .patient-wf-group-crumb-sep {
  color: var(--text-muted);
  font-weight: 500;
  user-select: none;
}

/* Patient Workflow — category / subcategory blocks (match task subtype chip surface) */
#patient-view .patient-wf-table tbody tr.patient-wf-group-header-row td {
  padding: 0 !important;
  border-bottom: none !important;
}
/* Gap between categories: spacer row after last task; margin when previous category is collapsed */
#patient-view tr.patient-wf-group-header-row + tr.patient-wf-group-header-row .patient-wf-group-header-cell {
  margin-top: var(--patient-wf-category-block-gap, 2.5rem);
}
#patient-view tr.patient-wf-category-block-spacer-row + tr.patient-wf-group-header-row .patient-wf-group-header-cell {
  margin-top: 0;
}
/* Spacer gap: padding on one cell (table rows ignore height); no actions rail in this row */
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-category-block-spacer-row {
  height: 0;
  line-height: 0;
  font-size: 0;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-category-block-spacer-row td {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  vertical-align: top;
  line-height: 0 !important;
  font-size: 0 !important;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-category-block-spacer-row .patient-wf-category-block-spacer-cell {
  padding-top: var(--patient-wf-category-block-spacer-height, 1.25rem) !important;
  padding-bottom: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  height: auto !important;
}
.patient-wf-group-header-row td {
  padding: 0 !important;
  border-bottom: none !important;
}
.patient-wf-group-header-cell {
  background: var(--border);
  border: 1px solid transparent;
  border-radius: 8px 0 0 8px;
  padding: 0.4rem var(--patient-wf-tree-inset, 12px) !important;
  box-sizing: border-box;
}
#patient-view .patient-wf-table tbody tr.patient-wf-group-header-row td.patient-wf-header-actions-cell {
  background: var(--border);
  border: 1px solid transparent;
  border-radius: 0 8px 8px 0;
  padding: 0.4rem 12px !important;
  box-sizing: border-box;
}
.patient-wf-group-header-inner {
  display: flex;
  align-items: center;
  gap: var(--patient-wf-tree-text-gap, 0.15rem);
  min-height: 1.75rem;
}
/* Same width as .patient-wf-group-toggle — keeps category + subcategory titles aligned */
.patient-wf-tree-marker-slot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--patient-wf-tree-marker, 1.125rem);
  height: var(--patient-wf-tree-marker, 1.125rem);
  flex-shrink: 0;
}
/* Legacy: hide old list-details subcategory icon if present in cached markup */
.patient-wf-subcategory-icon,
.patient-wf-hierarchy-marker .patient-wf-subcategory-icon {
  display: none !important;
}
.patient-wf-group-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5rem;
  color: var(--text-muted);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.patient-wf-group-drag-handle:active {
  cursor: grabbing;
}
.patient-wf-group-drag-handle .ti {
  font-size: 1rem;
  pointer-events: none;
}
.patient-wf-group-header-row--dragging .patient-wf-group-header-cell {
  opacity: 0.5;
}
.patient-wf-group-header-row--drop-target .patient-wf-group-header-cell {
  box-shadow: inset 0 3px 0 0 var(--primary);
}
.patient-wf-group-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--patient-wf-tree-marker, 1.125rem);
  height: var(--patient-wf-tree-marker, 1.125rem);
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.patient-wf-group-toggle .ti {
  font-size: 0.875rem;
  line-height: 1;
}
.patient-wf-group-toggle:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
}
.patient-wf-group-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}
.patient-wf-group-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-left: var(--patient-wf-header-title-count-gap, 0.5rem);
}
.patient-wf-group-added {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-left: 0.35rem;
}
.patient-wf-group-header-spacer {
  flex: 1;
  min-width: 0.5rem;
}
.patient-wf-group-add-task {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  min-height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.patient-wf-group-add-task:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
}
.patient-wf-group-add-task .ti {
  font-size: 1rem;
  pointer-events: none;
}
.patient-wf-group-menu-wrap {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.patient-wf-group-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.35rem;
  font-size: 1.1rem;
  line-height: 1;
  min-height: 1.75rem;
  min-width: 1.75rem;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.patient-wf-group-menu-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.patient-wf-group-menu-flyout {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.15rem;
  width: max-content;
  min-width: 9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 30;
  padding: 0.25rem 0;
}
.patient-wf-group-menu-flyout[hidden] {
  display: none;
}
.patient-wf-group-rename-btn,
.patient-wf-group-delete-btn {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.patient-wf-group-rename-btn:hover {
  background: var(--bg);
}
.patient-wf-group-delete-btn:hover {
  background: var(--bg);
  color: var(--danger);
}
.patient-wf-group-delete-btn {
  border-top: 1px solid var(--border);
}
.patient-wf-group-add-subcategory {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted, #64748b);
  cursor: pointer;
}
.patient-wf-group-add-subcategory:hover {
  background: var(--field-bg, #f1f5f9);
  color: var(--text, #111);
}
.patient-wf-group-add-subcategory .ti {
  font-size: 1rem;
}
.patient-wf-subcategory-header-row td {
  padding: 0 !important;
  padding-bottom: 0 !important;
  background: transparent;
  border-top: none;
  border-bottom: none;
  vertical-align: middle;
}
#patient-view .patient-wf-subcategory-header-cell {
  padding: 0.15rem var(--patient-wf-tree-inset, 12px) 0 !important;
}
#patient-view .patient-wf-subcategory-header-inner {
  position: relative;
}
#patient-view .patient-wf-task-row--under-subcategory td {
  border-top: none;
}
.patient-wf-subcategory-dot {
  position: relative;
  display: block;
  width: var(--patient-wf-dot-size, 10px);
  height: var(--patient-wf-dot-size, 10px);
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--primary, #4a45a8);
  box-sizing: border-box;
}
#patient-view tr.patient-wf-group-header-row + tr.patient-wf-subcategory-header-row td,
#patient-view tr.patient-wf-group-header-row + tr.patient-wf-task-row--under-subcategory td {
  padding-top: 0.35rem !important;
}
#patient-view .patient-wf-subcategory-dot--has-thread::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(-1 * var(--patient-wf-thread-bridge) - var(--patient-wf-thread-seam-overlap));
  width: 1.15px;
  height: calc(var(--patient-wf-thread-bridge) + var(--patient-wf-thread-seam-overlap));
  transform: translateX(-50%);
  background: var(--text, #1a1d21);
  pointer-events: none;
}
.patient-wf-subcategory-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text, #111);
}
.patient-wf-subcategory-count {
  font-size: 0.8125rem;
  color: var(--text-muted, #64748b);
  margin-left: var(--patient-wf-header-title-count-gap, 0.5rem);
}
.patient-wf-subcategory-header-row--locked .patient-wf-subcategory-title,
.patient-wf-subcategory-header-row--locked .patient-wf-subcategory-count {
  color: var(--text-muted, #64748b);
}
.patient-wf-subcategory-lock-icon {
  font-size: 0.875rem;
  color: var(--text-muted, #64748b);
  margin-right: 0.15rem;
}
#patient-view .patient-wf-task-row--locked {
  opacity: 0.55;
}
#patient-view .patient-wf-task-row--locked .workflow-status-trigger,
#patient-view .patient-wf-task-row--locked .workflow-assignee-trigger,
#patient-view .patient-wf-task-row--locked .workflow-date-trigger,
#patient-view .patient-wf-task-row--locked .patient-wf-decision-option-trigger,
#patient-view .patient-wf-task-row--locked .workflow-task-trigger,
#patient-view .patient-wf-task-row--locked .workflow-row-actions-btn {
  cursor: not-allowed;
}
.patient-wf-subcategory-header-spacer {
  flex: 1 1 auto;
  min-width: 0.5rem;
}
.patient-wf-subcategory-menu-wrap {
  position: relative;
  flex-shrink: 0;
}
.patient-wf-subcategory-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.35rem;
  font-size: 1.1rem;
  line-height: 1;
  min-height: 1.75rem;
  min-width: 1.75rem;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.patient-wf-subcategory-menu-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.patient-wf-subcategory-menu-btn .workflow-row-actions-icon {
  font-size: 0.95rem;
  line-height: 1;
  pointer-events: none;
}
.patient-wf-subcategory-menu-flyout {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.15rem;
  width: max-content;
  min-width: 9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 30;
  padding: 0.25rem 0;
}
.patient-wf-subcategory-menu-flyout[hidden] {
  display: none;
}
.patient-wf-subcategory-reorder-btn,
.patient-wf-subcategory-rename-btn,
.patient-wf-subcategory-delete-btn,
.patient-wf-task-reorder-btn {
  display: block;
  width: 100%;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.patient-wf-subcategory-reorder-btn:hover:not(:disabled),
.patient-wf-subcategory-rename-btn:hover,
.patient-wf-task-reorder-btn:hover:not(:disabled) {
  background: var(--bg);
}
.patient-wf-subcategory-reorder-btn:disabled,
.patient-wf-task-reorder-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.patient-wf-subcategory-delete-btn {
  border-top: 1px solid var(--border);
}
.patient-wf-subcategory-delete-btn:hover {
  background: var(--bg);
  color: var(--danger);
}

/* Patient Workflow: fixed actions rail — subcategory | + | ⋯ aligned across row types */
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) {
  --patient-wf-actions-slot-size: 1.75rem;
  --patient-wf-actions-rail-gap: 0.15rem;
}
#patient-view .record-card--workflow .patient-wf-table .patient-wf-group-menu-btn,
#patient-view .record-card--workflow .patient-wf-table .patient-wf-subcategory-menu-btn,
#patient-view .record-card--workflow .patient-wf-table .workflow-row-actions-btn,
#patient-view .record-card--workflow .patient-wf-table .patient-wf-group-add-task,
#patient-view .record-card--workflow .patient-wf-table .patient-wf-group-add-subcategory {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--patient-wf-actions-slot-size, 1.75rem);
  height: var(--patient-wf-actions-slot-size, 1.75rem);
  min-width: var(--patient-wf-actions-slot-size, 1.75rem);
  min-height: var(--patient-wf-actions-slot-size, 1.75rem);
  padding: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}
#patient-view .record-card--workflow .patient-wf-table td.workflow-row-actions-cell {
  vertical-align: middle !important;
}
#patient-view .record-card--workflow .patient-wf-table .patient-wf-actions-rail {
  display: grid;
  grid-template-columns:
    var(--patient-wf-actions-slot-size, 1.75rem)
    var(--patient-wf-actions-slot-size, 1.75rem)
    var(--patient-wf-actions-slot-size, 1.75rem);
  column-gap: var(--patient-wf-actions-rail-gap, 0.15rem);
  justify-content: end;
  align-items: center;
  width: max-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: 0;
  overflow: visible;
}
#patient-view .record-card--workflow .patient-wf-table .patient-wf-actions-rail-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--patient-wf-actions-slot-size, 1.75rem);
  min-width: var(--patient-wf-actions-slot-size, 1.75rem);
  height: var(--patient-wf-actions-slot-size, 1.75rem);
  box-sizing: border-box;
}
#patient-view .record-card--workflow .patient-wf-table .patient-wf-actions-rail-slot--menu .workflow-row-actions-wrap,
#patient-view .record-card--workflow .patient-wf-table .patient-wf-actions-rail-slot--menu .patient-wf-group-menu-wrap,
#patient-view .record-card--workflow .patient-wf-table .patient-wf-actions-rail-slot--menu .patient-wf-subcategory-menu-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
#patient-view .record-card--workflow .patient-wf-table .patient-wf-actions-rail-placeholder {
  display: block;
  width: var(--patient-wf-actions-slot-size, 1.75rem);
  height: var(--patient-wf-actions-slot-size, 1.75rem);
  flex-shrink: 0;
}
#patient-view .record-card--workflow .patient-wf-table td.patient-wf-header-actions-cell {
  white-space: nowrap;
  overflow: visible !important;
  max-width: none !important;
}
#patient-view .record-card--workflow .patient-wf-table tbody tr.patient-wf-group-header-row td.patient-wf-header-actions-cell,
#patient-view .record-card--workflow .patient-wf-table tbody tr.patient-wf-subcategory-header-row td.patient-wf-header-actions-cell {
  overflow: visible !important;
}
#patient-view .record-card--workflow .patient-wf-table tbody tr.patient-wf-group-header-row td,
#patient-view .record-card--workflow .patient-wf-table tbody tr.patient-wf-subcategory-header-row td {
  vertical-align: middle !important;
}
#patient-view .patient-wf-subcategory-header-inner.patient-wf-group-header-inner {
  min-height: 1.75rem;
}
.patient-wf-flyout-menu-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
}

.patient-wf-flyout-move {
  padding: 0.35rem 0.5rem 0.5rem;
  margin-bottom: 0;
}

.workflow-row-actions-flyout > .workflow-row-delete {
  border-top: 1px solid var(--border);
}
.patient-wf-flyout-move-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.patient-wf-flyout-move-btns {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 12rem;
  overflow-y: auto;
}
.workflow-row-move-group-opt {
  text-align: left;
  padding: 0.35rem 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 0.8125rem;
  color: var(--text);
  cursor: pointer;
}
.workflow-row-move-group-opt:hover {
  background: var(--field-bg);
}
.workflow-row-move-group-opt.workflow-row-move-group-opt--sub {
  padding-left: 1.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.workflow-row-move-group-opt.workflow-row-move-group-opt--sub:hover {
  color: var(--text);
}
#patient-view .patient-wf-table-wrap {
  margin-top: 0.75rem;
}
#patient-view .patient-wf-table {
  width: 100%;
  table-layout: fixed;
}
#patient-view .patient-wf-table th,
#patient-view .patient-wf-table td {
  vertical-align: middle;
  padding: 0.65rem 0.5rem;
  font-size: 0.875rem;
}
/* Patient Workflow tasks: tight rows, even horizontal column gaps */
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr:not(.workflow-section-header-row) td {
  padding-top: 0.2rem !important;
  padding-bottom: 0.2rem !important;
  padding-left: 12px !important;
  padding-right: 12px !important;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row td {
  padding-top: 0.35rem !important;
  padding-bottom: 0.35rem !important;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row--under-subcategory td {
  padding-top: var(--patient-wf-thread-task-padding-y) !important;
  padding-bottom: var(--patient-wf-thread-task-padding-y) !important;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row td.patient-wf-td-task-body {
  padding-left: 12px !important;
  padding-right: 2px !important;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row--under-subcategory td.patient-wf-td-task-body {
  padding-left: 12px !important;
  padding-right: 8px !important;
}
#patient-view .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row td.workflow-row-actions-cell {
  padding-left: 4px !important;
  overflow: visible !important;
}
/* Status pill tinting on task rows (data-status on tr) */
#patient-view .patient-wf-task-row[data-status="Backlog"] .patient-wf-workflow-pills .workflow-status-trigger {
  background: #e0f2fe;
  border-color: #7dd3fc;
}
#patient-view .patient-wf-task-row[data-status="On Hold"] .patient-wf-workflow-pills .workflow-status-trigger {
  background: #f3f4f6;
  border-color: #d1d5db;
}
#patient-view .patient-wf-task-row[data-status="Todo"] .patient-wf-workflow-pills .workflow-status-trigger,
#patient-view .patient-wf-task-row[data-status="To do"] .patient-wf-workflow-pills .workflow-status-trigger {
  background: #f3f4f6;
  border-color: #d1d5db;
}
#patient-view .patient-wf-task-row[data-status="In Progress"] .patient-wf-workflow-pills .workflow-status-trigger {
  background: #fef9c3;
  border-color: #fde047;
}
#patient-view .patient-wf-task-row[data-status="Completed"] .patient-wf-workflow-pills .workflow-status-trigger {
  background: #dcfce7;
  border-color: #86efac;
}
#patient-view .patient-wf-task-row[data-status="Canceled"] .patient-wf-workflow-pills .workflow-status-trigger {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: var(--text-muted);
}
#patient-view .patient-wf-task-row[data-status="Overdue"] .patient-wf-workflow-pills .workflow-status-trigger {
  background: #fee2e2;
  border-color: #fca5a5;
}
#patient-view .patient-wf-table .patient-wf-td-meta--task,
#patient-view .patient-wf-table .patient-wf-td-body,
#patient-view .patient-wf-table .patient-wf-td-main--task {
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
#patient-view .patient-wf-table tbody tr.patient-wf-note-row .patient-wf-td-body,
#patient-view .patient-wf-table tbody tr.patient-wf-message-row .patient-wf-td-body,
#patient-view .patient-wf-table tbody tr.patient-wf-pinned-row .patient-wf-td-body {
  white-space: normal;
}
#patient-view .patient-wf-body-with-icon {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
}
#patient-view .patient-wf-body-with-icon .workflow-note-body,
#patient-view .patient-wf-body-with-icon .patient-wf-message-body {
  min-width: 0;
  flex: 1;
}
/* Task row meta wrappers (legacy / outside .patient-wf-task-main) */
#patient-view .patient-wf-meta-cells.patient-wf-meta-cells--task {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  min-width: 0;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
}
#patient-view .patient-wf-td-meta--task .patient-wf-meta-cells.patient-wf-meta-cells--task {
  width: 100%;
  max-width: 100%;
}
#patient-view .patient-wf-meta-cells--task-left {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

#patient-view .patient-wf-decision-option {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: middle;
}
#patient-view .patient-wf-decision-option .patient-wf-decision-option-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: auto;
  max-width: none;
  min-width: 0;
  height: var(--workflow-control-height);
  padding: 0.35rem 0.65rem;
  box-sizing: border-box;
  font: inherit;
  font-size: var(--workflow-control-font-size);
  font-weight: 500;
  line-height: 1.25;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--field-bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: visible;
}
#patient-view .patient-wf-decision-option .patient-wf-decision-option-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

#patient-view .patient-wf-task-title--empty {
  color: var(--text-muted);
  font-weight: 400;
}
#patient-view .patient-wf-stage-text {
  color: var(--text);
  white-space: nowrap;
}

#patient-view button.workflow-task-trigger.patient-wf-task-id-link,
#patient-view button.workflow-task-trigger.workflow-task-id-link {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--primary, var(--text));
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  min-width: 0;
  flex: 0 0 auto;
}
#patient-view button.workflow-task-trigger.patient-wf-task-id-link:hover,
#patient-view button.workflow-task-trigger.workflow-task-id-link:hover {
  text-decoration: underline;
}
#patient-view button.workflow-task-trigger.patient-wf-task-id-link:focus-visible,
#patient-view button.workflow-task-trigger.workflow-task-id-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Program Treatment Plan rows mirrored in Patient Workflow */
#patient-view a.patient-wf-treatment-medication-link.patient-wf-stage-text {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  max-width: 100%;
}

#patient-view a.patient-wf-treatment-medication-link.patient-wf-stage-text:hover {
  text-decoration: underline;
}
#patient-view button.workflow-task-trigger.patient-wf-stage-text {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  border-radius: var(--radius-sm);
  min-width: 0;
}
#patient-view button.workflow-task-trigger.patient-wf-stage-text:hover {
  text-decoration: underline;
  color: var(--primary, var(--text));
}
#patient-view button.workflow-task-trigger.patient-wf-stage-text:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
#patient-view .patient-wf-label-chip {
  flex-shrink: 0;
  gap: 0.35rem;
}
#patient-view .patient-wf-label-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  flex-shrink: 0;
}
#patient-view .patient-wf-row-type-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}
/* Message row: grey circle, black filled bubble icon */
#patient-view .patient-wf-row-type-icon.patient-wf-msg-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--border);
  border: none;
  box-sizing: border-box;
  margin-top: 0;
  color: var(--text, #0a0a0a);
}
#patient-view .patient-wf-msg-icon .patient-wf-row-msg-icon-svg {
  display: block;
  flex-shrink: 0;
  width: 0.75rem;
  height: 0.75rem;
  color: inherit;
}
/* Notes row (incl. pinned): dark circle, light gray note icon */
#patient-view .patient-wf-row-type-icon.patient-wf-row-note-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--text);
  border: none;
  box-sizing: border-box;
  margin-top: 0;
  color: var(--border);
}
#patient-view .patient-wf-row-note-icon .patient-wf-note-row-svg {
  display: block;
  flex-shrink: 0;
  width: 0.78rem;
  height: 0.78rem;
  color: inherit;
}
#patient-view .patient-wf-body-with-icon--note-reply {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.35rem;
  min-width: 0;
  padding-left: 5px;
}
#patient-view .patient-wf-note-thread-connector {
  flex-shrink: 0;
  width: 0.875rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin-top: 0.12rem;
  color: var(--border, #e5e5e5);
}
#patient-view .patient-wf-note-thread-connector-svg {
  display: block;
  width: 0.875rem;
  height: 1.35rem;
  color: inherit;
}
#patient-view .patient-notes-panel-table .patient-wf-note-thread-connector {
  color: var(--text-muted, rgba(15, 23, 42, 0.55));
}
#patient-view .patient-wf-row-type-icon.patient-wf-row-note-icon--reply {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--text);
  border: none;
  box-sizing: border-box;
  margin-top: 0;
  color: var(--border);
}
#patient-view .patient-wf-row-note-icon--reply .patient-wf-note-reply-glyph {
  font-size: var(--text-2xs);
  line-height: 1;
}
#patient-view .patient-wf-table tbody tr.patient-wf-note-thread-row {
  background: transparent;
}
#patient-view .patient-wf-table tbody tr.patient-wf-note-thread-row td {
  background: transparent;
}
#patient-view .patient-wf-status-header-row td {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding-top: 1rem;
}
#patient-view .patient-wf-status-header-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
#patient-view .patient-wf-status-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.2rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  line-height: 1;
}
#patient-view .patient-wf-status-toggle:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.06);
}
#patient-view .patient-wf-status-chevron {
  font-size: var(--text-2xs);
  transition: transform 0.15s ease;
}
#patient-view .patient-wf-status-header-row--collapsed .patient-wf-status-chevron {
  transform: rotate(-90deg);
}
#patient-view .patient-wf-data-row.patient-wf-status-section-collapsed {
  display: none;
}
#patient-view .patient-wf-meta-cells {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}
#patient-view .patient-wf-status-header-text {
  font-weight: 600;
}
#patient-view .patient-wf-pinned-row {
  background: var(--primary-light);
}
#patient-view .patient-wf-pinned-row td {
  background: transparent;
}
#patient-view .patient-wf-table tbody tr.patient-wf-replied-row:not(.patient-wf-pinned-row) {
  background: rgba(22, 163, 74, 0.07);
}
#patient-view .patient-wf-table tbody tr.patient-wf-replied-row:not(.patient-wf-pinned-row) td {
  background: transparent;
}
#patient-view .patient-wf-note-row-shell {
  position: relative;
  padding-top: 0.1rem;
}
#patient-view .patient-wf-note-row-shell:not(.patient-wf-note-row-shell--editing) .patient-wf-body-with-icon {
  padding-right: 7.5rem;
}
#patient-view .patient-wf-note-row-actions {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
#patient-view .patient-wf-note-reply-btn,
#patient-view .patient-wf-note-edit-btn {
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
}
#patient-view .patient-wf-note-row:hover .patient-wf-note-row-actions,
#patient-view .patient-wf-pinned-row:hover .patient-wf-note-row-actions,
#patient-view .patient-wf-note-row-shell:focus-within .patient-wf-note-row-actions {
  opacity: 1;
  pointer-events: auto;
}
#patient-view .patient-wf-note-row-shell--editing .patient-wf-note-row-actions {
  display: none;
}
@media (hover: none) {
  #patient-view .patient-wf-note-row-actions {
    opacity: 1;
    pointer-events: auto;
  }
}
#patient-view .patient-wf-note-edit-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  flex: 1;
}
#patient-view .patient-wf-note-edit-inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0;
}
#patient-view .patient-wf-note-leading-chips {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
#patient-view .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-note-row > td,
#patient-view .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-pinned-row > td,
#patient-view .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-note-reply-draft-row > td {
  vertical-align: top;
}
#patient-view .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-note-row .workflow-row-actions-cell,
#patient-view .patient-wf-table.patient-notes-panel-table tbody tr.patient-wf-pinned-row .workflow-row-actions-cell {
  vertical-align: top;
}
#patient-view .patient-wf-body-with-icon .patient-wf-note-textarea {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}
#patient-view .patient-wf-note-reply-draft-row td {
  background: var(--bg);
  border-top: none;
  vertical-align: top;
}
/* Thread divider: must beat .plan-table tbody td { padding: 0.75rem 1rem } or rows look like blank gaps */
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-notes-thread-divider {
  height: 0;
  line-height: 0;
  font-size: 0;
}
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-notes-thread-divider td {
  padding: 0 !important;
  border-left: none;
  border-right: none;
  border-bottom: none;
  vertical-align: middle;
  height: 0 !important;
  line-height: 0 !important;
  font-size: 0 !important;
}
#patient-view .record-card--workflow .patient-wf-table.patient-notes-panel-table.workflow-table--patient.plan-table tbody tr.patient-notes-thread-divider .patient-notes-thread-divider-cell {
  padding: 0 !important;
  margin: 0;
  border-top: 1px solid var(--border);
  border-bottom: none;
  height: 0 !important;
  line-height: 0 !important;
  font-size: 0 !important;
  overflow: hidden;
}
#patient-view .patient-wf-note-reply-composer {
  padding: 0.35rem 0;
  box-sizing: border-box;
}
#patient-view .patient-wf-note-reply-composer-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}
#patient-view .patient-wf-note-reply-composer .patient-wf-note-reply-composer-input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  resize: none;
  min-height: 4rem;
}
#patient-view .patient-wf-note-reply-composer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
#patient-view .patient-wf-inline-textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-top: 0.5rem;
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  resize: none;
  min-height: 2.5rem;
}
#patient-view .patient-wf-replied-pill {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  vertical-align: middle;
}
#patient-view .patient-wf-pinned-badge {
  display: inline;
  margin: 0;
  padding: 0;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  vertical-align: baseline;
  text-align: inherit;
}
#patient-view .patient-wf-pinned-badge:hover {
  color: var(--text);
  text-decoration: underline;
  background: transparent;
}
#patient-view .patient-wf-td-type-label {
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.add-note-pin-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.add-note-pin-label input {
  margin: 0;
}

.workflow-status-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.workflow-status-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--workflow-control-height);
  padding: 0 0.75rem;
  box-sizing: border-box;
  font: inherit;
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  font-weight: 400;
  border: 1px solid transparent;
  border-radius: var(--workflow-control-radius);
  background: var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.workflow-status-tab:hover {
  background: var(--border-strong);
}

.workflow-status-tab.workflow-status-tab--active {
  font-weight: 600;
  background: var(--surface);
  color: var(--primary);
  border-color: var(--primary);
}

.workflow-status-tab.workflow-status-tab--active:hover {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--primary);
}

.workflow-filter-select {
  height: var(--workflow-control-height);
  padding: 0 var(--workflow-control-padding-x);
  font: inherit;
  font-size: var(--workflow-control-font-size);
  border: 1px solid var(--border);
  border-radius: var(--workflow-control-radius);
  background: var(--surface);
  color: var(--text);
  min-width: 8rem;
  cursor: pointer;
  box-sizing: border-box;
}

.workflow-btn {
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.workflow-btn:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}

.workflow-assignee-select {
  height: var(--workflow-control-height);
  padding: 0 var(--workflow-control-padding-x);
  font: inherit;
  font-size: var(--workflow-control-font-size);
  border: 1px solid var(--border);
  border-radius: var(--workflow-control-radius);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
  box-sizing: border-box;
}

/* Plan Timeline: top align all row content */
.plan-table.plan-timeline-table th,
.plan-table.plan-timeline-table td {
  vertical-align: top;
}

/* Treatment Plan table: nowrap; auto column widths (avoid fixed+colgroup collapse); scroll if needed */
.plan-table-wrap--treatment-plan {
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.plan-table.plan-timeline-table.plan-treatment-readonly-table {
  width: 100%;
  table-layout: fixed;
}

.plan-table.plan-timeline-table.plan-treatment-readonly-table th,
.plan-table.plan-timeline-table.plan-treatment-readonly-table td {
  text-align: left;
  white-space: nowrap;
  vertical-align: top;
}

/* Description column: flexible width + wrap (colgroup leaves remainder on .plan-treatment-col-description) */
.plan-table.plan-timeline-table.plan-treatment-readonly-table thead th:nth-child(6),
.plan-table.plan-timeline-table.plan-treatment-readonly-table tr.plan-treatment-main-row td:nth-child(6) {
  min-width: 0;
  white-space: normal;
  overflow: visible;
  word-wrap: break-word;
}

/* Dosage column: single-line ellipsis — Program & Medication use wider cols + visible overflow below */
.plan-table.plan-timeline-table.plan-treatment-readonly-table thead th:nth-child(7),
.plan-table.plan-timeline-table.plan-treatment-readonly-table tr.plan-treatment-main-row td:nth-child(7) {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Program name: wrap instead of clip (long labels e.g. Metabolic Optimization) */
.plan-table.plan-timeline-table.plan-treatment-readonly-table thead th:nth-child(2),
.plan-table.plan-timeline-table.plan-treatment-readonly-table tr.plan-treatment-main-row td.plan-timeline-program-cell {
  white-space: normal;
  overflow: visible;
  word-wrap: break-word;
}

/* Medication pill select: must not clip native selects */
.plan-table.plan-timeline-table.plan-treatment-readonly-table thead th:nth-child(5),
.plan-table.plan-timeline-table.plan-treatment-readonly-table tr.plan-treatment-main-row td.plan-treatment-medication-cell {
  overflow: visible;
}

.plan-table.plan-timeline-table.plan-treatment-readonly-table thead th:nth-child(1),
.plan-table.plan-timeline-table.plan-treatment-readonly-table tr.plan-treatment-main-row td:nth-child(1) {
  overflow: visible;
  width: 2rem;
  max-width: 2.25rem;
  text-align: center;
}

/* Match Patient Workflow group expand control (.patient-wf-group-toggle) */
.plan-table.plan-timeline-table.plan-treatment-readonly-table .plan-treatment-row-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.plan-table.plan-timeline-table.plan-treatment-readonly-table .plan-treatment-row-toggle:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
}

.plan-table.plan-timeline-table.plan-treatment-readonly-table .plan-treatment-row-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.plan-table.plan-timeline-table.plan-treatment-readonly-table .plan-treatment-toggle-icon {
  font-size: 1rem;
  pointer-events: none;
}

/* Treatment Plan table + New Program modal: pill native selects (match workflow-date-trigger; no decorative chevron) */
select.plan-treatment-pill-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none !important;
  height: var(--workflow-control-height);
  min-height: var(--workflow-control-height);
  max-width: 100%;
  padding: 0 var(--workflow-control-padding-x);
  box-sizing: border-box;
  font: inherit;
  font-size: var(--workflow-control-font-size);
  line-height: 1.25;
  border: 1px solid var(--border);
  border-radius: var(--workflow-control-radius);
  background-color: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.modal-dialog--new-plan select.plan-treatment-pill-select {
  background-color: var(--field-bg);
}

select.plan-treatment-pill-select:hover {
  border-color: var(--border-strong);
  background-color: var(--bg);
}

.modal-dialog--new-plan select.plan-treatment-pill-select:hover {
  background-color: var(--bg);
}

.plan-table.plan-timeline-table.plan-treatment-readonly-table tr.plan-treatment-main-row td.plan-treatment-month-cell,
.plan-table.plan-timeline-table.plan-treatment-readonly-table tr.plan-treatment-main-row td.plan-treatment-medication-cell,
.plan-table.plan-timeline-table.plan-treatment-readonly-table tr.plan-treatment-main-row td.plan-treatment-dosage-col {
  overflow: visible;
}

/* Treatment Plan: col widths — Description column has no fixed width and takes remaining space */
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table col.plan-treatment-col-expand {
  width: 2.25rem;
}
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table col.plan-treatment-col-program {
  width: 13rem;
}
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table col.plan-treatment-col-month {
  width: 5.25rem;
}
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table col.plan-treatment-col-date {
  width: 8rem;
}
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table col.plan-treatment-col-medication {
  width: 14rem;
}
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table col.plan-treatment-col-dosage {
  width: 8rem;
}
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table col.plan-treatment-col-status {
  width: 7rem;
}
/* col.plan-treatment-col-description: remainder */
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table thead th,
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table tbody td {
  padding-top: 0.75rem !important;
  padding-bottom: 0.75rem !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
}
/* Expand control + Program label share one visual row — middle-align so Program lines up with chevron */
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table thead th:nth-child(1),
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table thead th:nth-child(2),
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table tbody tr.plan-treatment-main-row td:nth-child(1),
#patient-overview-panel .plan-table.plan-timeline-table.plan-treatment-readonly-table tbody tr.plan-treatment-main-row td:nth-child(2) {
  vertical-align: middle;
}

.plan-table.plan-timeline-table.plan-treatment-readonly-table .plan-treatment-dosage-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex-wrap: wrap;
}

.plan-table.plan-timeline-table.plan-treatment-readonly-table .plan-treatment-dose-input {
  flex: 0 1 50%;
  max-width: 50%;
  width: 50%;
  min-width: 2.25rem;
  padding: 0.45rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--text);
}

.plan-table.plan-timeline-table.plan-treatment-readonly-table .plan-treatment-dose-units-display {
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Date + Status: interactive controls must not clip */
.plan-table.plan-timeline-table.plan-treatment-readonly-table thead th:nth-child(4),
.plan-table.plan-timeline-table.plan-treatment-readonly-table tr.plan-treatment-main-row td:nth-child(4),
.plan-table.plan-timeline-table.plan-treatment-readonly-table thead th:nth-child(8),
.plan-table.plan-timeline-table.plan-treatment-readonly-table tr.plan-treatment-main-row td:nth-child(8) {
  overflow: visible;
}

.plan-treatment-detail-row .plan-treatment-detail-cell {
  background: color-mix(in srgb, var(--bg) 88%, var(--surface));
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1rem 0.85rem;
  white-space: normal;
}

.plan-treatment-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.5rem;
  max-width: 100%;
}

@media (max-width: 720px) {
  .plan-treatment-detail-grid {
    grid-template-columns: 1fr;
  }
}

.plan-treatment-detail-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.plan-treatment-detail-body {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.plan-timeline-date-cell {
  white-space: nowrap;
}


.plan-timeline-treatment-cell {
  vertical-align: top;
}

.plan-timeline-treatment-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 200px;
}

.plan-timeline-treatment-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Treatment Plan: medication catalog row (Medication | Description | Patient dose | Dose units) */
.plan-timeline-treatment-row--catalog {
  display: grid;
  grid-template-columns: minmax(9rem, 13rem) minmax(5rem, 1fr) 4.5rem minmax(5.5rem, 8rem) 1.5rem;
  align-items: start;
  gap: 0.5rem;
  width: 100%;
  max-width: 52rem;
}

.plan-timeline-treatment-subhead {
  display: grid;
  grid-template-columns: minmax(9rem, 13rem) minmax(5rem, 1fr) 4.5rem minmax(5.5rem, 8rem) 1.5rem;
  gap: 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
}

.plan-timeline-treatment-subhead-actions {
  width: 1.5rem;
}

.plan-timeline-table-subhead th.plan-timeline-table-subhead-spacer {
  padding: 0;
  border: none;
  height: 0;
  line-height: 0;
  font-size: 0;
  overflow: hidden;
}

.plan-timeline-table-subhead .plan-timeline-treatment-subhead-cell {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
  vertical-align: bottom;
}

.plan-timeline-med-description {
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--text-muted);
  padding: 0.25rem 0;
  min-width: 0;
  word-break: break-word;
}

.plan-timeline-medication-type,
.plan-timeline-medication-input,
.plan-timeline-catalog-medication,
.plan-timeline-dosage-amount,
.plan-timeline-dosage-unit {
  padding: 0.2rem 0.4rem;
  font: inherit;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}

.plan-timeline-medication-type {
  width: auto;
  min-width: 6.5rem;
  max-width: 9rem;
  flex-shrink: 0;
  cursor: pointer;
}

.plan-timeline-medication-input {
  flex: 1;
  min-width: 120px;
}

.plan-timeline-catalog-medication {
  width: 100%;
  min-width: 0;
  cursor: pointer;
}

.plan-timeline-dosage-amount {
  width: 4rem;
  flex-shrink: 0;
}

.plan-timeline-dosage-unit {
  width: auto;
  min-width: 5rem;
  max-width: 7.5rem;
  flex-shrink: 0;
  cursor: pointer;
}

.plan-timeline-medication-type:focus,
.plan-timeline-medication-input:focus,
.plan-timeline-catalog-medication:focus,
.plan-timeline-dosage-amount:focus,
.plan-timeline-dosage-unit:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.plan-timeline-treatment-delete {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.plan-timeline-treatment-delete:hover {
  background: var(--error-bg, #fef2f2);
  color: var(--error, #b91c1c);
  border-color: var(--error, #b91c1c);
}

.plan-timeline-treatment-add {
  margin-top: 0.2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 400;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  display: inline-block;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  align-self: flex-start;
}
.plan-timeline-treatment-cell:hover .plan-timeline-treatment-add {
  opacity: 1;
  pointer-events: auto;
}
.plan-timeline-treatment-add:hover {
  background: var(--primary);
  color: white;
  border: 1px solid var(--primary);
}

.plan-timeline-table .plan-timeline-treatment {
  max-width: min(52rem, 100%);
  white-space: normal;
  word-wrap: break-word;
}

.plan-table-wrap {
  overflow: visible;
  margin-top: 0.5rem;
}

.plan-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.plan-table th,
.plan-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.plan-table th {
  font-weight: 600;
  color: #000;
  background: var(--bg);
  font-size: 0.8125rem;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
}

.plan-table td {
  color: var(--text);
}

/* Patient Workflow tasks table: no row/cell borders (overrides .plan-table th/td above) */
#patient-view table.patient-wf-table--no-dividers,
#patient-view table.patient-wf-table--no-dividers thead,
#patient-view table.patient-wf-table--no-dividers tbody,
#patient-view table.patient-wf-table--no-dividers tr,
#patient-view table.patient-wf-table--no-dividers th,
#patient-view table.patient-wf-table--no-dividers td {
  border: 0 none transparent !important;
  border-width: 0 !important;
  border-top-width: 0 !important;
  border-bottom-width: 0 !important;
  box-shadow: none !important;
  outline: none !important;
}
#patient-view table.patient-wf-table--no-dividers {
  border-collapse: collapse;
  border-spacing: 0;
}
#patient-view #patient-workflow-panel .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) th,
#patient-view #patient-workflow-panel .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) td {
  border: 0 !important;
  border-top: 0 !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
}

.plan-table tbody tr:hover:not(.workflow-section-header-row):not(.plan-program-note-row) {
  background: var(--primary-light-hover);
}

#patient-view #patient-workflow-panel .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row:hover,
#patient-view #patient-workflow-panel .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-task-row:hover td,
#patient-view #patient-workflow-panel .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-subcategory-header-row:hover,
#patient-view #patient-workflow-panel .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-subcategory-header-row:hover td,
#patient-view #patient-workflow-panel .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-data-row:not(.patient-wf-task-row):hover,
#patient-view #patient-workflow-panel .record-card--workflow .patient-wf-table.workflow-table--patient.plan-table:not(.patient-notes-table) tbody tr.patient-wf-data-row:not(.patient-wf-task-row):hover td {
  background: transparent !important;
}

.plan-table .plan-table--num {
  text-align: right;
}

.plan-table th:nth-child(6),
.plan-table td:nth-child(6),
.plan-table th:nth-child(n+7),
.plan-table td:nth-child(n+7) {
  text-align: right;
}

.plan-table-actions {
  text-align: center !important;
  width: 1%;
  white-space: nowrap;
}

/* Program table: read-only Status / Payment labels */
.plan-program-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  font-size: inherit;
  line-height: 1.2;
  color: var(--text);
}

.plan-program-label-text {
  white-space: nowrap;
}

.plan-program-label-icon {
  flex-shrink: 0;
}

.plan-program-label-icon--dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

.plan-program-label-icon--success {
  background: var(--success, #059669);
}

.plan-program-label-icon--danger {
  background: var(--danger);
}

.plan-program-label-icon.plan-program-label-icon--check {
  font-size: 0.75rem;
  color: var(--success, #059669);
  line-height: 1;
}

.plan-edit-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1;
  color: var(--text-muted);
  border: none;
  background: transparent;
}

.plan-edit-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.plan-row-actions-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.plan-row-actions-flyout {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.15rem;
  width: max-content;
  min-width: 7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 20;
  padding: 0.25rem 0;
}

.plan-row-actions-flyout[hidden] {
  display: none;
}

/* New Program modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: dissolveIn 0.2s ease;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: dissolveIn 0.2s ease;
}

.modal-dialog--new-plan {
  width: 100%;
  min-width: 920px;
  max-width: 1100px;
}

.modal-dialog--new-patient {
  width: min(100%, 520px);
  min-width: 0;
  max-width: min(520px, calc(100vw - 2rem));
  min-height: min(28rem, calc(90vh - 2rem));
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Delete patient / delete program confirmation dialogs */
.modal-dialog--delete-patient,
.modal-dialog--delete-program {
  width: 100%;
  max-width: min(calc(54vw * 0.6), calc(100vw - 2rem));
  min-width: 0;
  box-sizing: border-box;
}

.modal-dialog--delete-patient .modal-body,
.modal-dialog--delete-program .modal-body,
.modal-dialog--delete-workflow-group .modal-body {
  flex: 0 1 auto;
}

.modal-dialog--delete-patient .modal-footer.modal-footer--delete-patient,
.modal-dialog--delete-program .modal-footer.modal-footer--delete-program,
.modal-dialog--delete-workflow-group .modal-footer.modal-footer--delete-workflow-group {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.75rem;
  padding-bottom: 1rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.modal-footer.modal-footer--new-patient {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem 1rem;
}

/* New Patient modal: fields only (no section card / grid shell) */
#new-patient-modal .modal-body--new-patient {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem 1.5rem;
  align-content: start;
}

#new-patient-modal .modal-body--new-patient .profile-field-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  min-width: 0;
}

#new-patient-modal .modal-body--new-patient .profile-field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  text-align: left;
}

#new-patient-modal .modal-body--new-patient .profile-field-input {
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border-radius: var(--radius);
  width: 100%;
  text-align: left;
  box-sizing: border-box;
}

#new-patient-modal .modal-body--new-patient .record-dob-wrap.profile-field-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

#new-patient-modal .modal-body--new-patient .record-dob-wrap .record-age {
  flex-shrink: 0;
  margin-left: auto;
}

#new-patient-modal .modal-body--new-patient .record-dob-wrap .date-selector-wrap {
  flex: 1;
  min-width: 0;
  display: block;
  max-width: 100%;
}

#new-patient-modal .modal-body--new-patient .record-dob-wrap .date-selector-display {
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border: none;
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--text);
  box-sizing: border-box;
  width: 100%;
  text-align: left;
}

#new-patient-modal .modal-body--new-patient .record-dob-wrap .date-selector-wrap:focus-within .date-selector-display {
  box-shadow: 0 0 0 1px var(--primary);
}

#new-patient-modal .modal-body--new-patient .profile-asap-dropdown {
  flex: 1;
  min-width: 0;
  width: 100%;
  display: block;
}

#new-patient-modal .modal-body--new-patient .profile-asap-dropdown .workflow-filter-trigger {
  width: 100%;
  min-width: 0;
  text-align: left;
  justify-content: flex-start;
  border: none;
  background: var(--field-bg);
}

@media (max-width: 520px) {
  .new-patient-fields {
    grid-template-columns: 1fr;
  }
}

.modal-dialog--add-note {
  width: 100%;
  min-width: 420px;
  max-width: 560px;
  min-height: 0;
  max-height: 90vh;
  height: auto;
}

/* Patient: unified Add a New Item (workflow + note) */
/* Stack above .task-type-slide-overlay (z-index 1000, later in DOM) so clicks reach this dialog */
#add-new-item-modal.modal-overlay {
  z-index: 1015;
}

.modal-dialog--add-new-item {
  width: 100%;
  min-width: min(660px, 100vw - 2rem);
  max-width: 690px;
  height: min(400px, 92vh);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.modal-dialog--add-new-item > .modal-header {
  flex-shrink: 0;
}

/* Add Item v2: top row = patient · category · type · close (no separate header = no top divider) */
.modal-dialog--add-new-item.modal-dialog--add-new-item-v2 {
  height: min(400px, 92vh);
  max-height: 92vh;
  min-height: 0;
}

.modal-dialog--add-new-item.modal-dialog--add-new-item-v2 > .modal-body--add-new-item-v2 {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.add-new-item-header-strip {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  margin-bottom: 0.75rem;
  min-width: 0;
}

.add-new-item-header-sep {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  user-select: none;
}

/* Do not flex-grow: a growing block + width:100% input looked like a huge gap before Category */
.add-new-item-header-strip .add-new-item-patient-block {
  flex: 0 1 18rem;
  min-width: 8rem;
  max-width: min(100%, 22rem);
}

.add-new-item-header-strip .add-new-item-patient-block .add-note-patient-autocomplete {
  width: 100%;
  min-width: 0;
}

/* Default <input> width is ~20ch; stretch to fill the patient column so gap before Category is only flex gap */
.add-new-item-header-strip .add-note-patient-autocomplete .add-note-input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: var(--field-bg);
  border: 1px solid var(--border);
}

.add-new-item-header-strip .add-note-patient-autocomplete .add-note-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: none;
}

.add-new-item-header-close {
  flex-shrink: 0;
  margin-left: auto;
  align-self: center;
}

.add-new-item-chip-slot {
  flex-shrink: 0;
}

.add-new-item-chip-slot .task-type-modal-dropdown {
  display: inline-block;
  vertical-align: top;
}

.add-new-item-chip-slot .workflow-filter-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.35rem;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface, #fff);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.add-new-item-chip-slot .workflow-filter-trigger:hover {
  border-color: var(--border-strong, #cbd5e1);
  background: var(--bg, #f8fafc);
}

.add-new-item-chip-slot .workflow-filter-trigger--with-icon {
  gap: 0.45rem;
}

.add-new-item-chip-slot .workflow-filter-trigger-text {
  line-height: 1.2;
}

.add-new-item-dropdown-icon {
  font-size: 1.125rem;
  line-height: 1;
  opacity: 0.92;
  flex-shrink: 0;
}

#add-new-item-modal .workflow-filter-option-btn--with-icon {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
}

#add-new-item-modal .workflow-filter-option-btn--with-icon .workflow-filter-option-label {
  flex: 1 1 auto;
  min-width: 0;
}

/* Create Task modal */
.modal-dialog--add-new-item.modal-dialog--add-new-item-v2.modal-dialog--create-task {
  height: auto;
  min-height: min(440px, 68vh);
  max-height: 92vh;
}

.modal-dialog--create-task.modal-dialog--create-task-note-open {
  min-height: min(580px, 88vh);
}

.modal-dialog--add-new-item.modal-dialog--add-new-item-v2.modal-dialog--create-task > .modal-body--add-new-item-v2.modal-body--create-task {
  overflow: visible;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-body--create-task {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem 1.25rem;
  min-height: 0;
  overflow: visible;
}

.create-task-modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  min-width: 0;
}

.create-task-patient-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

.create-task-patient-autocomplete {
  flex: 1 1 auto;
  min-width: 0;
}

.create-task-patient-autocomplete .add-note-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  padding: 0.45rem 0.65rem;
}

.create-task-patient-autocomplete .add-note-input:focus {
  outline: none;
  border-color: var(--primary);
}

.create-task-new-patient-btn {
  flex-shrink: 0;
}

#add-new-item-modal .create-task-mode-tabs.progress-view-tabs {
  flex-shrink: 0;
  width: fit-content;
}

.create-task-content-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
}

#add-new-item-modal .create-task-description-input {
  flex: 1 1 auto;
  min-height: 5.5rem;
  max-height: 14rem;
  overflow-y: auto;
  text-align: left;
}

#add-new-item-modal .create-task-note-block .create-task-note-input {
  flex: 0 1 auto;
  min-height: 4.25rem;
  max-height: 10rem;
  overflow-y: auto;
  text-align: left;
}

.create-task-meta-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

.create-task-meta-field {
  flex: 0 0 auto;
}

.create-task-meta-field .workflow-filter-trigger {
  min-height: 2.25rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.875rem;
}

.create-task-meta-field .workflow-filter-trigger--with-icon {
  gap: 0.55rem;
}

#create-task-category-wrap .workflow-filter-trigger--with-icon .workflow-filter-trigger-text {
  margin-left: 0.12rem;
}

#create-task-type-wrap .workflow-filter-trigger--with-icon .add-new-item-dropdown-icon {
  opacity: 0.92;
}

#add-new-item-modal .create-task-assign-meta {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: none;
  overflow: visible;
}

#add-new-item-modal .create-task-assign-meta[hidden] {
  display: none !important;
}

#add-new-item-modal .create-task-assign-meta .add-new-item-workflow-meta-pill {
  flex: 0 0 auto;
}

#add-new-item-modal .create-task-assign-meta .task-type-modal-pills--workflow .workflow-status-trigger,
#add-new-item-modal .create-task-assign-meta .task-type-modal-pills--workflow .workflow-date-trigger,
#add-new-item-modal .create-task-assign-meta .task-type-modal-pills--workflow .workflow-assignee-trigger {
  min-height: 2.25rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.875rem;
}

#add-new-item-modal .create-task-note-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-left: auto;
  padding: 0;
  border: none;
  border-radius: var(--radius, 6px);
  background: transparent;
  color: var(--text-muted, #64748b);
  cursor: pointer;
}

#add-new-item-modal .create-task-note-toggle .ti-note {
  font-size: 1.2rem;
  line-height: 1;
}

#add-new-item-modal .create-task-note-toggle:hover,
#add-new-item-modal .create-task-note-toggle.patient-wf-task-note-btn--active {
  color: var(--text);
  background: var(--field-bg, rgba(0, 0, 0, 0.04));
}

.create-task-note-block[hidden] {
  display: none !important;
}

#add-new-item-modal .create-task-note-block:not([hidden]) {
  flex-shrink: 0;
}

#add-new-item-modal .create-task-note-block .add-note-mention-chips--under-field {
  flex-shrink: 0;
  overflow: visible;
}

.modal-dialog--create-task-note-open .create-task-description-input {
  flex: 0 1 auto;
  max-height: 9rem;
}

.modal-footer--create-task {
  flex-shrink: 0;
  justify-content: flex-end;
}

#new-patient-modal.modal-overlay {
  z-index: 1020;
}

.modal-dialog--new-patient-inline {
  display: flex;
  flex-direction: column;
}

.modal-dialog--new-patient-inline .new-patient-form--inline {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-dialog--new-patient-inline .modal-body--new-patient-inline {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 0.75rem 1.25rem 0.5rem;
  min-height: 0;
}

#new-patient-modal .new-patient-profile-fields {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

#new-patient-modal .new-patient-profile-fields > .profile-field-row--split {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  column-gap: 0.75rem;
  align-items: center;
  justify-items: start;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

#new-patient-modal .new-patient-profile-fields > .profile-field-row--split:first-child {
  padding-top: 0;
}

#new-patient-modal .new-patient-profile-fields > .profile-field-row--split:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

#new-patient-modal .new-patient-profile-fields .profile-field-label-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  min-width: 0;
  text-align: left;
}

#new-patient-modal .new-patient-profile-fields .profile-field-label {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}

#new-patient-modal .new-patient-profile-fields .profile-field-value-cell {
  width: 100%;
  min-width: 0;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

#new-patient-modal .new-patient-profile-fields .profile-field-input {
  width: 100%;
  min-height: 2rem;
  box-sizing: border-box;
  text-align: left;
}

.modal-footer--new-patient-inline {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.75rem 1.25rem 1rem;
  margin-top: auto;
}

#patient-workflow-panel .patient-wf-task-row.patient-wf-task-row--create-highlight .patient-wf-meta-cells--task {
  background: var(--surface, #fff);
  box-shadow: 0 0 0 2px var(--primary, #2563eb);
  border-radius: var(--workflow-control-radius);
  transition: box-shadow 0.2s ease, background 0.2s ease;
}

.add-new-item-content-stack {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.add-new-item-content-stack > .add-new-item-panel {
  flex: 1 1 auto;
  min-height: 0;
}

@media (max-width: 720px) {
  .add-new-item-header-strip {
    flex-wrap: wrap;
  }

  .add-new-item-header-close {
    margin-left: 0;
    order: 10;
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.modal-body--add-new-item {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.add-new-item-rail .add-new-item-patient-block,
.add-new-item-rail .add-new-item-patient-block .add-note-label,
.add-new-item-rail .add-note-patient-autocomplete {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  align-self: stretch;
}

/* Same outer width as category buttons: block-level + border-box (input is not a flex stretch by default) */
.add-new-item-rail .add-note-patient-autocomplete .add-note-input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: var(--field-bg);
  border: 1px solid var(--border);
}

.add-new-item-rail .add-note-patient-autocomplete .add-note-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: none;
}

/* Two columns: rail (patient + type) | main (workflow / note) */
.add-new-item-layout {
  display: grid;
  grid-template-columns: minmax(12.75rem, 15.75rem) minmax(0, 1fr);
  gap: 1.25rem 1.125rem;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.add-new-item-rail {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  padding-right: 0.6375rem;
  margin-right: 0;
  border-right: 1px solid var(--border);
}

.add-new-item-rail .add-new-item-patient-block {
  flex-shrink: 0;
}

.add-new-item-main {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.add-new-item-main-category-title {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: -0.01em;
}

.add-new-item-main > #add-new-item-workflow-panel,
.add-new-item-main > #add-new-item-note-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.add-new-item-category-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.add-new-item-category-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0.45rem 0.55rem;
  min-height: 2.35rem;
  font: inherit;
  /* Match .add-note-input in this modal (patient field) */
  font-size: 0.9375rem;
  font-weight: inherit;
  line-height: 1.2;
  text-align: left;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  box-sizing: border-box;
}

.add-new-item-category-card:hover {
  background: var(--surface);
  border-color: var(--text-muted);
}

.add-new-item-category-card.is-selected {
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  border-radius: 8px;
  box-shadow: none;
  font-weight: 600;
}

.add-new-item-category-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: inherit;
  font-weight: inherit;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-new-item-category-card.is-selected .add-new-item-category-label {
  font-weight: 600;
}

.add-new-item-category-icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  width: 1.35rem;
  text-align: center;
  opacity: 0.92;
}

.add-new-item-category-card.is-selected .add-new-item-category-icon {
  opacity: 1;
}

@media (max-width: 700px) {
  .add-new-item-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .add-new-item-rail {
    padding-right: 0;
    margin-right: 0;
    border-right: none;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
  }

  .add-new-item-category-grid {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .add-new-item-category-card {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 6.375rem;
  }
}

.add-new-item-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

.add-new-item-panel[hidden] {
  display: none !important;
}

/* New Item → workflow: category/type line, description, status/date/assignee, note */
.add-new-item-workflow-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  flex-shrink: 0;
  min-width: 0;
}

.add-new-item-workflow-category-type-line {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  width: 100%;
  min-width: 0;
  justify-content: flex-start;
}

.add-new-item-workflow-category-display {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.add-new-item-workflow-category-type-sep {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
}

/* Type control sits to the right of "Category /" (e.g. Form / Patient Intake) */
.add-new-item-workflow-type-slot {
  flex: 1 1 10rem;
  min-width: min(100%, 9rem);
  max-width: 100%;
  margin-left: auto;
}

.add-new-item-workflow-type-slot .task-type-modal-dropdown {
  display: block;
  width: 100%;
  max-width: 100%;
}

.add-new-item-workflow-type-slot .workflow-filter-trigger {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.9375rem;
  font-weight: 400;
  background: var(--field-bg);
  border: 1px solid var(--border);
  color: var(--text);
  justify-content: flex-start;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.add-new-item-workflow-type-slot .workflow-filter-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

.add-new-item-workflow-row--desc {
  gap: 0;
}

.add-new-item-panel--workflow-title {
  flex: 1 1 auto;
  min-height: 0;
  padding-top: 0.15rem;
}

.add-new-item-workflow-title-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0.15rem 0 0.35rem;
  border: none;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--text);
  resize: none;
}

.add-new-item-workflow-title-input::placeholder {
  color: var(--text-muted);
  font-weight: 600;
  opacity: 0.85;
}

.add-new-item-workflow-title-input:focus {
  outline: none;
}

.add-new-item-workflow-details-input,
#add-new-item-note-panel .add-new-item-note-composer-input,
#add-new-item-modal .add-new-item-note-composer-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0.15rem 0 0.35rem;
  border: none;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: calc(1.25rem - 2px);
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: normal;
  color: var(--text);
  resize: none;
}

.add-new-item-workflow-details-input {
  flex: 1 1 auto;
  min-height: 4.25rem;
  max-height: 12rem;
  padding-top: 0.35rem;
  overflow-y: auto;
}

.add-new-item-workflow-details-input::placeholder,
#add-new-item-note-panel .add-new-item-note-composer-input::placeholder,
#add-new-item-modal .add-new-item-note-composer-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0.85;
}

.add-new-item-workflow-details-input:focus,
#add-new-item-note-panel .add-new-item-note-composer-input:focus,
#add-new-item-modal .add-new-item-note-composer-input:focus {
  outline: none;
}

#add-new-item-note-panel .add-new-item-note-composer-input {
  flex: 1 1 auto;
  min-height: 4.25rem;
  max-height: none;
  text-align: left;
  overflow-y: auto;
}

.add-new-item-form-type-desc {
  margin: 0;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--text-muted, #64748b);
}

.add-new-item-form-type-desc--placeholder {
  font-style: italic;
  opacity: 0.9;
}

.add-new-item-form-type-desc[hidden],
.add-new-item-form-type-desc--placeholder[hidden] {
  display: none !important;
}

.add-new-item-workflow-desc-divider {
  border: none;
  border-top: 1px solid var(--border, #e5e7eb);
  margin: 0;
  width: 100%;
  flex-shrink: 0;
}

.add-new-item-workflow-meta-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  width: 100%;
  flex-shrink: 0;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

.add-new-item-workflow-meta-row .add-new-item-workflow-meta-pill {
  flex: 0 0 auto;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
}

.add-new-item-workflow-meta-row .add-new-item-workflow-meta-pills {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  flex: 0 0 auto;
}

.add-new-item-workflow-meta-row .workflow-status-combined,
.add-new-item-workflow-meta-row .workflow-assignee-combined,
.add-new-item-workflow-meta-row .workflow-date-combined {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  vertical-align: top;
}

.add-new-item-workflow-meta-row .workflow-status-popover[hidden],
.add-new-item-workflow-meta-row .workflow-assignee-popover[hidden],
.add-new-item-workflow-meta-row .workflow-date-popover[hidden] {
  display: none !important;
}

.add-new-item-workflow-meta-row .task-type-modal-pills--workflow .workflow-date-trigger,
.add-new-item-workflow-meta-row .task-type-modal-pills--workflow .workflow-assignee-trigger,
.add-new-item-workflow-meta-row .task-type-modal-pills--workflow .workflow-status-trigger,
.add-new-item-workflow-meta-row .task-type-modal-pills--workflow .workflow-filter-trigger {
  width: max-content;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--field-bg);
  border: 1px solid var(--border);
  color: var(--text);
  justify-content: flex-start;
  text-align: left;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

/* Status tinting in New Item workflow meta row */
.add-new-item-workflow-meta-row .task-type-modal-pills--workflow[data-status="Backlog"] .workflow-status-trigger {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.add-new-item-workflow-meta-row .task-type-modal-pills--workflow[data-status="On Hold"] .workflow-status-trigger {
  background: #ffedd5;
  border-color: #fdba74;
}

.add-new-item-workflow-meta-row .task-type-modal-pills--workflow[data-status="Todo"] .workflow-status-trigger,
.add-new-item-workflow-meta-row .task-type-modal-pills--workflow[data-status="To do"] .workflow-status-trigger {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.add-new-item-workflow-meta-row .task-type-modal-pills--workflow[data-status="In Progress"] .workflow-status-trigger {
  background: #f5e6d3;
  border-color: #d4a574;
}

.add-new-item-workflow-meta-row .task-type-modal-pills--workflow[data-status="Completed"] .workflow-status-trigger {
  background: #dcfce7;
  border-color: #86efac;
}

.add-new-item-workflow-meta-row .task-type-modal-pills--workflow[data-status="Canceled"] .workflow-status-trigger {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.add-new-item-workflow-meta-row .task-type-modal-pills--workflow[data-status="Overdue"] .workflow-status-trigger {
  background: #fee2e2;
  border-color: #fca5a5;
}

.add-new-item-workflow-meta-row .task-type-modal-pills--workflow .workflow-status-trigger:hover,
.add-new-item-workflow-meta-row .task-type-modal-pills--workflow .workflow-date-trigger:hover,
.add-new-item-workflow-meta-row .task-type-modal-pills--workflow .workflow-assignee-trigger:hover,
.add-new-item-workflow-meta-row .task-type-modal-pills--workflow .workflow-filter-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

.add-new-item-workflow-extra-pills-row {
  margin-top: 0.35rem;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.25rem;
}

.add-new-item-workflow-extra-pills-row[hidden] {
  display: none !important;
}

.task-type-modal-meta-row--extra-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.25rem 0.5rem;
  margin-bottom: 0.75rem;
}

.task-type-modal-meta-row--extra-pills[hidden] {
  display: none !important;
}

.task-type-modal-meta-row--extra-pills .task-type-modal-pills--workflow .workflow-filter-trigger {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--field-bg);
  border: 1px solid var(--border);
  color: var(--text);
  justify-content: flex-start;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-type-modal-meta-row--extra-pills .task-type-modal-pills--workflow .workflow-filter-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

.task-type-modal-meta-row--extra-pills .task-type-modal-pills--workflow .workflow-date-trigger,
.task-type-modal-meta-row--extra-pills .task-type-modal-pills--workflow .workflow-assignee-trigger {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--field-bg);
  border: 1px solid var(--border);
  color: var(--text);
  justify-content: flex-start;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-type-modal-meta-row--extra-pills .task-type-modal-pills--workflow .workflow-date-trigger:hover,
.task-type-modal-meta-row--extra-pills .task-type-modal-pills--workflow .workflow-assignee-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

.task-type-modal--workflow-subpage .patient-wf-task-subpage-col--right .task-type-modal-meta-row--extra-pills {
  display: none !important;
}

.add-new-item-details-field {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
  margin-top: 0.25rem;
}

.task-type-modal-form-type-desc {
  margin: 0 0 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--text-muted, #64748b);
}

.task-type-modal-form-type-desc[hidden] {
  display: none !important;
}

.task-type-modal-form-note-field .task-type-modal-form-note-input {
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.25rem;
  text-align: left;
  resize: none;
}

/* Workflow task note: same vertical sizing as Note tab (#ani-note-text), not stretched */
#add-new-item-workflow-panel .add-new-item-details-field .add-note-label--full {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
}

#add-new-item-workflow-panel .add-new-item-details-field .add-note-textarea {
  flex: 0 1 auto;
  min-height: 4.25rem;
  max-height: 12rem;
  width: 100%;
  text-align: left;
  resize: none;
}

/* Note tab: match flex so switching tabs doesn’t change modal height */
#add-new-item-note-panel .add-note-fields {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#add-new-item-note-panel .add-note-note-input-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.add-new-item-content-stack #add-new-item-note-panel .add-new-item-note-composer-input {
  flex: 1 1 auto;
}

#add-new-item-note-panel .add-note-mention-chips--under-field {
  flex-shrink: 0;
}

.modal-dialog--add-new-item > .add-new-item-workflow-meta-row {
  flex-shrink: 0;
  padding: 0 1.25rem 0.65rem;
  justify-content: flex-start;
  box-sizing: border-box;
}

.modal-dialog--add-new-item > .modal-footer {
  flex-shrink: 0;
}

/* Specificity over `.modal-footer` (defined later in this file) */
.modal-footer.modal-footer--add-new-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.modal-footer.modal-footer--add-new-item.modal-footer--add-new-item-v2 {
  justify-content: flex-end;
}

.modal-footer-add-new-item-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.85rem;
  flex-wrap: wrap;
  width: 100%;
  margin-left: auto;
}

.add-new-item-footer-pin {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.add-new-item-footer-pin[hidden] {
  display: none !important;
}

.add-new-item-footer-pin input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.patient-record-new-item-btn .task-type-modal-messages-btn-icon {
  font-size: 1rem;
}

.modal-dialog--add-note .add-note-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.add-note-form .modal-body {
  padding-bottom: 0.75rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 0 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.add-note-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.add-note-fields > .add-note-note-input-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.add-note-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
}

.add-note-label--full {
  grid-column: 1 / -1;
}

.add-note-mention-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.add-note-note-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.add-note-note-input-spacer {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.add-note-mention-chips--row {
  max-height: 6.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.add-note-mention-chip--team {
  border-style: dashed;
}

.add-note-mention-chip {
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 400;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--mention-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.add-note-mention-chip:hover {
  background: var(--primary-light);
  border-color: var(--mention-text);
}

.add-note-input {
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--text);
  resize: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.add-note-input:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--primary);
}

.add-note-date-readonly-value {
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--field-bg);
  border: none;
  border-radius: var(--radius-sm);
  cursor: default;
}

#add-note-date-label {
  overflow: visible;
}

#add-note-date-area {
  display: block;
  min-height: 2.5rem;
  margin-top: 0.35rem;
  overflow: visible;
}

.add-note-due-date-wrap .workflow-date-trigger {
  width: 100%;
  min-width: 10rem;
}

/* Invite user modal */
.modal-dialog--invite-user .invite-user-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

#new-workflow-group-modal .modal-footer--workflow-name-create,
#new-workflow-subcategory-modal .modal-footer--workflow-name-create,
#rename-workflow-group-modal .modal-footer--workflow-name-create,
#rename-workflow-subcategory-modal .modal-footer--workflow-name-create {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 0.75rem;
  padding-bottom: 1rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

#new-workflow-group-modal .invite-user-input--title-case,
#new-workflow-subcategory-modal .invite-user-input--title-case,
#rename-workflow-group-modal .invite-user-input--title-case,
#rename-workflow-subcategory-modal .invite-user-input--title-case {
  text-transform: capitalize;
}

.invite-user-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.invite-user-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.invite-user-hint {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
}

.invite-user-input {
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.invite-user-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.invite-user-select {
  cursor: pointer;
}

.modal-dialog--add-note .add-note-due-date-wrap {
  display: block;
  width: 100%;
}

.modal-dialog--add-note .modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.75rem 1.25rem 1rem;
}

/* Task-type slide-in overlay (Form, Appointment, Test, Billing, Order) */
.task-type-slide-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  overflow: visible;
  background: rgba(0, 0, 0, 0.3);
  animation: dissolveIn 0.2s ease;
  isolation: isolate;
}

.task-type-slide-overlay[hidden] {
  display: none;
}

/* Task-type modal shown inline on Patient Workflow task route (not fixed right overlay) */
.task-type-modal.task-type-modal--workflow-subpage.task-type-slide-overlay {
  position: static;
  inset: auto;
  z-index: auto;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: stretch;
  overflow: visible;
  background: transparent;
  animation: none;
  isolation: auto;
  width: 100%;
  min-height: 0;
}
/* No Form / title row, messages, or close — toolbar is on the workflow card */
.task-type-modal--workflow-subpage .task-type-modal-header {
  display: none !important;
}
/* Flatten slide “card”: no inner white box, full width */
.task-type-modal--workflow-subpage .task-type-slide-panel,
.task-type-modal--workflow-subpage .task-type-slide-panel.modal-dialog--task-type {
  flex: 1 1 auto;
  width: 100%;
  max-width: none !important;
  min-width: 0 !important;
  height: auto;
  min-height: 0;
  max-height: none;
  animation: none !important;
  transform: none !important;
  box-shadow: none !important;
  background: transparent !important;
  border: none;
  border-radius: 0;
}
.task-type-modal--workflow-subpage .task-type-slide-panel .modal-body {
  /* Flush left on task subpage; keep right/bottom inset for focus rings */
  padding: 0 1.25rem 1.25rem 0;
  width: 100%;
  max-width: none;
  overflow-x: visible;
  overflow-y: visible;
}
.task-type-modal--workflow-subpage .task-type-modal-footer {
  display: none;
}

/* Test task subpage: Automate/Save + last updated live in sticky toolbar; hide duplicate modal footer */
#task-type-modal-test.task-type-modal--workflow-subpage .task-type-modal-footer--test {
  display: none !important;
}

.task-type-modal-last-updated {
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--text-muted, #64748b);
}

.task-type-modal-last-updated-line {
  display: inline;
  font-weight: 400;
  color: var(--text, #111);
}

.task-type-slide-panel {
  position: relative;
  z-index: 2;
  width: 25vw;
  min-width: 320px;
  max-width: 480px;
  height: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
  background: var(--surface);
  /* Left: separation from messages drawer; broad shadow for overlay edge */
  box-shadow:
    -8px 0 24px rgba(0, 0, 0, 0.14),
    -3px 0 10px rgba(0, 0, 0, 0.1),
    -1px 0 0 rgba(0, 0, 0, 0.08);
  animation: taskTypeSlideIn 0.3s ease forwards;
}

@keyframes taskTypeSlideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes taskTypeSlideOut {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

/* Workflow task modal: messages drawer sits left of task panel, lower z-index, slides in from the right (under the task panel) */
@keyframes workflowMessagesSlideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes workflowMessagesSlideOut {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

.workflow-task-messages-drawer {
  position: relative;
  z-index: 1;
  width: 25vw;
  min-width: 320px;
  max-width: 480px;
  height: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  /* Right: drop shadow into the task panel (seam between overlays) */
  box-shadow:
    6px 0 18px rgba(0, 0, 0, 0.12),
    2px 0 8px rgba(0, 0, 0, 0.1),
    1px 0 0 rgba(0, 0, 0, 0.08);
}

.workflow-task-messages-drawer[hidden] {
  display: none !important;
}

.workflow-task-messages-drawer-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workflow-task-messages-drawer-panel > .patient-messages-thread-column {
  flex: 1 1 auto;
  min-height: 0;
}

.inbox-detail-header--drawer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.inbox-detail-header--drawer .inbox-detail-patient-name {
  flex: 1;
  min-width: 0;
}

.workflow-task-messages-drawer-close {
  flex-shrink: 0;
}

.task-type-modal-header-status-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

/* Messages icon: circle, page-bg fill, no border (patient header + task-type modal) */
.task-type-modal-messages-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  box-sizing: border-box;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.task-type-modal-messages-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.task-type-modal-messages-btn.is-active {
  color: var(--primary);
  background: var(--primary-light);
}

.task-type-modal-messages-btn-icon {
  display: block;
}

.task-type-modal-messages-btn .task-type-modal-messages-btn-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.modal-dialog--task-type {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  box-shadow: none;
}

/* Override width for slide-in panel (modal-dialog--task-type was forcing width: 100%) */
.task-type-slide-panel.modal-dialog--task-type {
  width: 25vw;
  min-width: 320px;
  max-width: 480px;
  /* Restore seam shadow (modal-dialog--task-type sets box-shadow: none) */
  box-shadow:
    -8px 0 24px rgba(0, 0, 0, 0.14),
    -3px 0 10px rgba(0, 0, 0, 0.1),
    -1px 0 0 rgba(0, 0, 0, 0.08);
}

.task-type-slide-panel .modal-header {
  flex-shrink: 0;
  overflow: visible;
}

.task-type-slide-panel .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Stack overlay fields vertically to prevent cutoff in narrow panel */
.task-type-slide-panel .task-type-modal-row,
.task-type-slide-panel .task-type-modal-row--half,
.task-type-slide-panel .task-type-modal-row--third {
  grid-template-columns: 1fr;
}

.task-type-slide-panel .task-type-modal-input,
.task-type-slide-panel .task-type-modal-type-select,
.task-type-slide-panel .task-type-modal-action-select {
  min-width: 0;
  box-sizing: border-box;
}

.task-type-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.task-type-modal-header .modal-title {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.task-type-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Messages + status live in body meta rows; header is title + actions only */
.task-type-modal-header-status .task-type-modal-pills {
  margin: 0;
}

.task-type-modal-header-status-row .task-type-modal-pills {
  min-width: 0;
  max-width: 100%;
}

.task-type-modal-meta {
  margin-bottom: 0;
  overflow: visible;
}

.task-type-modal-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: flex-start;
}

.task-type-modal-meta-row--primary {
  margin-bottom: 1rem;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 0.5rem 0.75rem;
}

.task-type-modal-meta-row--secondary {
  margin-bottom: 0;
}

.task-type-modal-pill-item--stacked {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.task-type-modal-meta-row--primary .task-type-modal-pill-item--stacked {
  flex: 1 1 0;
  min-width: 0;
}

.task-type-modal-meta-row--secondary .task-type-modal-pill-item--stacked {
  flex: 1 1 0;
  min-width: 5rem;
}

.task-type-modal-pill-item--stacked .task-type-modal-pill-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.2;
}

.task-type-modal-pill-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.task-type-modal-pill-row--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 0;
}

.task-type-modal-pill-row--inline .task-type-modal-pill-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}

.task-type-modal-pill-row:last-child {
  margin-bottom: 0;
}

.task-type-modal-pill-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 5rem;
}

.task-type-modal-pill-row--inline .task-type-modal-pill-label {
  min-width: 0;
  flex-shrink: 0;
  white-space: nowrap;
}

.task-type-modal-pill-value {
  flex: 1;
  min-width: 0;
}

.task-type-modal-meta .task-type-modal-pills {
  margin-bottom: 0;
}

/* Type / Stage / Label: pill-shaped triggers to match mockup */
.task-type-modal-meta-row--secondary .task-type-modal-type-wrap,
.task-type-modal-meta-row--secondary .task-type-modal-action-wrap,
.task-type-modal-meta-row--secondary .task-type-modal-label-wrap {
  width: 100%;
}

.task-type-modal-meta-row--secondary .task-type-modal-dropdown .workflow-filter-trigger {
  width: 100%;
  min-width: 0;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--field-bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.task-type-modal-meta-row--secondary .task-type-modal-dropdown .workflow-filter-trigger:hover {
  background: var(--field-bg);
  border-color: var(--border);
}

/* Task slide-in: Category / Type / Stage / Label stacked like Add Workflow (operations-task-modal-field) */
.task-type-slide-panel .operations-task-modal-field .task-type-modal-category-wrap,
.task-type-slide-panel .operations-task-modal-field .task-type-modal-type-wrap,
.task-type-slide-panel .operations-task-modal-field .task-type-modal-action-wrap,
.task-type-slide-panel .operations-task-modal-field .task-type-modal-label-wrap {
  width: 100%;
}
.task-type-slide-panel .operations-task-modal-field .task-type-modal-dropdown .workflow-filter-trigger {
  width: 100%;
  min-width: 0;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--field-bg);
  border: 1px solid var(--border);
  color: var(--text);
}
.task-type-slide-panel .operations-task-modal-field .task-type-modal-dropdown .workflow-filter-trigger:hover {
  background: var(--field-bg);
  border-color: var(--border);
}

.task-type-modal-field-dropdown {
  position: relative;
  z-index: 1;
}

.task-type-modal-field-dropdown .workflow-filter-trigger {
  width: 100%;
  min-width: 0;
  text-align: left;
  cursor: pointer;
  border: none;
  background: var(--field-bg);
}

.task-type-modal-field-dropdown .workflow-filter-trigger:hover {
  background: var(--field-bg);
}

.task-type-modal-fields-empty {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* Workflow task overlay / subpage: staged sections from task-subpages-fields.md */
.workflow-overlay-stage-breadcrumb {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted, #64748b);
}

.workflow-overlay-stage-section {
  margin-bottom: 1.15rem;
}

.workflow-overlay-stage-section:last-child {
  margin-bottom: 0;
}

.workflow-overlay-stage-heading {
  margin: 0 0 0.55rem;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text, #111);
}

/* Task subpage left column: stage label | fields (per section) */
.task-type-modal--workflow-subpage .workflow-overlay-stage-section--split {
  display: grid;
  grid-template-columns: minmax(5.25rem, 10rem) minmax(0, 1fr);
  gap: 0.5rem 1.15rem;
  align-items: start;
  margin-bottom: 1.25rem;
}

.task-type-modal--workflow-subpage .workflow-overlay-stage-section--split:last-child {
  margin-bottom: 0;
}

.task-type-modal--workflow-subpage .workflow-overlay-stage-section--split .workflow-overlay-stage-heading {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--text-muted, #64748b);
}

.task-type-modal--workflow-subpage .workflow-overlay-stage-fields-col {
  min-width: 0;
}

@media (max-width: 520px) {
  .task-type-modal--workflow-subpage .workflow-overlay-stage-section--split {
    grid-template-columns: 1fr;
  }

  .task-type-modal--workflow-subpage .workflow-overlay-stage-section--split .workflow-overlay-stage-heading {
    margin-bottom: 0.35rem;
  }
}

.task-type-modal-checkbox-cell {
  width: 100%;
}

.task-type-modal-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  margin: 0;
}

.task-type-modal-checkbox-label .task-type-modal-checkbox {
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.task-type-modal-checkbox-text {
  line-height: 1.4;
  color: var(--text);
}

.task-type-modal-header,
.task-type-modal-meta,
.task-type-modal-pills {
  overflow: visible;
}

.task-type-modal-type-wrap,
.task-type-modal-action-wrap {
  width: fit-content;
  max-width: 100%;
  align-self: flex-start;
}

.task-type-modal-dropdown {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  vertical-align: top;
}

.task-type-modal-dropdown .workflow-filter-trigger {
  width: auto;
  max-width: 100%;
  min-width: 0;
  text-align: left;
  border: none;
  background: var(--field-bg);
}

.task-type-modal-dropdown .workflow-filter-trigger:hover {
  background: var(--field-bg);
}

.task-type-modal-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.task-type-modal-pills button {
  pointer-events: auto;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.task-type-modal-pill {
  display: inline-flex;
  align-items: center;
}

/* Modal task header pills: inherit shared workflow control tokens */
.task-type-modal-pills--workflow .workflow-date-trigger,
.task-type-modal-pills--workflow .workflow-status-trigger,
.task-type-modal-pills--workflow .workflow-assignee-trigger {
  min-width: 0;
}

.task-type-modal-pills--workflow .workflow-date-trigger:hover,
.task-type-modal-pills--workflow .workflow-status-trigger:hover,
.task-type-modal-pills--workflow .workflow-assignee-trigger:hover {
  border-color: var(--border-strong);
  background: var(--bg);
}

.task-type-modal-meta-row--primary .task-type-modal-pills--workflow .workflow-status-trigger,
.task-type-modal-meta-row--primary .task-type-modal-pills--workflow .workflow-date-trigger,
.task-type-modal-meta-row--primary .task-type-modal-pills--workflow .workflow-assignee-trigger {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 999px;
  justify-content: flex-start;
}

/* Status dropdown color tinting (same as table) */
.task-type-modal-pills--workflow[data-status="Backlog"] .workflow-status-trigger {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.task-type-modal-pills--workflow[data-status="On Hold"] .workflow-status-trigger {
  background: #ffedd5;
  border-color: #fdba74;
}

.task-type-modal-pills--workflow[data-status="Todo"] .workflow-status-trigger,
.task-type-modal-pills--workflow[data-status="To do"] .workflow-status-trigger {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.task-type-modal-pills--workflow[data-status="In Progress"] .workflow-status-trigger {
  background: #f5e6d3;
  border-color: #d4a574;
}

.task-type-modal-pills--workflow[data-status="Completed"] .workflow-status-trigger {
  background: #dcfce7;
  border-color: #86efac;
}

.task-type-modal-pills--workflow[data-status="Canceled"] .workflow-status-trigger {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.task-type-modal-pills--workflow[data-status="Overdue"] .workflow-status-trigger {
  background: #fee2e2;
  border-color: #fca5a5;
}

.task-type-modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.task-type-modal-row--half {
  grid-template-columns: 1fr 1fr;
}

.task-type-modal-row--third {
  grid-template-columns: 2fr 1fr 1fr;
}

.task-type-modal-row--full,
.task-type-modal-row:has(.task-type-modal-textarea) {
  grid-template-columns: 1fr;
}

.task-type-modal-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.task-type-modal-label span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
}

.task-type-modal-input,
.task-type-modal-type-select,
.task-type-modal-action-select {
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--text);
}

.task-type-modal-input:focus,
.task-type-modal-type-select:focus,
.task-type-modal-action-select:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--primary);
}

.task-type-modal-input::placeholder,
.task-type-modal-textarea::placeholder {
  color: var(--text-faint);
}

.task-type-modal-textarea {
  resize: none;
  min-height: 4rem;
}

.task-type-modal-fields {
  margin-top: 0;
}

.task-type-modal-footer {
  margin-top: 0;
  padding: 1rem 1.25rem 1.25rem;
  flex-shrink: 0;
  border-top: none;
}

.task-type-modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.task-type-modal-divider--before-footer {
  margin-top: 1.25rem;
  margin-bottom: 0;
}

.task-type-modal-footer-btns {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0 0.5rem;
}

.task-type-modal-footer-btns .btn {
  padding: 0.5rem 1rem;
}

.task-type-modal-footer-btns .btn--primary {
  margin-left: auto;
}

/* Task modal Save: disabled → spinner → checkmark */
.task-type-modal-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 4.75rem;
}

.task-type-modal-save:disabled {
  cursor: not-allowed;
  opacity: 0.92;
}

.task-type-modal-save-label {
  flex-shrink: 0;
}

.task-type-modal-save-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.2s ease;
}

.task-type-modal-save.is-saving .task-type-modal-save-indicator,
.task-type-modal-save.is-saved .task-type-modal-save-indicator {
  width: 1.125rem;
}

.task-type-modal-save-spinner,
.task-type-modal-save-check {
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.task-type-modal-save.is-saving .task-type-modal-save-spinner {
  display: inline-flex;
}

.task-type-modal-save.is-saving .task-type-modal-save-spinner i {
  display: block;
  animation: task-type-modal-save-spin 0.65s linear infinite;
}

.task-type-modal-save.is-saved .task-type-modal-save-check {
  display: inline-flex;
  animation: task-type-modal-save-check 0.35s ease;
}

@keyframes task-type-modal-save-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes task-type-modal-save-check {
  0% {
    transform: scale(0.55);
    opacity: 0;
  }
  70% {
    transform: scale(1.12);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

#patient-view .patient-wf-task-subpage-btns .task-type-modal-save {
  min-width: 4.75rem;
}

.add-note-patient-autocomplete {
  position: relative;
}

.add-note-patient-list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin: 0;
  margin-top: 0.15rem;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 50;
  max-height: 12rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.add-note-patient-list[hidden] {
  display: none;
}

.add-note-patient-list-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  cursor: pointer;
}

.add-note-patient-list-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.add-note-patient-list-id {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-left: 0.35rem;
}

.add-note-select {
  cursor: pointer;
}

.add-note-textarea {
  resize: none;
  min-height: 4.25rem;
  max-height: 12rem;
  overflow-y: auto;
}

.new-dashboard-description {
  margin: 0 0 1rem 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.new-dashboard-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.new-dashboard-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.new-dashboard-input {
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.new-dashboard-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.new-dashboard-select {
  cursor: pointer;
}

.new-dashboard-textarea {
  resize: none;
  min-height: 5rem;
}

/* Create workspace (Linear-style) */
.view-new-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.view-new-breadcrumb {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.view-new-breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.view-new-breadcrumb a:hover {
  text-decoration: underline;
}

.view-new-breadcrumb-sep {
  margin: 0 0.35rem;
  color: var(--text-faint);
}

.view-new-page-title {
  margin: 0;
  font-size: var(--font-page-title);
  font-weight: 600;
  color: var(--text);
}

.view-new-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.view-new-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.view-new-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.view-new-title-display {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.view-new-title-display:hover,
.view-new-title-display:focus-visible {
  background: var(--bg);
  border-color: var(--border);
  outline: none;
}

.view-new-title-display.hidden,
.view-new-title-input.hidden {
  display: none;
}

.view-new-desc-wrap.hidden {
  display: none;
}

.view-new-description-display {
  margin: 0;
  padding: 0.35rem 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.view-new-description-display:hover {
  border-color: var(--border);
  background: var(--bg);
}

.view-new-description-display.hidden,
.view-new-description-input.hidden {
  display: none;
}

.view-new-add-description.hidden {
  display: none;
}

.view-new-add-description {
  align-self: flex-start;
  text-align: left;
}

.view-new-title-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  color: var(--text-muted);
}

.view-new-title-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0;
  font: inherit;
  font-size: 1.125rem;
  font-weight: 600;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.view-new-title-input:hover {
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.view-new-title-input:focus {
  outline: none;
  border-bottom-color: var(--primary);
  background: var(--bg);
  padding: 0.5rem 0;
  border-radius: var(--radius-sm);
}

.view-new-title-input::placeholder {
  color: var(--text-faint);
}

.view-new-desc-wrap {
  display: block;
}

.view-new-description-input {
  width: 100%;
  min-width: 40rem;
  max-width: 100%;
  padding: 0.5rem 0;
  font: inherit;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  resize: none;
  min-height: 4rem;
  box-sizing: border-box;
}

.view-new-description-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.view-new-content-tabs {
  display: flex;
  gap: 0.25rem;
}

.view-new-tab {
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.view-new-tab:hover {
  color: var(--text);
  background: var(--bg);
}

.view-new-tab--active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.view-new-config {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.view-new-config-heading {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.view-new-config-sub {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.view-new-task-scope-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

.view-new-task-scope-row label {
  font-size: 0.875rem;
  font-weight: 500;
}

.view-new-select {
  min-width: 12rem;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.view-new-column-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 28rem;
}

.view-new-col-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.view-new-col-label input {
  flex-shrink: 0;
}

/* Views configurable tables: match Tasks column widths — content-sized cols (width:1%) + Task col fills remainder */
.view-configurable-task-table {
  table-layout: auto;
  width: 100%;
}

.view-configurable-task-table tbody tr {
  height: auto;
  min-height: 2.75rem;
}

#view-detail-view .view-configurable-task-table tbody td,
#view-new-view .view-configurable-task-table tbody td {
  height: auto;
  min-height: 2.75rem;
  max-height: none;
  vertical-align: middle;
}

/* Merged Patient col (avatar + name): same markup as Tasks — .home-patient-cell-inner { gap: 0.5rem } */
#view-detail-view .view-configurable-task-table :is(th.view-col-th--patient_group, td.view-col-td--patient_group),
#view-new-view .view-configurable-task-table :is(th.view-col-th--patient_group, td.view-col-td--patient_group) {
  text-align: left;
  min-width: 10rem;
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}

#view-detail-view .view-configurable-task-table :is(th.view-col-th--patient_avatar, td.view-col-td--patient_avatar),
#view-new-view .view-configurable-task-table :is(th.view-col-th--patient_avatar, td.view-col-td--patient_avatar) {
  width: 1%;
  min-width: 2.5rem;
  white-space: nowrap;
}

#view-detail-view .view-configurable-task-table :is(th.view-col-th--patient_name, td.view-col-td--patient_name),
#view-new-view .view-configurable-task-table :is(th.view-col-th--patient_name, td.view-col-td--patient_name) {
  width: 1%;
  min-width: 10rem;
  white-space: nowrap;
}

#view-detail-view .view-configurable-task-table :is(th.view-col-th--program, td.view-col-td--program),
#view-detail-view .view-configurable-task-table :is(th.view-col-th--vital_testosterone, td.view-col-td--vital),
#view-detail-view .view-configurable-task-table :is(th.view-col-th--tests_last, td.view-col-td--tests_last),
#view-detail-view .view-configurable-task-table :is(th.view-col-th--current_medication, td.view-col-td--current_medication),
#view-detail-view .view-configurable-task-table :is(th.view-col-th--session_plan, td.view-col-td--session_plan),
#view-detail-view .view-configurable-task-table :is(th.view-col-th--status, td.view-col-td--status),
#view-detail-view .view-configurable-task-table :is(th.view-col-th--date, td.view-col-td--date),
#view-detail-view .view-configurable-task-table :is(th.view-col-th--assignee, td.view-col-td--assignee),
#view-new-view .view-configurable-task-table :is(th.view-col-th--program, td.view-col-td--program),
#view-new-view .view-configurable-task-table :is(th.view-col-th--vital_testosterone, td.view-col-td--vital),
#view-new-view .view-configurable-task-table :is(th.view-col-th--tests_last, td.view-col-td--tests_last),
#view-new-view .view-configurable-task-table :is(th.view-col-th--current_medication, td.view-col-td--current_medication),
#view-new-view .view-configurable-task-table :is(th.view-col-th--session_plan, td.view-col-td--session_plan),
#view-new-view .view-configurable-task-table :is(th.view-col-th--status, td.view-col-td--status),
#view-new-view .view-configurable-task-table :is(th.view-col-th--date, td.view-col-td--date),
#view-new-view .view-configurable-task-table :is(th.view-col-th--assignee, td.view-col-td--assignee) {
  width: 1%;
  min-width: 8rem;
  white-space: nowrap;
}

/* Same as Tasks col 2: grows to use remaining horizontal space */
#view-detail-view .view-configurable-task-table :is(th.view-col-th--task, td.view-col-td--task),
#view-new-view .view-configurable-task-table :is(th.view-col-th--task, td.view-col-td--task) {
  width: auto;
  min-width: 28rem;
  max-width: none;
  white-space: nowrap;
}

#view-detail-view .view-configurable-task-table td.view-col-td--task,
#view-new-view .view-configurable-task-table td.view-col-td--task {
  overflow: visible;
}

#view-detail-view .view-configurable-task-table :is(th.workflow-row-actions-header, td.workflow-row-actions-cell),
#view-new-view .view-configurable-task-table :is(th.workflow-row-actions-header, td.workflow-row-actions-cell) {
  width: 1%;
  min-width: 2.5rem;
  white-space: nowrap;
}

#view-detail-view .view-configurable-task-table td.view-col-td--patient_avatar,
#view-new-view .view-configurable-task-table td.view-col-td--patient_avatar {
  padding-right: 0.25rem;
}

#view-detail-view .view-configurable-task-table td.view-col-td--patient_name,
#view-new-view .view-configurable-task-table td.view-col-td--patient_name {
  padding-left: 0.25rem;
}

.view-configurable-task-table td.view-col-td--task .home-task-cell-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  overflow: visible;
  white-space: nowrap;
}

.view-configurable-task-table td.view-col-td--task .workflow-task-trigger {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  max-width: none;
}

.view-configurable-task-table td.view-col-td--task .workflow-task-meta-row--table .workflow-task-trigger.patient-wf-task-id-link,
.view-configurable-task-table td.view-col-td--task .workflow-task-meta-row--table .workflow-task-trigger.workflow-task-id-link {
  flex: 0 0 auto;
}
.view-configurable-task-table td.view-col-td--task .workflow-task-trigger:has(.workflow-task-chips) {
  flex-wrap: nowrap;
}

.view-configurable-task-table td.view-col-td--task .workflow-task-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

/* Same cell padding / vertical alignment as #home-view Tasks table */
#view-detail-view .table-wrap.home-table-wrap .home-table.workflow-table > thead > tr > th,
#view-detail-view .table-wrap.home-table-wrap .home-table.workflow-table > tbody > tr > td,
#view-new-view .table-wrap.home-table-wrap .home-table.workflow-table > thead > tr > th,
#view-new-view .table-wrap.home-table-wrap .home-table.workflow-table > tbody > tr > td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

/* Workspace tables: uniform body font size in every row cell (header row unchanged) */
#view-detail-view .table-wrap.home-table-wrap .home-table.workflow-table > tbody > tr > td,
#view-new-view .table-wrap.home-table-wrap .home-table.workflow-table > tbody > tr > td {
  font-size: var(--text-md);
}

#view-detail-view .table-wrap.home-table-wrap .home-table.workflow-table > tbody > tr > td :where(
  .patient-checklist-cell,
  .workflow-task-chip,
  .workflow-task-chip-text,
  .workflow-task-chip-tail,
  .workflow-date-trigger,
  .workflow-filter-trigger,
  .workflow-status-trigger,
  .workflow-assignee-trigger,
  .workflow-date-completed-at,
  .workflow-task-text,
  .workflow-type-icon--chips,
  button.workflow-task-trigger
),
#view-new-view .table-wrap.home-table-wrap .home-table.workflow-table > tbody > tr > td :where(
  .patient-checklist-cell,
  .workflow-task-chip,
  .workflow-task-chip-text,
  .workflow-task-chip-tail,
  .workflow-date-trigger,
  .workflow-filter-trigger,
  .workflow-status-trigger,
  .workflow-assignee-trigger,
  .workflow-date-completed-at,
  .workflow-task-text,
  .workflow-type-icon--chips,
  button.workflow-task-trigger
) {
  font-size: inherit;
}

#view-detail-view .table-wrap.home-table-wrap .home-table.workflow-table > tbody > tr > td .home-name-link,
#view-new-view .table-wrap.home-table-wrap .home-table.workflow-table > tbody > tr > td .home-name-link {
  font-size: inherit;
}

.view-new-table-wrap {
  margin-top: 0.5rem;
}

.view-new-table-section {
  min-height: 12rem;
}

.view-new-table-section .view-new-table {
  margin-top: 0;
}

/* View detail (saved view) page */
.view-detail-header {
  margin-bottom: 1rem;
}

.view-detail-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.view-detail-title-display {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0.15rem 0;
  font-size: var(--font-page-title);
  font-weight: 600;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.view-detail-title-display:hover,
.view-detail-title-display:focus-visible {
  border-color: var(--border);
  background: var(--bg);
  outline: none;
}

.view-detail-title-input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0.15rem 0;
  font-size: var(--font-page-title);
  font-weight: 600;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  box-sizing: border-box;
}

.view-detail-title-input.hidden {
  display: none;
}

.view-detail-title-display.hidden {
  display: none;
}

.view-detail-title-input:hover {
  border-color: var(--border);
  background: var(--bg);
}

.view-detail-description-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.view-detail-title-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.view-detail-actions-wrap {
  position: relative;
  flex-shrink: 0;
}

.view-detail-actions-btn {
  padding: 0.35rem 0.5rem;
  font-size: 1.1rem;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.view-detail-actions-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.view-detail-actions-flyout {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 10rem;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 100;
}

.view-detail-actions-flyout[hidden] {
  display: none;
}

.view-detail-action-delete {
  display: block;
  width: 100%;
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}

.view-detail-action-delete:hover {
  background: var(--danger-bg);
}

.view-detail-description-wrap {
  max-width: 40rem;
  margin-top: 0.35rem;
}

.view-detail-description-wrap.hidden {
  display: none;
}

.view-detail-description-display {
  margin: 0;
  padding: 0.25rem 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.view-detail-description-display:hover,
.view-detail-description-display:focus-visible {
  border-color: var(--border);
  background: var(--bg);
  outline: none;
}

.view-detail-description-display.hidden {
  display: none;
}

.view-detail-description-input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.4rem 0;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  box-sizing: border-box;
}

.view-detail-description-input.hidden {
  display: none;
}

.view-detail-add-description {
  display: inline-block;
  margin: 0.25rem 0 0 0;
  padding: 0.15rem 0;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.view-detail-add-description:hover {
  color: var(--text);
  background: var(--bg);
}

.view-detail-add-description.hidden {
  display: none;
}

.view-detail-toolbar {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

/* View detail: count left, search right (no workflow filters) */
.view-detail-filters-row.home-dashboard-filters-row {
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}

.view-detail-filters-row .view-detail-count {
  flex-shrink: 0;
}

.view-detail-toolbar-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
}

.view-detail-toolbar-controls .view-detail-actions-wrap {
  position: relative;
  flex-shrink: 0;
}

.view-detail-filter-chips,
.view-new-filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}

.view-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-elevated, #f3f4f6);
  border: 1px solid var(--border-subtle, #e5e7eb);
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-secondary, #4b5563);
}

.view-filter-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.view-filter-chip-remove:hover {
  background: rgba(0, 0, 0, 0.06);
}

.view-detail-filter-panel,
.view-detail-display-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 0.5rem;
  background: var(--surface-elevated, #fafafa);
}

.view-detail-filter-panel.hidden,
.view-detail-display-panel.hidden {
  display: none;
}

.view-detail-filter-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary, #4b5563);
}

.view-detail-filter-select {
  min-width: 10rem;
}

.view-detail-display-panel .view-detail-column-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  width: 100%;
}

.view-new-template-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.view-new-template-row label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary, #4b5563);
  white-space: nowrap;
}

.view-new-filter-add-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.view-detail-filters-row .home-dashboard-search {
  flex-shrink: 0;
  width: min(16rem, 36vw);
}

.view-detail-filters-row .view-detail-add-filter-btn,
.view-detail-filters-row #view-detail-display-btn {
  flex-shrink: 0;
}

.view-detail-toolbar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.view-detail-toolbar-row .search-wrap {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.view-detail-toolbar-row .btn {
  margin-left: auto;
}

.view-detail-table-wrap {
  margin-top: 0;
}

#sidebar-workspaces,
#sidebar-custom-views {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  width: 100%;
}

#sidebar-workspaces .sidebar-link,
#sidebar-custom-views .sidebar-link {
  margin-bottom: 0;
}

.new-patient-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.new-patient-form .modal-body {
  flex: 1 1 auto;
  padding-bottom: 0;
  overflow-x: hidden;
}

.new-patient-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem 1.25rem;
}

.new-patient-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
}

.new-patient-label--full {
  grid-column: 1 / -1;
}

.new-patient-input {
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--text);
}

.new-patient-input:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--primary);
}

.new-patient-select {
  cursor: pointer;
}

.new-patient-textarea {
  resize: none;
  min-height: 2.5rem;
}

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

.modal-title {
  margin: 0;
  font-size: calc(1.25rem - 2px);
  font-weight: 600;
  color: var(--text);
}

.modal-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1 1 auto;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn {
  padding: 0.15rem 0.75rem;
  font: inherit;
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.25;
  min-height: 2rem;
  box-sizing: border-box;
  border-radius: var(--btn-radius);
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Primary and Secondary Button styles share the same height via .btn */
.btn--primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* Secondary Button Style: white/surface background, primary-colored text and border */
.btn--secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn--secondary:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.btn--tertiary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn--tertiary:hover {
  background: var(--bg);
  border-color: var(--border-strong, var(--border));
  color: var(--text);
}

.btn--danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn--danger:hover {
  background: var(--danger);
  filter: brightness(1.1);
  border-color: var(--danger);
}

.new-plan-section {
  margin-bottom: 1.5rem;
}

.new-plan-section:last-child {
  margin-bottom: 0;
}

.new-plan-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.new-plan-section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.new-plan-section-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.modal-dialog--new-plan .modal-footer.modal-footer--new-plan {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.65rem;
  padding-bottom: 1rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.new-plan-medications-empty {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.02);
}

.new-plan-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.new-plan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.new-plan-table th,
.new-plan-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.new-plan-table th {
  font-weight: 600;
  color: #000;
  background: var(--bg);
  font-size: 0.8125rem;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  border-bottom: none;
}

.new-plan-table tbody tr:last-child td {
  border-bottom: none;
}

/* Match workflow overlay / task-type-modal inputs */
.modal-dialog--new-plan .new-plan-input {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--text);
}

.modal-dialog--new-plan .new-plan-input:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--primary);
}

.modal-dialog--new-plan .new-plan-currency-wrap,
.modal-dialog--new-plan .new-plan-pct-wrap {
  display: inline-flex;
  align-items: center;
  width: auto;
  max-width: 100%;
}

.modal-dialog--new-plan .new-plan-currency-wrap .new-plan-input {
  width: 11ch;
  min-width: 6.75rem;
  max-width: 100%;
  flex: 0 1 auto;
  text-align: right;
}

/* Additional Cost: 25% narrower than default currency input above */
.modal-dialog--new-plan .new-plan-currency-wrap .new-plan-additional-cost {
  width: 8.25ch;
  min-width: 5.0625rem;
}

.modal-dialog--new-plan .new-plan-pct-wrap .new-plan-input {
  width: 4.5ch;
  min-width: 2.5rem;
  flex: 0 1 auto;
  text-align: right;
}

.new-plan-currency-prefix,
.new-plan-pct-suffix {
  flex-shrink: 0;
  padding: 0 0.25rem 0 0.35rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.new-plan-pct-wrap .new-plan-pct-suffix {
  padding: 0 0.35rem 0 0.25rem;
}

.new-plan-total-cost {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.modal-dialog--new-plan #new-plan-plan-table th:last-child,
.modal-dialog--new-plan #new-plan-plan-table td:last-child {
  padding-right: 0.35rem;
}

.new-plan-table td {
  vertical-align: middle;
}

.new-plan-table td.new-plan-col-cost,
.new-plan-table td.new-plan-col-discount {
  width: 1%;
  white-space: nowrap;
}

.new-plan-program-td {
  min-width: 11rem;
}

.modal-dialog--new-plan .new-plan-program-name-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.new-plan-session-cost-static {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
}

.new-plan-section--program-note {
  margin-bottom: 1.5rem;
}

.new-plan-program-note-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.modal-dialog--new-plan .new-plan-program-note {
  width: 100%;
  min-height: 3rem;
  resize: none;
}

/* Treatment Plan: shared grid (header + rows), 20px column gap; labels align with controls */
.modal-dialog--new-plan .new-plan-medication-grid {
  display: grid;
  grid-template-columns: 2.5rem minmax(8rem, 1fr) minmax(10rem, 1.25fr) minmax(10rem, 14rem) 1.75rem;
  column-gap: 20px;
  row-gap: 0.5rem;
  align-items: center;
}

.modal-dialog--new-plan .new-plan-medication-head-row {
  margin: -0.75rem -0.75rem 0.5rem -0.75rem;
  padding: 0.65rem 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.modal-dialog--new-plan .new-plan-medication-head-cell {
  font-weight: 600;
  font-size: 0.8125rem;
  color: #000;
  text-align: left;
  text-transform: capitalize;
  letter-spacing: -0.01em;
  min-width: 0;
}

.modal-dialog--new-plan .new-plan-medication-head-cell--actions {
  width: 100%;
  padding: 0;
}

.modal-dialog--new-plan .new-plan-medication-grid > .new-plan-medication-session {
  justify-self: center;
}

.modal-dialog--new-plan .new-plan-medication-grid > .new-plan-medication-description,
.modal-dialog--new-plan .new-plan-medication-grid > .new-plan-dosage-cell {
  justify-self: start;
}

.modal-dialog--new-plan .new-plan-program-td .asap-dropdown {
  display: block;
  width: 100%;
}

.modal-dialog--new-plan .new-plan-program-td .workflow-filter-trigger {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-align: left;
  cursor: pointer;
  border: none;
  background: var(--field-bg);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.modal-dialog--new-plan .new-plan-program-td .workflow-filter-trigger:hover {
  background: var(--field-bg);
}

.new-plan-medications-wrap {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background: var(--surface);
}

.new-plan-medication-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.new-plan-medication-description {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-muted);
  min-width: 0;
  white-space: normal;
  word-wrap: break-word;
}

/* Month/Medication selects use .plan-treatment-pill-select (same as Treatment Plan table); layout only here */
.new-plan-medication-row .new-plan-medication-session,
.new-plan-medication-row .new-plan-medication-catalog-select {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.new-plan-dosage-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex-wrap: wrap;
}

.new-plan-medication-dose-input {
  flex: 1 1 5rem;
  min-width: 4rem;
  max-width: 100%;
  padding: 0.45rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--text);
}

.modal-dialog--new-plan .new-plan-dosage-cell .new-plan-medication-dose-input {
  flex: 0 1 25%;
  max-width: 25%;
  width: 25%;
  min-width: 2rem;
}

.new-plan-dose-units-display {
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.new-plan-medication-row .new-plan-medication-delete {
  justify-self: end;
}

/* Tighter seam between Dosage column and delete (grid column-gap stays 20px elsewhere) */
.modal-dialog--new-plan .new-plan-medication-grid .new-plan-medication-delete {
  margin-left: -14px;
}

.new-plan-medication-cell {
  min-width: 0;
}

.modal-dialog--new-plan .new-plan-medication-cell .asap-dropdown {
  display: block;
  width: 100%;
}

.modal-dialog--new-plan .new-plan-medication-cell--type {
  flex: 0 1 10rem;
  min-width: 8rem;
}

.modal-dialog--new-plan .new-plan-medication-cell--unit {
  flex: 0 1 7rem;
  min-width: 5.5rem;
}

.modal-dialog--new-plan .new-plan-medication-cell .workflow-filter-trigger {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-align: left;
  cursor: pointer;
  border: none;
  background: var(--field-bg);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.modal-dialog--new-plan .new-plan-medication-cell .workflow-filter-trigger:hover {
  background: var(--field-bg);
}

.new-plan-medication-input,
.new-plan-medication-amount {
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9375rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  color: var(--text);
  min-width: 0;
}

.new-plan-medication-input:focus,
.new-plan-medication-amount:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--primary);
}

.new-plan-medication-input {
  flex: 1;
  min-width: 120px;
}

.new-plan-medication-amount {
  width: 4rem;
  flex-shrink: 0;
}

.new-plan-medication-delete {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.new-plan-medication-delete:hover {
  background: var(--error-bg, #fef2f2);
  color: var(--error, #b91c1c);
}

/* Remove number input spinners in New Program modal */
.modal-dialog--new-plan input[type="number"]::-webkit-outer-spin-button,
.modal-dialog--new-plan input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.modal-dialog--new-plan input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Responsive */
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
  }

  .sidebar-logo-row,
  .sidebar-clinic-wrap,
  .sidebar-demo-footer {
    width: auto;
    padding-inline: 0;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: row;
    gap: 0.25rem;
    width: auto;
  }

  .sidebar-nav-inner {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem;
    width: auto;
  }

  .sidebar-group {
    width: auto;
  }

  .sidebar-link,
  .sidebar-group-title-row,
  .sidebar-pinned-item,
  #sidebar-workspaces,
  #sidebar-pinned-patients {
    width: auto;
    max-width: none;
    margin-inline: 0;
  }

  .main {
    grid-column: 1;
    grid-row: 2;
  }

  .sidebar-demo-footer {
    width: 100%;
    flex-basis: 100%;
    order: 10;
    margin-top: 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    justify-content: flex-start;
  }

  .patient-record {
    grid-template-columns: 1fr;
  }

  .patients-table {
    min-width: 640px;
  }

  .dashboard-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-wrap {
    max-width: none;
  }

  .main.assistant-open {
    flex-direction: column;
  }

  .main.patient-picker-open {
    flex-direction: column;
  }

  .main.assistant-open .assistant-dock {
    flex: 0 0 min(42vh, 380px);
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .main.patient-picker-open .patient-picker-dock {
    flex: 0 0 min(42vh, 320px);
    width: 100%;
    max-width: none;
    min-width: 0;
    order: -1;
  }

  .main.assistant-open .assistant-dock-header-spacer {
    display: none;
  }
}

/* —— Global Assistant (header toggle + inline dock) —— */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.assistant-toggle-btn {
  position: static;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.main:not(.assistant-open) .home-dashboard-title-row,
.main:not(.assistant-open) .patients-dashboard-title-row,
.main:not(.assistant-open) .page-header-title-row,
.main:not(.assistant-open):not(:has(#patient-view:not(.hidden))) .patient-record-breadcrumb,
.main:not(.assistant-open) .view-new-header,
.main:not(.assistant-open) .view-detail-title-row {
  padding-right: 2.25rem;
}

.assistant-toggle-btn:hover {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--text);
}

.assistant-toggle-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.assistant-toggle-btn.is-active,
.assistant-toggle-btn[aria-expanded="true"] {
  background: var(--primary-light);
  color: var(--primary);
}

.assistant-dock {
  display: none;
  flex: 0 0 var(--assistant-dock-width);
  width: var(--assistant-dock-width);
  min-width: 300px;
  max-width: 42vw;
  min-height: 0;
  flex-direction: column;
  background: var(--main-shell-bg);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.assistant-dock[hidden] {
  display: none !important;
}

.main.assistant-open .assistant-dock {
  display: flex;
}

.assistant-dock-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

.assistant-dock-header-spacer {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.assistant-dock-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.assistant-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.assistant-tabs {
  display: flex;
  flex-shrink: 0;
  gap: 0;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  background: var(--surface);
}

.assistant-tab {
  flex: 1;
  padding: 0.65rem 0.5rem;
  margin: 0;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}

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

.assistant-tab--active {
  color: var(--primary, #2563eb);
  border-bottom-color: var(--primary, #2563eb);
}

.assistant-panels {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.assistant-subpanel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow: hidden;
}

.assistant-subpanel[hidden] {
  display: none !important;
}

.assistant-disclaimer {
  flex-shrink: 0;
  margin: 0 0 0.75rem;
  font-size: 0.6875rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.assistant-subpanel .assistant-composer {
  flex-shrink: 0;
  margin-top: auto;
}

.assistant-chat-messages {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.assistant-chat-bubble {
  max-width: 92%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius, 8px);
  font-size: 0.875rem;
  line-height: 1.45;
}

.assistant-chat-bubble--user {
  align-self: flex-end;
  background: var(--primary-light, rgba(37, 99, 235, 0.12));
  color: var(--text);
}

.assistant-chat-bubble--assistant {
  align-self: flex-start;
  background: var(--field-bg, rgba(0, 0, 0, 0.04));
  color: var(--text);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.06));
}

.assistant-chat-bubble--task-guidance {
  white-space: pre-wrap;
}

.assistant-chat-bubble--task-guidance-rich {
  white-space: normal;
}

.assistant-chat-bubble--task-guidance-note {
  margin-top: 0.35rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
  background: transparent;
  border: none;
  padding: 0.15rem 0;
}

.assistant-guidance-blocks {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.assistant-guidance-block--text .assistant-guidance-paragraph {
  margin: 0 0 0.5rem;
  line-height: 1.5;
}

.assistant-guidance-block--text .assistant-guidance-paragraph:last-child {
  margin-bottom: 0;
}

.assistant-guidance-list {
  margin: 0;
  padding-left: 1.25rem;
  line-height: 1.5;
}

.assistant-guidance-list li + li {
  margin-top: 0.35rem;
}

.assistant-guidance-question-prompt {
  margin: 0 0 0.5rem;
  font-weight: 500;
  line-height: 1.45;
}

.assistant-guidance-question-tabs.progress-view-tabs {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

.assistant-guidance-option-btn.progress-view-tab {
  flex: 1 1 auto;
  justify-content: center;
  min-width: 0;
}

.assistant-guidance-action-btn {
  align-self: flex-start;
}

.assistant-chat-bubble--pending {
  opacity: 0.85;
  font-style: italic;
}

.assistant-composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 1rem 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.assistant-composer:focus-within {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.assistant-composer-input {
  width: 100%;
  min-height: 3.25rem;
  max-height: 12rem;
  padding: 0;
  border: none;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
}

.assistant-composer-input::placeholder {
  color: var(--text-faint);
}

.assistant-composer-input:focus {
  outline: none;
}

.assistant-composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.125rem;
}

.assistant-composer-footer .assistant-model-dropdown {
  flex: 0 1 auto;
  min-width: 0;
}

.assistant-model-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2rem;
  padding: 0 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  max-width: 100%;
}

.assistant-model-trigger:hover {
  background: var(--primary-light);
  color: var(--text);
}

.assistant-model-icon {
  font-size: 0.875rem;
  opacity: 0.75;
  flex-shrink: 0;
}

.assistant-model-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assistant-composer-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.assistant-composer-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.assistant-composer-send:hover {
  background: color-mix(in srgb, var(--text) 88%, var(--primary));
}

.assistant-composer-send:active {
  transform: scale(0.96);
}

.assistant-composer-send:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.assistant-composer-send i {
  font-size: 1rem;
  line-height: 1;
}

.assistant-dock .assistant-composer {
  padding: 0.75rem 0.75rem 0.625rem;
  gap: 0.5rem;
}

.assistant-dock .assistant-composer-input {
  font-size: 0.875rem;
  min-height: 2.75rem;
  max-height: 10rem;
}

.assistant-dock .assistant-composer-footer .assistant-model-dropdown {
  flex: 1 1 auto;
  max-width: calc(100% - 2.5rem);
}

.assistant-dock .assistant-subpanel {
  padding: 0.75rem 1rem 1rem;
}

.assistant-guidance-intro {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.assistant-guidance-search-wrap {
  position: relative;
  flex-shrink: 0;
  margin-bottom: 0.75rem;
}

.assistant-guidance-search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--text-muted);
  pointer-events: none;
}

.assistant-guidance-search {
  width: 100%;
  padding: 0.5rem 0.65rem 0.5rem 2rem;
  font: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: var(--radius-sm, 6px);
  background: var(--field-bg);
  color: var(--text);
}

.assistant-guidance-search:focus {
  outline: none;
  border-color: var(--primary, #2563eb);
}

.assistant-guidance-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.assistant-guidance-article {
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.assistant-guidance-article:hover {
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
  border-color: var(--primary, rgba(37, 99, 235, 0.35));
}

.assistant-guidance-article:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
}

.main.main--assistant-page .main-header-trailing .assistant-toggle-btn {
  opacity: 0.45;
  pointer-events: none;
}

.inbox-list-root {
  max-width: 920px;
}

/* Inbox split layout — workflow dock (patient-picker style) + patient detail */
.main.inbox-route-open {
  max-width: none;
}

.main.inbox-route-open .main-content-shell {
  flex-direction: row;
  align-items: stretch;
  gap: 0.75rem;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  flex: 1 1 auto;
  min-height: 0;
}

.main.inbox-route-open .main-content-shell > .view:not(.hidden) {
  min-height: 0;
}

.main.inbox-route-open #inbox-view.inbox-view-split {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.main.inbox-route-open.inbox-has-patient-selected #inbox-view.inbox-view-split {
  flex: 0 0 var(--patient-picker-dock-width);
  width: var(--patient-picker-dock-width);
  min-width: 260px;
  max-width: 36vw;
}

.main.inbox-route-open:not(.inbox-has-patient-selected) #inbox-view.inbox-view-split {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}

.main.inbox-route-open.inbox-has-patient-selected #patient-view:not(.hidden) {
  flex: 1 1 0;
  min-width: 0;
  display: flex !important;
  flex-direction: column;
  background: var(--main-shell-bg);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  padding: 1.5rem;
  box-sizing: border-box;
}

.main.inbox-route-open.inbox-has-patient-selected #patient-view .patient-view-sticky-header {
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  padding-left: 0;
  padding-right: 0;
}

.inbox-page-split {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.75rem;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  width: 100%;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}

.main.inbox-route-open .inbox-workflow-dock {
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--patient-picker-dock-width);
  width: var(--patient-picker-dock-width);
  min-width: 260px;
  max-width: 36vw;
  min-height: 0;
  background: var(--main-shell-bg);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.main.inbox-route-open.inbox-has-patient-selected .inbox-workflow-dock {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
}

.main.inbox-route-open .inbox-patient-pane {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--main-shell-bg);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.inbox-workflow-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.5rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

.inbox-workflow-dock-title {
  margin: 0;
  font-size: var(--font-section-title);
  font-weight: 600;
}

.inbox-workflow-dock-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.65rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

.inbox-workflow-dock-toolbar .progress-view-tabs.inbox-workflow-filter-tabs {
  display: flex;
  width: 100%;
  box-sizing: border-box;
}

.inbox-workflow-dock-toolbar .inbox-workflow-filter-tab {
  flex: 1 1 0;
  justify-content: center;
}

.inbox-workflow-dock-toolbar .patient-picker-search-wrap.inbox-workflow-search-wrap.search-wrap {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: none;
  margin: 0;
}

.inbox-workflow-search-wrap .search-icon {
  left: 0.65rem;
  font-size: 0.9375rem;
}

.inbox-workflow-search-wrap .inbox-workflow-search {
  width: 100%;
  box-sizing: border-box;
}

.inbox-workflow-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
}

.inbox-workflow-empty {
  margin: 2rem 1rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-align: center;
}

.inbox-workflow-item {
  display: block;
  width: 100%;
  padding: 0.85rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.inbox-workflow-item:hover {
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
}

.inbox-workflow-item--active {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  box-shadow: inset 3px 0 0 var(--primary);
}

.inbox-workflow-item--overdue .inbox-workflow-item-meta-field:last-child,
.inbox-workflow-item--overdue .inbox-workflow-item-path {
  color: var(--danger, #c0392b);
}

.inbox-workflow-item-patient {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  margin-bottom: 0.35rem;
}

.inbox-workflow-item-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.6875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.inbox-workflow-item-avatar--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.inbox-workflow-item-patient-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-workflow-item-path {
  margin: 0 0 0.45rem 0;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.inbox-workflow-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.inbox-workflow-item-meta-field {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.inbox-workflow-item-meta-icon {
  flex-shrink: 0;
  font-size: 0.8125rem;
  opacity: 0.75;
  line-height: 1;
}

.inbox-workflow-item-meta-label {
  font-weight: 600;
  color: var(--text-faint, var(--text-muted));
  margin-right: 0.2rem;
}

.inbox-patient-pane--empty .inbox-detail-empty {
  margin: auto;
}

.main.inbox-route-open.inbox-has-patient-selected .inbox-patient-pane {
  display: none;
}

.inbox-list-empty {
  margin: 2rem 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  text-align: center;
}

.inbox-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.inbox-item:hover {
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
}

.inbox-item-type {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding-top: 0.15rem;
  min-width: 3.5rem;
}

.inbox-item-body {
  flex: 1;
  min-width: 0;
}

.inbox-item-title {
  margin: 0 0 0.2rem 0;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-item-meta {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.inbox-item-date {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-faint);
  padding-top: 0.2rem;
}

.assistant-page-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.assistant-page-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem 2rem;
  overflow-y: auto;
}

.assistant-page-layout--chat-active {
  align-items: stretch;
  justify-content: flex-start;
  padding-top: 1.5rem;
}

.assistant-page-inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.25rem;
}

.assistant-page-layout--chat-active .assistant-page-inner {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 800px;
  gap: 1rem;
}

.assistant-page-landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0 0.25rem;
  text-align: center;
}

.assistant-page-hero-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: color-mix(in srgb, var(--primary) 55%, var(--text-muted));
  font-size: 1.75rem;
}

.assistant-page-hero-title {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.125rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.assistant-page-chat-thread {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.assistant-page-chat-messages {
  flex: 1 1 auto;
  min-height: 8rem;
  max-height: none;
  overflow-y: auto;
}

.assistant-page-examples {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.assistant-page-examples-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.assistant-page-examples-heading {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.assistant-page-examples-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
}

.assistant-page-examples-dismiss:hover {
  background: var(--field-bg);
  color: var(--text-muted);
}

.assistant-page-examples-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.assistant-page-example-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.875rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.assistant-page-example-card:hover {
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
  box-shadow: var(--shadow);
  background: var(--primary-light-hover);
}

.assistant-page-example-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.assistant-page-example-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--text-muted);
  font-size: 0.95rem;
}

.assistant-page-example-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.assistant-page-example-desc {
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.assistant-page-disclaimer {
  margin: 0;
  text-align: center;
  font-size: 0.6875rem;
  line-height: 1.45;
  color: var(--text-faint);
}

@media (max-width: 768px) {
  .assistant-page-layout {
    padding: 1.5rem 1rem 1.25rem;
  }

  .assistant-page-examples-grid {
    grid-template-columns: 1fr;
  }
}

.assistant-page-body {
  padding: 0 1.25rem 1.25rem;
}

.assistant-page-shell {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 10rem);
  max-width: 840px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.assistant-page-shell .assistant-panels {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.assistant-page-shell .assistant-subpanel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.assistant-page-shell .assistant-chat-messages {
  flex: 1;
  min-height: 12rem;
  max-height: none;
}

.patient-picker-dock {
  display: none;
  flex: 0 0 var(--patient-picker-dock-width);
  width: var(--patient-picker-dock-width);
  min-width: 260px;
  max-width: 36vw;
  min-height: 0;
  flex-direction: column;
  background: var(--main-shell-bg);
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.patient-picker-dock[hidden] {
  display: none !important;
}

.main.patient-picker-open .patient-picker-dock {
  display: flex;
}

.patient-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.5rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

.patient-picker-header .patient-picker-close {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
}

.patient-picker-header .patient-picker-close svg {
  width: 14px;
  height: 14px;
}

.patient-picker-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.patient-picker-search-wrap.search-wrap {
  position: relative;
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  margin: 0.75rem 1rem 0.5rem;
}

.patient-picker-search-wrap .search-icon {
  left: 0.65rem;
  font-size: 0.9375rem;
}

.patient-picker-search-wrap .patient-picker-search {
  width: 100%;
  box-sizing: border-box;
}

.patient-picker-list {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem 1rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  align-self: stretch;
}

.patient-picker-item {
  display: block;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.patient-picker-item:hover,
.patient-picker-item:focus-visible {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  outline: none;
}

.patient-picker-item-name {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
}

.patient-picker-item-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.patient-picker-empty {
  padding: 0.75rem;
}

.patient-checklist-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
}

/* Program cost table — metrics cluster (Quantity / Cost / Subtotal / remove) */
#patient-view #patient-overview-panel .patient-program-cost-table-metrics {
  width: 0;
  min-width: max-content;
  white-space: nowrap;
  padding: 0.55rem 0.65rem !important;
  vertical-align: middle;
}

#patient-view #patient-overview-panel .patient-program-cost-metrics-row {
  display: grid;
  grid-template-columns: minmax(2.75rem, max-content) minmax(3.5rem, max-content) minmax(4.75rem, max-content) 1.5rem;
  column-gap: 0.75rem;
  justify-items: end;
  align-items: center;
  width: max-content;
  margin-left: auto;
}

#patient-view #patient-overview-panel .patient-program-cost-metrics-row:not(.patient-program-cost-metrics-row--header) .patient-program-cost-table-qty,
#patient-view #patient-overview-panel .patient-program-cost-metrics-row:not(.patient-program-cost-metrics-row--header) .patient-program-cost-table-cost,
#patient-view #patient-overview-panel .patient-program-cost-metrics-row:not(.patient-program-cost-metrics-row--header) .patient-program-cost-table-subtotal,
#patient-view #patient-overview-panel .patient-program-cost-metrics-row:not(.patient-program-cost-metrics-row--header) .patient-program-cost-table-actions {
  width: auto;
  min-width: 0;
  max-width: none;
  padding: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#patient-view #patient-overview-panel .patient-program-cost-metrics-row--header .patient-program-cost-table-qty,
#patient-view #patient-overview-panel .patient-program-cost-metrics-row--header .patient-program-cost-table-cost,
#patient-view #patient-overview-panel .patient-program-cost-metrics-row--header .patient-program-cost-table-subtotal {
  min-width: max-content;
  white-space: nowrap;
  font: inherit;
  color: inherit;
  text-transform: none;
  letter-spacing: normal;
}

#patient-view #patient-overview-panel .patient-program-cost-table th.patient-program-cost-table-metrics {
  padding-left: 0.15rem !important;
  padding-right: 0.65rem !important;
  text-align: right;
}

#patient-view #patient-overview-panel .patient-program-cost-metrics-row .patient-program-cost-table-actions {
  justify-self: end;
  width: 1.5rem;
}

#patient-view #patient-overview-panel .patient-program-cost-metrics-row .patient-program-cost-footer-totals-cell,
#patient-view #patient-overview-panel .patient-program-cost-metrics-row .patient-program-cost-fee-subtotal {
  grid-column: 3;
  justify-self: end;
}

/* Program materials table — metrics cluster aligned with cost Subtotal + actions spacer */
#patient-view #patient-overview-panel .patient-program-materials-table-metrics {
  width: 0;
  min-width: max-content;
  white-space: nowrap;
  padding: 0.55rem 0.65rem !important;
  vertical-align: middle;
}

#patient-view #patient-overview-panel .patient-program-materials-metrics-row {
  display: grid;
  grid-template-columns: minmax(2.75rem, max-content) minmax(3.5rem, max-content) minmax(4.75rem, max-content) 1.5rem;
  column-gap: 0.75rem;
  justify-items: end;
  align-items: center;
  width: max-content;
  margin-left: auto;
}

#patient-view #patient-overview-panel .patient-program-materials-metrics-row:not(.patient-program-materials-metrics-row--header) .patient-program-materials-table-status,
#patient-view #patient-overview-panel .patient-program-materials-metrics-row:not(.patient-program-materials-metrics-row--header) .patient-program-materials-table-date {
  width: auto;
  min-width: 0;
  max-width: none;
  padding: 0;
  text-align: right;
}

#patient-view #patient-overview-panel .patient-program-materials-metrics-row--header .patient-program-materials-table-status,
#patient-view #patient-overview-panel .patient-program-materials-metrics-row--header .patient-program-materials-table-date {
  min-width: max-content;
  white-space: nowrap;
  font: inherit;
  color: inherit;
  text-transform: none;
  letter-spacing: normal;
}

#patient-view #patient-overview-panel .patient-program-materials-table th.patient-program-materials-table-metrics {
  padding-left: 0.15rem !important;
  padding-right: 0.65rem !important;
  text-align: right;
}

#patient-view #patient-overview-panel .patient-program-materials-metrics-row:not(.patient-program-materials-metrics-row--header) .patient-program-materials-table-date {
  color: var(--text-muted);
}

#patient-view #patient-overview-panel .patient-program-materials-metrics-row .patient-program-materials-table-actions-spacer {
  width: 1.5rem;
}

/* Item column grows into remaining space; metrics column stays shrink-wrapped */
#patient-view #patient-overview-panel .patient-program-cost-table .patient-program-cost-table-item,
#patient-view #patient-overview-panel .patient-program-materials-table .patient-program-materials-table-item {
  width: auto;
  min-width: 0;
}

#patient-view #patient-overview-panel .patient-program-cost-table .patient-program-table-item-text,
#patient-view #patient-overview-panel .patient-program-materials-table .patient-program-table-item-text {
  flex: 1 1 auto;
  min-width: 0;
}

