/* Patient Board — minimal read-only clinical viewer */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-body: "Aptos", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-heading: "Aptos Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font: var(--font-body);
  --mono: "Cascadia Mono", "Consolas", monospace;

  --bg:                #f4f7fb;
  --surface:           rgba(255, 255, 255, 0.94);
  --surface-strong:    #ffffff;
  --surface-alt:       rgba(255, 255, 255, 0.88);
  --border:            rgba(15, 23, 42, 0.12);
  --text:              #15263b;
  --muted:             #61748a;
  --accent:            #10b981;
  --accent-bg:         rgba(16, 185, 129, 0.12);
  --accent-secondary:  #f43f5e;
  --accent-tertiary:   #f59e0b;
  --pill-good:         #047857;
  --pill-good-bg:      rgba(16, 185, 129, 0.14);
  --pill-good-border:  rgba(16, 185, 129, 0.24);
  --pill-warn:         #b45309;
  --pill-warn-bg:      rgba(245, 158, 11, 0.16);
  --pill-warn-border:  rgba(245, 158, 11, 0.24);
  --pill-risk:         #be123c;
  --pill-risk-bg:      rgba(244, 63, 94, 0.14);
  --pill-risk-border:  rgba(244, 63, 94, 0.24);
  --shadow:            0 24px 56px rgba(15, 23, 42, 0.14);

  --sidebar-w: 340px;
  --sidebar-min-w: 300px;
  --sidebar-max-w: 520px;
  --topbar-h:  60px;
  --status-h:  32px;
  --card-min:  228px;
  --card-gap:  42px;
  --radius:    16px;
  --radius-sm: 12px;
  --topbar-bg: rgba(255, 255, 255, 0.94);
  --topbar-border: rgba(15, 23, 42, 0.06);
  --topbar-divider: rgba(148, 163, 184, 0.18);
  --topbar-text: #142133;
  --topbar-muted: #5f7188;
  --topbar-search-bg: rgba(255, 255, 255, 0.96);
  --topbar-search-border: rgba(148, 163, 184, 0.18);
  --topbar-search-icon: #64748b;
  --topbar-search-placeholder: #7b8da5;
  --topbar-popover-bg: #ffffff;
  --topbar-popover-shadow: 0 16px 28px rgba(15, 23, 42, 0.14);
  --detail-divider: rgba(148, 163, 184, 0.28);
  --section-title-bg: rgba(241, 245, 249, 0.98);
  --section-title-border: rgba(148, 163, 184, 0.2);
  --section-title-text: #475569;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(16, 185, 129, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(244, 63, 94, 0.09), transparent 24%),
    radial-gradient(circle at bottom right, rgba(245, 158, 11, 0.08), transparent 22%),
    linear-gradient(180deg, #fcfdff 0%, var(--bg) 100%);
  transition: background 0.2s ease, color 0.2s ease;
}

button, input, select, textarea { font: inherit; }

/* ── Shell ─────────────────────────────────── */
.boardShell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Topbar ─────────────────────────────────── */
.boardTopbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: var(--topbar-h);
  padding: 10px 18px;
  background: var(--topbar-bg);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--topbar-border);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  overflow: visible;
  box-shadow: none;
}

.boardHeaderLoading {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 18px 10px;
  background: var(--topbar-bg);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--topbar-border);
}
.boardHeaderLoading.hidden { display: none !important; }
.boardHeaderLoadingBar {
  position: relative;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
}
.boardHeaderLoadingBar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 -38%;
  width: 38%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent 0%, rgba(16, 185, 129, 0.34) 12%, var(--accent) 52%, rgba(16, 185, 129, 0.34) 88%, transparent 100%);
  animation: board-progress-slide 1.15s ease-in-out infinite;
}
.boardHeaderLoadingText {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.boardBrand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
  position: relative;
}
.boardBrandText {
  display: flex;
  align-items: center;
  min-width: 0;
}
.boardBrandMark {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 9px;
  background: rgba(16, 185, 129, 0.08);
  color: #2fd19a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.12);
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.boardBrandMark:hover {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
}
.boardBrandMark:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12), inset 0 0 0 1px rgba(52, 211, 153, 0.18);
}
.boardBrandMark .bdIcon {
  margin-right: 0;
}
.boardBrand h1 {
  font-family: var(--font-heading);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: clamp(1.05rem, 1.25vw, 1.55rem);
  font-weight: 800;
  color: var(--topbar-text);
  letter-spacing: -0.045em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.boardBrandWord {
  color: var(--topbar-text);
}
.boardBrandWord.isAccent {
  color: #22d399;
}

.boardHeaderSearch {
  display: flex;
  justify-content: flex-start;
  min-width: 0;
  flex: 0 0 auto;
}
.boardHeaderSearchWrap {
  position: relative;
  display: flex;
  align-items: center;
  width: clamp(240px, 20vw, 340px);
}
.boardHeaderSearchActions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.boardHeaderSearchIcon {
  position: absolute;
  left: 12px;
  color: var(--topbar-search-icon);
  pointer-events: none;
}
.boardHeaderSearchWrap input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 10px 80px 10px 36px;
  border: 1px solid var(--topbar-search-border);
  border-radius: 14px;
  font-family: var(--font);
  font-size: 13px;
  background: var(--topbar-search-bg);
  color: var(--topbar-text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.boardHeaderSearchWrap input::placeholder {
  color: var(--topbar-search-placeholder);
}
.boardHeaderSearchWrap input:focus {
  border-color: rgba(52, 211, 153, 0.32);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.08);
}
.boardSearchFilterBtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--topbar-muted);
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}
.boardHeaderPopoverAnchorSearch {
  z-index: 4;
}
.boardSearchFilterBtn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--topbar-text);
}
.boardSearchFilterBtn .bdIcon {
  margin-right: 0;
}
.boardSearchFilterBtn.isActive {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
}
.boardSearchFavoriteBtn.isActive {
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.2);
}
.boardSearchFilterCount {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #21c58a;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}

.boardTopbarActions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
}

.boardTopbarPrimary.boardBtn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--topbar-search-border);
  background: var(--topbar-search-bg);
  color: var(--topbar-muted);
  box-shadow: none;
  font-size: 12px;
  font-weight: 700;
}
.boardTopbarPrimary.boardBtn.hasPending {
  border-color: rgba(16, 185, 129, 0.26);
  background: linear-gradient(180deg, #19c987 0%, #11b276 100%);
  color: #f6fffb;
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.boardTopbarPrimary.boardBtn.hasPending:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.boardTopbarPrimary.boardBtn:disabled {
  opacity: 1;
  box-shadow: none;
  transform: none;
}
.boardTopbarPrimary .btnLabel {
  white-space: nowrap;
}
.boardTopbarPrimaryCount {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 7px;
  background: rgba(4, 120, 87, 0.42);
  color: #ecfdf5;
  font-size: 11px;
  font-weight: 800;
}

.boardTopbarNav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.boardTopbarLink {
  min-height: 44px;
  padding: 0 14px;
  border: none;
  background: transparent;
  color: var(--topbar-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}
.boardTopbarLink:hover {
  color: var(--topbar-text);
  background: rgba(255, 255, 255, 0.04);
}
.boardTopbarLink .bdIcon {
  margin-right: 0;
  opacity: 0.92;
}

.boardTopbarUtilities {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  padding-left: 14px;
  border-left: 1px solid var(--topbar-divider);
}

.boardTopbarIconBtn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--topbar-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.boardTopbarIconBtn:hover,
.boardTopbarIconBtn.isActive {
  background: rgba(255, 255, 255, 0.04);
  color: var(--topbar-text);
}
.boardTopbarIconBtn .bdIcon {
  margin-right: 0;
}

#btnSidebarToggle.boardBtn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--topbar-muted);
  box-shadow: none;
}
#btnSidebarToggle.boardBtn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--topbar-text);
}

.boardRefreshedTime {
  position: absolute;
  top: calc(100% + 8px);
  left: 44px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 11px;
  border: 1px solid var(--topbar-divider);
  background: var(--topbar-popover-bg);
  color: var(--topbar-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: var(--topbar-popover-shadow);
  white-space: nowrap;
  z-index: 24;
}
.boardRefreshedTime.hidden {
  display: none !important;
}
.boardRefreshedTime .bdIcon {
  margin-right: 0;
  color: #34d399;
}
.boardHeaderPopoverAnchor {
  position: relative;
  z-index: 3;
}
.favoriteFiltersPopover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  width: min(360px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.favoriteFiltersPopover.hidden {
  display: none !important;
}
.favoriteFiltersPopoverHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.favoriteFiltersTitle {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
}
.favoriteFiltersHint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.favoriteFiltersActions {
  justify-content: flex-start;
}
.favoriteFiltersList {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}
.favoriteFiltersEmpty {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
}
.favoriteFilterItem {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
}
.favoriteFilterItemBody {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.favoriteFilterItemTitle {
  font-size: 13px;
  font-weight: 700;
}
.favoriteFilterItemSummary {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.favoriteFilterItemActions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.favoriteDeleteBtn {
  padding-inline: 9px;
}
.favoriteDeleteBtn .bdIcon {
  margin-right: 0;
}

/* ── Inline SVG icons ───────────────────────── */
.bdIcon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.boardBtn .bdIcon { margin-right: 5px; }

/* ── Buttons ─────────────────────────────────── */
.boardBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.14s ease, background 0.14s ease, color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, opacity 0.12s;
  white-space: nowrap;
}
.boardBtnGhost {
  background: var(--surface-alt);
  color: var(--text);
}
.boardBtnGhost:hover {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: rgba(16, 185, 129, 0.28);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}
.boardBtnGhost.isActive {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: rgba(16, 185, 129, 0.28);
}
.boardBtnPrimary {
  background: linear-gradient(135deg, var(--accent) 0%, #0f766e 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 16px 32px rgba(16, 185, 129, 0.22);
}
.boardBtnPrimary:hover { opacity: 0.96; transform: translateY(-1px); }
.boardBtn:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
  box-shadow: none;
}
.boardBtn:disabled:hover {
  transform: none;
  box-shadow: none;
}
.boardBtnSm { padding: 4px 10px; font-size: 16px; }
.boardBtnIcon {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  gap: 0;
}
.boardBtnIcon .bdIcon { margin-right: 0; }
.boardBtnIcon.isActive {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: rgba(16, 185, 129, 0.28);
}

/* ── Workspace ─────────────────────────────────── */
.boardWorkspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* ── Sidebar ─────────────────────────────────── */
.boardSidebar {
  width: clamp(var(--sidebar-min-w), var(--sidebar-w), var(--sidebar-max-w));
  flex-shrink: 0;
  min-width: var(--sidebar-min-w);
  max-width: var(--sidebar-max-w);
  background: var(--surface);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, border-color 0.2s ease;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

/* ── Sidebar collapsed ───────────────────────── */
.boardSidebar.isCollapsed {
  width: 0;
  min-width: 0;
  border-right-color: transparent;
}
.boardSidebar.isCollapsed .sidebarHead,
.boardSidebar.isCollapsed .sidebarSearch,
.boardSidebar.isCollapsed .milestoneFilterBanner,
.boardSidebar.isCollapsed .patientList {
  display: none;
}
.sidebarResizeHandle {
  position: relative;
  flex: 0 0 12px;
  width: 12px;
  cursor: col-resize;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.06), rgba(148, 163, 184, 0));
  transition: background 0.14s ease, opacity 0.14s ease, width 0.2s ease;
}
.sidebarResizeHandle::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 5px;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0), rgba(148, 163, 184, 0.58) 18%, rgba(148, 163, 184, 0.58) 82%, rgba(148, 163, 184, 0));
}
.sidebarResizeHandle:hover,
.sidebarResizeHandle.isDragging {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.02));
}
.sidebarResizeHandle:hover::before,
.sidebarResizeHandle.isDragging::before {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0), rgba(16, 185, 129, 0.78) 18%, rgba(16, 185, 129, 0.78) 82%, rgba(16, 185, 129, 0));
}
.sidebarResizeHandle.isHidden {
  width: 0;
  flex-basis: 0;
  opacity: 0;
  pointer-events: none;
}
body.isResizingSidebar {
  cursor: col-resize;
  user-select: none;
}
#btnSidebarToggle {
  font-size: 16px;
  line-height: 1;
}

.sidebarHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebarHeadActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.sidebarTitle {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
}
.sidebarTitleCounts {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.sidebarSearch {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebarSearchWrap {
  position: relative;
  display: flex;
  align-items: center;
}
.sidebarSearchIcon {
  position: absolute;
  left: 9px;
  color: var(--muted);
  pointer-events: none;
}
.sidebarSearch input {
  width: 100%;
  padding: 10px 12px 10px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}
.sidebarSearch input:focus {
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}
.sidebarFilterToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.boardFiltersTrayScrim {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.34);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 24;
}
.boardFiltersTrayScrim.isVisible {
  opacity: 1;
  pointer-events: auto;
}
.boardFiltersTray {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, calc(100vw - 32px));
  max-width: 100%;
  background: var(--surface);
  backdrop-filter: blur(18px);
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 48px rgba(15, 23, 42, 0.2);
  transform: translateX(calc(100% + 18px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.18s ease, border-color 0.18s ease;
  z-index: 25;
  display: flex;
}
.boardFiltersTray.isOpen {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}
.advancedFilterPanel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  margin-top: 0;
  padding: 18px 16px;
  border-top: 0;
  background: transparent;
  overflow: hidden;
}
.advancedFilterPanelHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.advancedFilterPanelTitleBlock {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.advancedFilterPanelTitle {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.advancedFilterPanelActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.advancedFilterSummary {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
.advancedFilterRows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}
.advancedFilterRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}
.advancedFilterRow > :first-child {
  grid-column: 1 / -1;
}
.advancedFilterRow.isFieldBound {
  grid-template-columns: minmax(92px, 0.95fr) minmax(116px, 0.74fr) minmax(0, 1.55fr);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.advancedFilterRow.isFieldBound.isActiveRule {
  border-color: rgba(16, 185, 129, 0.34);
  background:
    linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.03)),
    var(--surface-alt);
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.12);
}
.advancedFilterRow.isFieldBound.hasRange {
  grid-template-columns: minmax(92px, 0.95fr) minmax(116px, 0.74fr) minmax(0, 1fr) minmax(0, 1fr);
}
.advancedFilterRow.isFieldBound > :first-child {
  grid-column: auto;
}
.advancedFilterFieldSummary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  align-self: stretch;
  justify-content: center;
}
.advancedFilterFieldTitle {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}
.advancedFilterFieldType {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.advancedFilterControl {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.advancedFilterControl span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.advancedFilterControl input,
.advancedFilterControl select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}
.advancedFilterControl input:focus,
.advancedFilterControl select:focus {
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}
.advancedFilterRemove {
  align-self: end;
  justify-self: end;
}
.advancedFilterEmpty {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 12px;
  background: rgba(148, 163, 184, 0.06);
}

/* ── Milestone filter banner ─────────────────── */
.milestoneFilterBanner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-bg);
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
}
.milestoneFilterBanner.hidden { display: none !important; }

.patientList {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0;
}

.patientItem {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.patientItem:hover { background: var(--accent-bg); }
.patientItem.isSelected { background: var(--accent-bg); }
.patientItem.isSelected .patientItemKey { color: var(--accent); }

.patientIcon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
  margin-top: 1px;
  transition: background 0.12s, color 0.12s;
}
.patientItem.isSelected .patientIcon {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: rgba(16, 185, 129, 0.28);
}

.patientItemText {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.patientItemHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}
.patientItemKey {
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.patientItemPill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.patientItemPill.isFresh {
  color: var(--pill-good);
  background: var(--pill-good-bg);
  border-color: var(--pill-good-border);
}
.patientItemPill.isWarning {
  color: var(--pill-warn);
  background: var(--pill-warn-bg);
  border-color: var(--pill-warn-border);
}
.patientItemPill.isCritical {
  color: var(--pill-risk);
  background: var(--pill-risk-bg);
  border-color: var(--pill-risk-border);
}
.patientItemPill .bdIcon {
  margin-right: 0;
}
.patientWorkflowBadge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--workflow-color) 26%, transparent);
  background: color-mix(in srgb, var(--workflow-color) 14%, transparent);
  color: var(--workflow-color);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  white-space: normal;
  max-width: 100%;
}
.patientWorkflowBadge.isConflict {
  box-shadow: 0 0 0 1px rgba(244, 63, 94, 0.28);
}
.patientWorkflowBadge.isPending {
  border-style: dashed;
}
.patientWorkflowMeta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.patientItemName {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.patientItemSub {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Main ─────────────────────────────────── */
.boardMain {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--detail-divider);
  border-radius: 0;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.boardInitialLoading {
  position: absolute;
  inset: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}
.boardInitialLoading.hidden { display: none !important; }
.boardInitialLoadingCard {
  width: min(460px, calc(100vw - 72px));
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border-radius: 22px;
  border: 1px solid rgba(16, 185, 129, 0.18);
  background:
    linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(244, 63, 94, 0.08)),
    var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: 0 28px 64px rgba(15, 23, 42, 0.18);
}
.boardInitialLoadingPulse {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.08) 48%, transparent 70%);
}
.boardInitialLoadingPulse::before,
.boardInitialLoadingPulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid rgba(16, 185, 129, 0.22);
  animation: board-pulse-ring 1.6s ease-out infinite;
}
.boardInitialLoadingPulse::after {
  animation-delay: 0.8s;
}
.boardInitialLoadingBody {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.boardInitialLoadingTitle {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.boardInitialLoadingText {
  font-size: 13px;
  color: var(--muted);
}

.boardEmpty {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

/* ── Flow stage ─────────────────────────────────── */
.boardFlowStage {
  position: relative;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--detail-divider);
  border-radius: 0;
  padding: 10px 0 22px;
  min-width: 0;
  min-height: 136px;
  flex-shrink: 0;
  overflow: visible;
  backdrop-filter: none;
  box-shadow: none;
}

.connectorSvg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.flowRows {
  display: flex;
  flex-direction: column;
  gap: 36px;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.flowRow {
  display: grid;
  gap: var(--card-gap);
  min-width: 0;
}

/* ── Zone label ─────────────────────────────────── */
.flowZoneLabel {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-family: var(--font-heading);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  padding: 4px 2px;
}
.flowZoneLabel::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Flow cards ─────────────────────────────────── */
.flowCard {
  --flow-card-title-color: var(--text);
  --flow-card-subtitle-color: var(--muted);
  --flow-card-meta-color: var(--muted);
  --flow-card-icon-bg: rgba(var(--card-accent-rgb, 16 185 129) / 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)) , var(--surface-strong);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  border-left: 4px solid var(--card-accent, var(--accent));
  position: relative;
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.08);
}
.flowCard.isHighlighted {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card-accent, var(--accent)) 10%, transparent), transparent 54%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    var(--surface-strong);
  border-color: var(--border);
  box-shadow:
    0 18px 30px rgba(15, 23, 42, 0.08),
    inset 0 0 0 1px color-mix(in srgb, var(--card-accent, var(--accent)) 22%, transparent);
}
.flowCard[data-template="milestone"] {
  cursor: pointer;
}
.flowCard.isFilterActive {
  --flow-card-title-color: #1f1806;
  --flow-card-subtitle-color: #44350d;
  --flow-card-meta-color: #4f4011;
  --flow-card-icon-bg: rgba(120, 53, 15, 0.1);
  background: rgba(228, 217, 137, 0.98);
  border-color: rgba(217, 119, 6, 0.42);
  border-left-color: rgba(217, 119, 6, 0.78);
  box-shadow: none;
  transform: none;
  outline: none;
}

