/* Keep Labentra modal workflows above all workspace overlays. */
[role="dialog"][aria-label="Add Internal Test"],
[role="dialog"][aria-label="Edit Internal Test"],
[role="dialog"][aria-label="View Internal Test"],
[role="dialog"][aria-label="COA Template Library"],
[role="dialog"][aria-label="Labentra Test Request"],
[role="dialog"][aria-label="Labentra Template Library"],
[role="dialog"][class*="z-[9800]"] {
  z-index: 30000 !important;
  isolation: isolate !important;
}

/* Template Library edit workflow: the edit overlay is created separately from the library modal. */
#labentra-template-edit-overlay {
  z-index: 2147483000 !important;
  isolation: isolate !important;
  pointer-events: auto !important;
}

/* Matrix action workflows: keep only the action dialogs above the Labentra page. */
[role="dialog"][class*="z-[120000]"],
[role="dialog"][aria-label="Edit submitted test request"] {
  z-index: 2147483000 !important;
  isolation: isolate !important;
  pointer-events: auto !important;
}

/* Keep matrix action controls clickable on the normal Labentra page. */
button[data-lab-result-action],
section[aria-label="Submitted Test Requests"] button[title="Edit request"],
section[aria-label="Submitted Test Requests"] button[title="Delete request"] {
  position: relative !important;
  z-index: 2147482000 !important;
  pointer-events: auto !important;
}

/* When any Labentra modal is open, underlying matrix actions must stay behind it. */
body:has([role="dialog"]) button[data-lab-result-action],
body:has([role="dialog"]) section[aria-label="Submitted Test Requests"] button[title="Edit request"],
body:has([role="dialog"]) section[aria-label="Submitted Test Requests"] button[title="Delete request"] {
  z-index: 1 !important;
  pointer-events: none !important;
}
