*:has(+ * :is(udg-universal-data-grid, c-universal-data-grid)) > .flexipageHeader {
  /* Styles applied to the header */
  display:none !important;
}

/* Picklist overlay styles */
.universal-data-grid .picklist-overlay .slds-dropdown {
    position: fixed !important;
    max-height: 200px !important;
    min-height: 50px !important;
    width: auto !important;
    max-width: 30% !important;
    overflow-y: auto !important;
    z-index: 9001 !important;
    background: white !important;
    border: 2px solid #0176d3 !important;
    border-radius: 0.25rem !important;
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.28) !important;
    margin-top: 2px !important;
}

/* c-multi-select-combobox in picklist overlay (synthetic shadow supplement - inline JS styles are primary) */
.universal-data-grid .picklist-overlay c-multi-select-combobox {
    width: 100%;
    max-width: 100%;
}

/* Force dropdown visible when open (supplements inline JS styles set on open) */
.universal-data-grid .picklist-overlay .slds-combobox.slds-is-open .slds-dropdown {
    display: block !important;
}

/* Prevent the combobox outer container from clipping the fixed dropdown */
.universal-data-grid .picklist-overlay c-multi-select-combobox .slds-combobox {
    overflow: visible !important;
}

/* Input sizing for c-multi-select-combobox */
.universal-data-grid .picklist-overlay c-multi-select-combobox .multi-select-combobox__input {
    min-height: 2rem !important;
    height: 2rem !important;
    line-height: 2rem !important;
}

/* Prevent icon from intercepting clicks for c-multi-select-combobox */
.universal-data-grid .picklist-overlay c-multi-select-combobox .multi-select-combobox__icon,
.universal-data-grid .multi-picklist-overlay c-multi-select-combobox .multi-select-combobox__icon {
    pointer-events: none !important;
}

/* Multi-picklist overlay styles (used by multiPicklist LWC with c-multi-select-combobox) */
/* The overlay div itself is position:fixed and positioned by JS in multiPicklist._calculateOverlayPosition().
   The dropdown is position:absolute relative to .slds-combobox inside the overlay — no coordinate
   compensation needed since the overlay is already correctly placed. */
.universal-data-grid .multi-picklist-overlay .slds-dropdown {
    position: absolute !important;
    max-height: 200px !important;
    min-height: 50px !important;
    width: 100% !important;
    overflow-y: auto !important;
    z-index: 1 !important;
    background: white !important;
    border: 2px solid #0176d3 !important;
    border-radius: 0.25rem !important;
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.28) !important;
    margin-top: 2px !important;
}

.universal-data-grid .multi-picklist-overlay c-multi-select-combobox {
    width: 100%;
    max-width: 100%;
}

/* Remove default SLDS form-element margin in overlay context to prevent vertical misalignment */
.universal-data-grid .multi-picklist-overlay c-multi-select-combobox .slds-form-element {
    margin-bottom: 0 !important;
}

/* Force dropdown visible when open */
.universal-data-grid .multi-picklist-overlay .slds-combobox.slds-is-open .slds-dropdown {
    display: block !important;
}

/* Prevent outer container from clipping the fixed dropdown */
.universal-data-grid .multi-picklist-overlay c-multi-select-combobox .slds-combobox {
    overflow: visible !important;
}

/* Input sizing */
.universal-data-grid .multi-picklist-overlay c-multi-select-combobox .multi-select-combobox__input {
    min-height: 2rem !important;
    height: 2rem !important;
    line-height: 2rem !important;
}

/* Dropdown item styles */
.universal-data-grid .multi-picklist-overlay .slds-dropdown .slds-listbox__item {
    background: white !important;
    border-bottom: 1px solid #f3f3f3 !important;
}

.universal-data-grid .multi-picklist-overlay .slds-dropdown .slds-listbox__item:hover {
    background: #f3f3f3 !important;
}

.universal-data-grid .multi-picklist-overlay .slds-dropdown .slds-listbox__item[aria-selected="true"] {
    background: #0176d3 !important;
    color: white !important;
}

/* lightning-combobox picklist overlay rules (retained for any remaining uses) */
.universal-data-grid .picklist-overlay lightning-combobox {
    --slds-c-combobox-color-background: white;
    --slds-c-combobox-color-border: #d8dde6;
    --slds-c-combobox-sizing-border: 1px;
    --slds-c-combobox-dropdown-color-background: white;
    --slds-c-combobox-dropdown-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);
    width: 100%;
    max-width: 100%;
}

/* Additional styling for picklist-overlay combobox */
.universal-data-grid .picklist-overlay lightning-combobox .slds-combobox_container {
    position: relative !important;
    z-index: 10 !important;
    min-height: 2rem !important;
    height: 2rem !important;
}

.universal-data-grid .picklist-overlay lightning-combobox .slds-combobox__input {
    min-height: 2rem !important;
    height: 2rem !important;
}

.universal-data-grid .picklist-overlay lightning-combobox .slds-combobox__button {
    height: 2rem !important;
}

/* Fix chevron click issue in newer Salesforce styling (SLDS2) - prevent chevron from intercepting clicks */
.universal-data-grid .picklist-overlay lightning-combobox .slds-input__icon.slds-input__icon_right.slds-icon-utility-down.slds-icon_container,
.universal-data-grid .picklist-overlay lightning-combobox .slds-input__icon.slds-input__icon_right {
    pointer-events: none !important;
}