.flowCard.isFilterActive .patientItemPill {
  font-weight: 800;
}

.flowCard.isFilterActive .patientItemPill.isFresh {
  color: #14532d;
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(20, 83, 45, 0.28);
}

.flowCard.isFilterActive .patientItemPill.isWarning {
  color: #7c2d12;
  background: rgba(180, 83, 9, 0.14);
  border-color: rgba(124, 45, 18, 0.24);
}

.flowCard.isFilterActive .patientItemPill.isCritical {
  color: #7f1d43;
  background: rgba(190, 24, 93, 0.14);
  border-color: rgba(127, 29, 67, 0.24);
}

.flowCardHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.flowCardBadge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 0 var(--radius) 0 var(--radius-sm);
  background: var(--card-accent, var(--accent));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  letter-spacing: 0.02em;
}
.flowCardTitle {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--flow-card-title-color);
  margin-top: 2px;
  letter-spacing: -0.02em;
}
.flowCardSubtitle {
  font-size: 12px;
  color: var(--flow-card-subtitle-color);
}
.flowCardIcon {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: var(--card-accent, var(--accent));
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--flow-card-icon-bg);
}
.flowCardValue {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--card-accent, var(--accent));
  word-break: break-word;
}
.cardNum {
  font-family: var(--font-heading);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.cardSuf {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.3;
  color: var(--flow-card-meta-color);
  padding-bottom: 2px;
}
.flowCardMeta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--flow-card-meta-color);
  flex-wrap: wrap;
}
.flowTimePill {
  padding: 2px 7px;
}
.flowDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--card-accent, var(--accent));
  flex-shrink: 0;
}
.flowAlertPill {
  background: rgba(244, 63, 94, 0.14);
  color: var(--accent-secondary);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
}

/* ── Connector SVG paths ─────────────────────────────────── */
.connectorPath {
  fill: none;
  stroke: rgba(100, 116, 139, 0.8);
  stroke-width: 4.5;
  opacity: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Patient detail panel ───────────────────────── */
.patientDetailPanel {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 18px 0 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex-shrink: 0;
  backdrop-filter: none;
  box-shadow: none;
}
.patientDetailPanel.hidden { display: none !important; }
.patientDetailPanel > * + * {
  border-top: 1px solid var(--detail-divider);
  margin-top: 18px;
  padding-top: 18px;
}

.patientDetailFields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 14px;
}

.patientDetailTimelineSection {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.patientDetailTimelineGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px 12px;
}

.patientDetailTimelineRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.patientDetailTimelineMeta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.patientDetailTimelineLabel {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}

.patientDetailTimelineValue {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.patientDetailTimePill {
  padding: 4px 9px;
  font-size: 11px;
}

.patientDetailField {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.07);
  background: rgba(255, 255, 255, 0.54);
}
.patientDetailField.isWide {
  grid-column: 1 / -1;
}
.patientDetailLabel {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.patientDetailValue {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.patientDetailValue.isMono {
  font-family: var(--mono);
  font-size: 12px;
}
.patientDetailValue.isLongText {
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  line-height: 1.55;
  font-weight: 400;
}

.patientInfoSubsections {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(420px, 1.7fr) minmax(240px, 1fr);
  gap: 10px;
  align-items: start;
}

.patientInfoSubsection {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--section-title-border) 78%, var(--accent));
  border-radius: 6px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 94%, var(--accent) 6%), var(--surface-strong)),
    var(--surface-strong);
  box-shadow:
    inset 0 2px 0 color-mix(in srgb, var(--accent) 48%, transparent),
    0 10px 22px rgba(15, 23, 42, 0.06);
}

.patientInfoSubsection:first-child {
  padding-top: 0;
  border-top: 1px solid color-mix(in srgb, var(--section-title-border) 78%, var(--accent));
}

.patientInfoSubsectionTitle {
  margin: 0;
  padding: 9px 12px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.2;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--section-title-bg) 72%, var(--surface-alt));
  border-bottom: 1px solid var(--section-title-border);
}

.patientInfoGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 10px;
  padding: 7px 12px 10px;
}

.patientInfoClinicalGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
}

.patientInfoColumn {
  min-width: 0;
  border-left: 1px solid color-mix(in srgb, var(--detail-divider) 78%, transparent);
}

.patientInfoColumn:first-child {
  border-left: 0;
}

.patientInfoColumnTitle {
  padding: 8px 12px 2px;
  color: color-mix(in srgb, var(--muted) 78%, var(--text));
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.patientInfoCell {
  display: block;
  min-width: 0;
  max-width: none;
  padding: 6px 3px 7px;
  border-bottom: 1px solid color-mix(in srgb, var(--detail-divider) 88%, transparent);
}

.patientInfoCell:last-child {
  border-bottom: 0;
}

.patientInfoCell.isWide {
  grid-column: 1 / -1;
  max-width: none;
}

.patientInfoLabel {
  margin: 0 0 2px;
  color: color-mix(in srgb, var(--muted) 70%, var(--text));
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.25;
  text-transform: uppercase;
}

.patientInfoValue {
  color: var(--text);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.patientInfoValue.isMissing {
  color: var(--muted);
  font-weight: 500;
}

.patientInfoValue.isLongText {
  white-space: pre-wrap;
  line-height: 1.38;
}

.patientInfoValue.hasExpandable {
  white-space: normal;
}

.patientInfoExpandable {
  margin-top: 1px;
  min-width: 0;
}

.patientInfoExpandable summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--detail-divider) 82%, var(--accent));
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-alt) 88%, var(--accent) 6%), var(--surface-alt)),
    var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.patientInfoExpandable summary::-webkit-details-marker {
  display: none;
}

.patientInfoExpandable summary::before {
  content: "+";
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.patientInfoExpandable[open] summary::before {
  content: "-";
}

.patientInfoExpandable summary:hover {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--detail-divider));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-alt) 78%, var(--accent) 10%), var(--surface-alt)),
    var(--surface-alt);
}

.patientInfoExpandableTitle {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patientInfoExpandableMeta {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.patientInfoExpandablePreview {
  margin: 7px 2px 0;
  color: color-mix(in srgb, var(--muted) 82%, var(--text));
  display: -webkit-box;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.patientInfoBulletList,
.patientInfoLongTextBlock {
  max-height: 280px;
  overflow: auto;
  scrollbar-width: thin;
  border: 1px solid color-mix(in srgb, var(--detail-divider) 86%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-alt));
}

.patientInfoBulletList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 5px 16px;
  margin: 8px 0 0;
  padding: 9px 10px 9px 24px;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.patientInfoBulletList li {
  min-width: 0;
  padding-right: 6px;
  break-inside: avoid;
}

.patientInfoItemCount {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: color-mix(in srgb, var(--accent) 76%, var(--text));
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

.patientInfoLongTextBlock {
  margin-top: 8px;
  padding: 9px 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.42;
  white-space: pre-wrap;
}

body.modeDark .patientInfoSubsection {
  border-color: rgba(82, 139, 184, 0.72);
  background:
    linear-gradient(180deg, rgba(31, 48, 66, 0.88), rgba(18, 29, 43, 0.92)),
    var(--surface-strong);
  box-shadow:
    inset 0 2px 0 rgba(80, 169, 230, 0.68),
    0 14px 28px rgba(0, 0, 0, 0.16);
}

body.modeDark .patientInfoSubsectionTitle {
  color: #eef6ff;
  background: rgba(35, 53, 73, 0.82);
  border-bottom-color: rgba(87, 132, 170, 0.64);
}

body.modeDark .patientInfoCell {
  border-bottom-color: rgba(87, 132, 170, 0.5);
}

body.modeDark .patientInfoColumn {
  border-left-color: rgba(87, 132, 170, 0.5);
}

body.modeDark .patientInfoValue {
  color: #f8fbff;
}

body.modeDark .patientInfoLabel,
body.modeDark .patientInfoValue.isMissing {
  color: #aebdca;
}

body.modeDark .patientInfoExpandable summary {
  border-color: rgba(87, 132, 170, 0.58);
  background:
    linear-gradient(180deg, rgba(35, 53, 73, 0.78), rgba(18, 29, 43, 0.92)),
    var(--surface-strong);
  color: #f8fbff;
}

body.modeDark .patientInfoExpandable summary:hover {
  border-color: rgba(80, 169, 230, 0.76);
  background:
    linear-gradient(180deg, rgba(44, 70, 96, 0.84), rgba(18, 29, 43, 0.94)),
    var(--surface-strong);
}

body.modeDark .patientInfoExpandable summary::before {
  background: rgba(80, 169, 230, 0.18);
  color: #bde8ff;
}

body.modeDark .patientInfoExpandableTitle {
  color: #f8fbff;
}

body.modeDark .patientInfoExpandableMeta,
body.modeDark .patientInfoExpandablePreview {
  color: #aebdca;
}

body.modeDark .patientInfoBulletList,
body.modeDark .patientInfoLongTextBlock {
  border-color: rgba(87, 132, 170, 0.48);
  background: rgba(7, 15, 26, 0.38);
}

body.modeDark .patientInfoItemCount {
  border-color: rgba(80, 169, 230, 0.36);
  background: rgba(80, 169, 230, 0.16);
  color: #d9efff;
}

/* ── Patient detail — section title ─────────────── */
.vitalsEwsPanel {
  margin: 0 0 10px;
  border: 1px solid var(--detail-divider);
  background: color-mix(in srgb, var(--surface-alt) 72%, var(--surface));
}
.vitalsEwsTitle,
.vitalsGroupTitle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--text) 84%, var(--accent));
}
.vitalsEwsGroups {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr);
  gap: 8px;
  padding: 0 10px 10px;
}
.vitalsGroup { min-width: 0; }
.vitalsGroupTitle {
  padding: 0 0 5px;
  font-size: 10px;
  color: var(--muted);
}
.vitalsTileGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 6px;
}
.vitalsTile {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid color-mix(in srgb, var(--detail-divider) 84%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.vitalsTileIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--accent);
  background: var(--accent-bg);
}
.vitalIcon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vitalsTileBody { min-width: 0; }
.vitalsTileLabel {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
}
.vitalsTileValue {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}
.vitalsTile.isWarning {
  border-color: color-mix(in srgb, var(--pill-warn-border) 74%, var(--detail-divider));
  background: color-mix(in srgb, var(--pill-warn-bg) 54%, var(--surface));
}
.vitalsTile.isWarning .vitalsTileIcon {
  color: var(--pill-warn);
  background: var(--pill-warn-bg);
}
.vitalsTile.isMissing { opacity: 0.74; }
body.modeDark .vitalsEwsPanel,
body.modeDark .vitalsTile {
  background: rgba(15, 23, 42, 0.56);
  border-color: rgba(87, 132, 170, 0.45);
}

.patientDetailSectionTitle,
.patientDetailMilestoneSectionLabel,
.workflowPanelTitle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 0;
  background: var(--section-title-bg);
  border: 1px solid var(--section-title-border);
  color: var(--section-title-text);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.2;
  box-sizing: border-box;
}
.patientDetailSectionTitle {
  margin-bottom: 8px;
}

.detailSectionToggle {
  cursor: pointer;
  text-align: left;
  appearance: none;
}

.detailSectionToggle:hover {
  border-color: color-mix(in srgb, var(--section-title-border) 68%, var(--accent));
}

.detailSectionHeaderMain {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.detailSectionHeaderMeta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 700;
}

.detailSectionChevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-left: auto;
  transition: transform 0.16s ease;
}

.detailSectionHeaderMeta + .detailSectionChevron {
  margin-left: 0;
}

.detailCollapsibleSection[data-detail-collapsed="false"] > .detailSectionToggle .detailSectionChevron {
  transform: rotate(90deg);
}

.detailCollapsibleBody[hidden] {
  display: none !important;
}

/* ── Patient detail — milestones section ─────────── */
.patientDetailMilestonesSection {
  border-top: 0;
  padding-top: 0;
}