/* Fix chevron click issue for newere Salesforce styling (SLDS2) for searchable-combobox */
.universal-data-grid c-searchable-combobox .slds-input__icon.slds-input__icon_right.slds-icon-utility-down.slds-icon_container,
.universal-data-grid c-searchable-combobox .slds-input__icon.slds-input__icon_right {
    pointer-events: none !important;
}

/* Style dropdown items for better visibility */
.universal-data-grid .picklist-overlay .slds-dropdown .slds-listbox__item {
    /* padding: 0.5rem !important; */
    background: white !important;
    border-bottom: 1px solid #f3f3f3 !important;
}

/* Hover state for dropdown items */
.universal-data-grid .picklist-overlay .slds-dropdown .slds-listbox__item:hover {
    background: #f3f3f3 !important;
}

/* Selected state for dropdown items */
.universal-data-grid .picklist-overlay .slds-dropdown .slds-listbox__item[aria-selected="true"] {
    background: #0176d3 !important;
    color: white !important;
}

/* Ensure combobox doesn't cause margin issues */
.universal-data-grid .picklist-overlay lightning-combobox [lightning-combobox_combobox-host] {
    margin-bottom: 0px !important;
}
.universal-data-grid .picklist-overlay lightning-combobox [lightning-combobox_combobox-host] {
    margin-bottom: 0px !important;
}

.universal-data-grid [lightning-combobox_combobox-host]{
    margin-bottom: 17px;
}

.universal-data-grid th.slds-has-focus, .universal-data-grid td.slds-has-focus{
    box-shadow: none !important;
}

.universal-data-grid .slds-table_edit thead th:first-child{
    width: 60px;
}

/* Fix for lightning datatable bottom bar appearing above picklist dropdowns - scoped to universalDataGrid */
.universal-data-grid .slds-docked-form-footer {
    z-index: 19 !important;
}

/* Object selector overlay styles */
.universal-data-grid .object-selector-overlay .slds-dropdown {
    position: fixed !important; 
    max-height: 200px !important;
    min-height: 50px !important;
    width: auto !important;
    max-width: 30% !important;
    overflow-y: auto !important;
    z-index: 22 !important;
    background: white !important;
    border: 2px solid #0176d3 !important;
    border-radius: 0.25rem !important;
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.28) !important;
    margin-top: 2px !important;
}

.universal-data-grid .object-selector-overlay lightning-combobox {
    --slds-c-combobox-color-background: white;
    --slds-c-combobox-color-border: #d8dde6;
    --slds-c-combobox-sizing-border: 1px;
    --slds-c-combobox-dropdown-color-background: white;
    --slds-c-combobox-dropdown-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);
    width: 100%;
    max-width: 100%;
}

.universal-data-grid .object-selector-overlay lightning-combobox .slds-combobox_container {
    position: relative !important;
    min-height: 2rem !important;
    height: 2rem !important;
}

.universal-data-grid .object-selector-overlay lightning-combobox .slds-combobox__input {
    min-height: 2rem !important;
    height: 2rem !important;
    padding-right: 1.75rem !important;
}

.universal-data-grid .object-selector-overlay lightning-combobox .slds-combobox__form-element button {
    right: 0 !important;
}

.universal-data-grid .object-selector-overlay .slds-dropdown .slds-listbox__item {
    padding: 0.5rem !important;
    background: white !important;
    border-bottom: 1px solid #f3f3f3 !important;
    z-index: 1100;
}

.universal-data-grid .object-selector-overlay .slds-dropdown .slds-listbox__item:hover {
    background: #f3f3f3 !important;
}

.universal-data-grid .object-selector-overlay .slds-dropdown .slds-listbox__item[aria-selected="true"] {
    background: #0176d3 !important;
    color: white !important;
}

.universal-data-grid .object-selector-overlay lightning-combobox .slds-input__icon.slds-input__icon_right {
   padding-left: 0.25rem !important;
   pointer-events: none !important;
}

/* Record picker styles */
.universal-data-grid .recordpicker-container lightning-grouped-combobox {
    margin-bottom: 0 !important; /* fix issue with Experience Sites adding margin bottom to record picker */
}

.universal-data-grid .recordpicker-overlay .slds-dropdown {
    position: fixed !important;
    max-height: 200px !important;
    min-height: 50px !important;
    width: auto !important;
    max-width: 30% !important;
    overflow-y: auto !important;
    z-index: 25 !important;
    background: white !important;
    border: 2px solid #0176d3 !important;
    border-radius: 0.25rem !important;
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.28) !important;
    margin-top: 2px !important;
}

.universal-data-grid .recordpicker-overlay lightning-record-picker {
    --slds-c-combobox-color-background: white;
    --slds-c-combobox-color-border: #d8dde6;
    --slds-c-combobox-sizing-border: 1px;
    --slds-c-combobox-dropdown-color-background: white;
    --slds-c-combobox-dropdown-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.16);
    width: 100%;
    max-width: 100%;
}

/* Additional styling for recordpicker-overlay */
.universal-data-grid .recordpicker-overlay lightning-record-picker .slds-combobox_container {
    position: relative !important;
    min-height: 2rem !important;
    height: 2rem !important;
}

.universal-data-grid .recordpicker-overlay lightning-record-picker .slds-combobox__input {
    min-height: 2rem !important;
    height: 2rem !important;
}

.universal-data-grid .recordpicker-overlay lightning-record-picker .slds-combobox__button {
    height: 2rem !important;
}