.patientDetailMilestoneSections {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.patientDetailMilestoneSectionBlock {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.patientDetailMilestoneSectionLabel {
  letter-spacing: 0.08em;
}

.patientDetailMilestones {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  align-items: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 10px 10px 0;
  scrollbar-width: thin;
}

.patientDetailMilestoneItem {
  flex: 0 0 232px;
  min-width: 232px;
  margin-right: -10px;
  display: flex;
  flex-direction: column;
}

.patientDetailMilestoneItem.hasNote {
  flex-basis: 310px;
  min-width: 310px;
}

.patientDetailMilestoneRow {
  --milestone-shape: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%, 14px 50%);
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "icon name status"
    "icon name status";
  align-items: center;
  gap: 8px 10px;
  font-size: 12px;
  padding: 12px 28px 12px 24px;
  width: 100%;
  min-width: 0;
  min-height: 64px;
  border: 1px solid transparent;
  clip-path: var(--milestone-shape);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.patientDetailMilestoneRow.isFirst {
  --milestone-shape: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%);
  padding-left: 16px;
}

.patientDetailMilestoneRow.isPassed {
  background: var(--pill-good-bg);
  border-color: var(--pill-good-border);
  color: var(--pill-good);
}

.patientDetailMilestoneRow.isFailed {
  background: var(--pill-risk-bg);
  border-color: var(--pill-risk-border);
  color: var(--pill-risk);
}

.patientDetailMilestoneRow.isUnknown {
  background: transparent;
  color: var(--muted);
}

.patientDetailMilestoneIcon {
  grid-area: icon;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.patientDetailMilestoneName {
  grid-area: name;
  font-weight: 500;
  color: var(--text);
  line-height: 1.25;
  padding-right: 2px;
}

.patientDetailMilestoneRow.isPassed .patientDetailMilestoneName { color: var(--pill-good); }
.patientDetailMilestoneRow.isFailed .patientDetailMilestoneName { color: var(--pill-risk); }

.patientDetailMilestoneStatus {
  grid-area: status;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  justify-self: end;
  align-self: start;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.12);
  color: currentColor;
  white-space: nowrap;
}

.patientDetailMilestoneMeta {
  margin: 6px 18px 0 16px;
  padding: 8px 10px;
  min-height: 42px;
  border: 1px solid var(--border);
  border-top: 0;
  background: color-mix(in srgb, var(--surface-alt) 84%, transparent);
  color: var(--muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.patientDetailMilestoneTime {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.patientDetailMilestoneTime.isMissing {
  opacity: 0.72;
}

.patientDetailMilestoneDate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patientDetailMilestoneTimePill {
  margin-left: auto;
  flex-shrink: 0;
  padding: 3px 7px;
  font-size: 10px;
}

.patientDetailMilestoneNoteBox {
  margin-top: 8px;
  padding: 8px 9px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.patientDetailMilestoneNoteLabel {
  margin-bottom: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.patientDetailMilestoneNoteText {
  color: var(--text);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.workflowPanel {
  margin-bottom: 0;
  padding: 0;
  border-radius: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.workflowPanelState {
  font-size: 12px;
  color: var(--muted);
}
.workflowPanelState.isError {
  color: var(--pill-risk);
}
.workflowPendingBanner {
  margin-top: 14px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px dashed rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}
.workflowPendingBanner.isWarning {
  border-color: rgba(244, 63, 94, 0.34);
  background: rgba(244, 63, 94, 0.08);
}
.workflowPendingTitle {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}
.workflowPendingText {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.workflowCompactControlGrid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) repeat(4, auto);
  gap: 10px;
  margin-top: 14px;
  align-items: end;
}
.workflowPrimaryGrid {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(360px, 1.18fr);
  gap: 10px;
  margin-top: 10px;
  align-items: end;
}
.workflowStatusControl,
.workflowNoteComposer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  min-width: 0;
}
.workflowSecondaryToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
}
.workflowSecondaryToolbar.isWarning {
  border-color: rgba(244, 63, 94, 0.34);
  background: rgba(244, 63, 94, 0.08);
}
.workflowSecondarySummary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.workflowSecondaryWarning {
  color: var(--pill-risk);
}
.workflowSecondaryActions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  flex: 0 0 auto;
}
.workflowSelectField {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.workflowSelectField span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.workflowSelectField select,
.workflowSelectField textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}
.workflowSelectField select:focus,
.workflowSelectField textarea:focus {
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}
.workflowPanelHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.workflowPanelHead > div {
  flex: 1;
  min-width: 0;
}
.workflowPanelTitle {
  margin-bottom: 6px;
}
.workflowPanelMeta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.workflowPanelBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  min-height: 34px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--workflow-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--workflow-color) 26%, transparent);
  color: var(--workflow-color);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}
.workflowPanelBadge.isPending {
  border-style: dashed;
}
.workflowStatusGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.workflowStatusBtn {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--workflow-color) 22%, var(--border));
  background: color-mix(in srgb, var(--workflow-color) 10%, var(--surface-strong));
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}
.workflowStatusBtn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--workflow-color) 40%, transparent);
}
.workflowStatusBtn.isActive {
  color: var(--workflow-color);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--workflow-color) 30%, transparent);
}
.workflowStatusBtn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}
.workflowComposer {
  margin-top: 14px;
}
.workflowCompactNoteRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 10px;
  align-items: end;
}
.workflowNoteField {
  min-width: 0;
}
.workflowComposerLabel {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.workflowNoteInput {
  width: 100%;
  min-height: 62px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  resize: vertical;
}
.workflowComposerActions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.workflowComposerActionsCompact {
  margin-top: 0;
  align-items: center;
}
.workflowCompactControlGrid .boardBtn,
.workflowStatusControl .boardBtn,
.workflowNoteComposer .boardBtn,
.workflowSecondaryActions .boardBtn,
.workflowComposerActionsCompact .boardBtn,
.workflowHistoryBodyActions .boardBtn {
  padding: 8px 11px;
  font-size: 12px;
}
.workflowHistoryStack {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.workflowCompactSummary {
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  font-size: 12px;
  color: var(--muted);
}
.workflowCompactSummary strong {
  color: var(--text);
}
.workflowHistoryFold {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
  overflow: hidden;
}
.workflowHistorySummary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}
.workflowHistorySummary::-webkit-details-marker {
  display: none;
}
.workflowHistorySummary::after {
  content: "\25be";
  color: var(--muted);
  font-size: 11px;
  margin-left: auto;
}
.workflowHistoryFold[open] .workflowHistorySummary::after {
  transform: rotate(180deg);
}
.workflowHistorySummaryLabel {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.workflowHistorySummaryMeta {
  font-size: 11px;
  color: var(--muted);
  margin-right: 8px;
}
.workflowHistoryFoldBody {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}
.workflowPendingFooter {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}
.workflowHistoryBodyActions {
  display: flex;
  justify-content: flex-end;
}
.workflowHistoryCompact {
  display: grid;
}
.workflowHistoryRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.workflowHistoryCompact .workflowHistoryRow:first-child {
  border-top: 0;
}
.workflowHistoryRow.isPending {
  border-top-color: rgba(245, 158, 11, 0.22);
}
.workflowHistoryRowMain {
  min-width: 0;
}
.workflowHistoryRowMeta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  min-width: 0;
}
.workflowHistoryRowActions {
  display: flex;
  align-items: flex-start;
}
.workflowHistory {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.workflowHistorySection + .workflowHistorySection {
  margin-top: 16px;
}
.workflowHistorySectionHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}
.workflowHistorySectionTitle {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.workflowHistoryItem {
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}
.workflowHistoryItem.isPending {
  border-style: dashed;
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}
.workflowHistoryHead {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.workflowHistoryHeadActions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.workflowHistoryType {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
}
.workflowHistoryWhen,
.workflowHistoryMeta,
.workflowHistoryEmpty {
  font-size: 11px;
  color: var(--muted);
}
.workflowHistoryMeta {
  margin-top: 4px;
}
.workflowHistoryNote {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
}
.workflowHistoryAction {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.workflowHistoryAction:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(244, 63, 94, 0.28);
}
.workflowHistoryAction:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}
.boardBtn.hasPending {
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.26), 0 10px 26px rgba(245, 158, 11, 0.16);
}

/* ── Patient detail — actions row (Copy + Escalate) ── */
.patientDetailActions {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 0;
  padding-top: 0;
  flex-wrap: wrap;
}

.patientClinicalQueries {
  display: grid;
  gap: 10px;
}
.clinicalQueryList {
  display: grid;
  gap: 8px;
}
.clinicalQueryCard {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--detail-divider);
  background: color-mix(in srgb, var(--surface-alt) 70%, transparent);
}
.clinicalQueryBtn {
  justify-self: start;
  gap: 7px;
}
.onDemandStatus {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  max-width: 100%;
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--detail-divider) 82%, transparent);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.onDemandStatus.isError {
  border-color: var(--pill-risk-border);
  background: var(--pill-risk-bg);
  color: var(--pill-risk);
}
.onDemandResult {
  display: grid;
  gap: 7px;
}
.onDemandResultTitle {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
}
.orderResultTable {
  gap: 8px;
}
.orderResultToolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.orderResultMeta,
.orderFilterTips {
  font-size: 11px;
  color: var(--muted);
}
.orderFilterTips code {
  font-size: 10px;
  color: var(--accent);
}
.orderResultActions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.orderSearchBox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: min(260px, 100%);
  padding: 6px 8px;
  border: 1px solid var(--detail-divider);
  background: var(--surface);
  color: var(--muted);
}
.orderSearchBox input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
.orderTypeSelector {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--detail-divider);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
}
.orderTypeSelectorHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.orderTypeSelectorTitle {
  font-size: 12px;
  font-weight: 850;
  color: var(--text);
}
.orderTypeSelectorMeta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}
.orderTypeSelectorActions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.orderTypeChipGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.orderTypeChip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid color-mix(in srgb, var(--detail-divider) 82%, transparent);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.orderTypeChip input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}
.orderTypeChip.isSelected {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--detail-divider));
  background: var(--accent-bg);
  color: var(--accent);
}
.orderTypeChipText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.orderTypeChipCount {
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 12%, transparent);
  font-size: 10px;
  font-weight: 850;
}
.onDemandTableWrap {
  overflow: auto;
  border: 1px solid var(--border);
  max-height: 260px;
}
.orderTableWrap {
  max-height: 380px;
}
.onDemandTable {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.onDemandTable th,
.onDemandTable td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.onDemandTable th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-alt);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
}
.orderHeadCell {
  display: grid;
  gap: 5px;
  min-width: 150px;
  position: relative;
}
.onDemandTable th:has(.orderListFilter[open]) {
  z-index: 8;
}
.orderSortBtn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 850;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}
.orderSortBtn.isActive {
  color: var(--accent);
}
.orderSortDir {
  flex: 0 0 auto;
  font-size: 12px;
}
.orderFilterInput {
  width: 100%;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid color-mix(in srgb, var(--detail-divider) 78%, transparent);
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
  outline: 0;
}
.orderFilterInput:focus,
.orderSearchBox:focus-within {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--detail-divider));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent);
}
.orderListFilter {
  position: relative;
  width: 100%;
}
.orderListFilterSummary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 7px;
  border: 1px solid color-mix(in srgb, var(--detail-divider) 78%, transparent);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  cursor: pointer;
  list-style: none;
}
.orderListFilterSummary::-webkit-details-marker {
  display: none;
}
.orderListFilter[open] .orderListFilterSummary,
.orderListFilterSummary:hover {
  border-color: color-mix(in srgb, var(--accent) 44%, var(--detail-divider));
  color: var(--accent);
}
.orderListFilterPanel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  display: grid;
  gap: 7px;
  width: min(320px, 80vw);
  max-height: 280px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--detail-divider) 86%, transparent);
  background: var(--surface);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  text-transform: none;
}
.orderListFilterModes,
.orderListFilterActions {
  display: flex;
  gap: 5px;
}
.orderListFilterMode,
.orderListFilterActions button {
  flex: 1 1 0;
  min-height: 24px;
  border: 1px solid color-mix(in srgb, var(--detail-divider) 76%, transparent);
  background: var(--surface-alt);
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  font-weight: 850;
  cursor: pointer;
}
.orderListFilterMode.isActive {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--detail-divider));
  background: var(--accent-bg);
  color: var(--accent);
}
.orderListFilterOptions {
  display: grid;
  gap: 3px;
  max-height: 190px;
  overflow: auto;
  padding-right: 2px;
}
.orderListFilterOption {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 5px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.orderListFilterOption:hover,
.orderListFilterOption.isSelected {
  background: color-mix(in srgb, var(--accent-bg) 74%, transparent);
}
.orderListFilterOption input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--accent);
}
.orderListFilterLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.orderListFilterCount {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}
.orderListFilterEmpty {
  padding: 8px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.inlineSpinner {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: inlineSpin 0.7s linear infinite;
}
@keyframes inlineSpin { to { transform: rotate(360deg); } }

.patientDetailCopyBtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(16, 185, 129, 0.25);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  letter-spacing: 0.02em;
}
.patientDetailCopyBtn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.4);
}

.patientDetailEscalateBtn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  background: var(--pill-risk-bg);
  color: var(--pill-risk);
  border: 1px solid var(--pill-risk-border);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  letter-spacing: 0.02em;
}
.patientDetailEscalateBtn:hover {
  background: rgba(244, 63, 94, 0.22);
  border-color: rgba(244, 63, 94, 0.4);
}

/* ── Status bar ─────────────────────────────────── */
.boardStatus {
  height: var(--status-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.86);
  color: var(--accent);
  border-top: 1px solid rgba(16, 185, 129, 0.22);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.boardStatus.isError {
  color: var(--accent-secondary);
  border-top-color: rgba(244, 63, 94, 0.24);
}

/* ── Modal ─────────────────────────────────── */
.boardModal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.boardModal.hidden { display: none; }

.boardModalCard {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
  backdrop-filter: blur(18px);
}
.boardModalCardWide {
  width: min(1020px, calc(100vw - 32px));
}
.boardModalCardCredentials {
  width: min(1180px, calc(100vw - 32px));
  max-height: min(74vh, 640px);
  overflow: hidden;
  padding: 18px 20px;
  gap: 12px;
}
.boardModalCardPlEmail {
  width: min(640px, calc(100vw - 32px));
}
.boardModalCardPage {
  width: min(1480px, calc(100vw - 32px));
  height: min(90vh, calc(100vh - 32px));
}
.boardModalHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.boardModalHeadPage {
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.boardModalHead h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
}
.boardModalTitleBlock {
  display: grid;
  gap: 6px;
}
.boardModalBody {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.boardModalCardCredentials .boardModalBody {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  gap: 10px;
}
.boardModalBodyReport {
  gap: 16px;
}
.boardModalBodyPage {
  flex: 1;
  min-height: 0;
  gap: 14px;
}
.boardModalActionsWrap {
  flex-wrap: wrap;
}
.boardHint {
  font-size: 12px;
  color: var(--muted);
}
.boardField {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.boardField span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.boardField input,
.boardField select,
.boardField textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}
.boardField input:focus,
.boardField select:focus,
.boardField textarea:focus {
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}
.boardCheckboxRow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.boardModalActions {
  display: flex;
  gap: 8px;
}
.reportFiltersGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.reportModalActions {
  justify-content: flex-start;
  flex-wrap: wrap;
}
.reportStagingPanel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-strong);
}
.reportStagingHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.reportStagingHead h3 {
  margin: 0 0 4px;
  font-size: 15px;
}
.reportStagedList {
  display: grid;
  gap: 10px;
}
.reportStagedItem {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(16, 185, 129, 0.18);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.09), rgba(255, 255, 255, 0.04));
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
}
.reportStagedItemHead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.reportStagedMeta {
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}
.reportStagedPreview {
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}
.reportStagedEmpty {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
}
.reportSummary {
  display: grid;
  gap: 12px;
}
.reportSummaryGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.reportSummaryCard {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.reportSummaryCard strong {
  font-size: 22px;
  line-height: 1;
}
.reportSummaryCard span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.reportSummaryLists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.reportSummaryTitle {
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.reportSummaryLine {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  font-size: 12px;
}
.reportPreview {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
}
.reportPreviewTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.reportPreviewTable th,
.reportPreviewTable td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.reportPreviewTable th {
  position: sticky;
  top: 0;
  background: var(--surface-alt);
  z-index: 1;
}
.reportPreviewEmpty {
  padding: 18px;
  font-size: 12px;
  color: var(--muted);
}
.plEmailFormatGroup {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
}
.plEmailFormatGroup legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.plEmailFormatOption {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
  cursor: pointer;
}
.plEmailFormatOption input {
  margin-top: 3px;
}
.plEmailFormatOption span {
  display: grid;
  gap: 3px;
}
.plEmailFormatOption strong {
  font-size: 13px;
  color: var(--text);
}
.plEmailFormatOption small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.datasheetSummary {
  display: grid;
  gap: 12px;
}
.datasheetColumnPanel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-alt) 82%, var(--surface));
}
.datasheetColumnPanel.hidden { display: none; }
.datasheetColumnPanelHead {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.datasheetColumnActions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.datasheetColumnList {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  scrollbar-width: thin;
}
.datasheetColumnItem {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid color-mix(in srgb, var(--border) 84%, transparent);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
}
.datasheetColumnItem span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.datasheetExportOptions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.datasheetSummaryGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.datasheetSummaryCard {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}
.datasheetSummaryCard strong {
  font-size: 22px;
  line-height: 1;
}
.datasheetSummaryCard span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.datasheetSummaryMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  font-size: 12px;
  color: var(--muted);
}
.datasheetSummaryMeta code {
  font-family: var(--mono);
  font-size: 11px;
}
.datasheetTableWrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
}
.datasheetTable {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.datasheetTable th,
.datasheetTable td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid rgba(148, 163, 184, 0.12);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  max-width: 260px;
  min-width: 150px;
  word-break: break-word;
}
.datasheetTable th:last-child,
.datasheetTable td:last-child {
  border-right: none;
}
.datasheetTable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-alt);
  padding: 8px 10px 10px;
}
.datasheetTable tbody tr:nth-child(even) td {
  background: rgba(148, 163, 184, 0.05);
}
.datasheetHeadCell {
  display: grid;
  gap: 8px;
}
.datasheetSortBtn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.datasheetSortBtn.isActive {
  color: var(--accent);
}
.datasheetSortLabel {
  min-width: 0;
}
.datasheetSortDir {
  flex-shrink: 0;
  color: var(--muted);
}
.datasheetSortBtn.isActive .datasheetSortDir {
  color: inherit;
}
.datasheetFilterInput {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}
.datasheetFilterInput:focus {
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}
.datasheetEmptyCell {
  color: var(--muted);
  font-style: italic;
}
.boardCredStatus {
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
}
.boardCredStatus.isError {
  color: var(--pill-risk);
}

.configTabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  margin: 2px 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.08);
}
.configTab {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}
.configTab.isActive {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #0F766E);
  box-shadow: 0 10px 22px rgba(16, 185, 129, 0.22);
}
.credentialModalBody {
  display: block;
}
.configPanel:not(.isActive) {
  display: none;
}
.credentialPanel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.42);
}
.credentialPanel h3 {
  margin: 0;
  font-size: 15px;
}
.credentialGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.credentialFieldWide {
  grid-column: 1 / -1;
}
.credentialChecks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.extensionBridgeStatusPills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 2px;
}

.extensionInstallNotice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin: 12px 0;
  border: 1px solid rgba(220, 38, 38, 0.22);
  border-radius: 8px;
  background: rgba(254, 242, 242, 0.88);
  color: #7f1d1d;
}
.extensionInstallNotice.hidden {
  display: none !important;
}
.extensionInstallNotice strong,
.extensionInstallNotice span {
  display: block;
}
.extensionInstallNotice span {
  margin-top: 2px;
  font-size: 12px;
  color: #991b1b;
}
.extensionInstallActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.extensionBridgePill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.extensionBridgePill.isGood {
  border-color: rgba(16, 185, 129, 0.35);
  color: var(--pill-good);
}

.extensionBridgePill.isBad {
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--pill-risk);
}

.extensionBridgeGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.5);
}

.extensionBridgeGrid div {
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-alt);
}

.extensionBridgeGrid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.extensionBridgeGrid strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.extensionBridgeGridWide {
  grid-column: 1 / -1;
}