/* Style dropdown items for better visibility */
.universal-data-grid .recordpicker-overlay .slds-dropdown .slds-listbox__item {
    padding: 0.5rem !important;
    background: white !important;
    border-bottom: 1px solid #f3f3f3 !important;
    z-index: 25 !important;
}

/* Hover state for dropdown items */
.universal-data-grid .recordpicker-overlay .slds-dropdown .slds-listbox__item:hover {
    background: #f3f3f3 !important;
}

/* Selected state for dropdown items */
.universal-data-grid .recordpicker-overlay .slds-dropdown .slds-listbox__item[aria-selected="true"] {
    background: #0176d3 !important;
    color: white !important;
}

/* Ensure record picker doesn't cause margin issues */
.universal-data-grid .recordpicker-overlay lightning-record-picker [lightning-record-picker_record-picker-host] {
    margin-bottom: 0px !important;
}

/* Sticky Header Implementation for Lightning Datatable */
/* Override the problematic SLDS class that creates the bar above headers - scoped to universalDataGrid */
.universal-data-grid .slds-table_header-fixed_container {
    border-top: none !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Target the outer container to set up proper scrolling - scoped to universalDataGrid */
.universal-data-grid .dt-outer-container {
    position: relative !important;
    /* Remove height override that might interfere with scrolling */
}

/* Make the vertical scrollable container handle the overflow - scoped to universalDataGrid */
.universal-data-grid .slds-scrollable_y {
    max-height: 19rem !important;
    overflow-y: auto !important;
    /* Remove position and height overrides that interfere with scrollbar */
}

/* Ensure scrollbar is always visible and properly styled */
.universal-data-grid .slds-scrollable_y::-webkit-scrollbar {
    width: 8px !important;
    background-color: #f1f1f1 !important;
}

.universal-data-grid .slds-scrollable_y::-webkit-scrollbar-thumb {
    background-color: #c1c1c1 !important;
    border-radius: 4px !important;
}

.universal-data-grid .slds-scrollable_y::-webkit-scrollbar-thumb:hover {
    background-color: #a8a8a8 !important;
}

/* Fix horizontal scrollbar styling */
.universal-data-grid .slds-scrollable_x::-webkit-scrollbar {
    height: 8px !important;
    background-color: #f1f1f1 !important;
}

.universal-data-grid .slds-scrollable_x::-webkit-scrollbar-thumb {
    background-color: #c1c1c1 !important;
    border-radius: 4px !important;
}

.universal-data-grid .slds-scrollable_x::-webkit-scrollbar-thumb:hover {
    background-color: #a8a8a8 !important;
}

/* For small tables (≤10 rows), remove scrolling completely - scoped to universalDataGrid */
.universal-data-grid .small-table .slds-scrollable_y {
    height: fit-content !important;
    max-height: none !important;
    overflow: visible !important;
    overflow-y: visible !important;
}

/* Salesforce bug (extra gap below last row in table when there's a sticky header) workaround for sticky headers with a between 11-20 rows */
.universal-data-grid .medium-table .slds-table .slds-resizable__divider {
    display: none !important;
}
.universal-data-grid .medium-table .slds-table .slds-resizable__handle {
    border-left: 1px solid #949494 !important;
    cursor: col-resize !important;
    margin-right: -7px !important;
}
.universal-data-grid .medium-table .slds-table .slds-resizable__handle:hover {
    border-left: 5px solid #0176d3 !important;
}


/* Resizable divider fix for small and medium tables*/
.universal-data-grid.freeze-mode-enabled .small-table .slds-table .slds-resizable__handle:active::after {
    content: "";
    position: absolute; /* does not interfere with other components on the page due to containment */
    left: -1px;
    top: 100%;
    height: 500px;
    width: 1px;
    background-color: #0176d3;
    z-index: 1101;
}
.universal-data-grid .medium-table .slds-table .slds-resizable__handle:active::after {
    content: "";
    position: absolute; /* does not interfere with other components on the page due to containment */
    left: -1px;
    top: 100%;
    height: 1000px;
    width: 1px;
    background-color: #0176d3;
    z-index: 1000;
}


/* Apply same workaround for small tables when freeze mode is enabled */
.universal-data-grid.freeze-mode-enabled .small-table .slds-table .slds-resizable__divider {
    display: none !important;
}
.universal-data-grid.freeze-mode-enabled .small-table .slds-table .slds-resizable__handle {
    border-left: 1px solid #949494 !important;
    cursor: col-resize !important;
    margin-right: -7px !important;
}
.universal-data-grid.freeze-mode-enabled .small-table .slds-table .slds-resizable__handle:hover {
    border-left: 5px solid #0176d3 !important;
}

/* Force the horizontal scrollable container to also size naturally - scoped to universalDataGrid */
.universal-data-grid .slds-table_header-fixed_container.slds-scrollable_x {
    overflow-x: auto !important;
    /* Remove height overrides that might interfere with horizontal scrollbar */
}

/* Override any forced heights on the outer container - scoped to universalDataGrid */
.universal-data-grid .dt-outer-container[style*="height"] {
    height: auto !important;
}

/* Apply sticky positioning to the table header - scoped to universalDataGrid */
.universal-data-grid .slds-table.slds-table_header-fixed thead[data-rowgroup-header] {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    /* background-color: #fafaf9 !important; */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Ensure all header cells have proper background - scoped to universalDataGrid */
.universal-data-grid .slds-table.slds-table_header-fixed thead[data-rowgroup-header] th {
    /* background-color: #fafaf9 !important; */
    position: sticky !important;
    top: 0 !important;
    border-bottom: 1px solid #c9c7c5 !important;
}

/* Prevent first table row from being hidden behind sticky header - scoped to universalDataGrid */
.universal-data-grid .slds-table.slds-table_header-fixed tbody[data-rowgroup-body] {
    position: relative !important;
}

/* Ensure first table row is visible and not cut off - scoped to universalDataGrid */
.universal-data-grid .slds-table.slds-table_header-fixed tbody[data-rowgroup-body] tr:first-child {
    margin-top: 0 !important;
    border-top: none !important;
}

/* Ensure proper spacing between header and body - scoped to universalDataGrid */
.universal-data-grid .slds-table.slds-table_header-fixed {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

/* Alternative targeting for broader compatibility - scoped to universalDataGrid */
.universal-data-grid table[role="grid"] thead {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    /* background-color: #fafaf9 !important; */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.universal-data-grid table[role="grid"] thead th {
    position: sticky !important;
    top: 0 !important;
}

/* Fullscreen mode styling */
.universal-data-grid.fullscreen-mode {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9000 !important;
    background: white !important;
    overflow: auto !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Make header sticky when in fullscreen */
.universal-data-grid .fullscreen-mode .slds-page-header {
    position: sticky !important;
    top: 0 !important;
    background: white !important;
    z-index: 9001 !important;
    border-bottom: 1px solid #dddbda !important;
}

/* Increase max-height in fullscreen mode for better space utilization - scoped to universalDataGrid, but exclude freeze-mode */
.universal-data-grid.fullscreen-mode:not(.freeze-mode-rownum):not(.freeze-mode-checkbox):not(.freeze-mode-rownum-checkbox) .slds-scrollable_y {
    max-height: calc(100vh - 14rem) !important;
}

/* Special handling for freeze-mode in fullscreen - maintain scrolling capability */
.universal-data-grid.freeze-mode-enabled .slds-scrollable_y {
    max-height: calc(100vh - 14rem) !important;
    overflow-y: auto !important;
}

/* Override data-table-container max-height in fullscreen mode - scoped to universalDataGrid, but exclude freeze-mode */
.universal-data-grid.fullscreen-mode:not(.freeze-mode-rownum):not(.freeze-mode-checkbox):not(.freeze-mode-rownum-checkbox) .data-table-container {
    max-height: calc(100vh - 12rem) !important;
}

/* Data table container for freeze-mode in fullscreen */
.universal-data-grid.fullscreen-mode.freeze-mode-enabled .data-table-container {
    max-height: calc(100vh - 5px) !important;
    overflow: visible !important;
}

/* Fullscreen mode 2 - expands within existing page layout instead of taking over entire viewport */
.universal-data-grid .taller-mode {
    width: 100% !important;
    height: 100% !important;
    max-height: calc(100vh - 10rem) !important; /* Adjust based on page header/footer space */
    overflow: visible !important;
    border: 1px solid #dddbda !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Increase max-height in fullscreen mode 2 for better space utilization - scoped to universalDataGrid, but exclude freeze-mode */
.universal-data-grid.taller-mode:not(.freeze-mode-rownum):not(.freeze-mode-checkbox):not(.freeze-mode-rownum-checkbox) .slds-scrollable_y {
    max-height: calc(100vh - 12rem) !important;
}

/* Special handling for small tables in fullscreen mode 2 (prevent excess vertical scroll space) */
.universal-data-grid.taller-mode:not(:has(.small-table)) .slds-scrollable_y {
    max-height: calc(100vh - 12rem) !important;
    overflow-y: auto !important;
}

/* Override data-table-container max-height in fullscreen mode 2 - scoped to universalDataGrid, but exclude freeze-mode */
.universal-data-grid.taller-mode:not(.freeze-mode-rownum):not(.freeze-mode-checkbox):not(.freeze-mode-rownum-checkbox) .data-table-container {
    max-height: calc(100vh - 10rem) !important;
}

/* Data table container for freeze-mode in fullscreen mode 2 */
.universal-data-grid.taller-mode .data-table-container {
    max-height: calc(100vh - 8rem) !important;
    overflow: visible !important;
}

/* Hide the outer horizontal scrollbar in freeze-mode - only show the inner one */
/* Use width differential pattern similar to fullscreen vertical scrollbars */
.universal-data-grid.freeze-mode-enabled .slds-table_header-fixed_container.slds-scrollable_x {
    overflow-x: hidden !important;
    max-width: calc(100% - 1rem) !important; /* Make outer container narrower */
}

/* Ensure inner scrollable container has full width for proper scrollbar display */
.universal-data-grid.freeze-mode-enabled .slds-scrollable_y {
    max-width: 100% !important; /* Inner container gets full width */
    width: 100% !important;
}

/* Document builder mode - grid grows to fit its content: no vertical or horizontal scrollbars, dynamic height.
   Usage: set the grid's "CSS class" property to document-builder-mode.
   Placed after the freeze-mode rules so it wins specificity ties. */
.universal-data-grid.document-builder-mode,
.universal-data-grid.document-builder-mode .data-table-container,
.universal-data-grid.document-builder-mode .dt-outer-container,
.universal-data-grid.document-builder-mode .dt-outer-container[style*="height"] {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

.universal-data-grid.document-builder-mode .slds-scrollable_y,
.universal-data-grid.document-builder-mode .slds-table_header-fixed_container.slds-scrollable_x,
.universal-data-grid.document-builder-mode.freeze-mode-enabled .slds-scrollable_y,
.universal-data-grid.document-builder-mode.freeze-mode-enabled .slds-table_header-fixed_container.slds-scrollable_x {
    height: auto !important;
    max-height: none !important;
    max-width: 100% !important;
    overflow: visible !important;
}

/* Adjust content padding in fullscreen */
.fullscreen-mode > div {
    padding: 1rem !important;
}

/* Ensure sections don't have excessive margin in fullscreen */
.fullscreen-mode section {
    margin: 0.5rem !important;
}

/* Hide this element due to Salesforce platform bug (multi row edit doesn't work out of box) */
lightning-input[data-mass-selection="true"] {
  display: none !important;
}

/* Hide popover footer when mass selection is active */
.slds-popover__body:has([data-mass-selection="true"]) ~ .slds-popover__footer {
  display: none !important;
}

/* Button bar responsive handling */
.universal-data-grid .slds-page-header .slds-col.slds-no-flex {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

.universal-data-grid .slds-page-header .slds-grid.slds-wrap {
    justify-content: flex-end !important;
    align-items: flex-start !important;
    gap: 0.125rem !important; /* Match the xxx-small gutter spacing for both horizontal and vertical */
}

/* Make each button container wrap properly */
.universal-data-grid .slds-page-header .slds-grid.slds-wrap > .slds-col {
    flex: 0 0 auto !important;
    margin-bottom: 0 !important;
}

/* On smaller screens, allow wrapping but don't force full width */
@media (max-width: 1366px) {
    .universal-data-grid .slds-page-header .slds-grid.slds-wrap > .slds-col {
        margin-bottom: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Make buttons slightly smaller on smaller screens for better fit */
    .universal-data-grid .slds-page-header lightning-button {
        font-size: 0.875rem !important;
    }
    
    .universal-data-grid .slds-page-header lightning-button-icon {
        --slds-c-button-sizing-border: 1px;
    }
}

/* Delete button styling - make it prominently red */
.universal-data-grid .slds-page-header lightning-button-icon[data-element-id="delete-selected-button"] {
    --slds-c-button-destructive-color-background: #d73527 !important;
    --slds-c-button-destructive-color-background-hover: #ba281e !important;
    --slds-c-button-destructive-color-background-focus: #ba281e !important;
    --slds-c-button-destructive-color-border: #d73527 !important;
    --slds-c-button-destructive-color-border-hover: #ba281e !important;
    --slds-c-button-destructive-color-border-focus: #ba281e !important;
}

.universal-data-grid .slds-page-header lightning-button-icon[data-element-id="delete-selected-button"] button {
    background-color: #d73527 !important;
    border-color: #d73527 !important;
    color: white !important;
}

.universal-data-grid .slds-page-header lightning-button-icon[data-element-id="delete-selected-button"] button:hover {
    background-color: #ba281e !important;
    border-color: #ba281e !important;
    color: white !important;
}

.universal-data-grid .slds-page-header lightning-button-icon[data-element-id="delete-selected-button"] button:focus {
    background-color: #ba281e !important;
    border-color: #ba281e !important;
    color: white !important;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #d73527 !important;
}

/* Alternative approach using variant="destructive" override */
.universal-data-grid .slds-page-header lightning-button-icon[variant="destructive"] {
    --slds-c-button-destructive-color-background: #d73527 !important;
    --slds-c-button-destructive-color-background-hover: #ba281e !important;
    --slds-c-button-destructive-color-background-focus: #ba281e !important;
}

.universal-data-grid .slds-page-header lightning-button-icon[variant="destructive"] button {
    background-color: #d73527 !important;
    border-color: #d73527 !important;
    color: white !important;
}

.universal-data-grid .slds-page-header lightning-button-icon[variant="destructive"] button:hover {
    background-color: #ba281e !important;
    border-color: #ba281e !important;
}

/* Icon color override */
.universal-data-grid .slds-page-header lightning-button-icon[data-element-id="delete-selected-button"] .slds-button__icon,
.universal-data-grid .slds-page-header lightning-button-icon[variant="destructive"] .slds-button__icon {
    fill: white !important;
}

/* Set non-frozen headers to a lower z-index so frozen headers stay on top */
.universal-data-grid .slds-table thead th:not(.frozen-column) {
    z-index: 8 !important;
}

.universal-data-grid .slds-table thead th .slds-cell-fixed {
    position: static !important;
}

/* ==========================================================================
   FREEZE MODE CSS - ALL PERMUTATIONS
   Row number column: 52px wide
   Checkbox column: 32px wide
   Row number always comes before checkbox (if both exist)
   ========================================================================== */

/* 1. FREEZE-MODE-ROWNUM: Row number column only (no checkbox) */
/* Target Row number column header */
.universal-data-grid.freeze-mode-rownum .slds-table thead th[data-col-key-value="0-rowNumber-0"] {
    position: sticky !important;
    left: 0 !important; 
    z-index: 12 !important;
    /* background-color: #fafaf9 !important; */
}

/* Target Row number cells in column */
.universal-data-grid.freeze-mode-rownum .slds-table tbody td[data-col-key-value="0-rowNumber-0"] {
    position: sticky !important;
    left: 0 !important;
    z-index: 3 !important;
    background-color: #F3F3F3 !important; 
} 

/* Target Record name column header - positioned after row number (52px) */
.universal-data-grid.freeze-mode-rownum .slds-table thead th[role="columnheader"][data-col-key-value$="-1"],
.universal-data-grid.freeze-mode-rownum .slds-table thead th[role="columnheader"][data-col-key-value$="-1"]{
    position: sticky !important;
    left: 52px !important; 
    z-index: 10 !important;
    /* background-color: #fafaf9 !important; */
    border-right: 2px solid #c9c7c5 !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important;
}

/* Target record name cells in column - positioned after row number (52px) */
.universal-data-grid.freeze-mode-rownum .slds-table tbody td.frozen-column {
    position: sticky !important;
    left: 52px !important;
    z-index: 9 !important;
    background-color: var(--slds-g-color-surface-3) !important; 
    border-right: 2px solid #c9c7c5 !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important;
}

/* Frozen Column Implementation - positioned after row number (52px) */
.universal-data-grid.freeze-mode-rownum .frozen-column {
    position: sticky !important;
    left: 52px !important;
    z-index: 9 !important;
    background-color: var(--slds-g-color-surface-3) !important; 
    border-right: 2px solid #c9c7c5 !important;
}

/* 2. FREEZE-MODE-CHECKBOX: Checkbox column only (no row number) */
/* Target Checkbox column header */
.universal-data-grid.freeze-mode-checkbox .slds-table thead th[data-col-key-value="0-SELECTABLE_CHECKBOX-0"] {
    position: sticky !important;
    left: 0 !important; 
    z-index: 12 !important;
}

/* Target Checkbox cells in column */
.universal-data-grid.freeze-mode-checkbox .slds-table tbody td[data-col-key-value="0-SELECTABLE_CHECKBOX-0"] {
    position: sticky !important;
    left: 0 !important;
    z-index: 3 !important;
    background-color: var(--slds-g-color-surface-3) !important; 
} 

/* Target Record name column header - positioned after checkbox (32px) */
.universal-data-grid.freeze-mode-checkbox .slds-table thead th[role="columnheader"][data-col-key-value$="-1"],
.universal-data-grid.freeze-mode-checkbox .slds-table thead th[role="columnheader"][data-col-key-value$="-1"] {
    position: sticky !important;
    left: 32px !important; 
    z-index: 10 !important;
    /* background-color: #fafaf9 !important; */
    border-right: 2px solid #c9c7c5 !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important;
}

/* Target record name cells in column - positioned after checkbox (32px) */
.universal-data-grid.freeze-mode-checkbox .slds-table tbody td.frozen-column {
    position: sticky !important;
    left: 32px !important;
    z-index: 9 !important;
    background-color: var(--slds-g-color-surface-3) !important; 
    border-right: 2px solid #c9c7c5 !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important;
}

/* Frozen Column Implementation - positioned after checkbox (32px) */
.universal-data-grid.freeze-mode-checkbox .frozen-column {
    position: sticky !important;
    left: 32px !important;
    z-index: 9 !important;
    background-color: var(--slds-g-color-surface-3) !important; 
    border-right: 2px solid #c9c7c5 !important;
}

/* 3. FREEZE-MODE-ROWNUM-CHECKBOX: Both row number and checkbox columns */
/* Target Row number column header */
.universal-data-grid.freeze-mode-rownum-checkbox .slds-table thead th[data-col-key-value="0-rowNumber-0"] {
    position: sticky !important;
    left: 0 !important; 
    z-index: 12 !important;
    /* background-color: #fafaf9 !important; */
}

/* Target Row number cells in column */
.universal-data-grid.freeze-mode-rownum-checkbox .slds-table tbody td[data-col-key-value="0-rowNumber-0"] {
    position: sticky !important;
    left: 0 !important;
    z-index: 3 !important;
    background-color: var(--slds-g-color-surface-3) !important;
} 

/* Target Checkbox column header - positioned after row number (52px) */
.universal-data-grid.freeze-mode-rownum-checkbox .slds-table thead th[data-col-key-value="1-SELECTABLE_CHECKBOX-1"] {
    position: sticky !important;
    left: 52px !important; 
    z-index: 12 !important;
}

/* Target Checkbox cells in column - positioned after row number (52px) */
.universal-data-grid.freeze-mode-rownum-checkbox .slds-table tbody td[data-col-key-value="1-SELECTABLE_CHECKBOX-1"] {
    position: sticky !important;
    left: 52px !important;
    z-index: 3 !important; 
    background-color: var(--slds-g-color-surface-3) !important; 
} 

/* Target Record name column header - positioned after row number + checkbox (52px + 32px = 84px) */
.universal-data-grid.freeze-mode-rownum-checkbox .slds-table thead th[role="columnheader"][data-col-key-value$="-2"],
.universal-data-grid.freeze-mode-rownum-checkbox .slds-table thead th[role="columnheader"][data-col-key-value$="-2"] {
    position: sticky !important;
    left: 84px !important; 
    z-index: 10 !important;
    /* background-color: #fafaf9 !important; */
    border-right: 2px solid #c9c7c5 !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important;
}

/* Target record name cells in column - positioned after row number + checkbox (52px + 32px = 84px) */
.universal-data-grid.freeze-mode-rownum-checkbox .slds-table tbody td.frozen-column {
    position: sticky !important;
    left: 84px !important;
    z-index: 9 !important;
    background-color: var(--slds-g-color-surface-3) !important; 
    border-right: 2px solid #c9c7c5 !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important;
}

/* Frozen Column Implementation - positioned after row number + checkbox (52px + 32px = 84px) */
.universal-data-grid.freeze-mode-rownum-checkbox .frozen-column {
    position: sticky !important;
    left: 84px !important;
    z-index: 9 !important;
    background-color: var(--slds-g-color-surface-3) !important; 
    border-right: 2px solid #c9c7c5 !important;
}

/* Ensure frozen columns work properly in both header and body */
.universal-data-grid .slds-table thead th.frozen-column {
    position: sticky !important;
    left: 0 !important;
    z-index: 10 !important; /* Higher than non-frozen headers (8) and frozen body cells (9) */
    background-color: var(--slds-g-color-surface-3) !important; 
    border-right: 2px solid #c9c7c5 !important;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1) !important; /* Add shadow for visual separation */
}

/* Ensure frozen columns maintain proper styling during hover and selection */
.universal-data-grid .slds-table tbody tr:hover td.frozen-column {
     background-color: var(--slds-g-color-surface-3) !important; 
}

.universal-data-grid .slds-table tbody tr.slds-is-selected td.frozen-column {
   background-color: var(--slds-g-color-surface-3) !important; 
}

/* When checkbox column is present, adjust frozen column positioning */
.universal-data-grid .slds-table:not(.slds-no-row-hover) thead th.frozen-column:nth-child(2),
.universal-data-grid .slds-table:not(.slds-no-row-hover) tbody td.frozen-column:nth-child(2) {
    left: 60px !important; /* Position after checkbox column */
}

/* When checkbox column is hidden, frozen column should be at left edge */
.universal-data-grid .slds-table thead th.frozen-column:first-child,
.universal-data-grid .slds-table tbody td.frozen-column:first-child {
    left: 0 !important;
}

/* Update frozen body cells to match header positioning */
.universal-data-grid .slds-table tbody td.frozen-column {
    left: 84px !important; /* Match the header positioning when checkbox is present */
}

/* When checkbox is hidden, position frozen body cells to match header */
.universal-data-grid .slds-table[hide-checkbox-column] tbody td.frozen-column,
.universal-data-grid .slds-table.slds-no-row-hover tbody td.frozen-column {
    left: 52px !important; /* Match the header positioning when checkbox is hidden */
}

/* Ensure the table container allows horizontal scrolling while keeping frozen columns in place */
.universal-data-grid .slds-scrollable_x {
    overflow-x: auto !important;
}

/* Special handling for frozen columns in edit mode */
.universal-data-grid .slds-table_edit thead th.frozen-column,
.universal-data-grid .slds-table_edit tbody td.frozen-column {
     background-color: #fafaf9 !important; 
}

.universal-data-grid lightning-primitive-header-actions .slds-dropdown lightning-menu-item:last-child {
    display: none !important;
}

/* related-record name link cells (type: 'button'): SLDS sets white-space: normal on the inner button, so truncate there */
.universal-data-grid lightning-button.udm-record-link {
    display: block;
    max-width: 100%;
}

.universal-data-grid lightning-button.udm-record-link:not(.udm-wrap) button {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.universal-data-grid lightning-button.udm-record-link.udm-wrap button {
    text-align: left;
    white-space: normal;
}

/* make row actions dropdown scrollable */
.universal-data-grid [data-col-key-value*="-action-"] .slds-dropdown[part*="dropdown"],
.universal-data-grid [data-col-key-value*="-action-"] lightning-button-menu .slds-dropdown {
    max-height: 220px !important;        
    overflow-y: auto !important;
}

/* make column header dropdown scrollable */
.universal-data-grid lightning-primitive-header-actions .slds-dropdown[part*="dropdown"],
.universal-data-grid .slds-th__action-button .slds-dropdown {
    max-height: 320px !important;        
    overflow-y: auto !important;
}

/* Target slds-scrollable_y when row action column dropdown menu is open (fix issue with row action drop down hiding rows in small tables */
.universal-data-grid .small-table .slds-scrollable_y:has([data-col-key-value*="-action-"] lightning-button-menu.slds-dropdown-trigger.slds-is-open) {
    margin-bottom: 13.75rem !important;
}
.universal-data-grid .small-table .slds-scrollable_y:has([data-col-key-value*="-SELECTABLE_BUTTON_MENU-"] lightning-button-menu.slds-dropdown-trigger.slds-is-open) {
    margin-bottom: 7.25rem !important;
}

/* Apply margin to data table section when filter combobox dropdown is open (prevents cutoff without pushing filter section) - mobile only */
@media screen and (max-width: 768px) {
    .universal-data-grid section:has(.filter-container .slds-combobox.slds-dropdown-trigger.slds-dropdown-trigger_click.slds-is-open) + section .small-table,
    .universal-data-grid section:has(.filter-container .slds-combobox.slds-dropdown-trigger.slds-dropdown-trigger_click.slds-is-open) + section.no-records-container {
        margin-bottom: 13.75rem !important;
    }
}

/* Fix for freeze mode: allow dropdown to escape overflow container */
.universal-data-grid.freeze-mode-enabled .small-table .slds-scrollable_y:has([data-col-key-value*="-action-"] lightning-button-menu.slds-dropdown-trigger.slds-is-open) {
    overflow-y: visible !important;
    margin-bottom: 13.75rem !important;
}
.universal-data-grid.freeze-mode-enabled .slds-scrollable_y:has([data-col-key-value*="-SELECTABLE_BUTTON_MENU-"] lightning-button-menu.slds-dropdown-trigger.slds-is-open) {
    overflow-y: visible !important;
    margin-bottom: 7.25rem !important;
}

/* prevent bottom bar from hiding horizontal scrollbar */
.universal-data-grid .slds-docked-form-footer.slds-is-absolute { 
    margin-bottom: 8px !important;
}
.universal-data-grid .dt-outer-container:has(.slds-docked-form-footer.slds-is-absolute) .slds-scrollable_y {
    margin-bottom: 8px !important;
}

/* set hover color to white for custom cells to follow standard related list behavior */
.universal-data-grid tr td:not(.slds-is-edited):hover,
.universal-data-grid tr th:not(.slds-is-edited):hover {
  background-color: inherit !important;
}

/* fix Salesforce lightning-data-table quirk where selected rows do not highlight properly in edit mode */
.universal-data-grid tr td.slds-is-edited,
.universal-data-grid tr th.slds-is-edited {
    background-color: #f9e3b6 !important;
}

/* make edited cells more visually distinct with a stronger font weight */
.universal-data-grid tr td.slds-is-edited .display-value {
    font-weight: 500 !important;
}

/* Error state styling - red border for table cells with errors */
.universal-data-grid tr td.slds-is-edited.slds-has-error {
  border: 3px solid #c23934 !important;
}

/* Constrain save menu button size to match other toolbar icons */
.universal-data-grid .save-menu .slds-button {
  height: 1.5rem !important;
}

/* basic-type cells styling overrides for better alignment of input fields */
.universal-data-grid .basictype-container .right-align-input {
  width: 100% !important;
  padding-right: 1.08rem !important;
}
.universal-data-grid .basictype-container .right-align-input .slds-input {
  text-align: right !important;
  padding-right: 1rem !important;
}
.universal-data-grid .basictype-container .right-align-input-percent {
  padding-right: 1.7rem !important;
}

/* currency cells special styling */
.universal-data-grid .currency-container .right-align-input {
  width: 100% !important;
  padding-right: 1.08rem !important;
}
.universal-data-grid .currency-container .right-align-input .slds-input {
  text-align: right !important;
  padding-right: 1rem !important;
}

/* Center-align checkbox fields */
.universal-data-grid .display-value:has(.center-align-input) {
  display: flex !important;
  justify-content: center !important;
  width: 100% !important;
}

.universal-data-grid .center-align-input {
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
  width: auto !important;
}

.universal-data-grid .slds-cell-edit:has(.center-align-input) {
  justify-content: center !important;
}

/** force boolean field checkboxes to center even for inline rendermode */
.universal-data-grid td[data-col-key-value*="-boolean-"] [data-cell-type="boolean"] {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}


/* ==========================================================================
   DOCUMENT BUILDER MODE - remove sticky header behavior
   Kept at the end of the file so these overrides follow every header rule.
   Selectors mirror the sticky header rules above plus .document-builder-mode.
   ========================================================================== */
.universal-data-grid.document-builder-mode .slds-table.slds-table_header-fixed thead[data-rowgroup-header],
.universal-data-grid.document-builder-mode table[role="grid"] thead {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
    box-shadow: none !important;
}

.universal-data-grid.document-builder-mode .slds-table.slds-table_header-fixed thead[data-rowgroup-header] th,
.universal-data-grid.document-builder-mode table[role="grid"] thead th {
    position: static !important;
    top: auto !important;
    z-index: auto !important;
}


.universal-data-grid .slds-table td[data-col-key-value*="-button-"] {
  padding-top: inherit;
  padding-bottom: inherit;
}

.universal-data-grid td[data-col-key-value*="-button-"] .slds-button,
.universal-data-grid td[data-col-key-value*="-button-"] lightning-button::part(button),
.universal-data-grid td[data-col-key-value*="-button-"] lightning-button-menu::part(button) {
    font-weight: 400;
}


/** Experience cloud: make the table banner actions cicles instead of ovals */
.universal-data-grid .slds-page-header .slds-button-group lightning-button-icon {
    display: inline-flex;
    height: 1.5rem;
    width: 1.5rem;
}

/**
 * Virtual rendering (Render mode = role-based). The grid is div[role="grid"] instead of a table,
 * and the container gets the .virtual-rendering class from universalDataGrid.
 */

/* fill the container (the height:auto override above would let the grid outgrow it) */
.universal-data-grid .virtual-rendering .dt-outer-container[style*="height"] {
    height: 100% !important;
}

/* keep the header in normal flow (sticky) so rows start below it at any header height, including wrapped headers */
.universal-data-grid .virtual-rendering [role="grid"] > [role="rowgroup"]:first-child {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
}

.universal-data-grid .virtual-rendering [role="grid"] > [role="rowgroup"]:first-child lightning-primitive-header-factory.slds-cell-fixed {
    position: relative;
    height: auto;
    min-height: 2rem;
}

/* vertically center cell content (table cells do this natively; div cells do not) */
.universal-data-grid .virtual-rendering [role="grid"] [role="row"] > [role="gridcell"],
.universal-data-grid .virtual-rendering [role="grid"] [role="row"] > [role="rowheader"] {
    display: flex;
    align-items: center;
}

.universal-data-grid .virtual-rendering [role="grid"] [role="row"] > [role="gridcell"] > *,
.universal-data-grid .virtual-rendering [role="grid"] [role="row"] > [role="rowheader"] > * {
    flex: 1 1 auto;
    min-width: 0;
}

/* match the table-mode th weight for the first (name) column */
.universal-data-grid .virtual-rendering [role="grid"] [role="row"] > [role="rowheader"] {
    font-weight: 500;
}