.templateSettingsLayout {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  height: min(54vh, 540px);
}
.templateLibraryPanel,
.templateEditorPanel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}
.templateLibraryPanel {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
}
.templateLibraryHead,
.templateEditorHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.templateLibraryHead h3,
.templateEditorHead h3 {
  margin: 0;
  font-size: 15px;
}
.templateLibraryActions,
.templateEditorToolbar,
.templatePickerActions,
.templateInlineActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.templateEditorStatus {
  flex: 1 1 100%;
  min-height: 16px;
  margin-top: 2px;
  text-align: right;
}
.templateLibraryGroups,
.templateLibraryList,
.templatePickerList,
.templateScheduleHistory,
.templateEditorForm,
.templateSourceSection,
.templateComposerFields,
.templatePreviewWarnings,
.templatePreviewBody {
  display: grid;
  gap: 10px;
}
.templateLibraryGroups {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}
.templateLibraryGroup {
  display: grid;
  gap: 8px;
}
.templateLibraryGroupBar,
.templateSectionBar,
.templateSubsectionHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.templateLibraryGroupBar {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: rgba(148, 163, 184, 0.08);
}
.templateLibraryGroupBar h4,
.templateSectionBar h4,
.templateSubsectionHead h5 {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.templateLibraryCount {
  display: inline-flex;
  min-width: 28px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: #0f766e;
  font-size: 11px;
  font-weight: 800;
}
.templateLibraryItem,
.templatePickerItem,
.templatePreviewCard {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
}
.templateLibraryItem.isSelected,
.templatePickerItem.isSelected {
  border-color: rgba(16, 185, 129, 0.34);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
}
.templateLibraryItem.isDisabled,
.templatePickerItem.isDisabled {
  opacity: 0.72;
}
.templateLibraryItemHead,
.templatePickerItemHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.templateLibraryItemTitle,
.templatePickerItemTitle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: var(--fg);
}
.templateLibraryItemTitle input,
.templatePickerItemTitle input {
  margin-top: 2px;
}
.templateLibraryMeta,
.templatePickerMeta,
.templateScheduleMeta,
.templatePreviewSummary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  font-size: 12px;
  color: var(--muted);
}
.templateMetaPill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid rgba(100, 116, 139, 0.16);
  background: rgba(255, 255, 255, 0.58);
}
.templateMetaPill.isAccent {
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.08);
  color: #0f766e;
}
.templateLibraryRowActions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.templateEditorPanel {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.42);
  overflow-y: auto;
}
.templateEditorEmpty,
.emailTemplateEmptyState {
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
  font-size: 13px;
  background: rgba(248, 250, 252, 0.55);
}
.templateEditorMetaGrid,
.templatePatientConfigGrid,
.templateScheduleGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}
.templateComposerLayout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
  gap: 10px;
  align-items: start;
}
.templateComposerPanel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.05);
}
.templateComposerHead h4 {
  margin: 0 0 4px;
  font-size: 13px;
}
.templateComposerTokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 168px;
  overflow-y: auto;
  padding-right: 2px;
}
.templateTokenChip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.22);
  background: rgba(255, 255, 255, 0.9);
  color: #0f766e;
  font-size: 12px;
  font-weight: 700;
  cursor: grab;
  user-select: none;
}
.templateTokenChip.isSummary {
  border-color: rgba(37, 99, 235, 0.2);
  color: #1d4ed8;
}
.templateTokenChip.isRow {
  border-color: rgba(244, 63, 94, 0.22);
  color: #be123c;
}
.templateTokenChip.isDragging {
  opacity: 0.55;
}
.templateTokenTarget.isDropReady {
  border-color: rgba(16, 185, 129, 0.46);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.14);
}
.templateSubsection {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.52);
}
.templateFieldPickerSection {
  margin-top: 0;
  padding: 10px 12px;
  border-radius: 12px;
}
.templateAdvancedFilterRows {
  min-height: 42px;
}
.templateEditorForm #emailTemplateRecipients {
  min-height: 62px;
}
.templateEditorForm #emailTemplateBody {
  min-height: 118px;
}
.templateFieldPickerSection .plEmailFieldsHeader {
  align-items: center;
}
.templateFieldPickerSection .plEmailFieldsHeader .boardHint {
  display: none;
}
.templateFieldPickerSection .emailFieldsList {
  padding: 8px;
}
.templateFieldPickerSection .emailFieldDualPicker {
  gap: 8px;
}
.templateFieldPickerSection .emailFieldBucketHead {
  padding: 7px 8px;
}
.templateFieldPickerSection .emailFieldDropZone {
  min-height: 112px;
  max-height: 164px;
  gap: 6px;
  padding: 8px;
}
.templateFieldPickerSection .emailFieldPill {
  min-height: 30px;
  padding: 5px 7px;
}
.templateFieldPickerSection .emailFieldMiniBtn {
  padding: 2px 6px;
}
.templateFieldPickerSection + .plEmailFormatGroup {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}
.templateFieldPickerSection + .plEmailFormatGroup legend {
  grid-column: 1 / -1;
}
.templateFieldPickerSection + .plEmailFormatGroup .plEmailFormatOption {
  padding: 8px 10px;
}
.templatePickerPanel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-strong);
  overflow: hidden;
}
.templatePickerPanel[open] {
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}
.templatePickerSummary {
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 800;
  color: var(--fg);
}
.templatePickerSummary::-webkit-details-marker {
  display: none;
}
.templatePickerSummary::after {
  content: "View";
  float: right;
  color: var(--muted);
  font-weight: 700;
}
.templatePickerPanel[open] .templatePickerSummary::after {
  content: "Hide";
}
.templatePickerBody {
  display: grid;
  gap: 12px;
  padding: 0 14px 14px;
}
.templatePreviewWarning {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(244, 63, 94, 0.22);
  background: rgba(254, 242, 242, 0.88);
  color: #991b1b;
  font-size: 12px;
}
.templatePreviewPre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  max-height: 136px;
  overflow: auto;
}
.templatePreviewHtmlFrame {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.templatePreviewHtmlFrame iframe {
  width: 100%;
  height: min(220px, 28vh);
  min-height: 160px;
  border: 0;
  display: block;
}
.boardModalCardTemplatePreview {
  width: min(900px, calc(100vw - 32px));
  max-height: min(76vh, 640px);
  overflow: hidden;
  padding: 18px 20px;
}
.boardModalCardTemplatePreview .boardModalBody {
  min-height: 0;
  overflow-y: auto;
  gap: 10px;
  padding-right: 4px;
}
.boardModalCardTemplatePreview .templatePreviewBody {
  max-height: min(52vh, 430px);
  overflow-y: auto;
  padding-right: 2px;
}
.boardModalCardTemplatePreview .templatePreviewCard {
  gap: 6px;
  padding: 10px 12px;
}
.boardModalCardTemplatePreview .templatePreviewCard h3 {
  margin: 0;
  font-size: 13px;
}

/* ── Email fields config ─────────────────────── */
.emailFieldsConfig {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(16, 185, 129, 0.04);
}
.emailFieldsConfigTitle {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}
.emailFieldsConfigActions {
  display: flex;
  gap: 8px;
}
.emailFieldsList {
  display: block;
  max-height: none;
  overflow: visible;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.emailFieldDualPicker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.emailFieldBucket {
  min-width: 0;
  border: 1px solid rgba(100, 116, 139, 0.18);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.7);
  overflow: hidden;
}
.emailFieldBucketSelected {
  background: rgba(236, 253, 245, 0.7);
  border-color: rgba(16, 185, 129, 0.24);
}
.emailFieldBucketHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(100, 116, 139, 0.14);
  color: var(--fg);
  font-size: 12px;
}
.emailFieldBucketHead span {
  display: inline-flex;
  min-width: 24px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: #0f766e;
  font-size: 11px;
  font-weight: 800;
}
.emailFieldDropZone {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 180px;
  max-height: 260px;
  overflow-y: auto;
  padding: 10px;
}
.emailFieldPill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 8px;
  border: 1px solid rgba(100, 116, 139, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  color: var(--fg);
  cursor: grab;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04);
}
.emailFieldPill.isSelected {
  border-color: rgba(16, 185, 129, 0.28);
  background: rgba(255, 255, 255, 0.9);
}
.emailFieldPill.isDragging {
  opacity: 0.55;
}
.emailFieldDragHandle {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: -1px;
}
.emailFieldPillLabel {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.emailFieldMiniBtn {
  flex: 0 0 auto;
  border: 1px solid rgba(100, 116, 139, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.emailFieldMiniBtn:hover:not(:disabled) {
  color: var(--fg);
  border-color: rgba(16, 185, 129, 0.28);
}
.emailFieldMiniBtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.emailFieldMiniBtnPrimary {
  color: #0f766e;
  border-color: rgba(16, 185, 129, 0.26);
}
.emailFieldsEmpty {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 4px;
  text-align: center;
}
.plEmailFieldsConfig {
  margin-top: 2px;
  background: rgba(15, 118, 110, 0.05);
}
.plEmailFieldsHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.plEmailFieldsHeader .boardHint {
  margin: 4px 0 0;
}
.plEmailFieldsList {
  padding: 10px;
}
.plEmailFieldsActions {
  align-items: center;
  gap: 10px;
  margin-top: 0;
}
.orderDetailsSourceSection {
  margin-top: 2px;
}
.orderDetailsConfig {
  display: grid;
  gap: 12px;
}
.orderDetailsGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.orderDetailsFull {
  grid-column: 1 / -1;
}
.orderDetailsColumnPanel {
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  overflow: hidden;
}
.orderDetailsColumnHead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(15, 118, 110, 0.12);
}
.orderDetailsColumnHead strong {
  font-size: 12px;
  color: var(--fg);
  flex: 1 1 auto;
}
.orderDetailsColumnHead span {
  font-size: 11px;
  color: var(--muted);
}
.orderDetailsColumnGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 7px;
  padding: 10px;
  max-height: 230px;
  overflow: auto;
}
.orderDetailsColumnItem {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(100, 116, 139, 0.14);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.78);
  font-size: 12px;
  color: var(--fg);
}
.orderDetailsColumnItem span {
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 760px) {
  .emailFieldDualPicker {
    grid-template-columns: 1fr;
  }
  .orderDetailsGrid {
    grid-template-columns: 1fr;
  }
  .plEmailFieldsHeader {
    flex-direction: column;
  }
}

/* ── Utility ─────────────────────────────────── */
.hidden { display: none !important; }

@keyframes board-progress-slide {
  0% { transform: translateX(0); }
  100% { transform: translateX(360%); }
}

@keyframes board-pulse-ring {
  0% {
    transform: scale(0.72);
    opacity: 0.88;
  }
  100% {
    transform: scale(1.16);
    opacity: 0;
  }
}

/* ── Scrollbars ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.14); border-radius: 99px; }

/* ═══════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════ */
body.modeDark {
  --bg:                #0f172a;
  --surface:           rgba(15, 23, 42, 0.84);
  --surface-strong:    #111b2c;
  --surface-alt:       rgba(17, 27, 44, 0.74);
  --border:            rgba(148, 163, 184, 0.18);
  --text:              #edf4fc;
  --muted:             #9cb0c6;
  --accent:            #10b981;
  --accent-bg:         rgba(16, 185, 129, 0.16);
  --pill-good:         #6ee7b7;
  --pill-good-bg:      rgba(16, 185, 129, 0.18);
  --pill-good-border:  rgba(16, 185, 129, 0.26);
  --pill-warn:         #fbbf24;
  --pill-warn-bg:      rgba(245, 158, 11, 0.18);
  --pill-warn-border:  rgba(245, 158, 11, 0.28);
  --pill-risk:         #fda4af;
  --pill-risk-bg:      rgba(244, 63, 94, 0.18);
  --pill-risk-border:  rgba(244, 63, 94, 0.26);
  --shadow:            0 28px 72px rgba(2, 6, 23, 0.52);
  --topbar-bg:         #0b1220;
  --topbar-border:     rgba(148, 163, 184, 0.12);
  --topbar-divider:    rgba(148, 163, 184, 0.16);
  --topbar-text:       #f7fbff;
  --topbar-muted:      #98a8c0;
  --topbar-search-bg:  #151d2d;
  --topbar-search-border: rgba(148, 163, 184, 0.14);
  --topbar-search-icon: #5d6d86;
  --topbar-search-placeholder: #70819a;
  --topbar-popover-bg: rgba(8, 13, 24, 0.98);
  --topbar-popover-shadow: 0 16px 28px rgba(2, 6, 23, 0.32);
  --detail-divider: rgba(148, 163, 184, 0.26);
  --section-title-bg: rgba(30, 41, 59, 0.78);
  --section-title-border: rgba(148, 163, 184, 0.24);
  --section-title-text: #d7e1ee;
  background:
    radial-gradient(circle at top left, rgba(16, 185, 129, 0.2), transparent 30%),
    radial-gradient(circle at top right, rgba(244, 63, 94, 0.14), transparent 24%),
    radial-gradient(circle at bottom right, rgba(245, 158, 11, 0.12), transparent 20%),
    linear-gradient(180deg, #020617 0%, #0f172a 100%);
}

body.modeDark .sidebarSearch input,
body.modeDark .boardHeaderSearchWrap input,
body.modeDark .boardField input,
body.modeDark .boardField select,
body.modeDark .boardField textarea {
  background: rgba(15, 23, 42, 0.9);
}
body.modeDark .favoriteFiltersPopover,
body.modeDark .favoriteFilterItem,
body.modeDark .favoriteFiltersEmpty {
  background: rgba(15, 23, 42, 0.84);
}
body.modeDark .credentialPanel {
  background: rgba(15, 23, 42, 0.45);
}
body.modeDark .templateLibraryPanel,
body.modeDark .templateEditorPanel {
  background: rgba(15, 23, 42, 0.45);
}
body.modeDark .templateLibraryGroupBar,
body.modeDark .templateSubsection,
body.modeDark .templateEditorEmpty,
body.modeDark .templatePickerPanel,
body.modeDark .templatePreviewCard,
body.modeDark .emailTemplateEmptyState {
  background: rgba(15, 23, 42, 0.58);
}
body.modeDark .templateLibraryItem,
body.modeDark .templatePickerItem,
body.modeDark .templatePreviewHtmlFrame {
  background: rgba(15, 23, 42, 0.72);
}
body.modeDark .templateMetaPill {
  background: rgba(15, 23, 42, 0.82);
  border-color: rgba(148, 163, 184, 0.16);
}
body.modeDark .templateTokenChip {
  background: rgba(15, 23, 42, 0.88);
}
body.modeDark .emailFieldsConfig {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.18);
}
body.modeDark .emailFieldsList {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(255, 255, 255, 0.08);
}
body.modeDark .emailFieldBucket {
  background: rgba(15, 23, 42, 0.62);
  border-color: rgba(148, 163, 184, 0.14);
}
body.modeDark .emailFieldBucketSelected {
  background: rgba(6, 78, 59, 0.25);
  border-color: rgba(16, 185, 129, 0.2);
}
body.modeDark .emailFieldPill {
  background: rgba(15, 23, 42, 0.78);
  border-color: rgba(148, 163, 184, 0.14);
  color: var(--fg);
}
body.modeDark .emailFieldMiniBtn {
  background: rgba(15, 23, 42, 0.82);
}
body.modeDark .orderDetailsColumnPanel,
body.modeDark .orderDetailsColumnItem {
  background: rgba(15, 23, 42, 0.62);
  border-color: rgba(148, 163, 184, 0.14);
}

@media (max-width: 820px) {
  .templateSettingsLayout,
  .templateComposerLayout,
  .credentialModalBody,
  .credentialGrid,
  .credentialChecks,
  .templateEditorMetaGrid,
  .templatePatientConfigGrid,
  .templateScheduleGrid {
    grid-template-columns: 1fr;
  }
  .emailFieldsList {
    grid-template-columns: 1fr;
  }
}

body.modeDark .connectorPath {
  stroke: rgba(156, 176, 198, 0.8);
}

body.modeDark .boardStatus {
  background: rgba(2, 6, 23, 0.92);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.28);
}

body.modeDark .boardStatus.isError {
  background: rgba(2, 6, 23, 0.92);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.3);
}

body.modeDark .boardHeaderLoadingBar {
  background: rgba(51, 65, 85, 0.5);
}

body.modeDark .boardInitialLoadingCard {
  background:
    linear-gradient(135deg, rgba(16, 185, 129, 0.16), rgba(244, 63, 94, 0.1)),
    rgba(15, 23, 42, 0.92);
  border-color: rgba(52, 211, 153, 0.18);
}

body.modeDark ::-webkit-scrollbar-thumb {
  background: rgba(156, 176, 198, 0.2);
}

body.modeDark .patientIcon {
  background: rgba(248, 250, 252, 0.04);
}

body.modeDark .flowCard.isFilterActive {
  --flow-card-title-color: #1b1404;
  --flow-card-subtitle-color: #3b2e0b;
  --flow-card-meta-color: #45370e;
  --flow-card-icon-bg: rgba(120, 53, 15, 0.08);
}

body.modeDark .patientDetailTimelineRow {
  background: rgba(20, 32, 52, 0.92);
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

body.modeDark .patientDetailTimelineLabel {
  color: #e6eef8;
}

body.modeDark .patientDetailTimelineValue,
body.modeDark .patientDetailLabel,
body.modeDark .patientDetailMilestoneStatus {
  color: #b7c7da;
}

body.modeDark .patientDetailField {
  background: rgba(51, 65, 85, 0.72);
  border-color: rgba(148, 163, 184, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

body.modeDark .patientDetailValue,
body.modeDark .patientDetailMilestoneName {
  color: #f8fbff;
}

body.modeDark .patientDetailMilestonesSection {
  border-top-color: rgba(148, 163, 184, 0.18);
}

body.modeDark .patientDetailMilestoneRow {
  box-shadow: 0 14px 28px rgba(2, 6, 23, 0.32);
}

body.modeDark .patientDetailMilestoneRow.isUnknown {
  background: rgba(30, 41, 59, 0.48);
  border-color: rgba(148, 163, 184, 0.14);
  color: #b7c7da;
}

body.modeDark .patientDetailMilestoneIcon {
  background: rgba(2, 6, 23, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

body.modeDark .patientDetailMilestoneStatus {
  background: rgba(2, 6, 23, 0.18);
}

body.modeDark .patientDetailMilestoneMeta {
  background: rgba(20, 32, 52, 0.72);
  border-color: rgba(148, 163, 184, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body.modeDark .patientDetailMilestoneTime,
body.modeDark .patientDetailMilestoneNoteLabel {
  color: #b7c7da;
}

body.modeDark .patientDetailMilestoneNoteBox {
  background: rgba(15, 118, 110, 0.12);
  border-color: rgba(45, 212, 191, 0.2);
}

body.modeDark .patientDetailMilestoneNoteText {
  color: #f8fbff;
}

@media (max-width: 960px) {
  :root {
    --card-gap: 28px;
  }

  .workflowCompactControlGrid,
  .workflowPrimaryGrid,
  .workflowStatusControl,
  .workflowNoteComposer,
  .workflowCompactNoteRow,
  .workflowHistoryRow {
    grid-template-columns: 1fr;
  }

  .workflowSecondaryToolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workflowSecondaryActions {
    justify-content: flex-start;
  }

  .workflowHistoryRowMeta,
  .workflowHistoryRowActions,
  .workflowHistoryBodyActions {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .advancedFilterRow,
  .advancedFilterRow.isFieldBound,
  .advancedFilterRow.isFieldBound.hasRange {
    grid-template-columns: 1fr;
  }

  .advancedFilterRemove {
    justify-self: start;
  }

  .boardTopbar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }

  .boardBrand {
    flex: 1 1 100%;
  }

  .boardHeaderSearch {
    order: 2;
    flex: 1 1 260px;
  }

  .boardHeaderSearchWrap {
    width: min(100%, 360px);
  }

  .boardHeaderLoading {
    padding: 0 16px 10px;
  }

  .boardTopbarActions {
    order: 3;
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 720px) {
  :root {
    --card-gap: 22px;
  }

  .boardTopbar {
    align-items: stretch;
    padding: 12px 14px;
  }

  .boardHeaderLoading {
    padding: 0 14px 10px;
  }

  .boardBrand {
    gap: 10px;
  }

  .boardBrand h1 {
    font-size: 1.1rem;
    line-height: 1;
    white-space: normal;
  }

  .boardHeaderSearch {
    order: 2;
    flex: 1 1 100%;
  }

  .boardHeaderSearchWrap {
    width: 100%;
  }

  .boardTopbarActions {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    gap: 10px;
  }

  .boardTopbarPrimary.boardBtn {
    order: 1;
  }

  .boardTopbarNav {
    order: 2;
  }

  .boardTopbarUtilities {
    order: 3;
  }

  .favoriteFiltersPopover {
    right: auto;
    left: 0;
    width: min(100vw - 32px, 360px);
  }

  .boardMain {
    padding: 14px;
  }

  .boardInitialLoading {
    inset: 14px;
  }

  .boardInitialLoadingCard {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .boardFlowStage,
  .patientDetailPanel {
    padding: 16px;
  }

  .patientDetailFields,
  .patientInfoGrid,
  .patientInfoSubsections,
  .patientInfoClinicalGrid,
  .vitalsEwsGroups,
  .datasheetColumnPanelHead,
  .patientDetailTimelineGrid,
  .workflowHistoryStack {
    grid-template-columns: 1fr;
  }

  .patientInfoColumn {
    border-left: 0;
    border-top: 1px solid color-mix(in srgb, var(--detail-divider) 78%, transparent);
  }

  .patientInfoColumn:first-child {
    border-top: 0;
  }

  .patientInfoSubsection {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .patientInfoCell,
  .patientInfoCell.isWide {
    max-width: none;
  }

  .patientInfoBulletList {
    grid-template-columns: 1fr;
    max-height: 220px;
  }

  .patientInfoLongTextBlock {
    max-height: 220px;
  }

  .flowRows {
    gap: 30px;
  }

  .flowCard {
    padding: 14px;
  }
}
