:root {
    --grid-primary: var(--brand-primary, var(--bs-primary, #0d6efd));
    --grid-primary-rgb: var(--brand-primary-rgb, var(--bs-primary-rgb, 13, 110, 253));
    --cui-table-bg: #fafbfc;
}

/* Could be enabled if you want the primary colors to be present in the grid rows */
.table.table-primary-striped {
    --cui-table-accent-bg: color-mix(in srgb, var(--brand-primary, var(--bs-primary, #0d6efd)) 4%, #fff) !important;
}

.table.table-not-striped {
    --cui-table-bg: var(--bs-body-bg, #fff) !important;
    --cui-table-bg-type: var(--bs-body-bg, #fff) !important;
    --cui-table-striped-bg: transparent !important;
    --cui-table-accent-bg: transparent !important;
    --cui-table-active-bg: transparent !important;
    --cui-table-hover-bg: transparent !important;
}

/* hard fallback in case a rule still paints */
.table.table-not-striped>tbody>tr>* {
    background-color: var(--bs-body-bg, #fff) !important;
}

.table.table-striped {
    --cui-table-striped-bg: #fbfcfe !important;
    --cui-table-striped-color: inherit !important;
}

/* 
   Table spacing & alignment
   - Overrides inline 0px padding from GridCell with !important
   - Vertically centers everything for a tidy look
*/
table.table> :not(caption)>*>th,
table.table> :not(caption)>*>td {
    padding: .55rem .75rem !important;
    vertical-align: middle;
}

/* Compact mode — reduces vertical spacing and slightly trims horizontal padding */
.table.table-compact> :not(caption)>*>th,
.table.table-compact> :not(caption)>*>td {
    padding: 0rem 0.5rem !important;
    vertical-align: middle;
}

/* 
   Hover state
   - Subtle brand-tinted hover across the whole row
*/

.table.table-hover {
    --cui-table-hover-bg: color-mix(in srgb, var(--brand-primary, var(--bs-primary, #0d6efd)) 7%, #fff) !important;
    transition: background-color .15s ease-in-out;
}

/*
   Consistent truncation for long cell text
   - Works with renderTypography + text-truncate
*/
table.table {
    table-layout: fixed;
}

table.table td>* {
    min-width: 0;
    /* enable truncation in flex-like contexts */
}

table.table .text-truncate {
    max-width: 100%;
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Secondary columns commonly contain descriptions. A neutral muted tone keeps
   them subordinate without the low contrast of the brand mint on white. */
.nova-grid-secondary-text {
    color: var(--na-text-muted, #6b7585);
}

/* Give dense rows enough weight while keeping supporting descriptions and
   technical values lighter for hierarchy. */
table.nova-grid tbody td {
    font-weight: 500;
}

table.nova-grid :is(.nova-grid-secondary-text, .font-monospace) {
    font-weight: 400;
}

/* 
   Make numeric cells right-aligned
 */
table.table td {
    text-align: start;
}

table.table td:has(> .text-end),
table.table td.text-end {
    text-align: end;
}

/* 
   Actions column tidy-up
   - Buttons/links in the last cell sit nicely with spacing
*/
table.table tbody tr>td:last-child>* {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

/*
   Global action buttons (".button-table-global-actions")
   - Clean icon buttons that react on hover without heavy borders
*/
.button-table-global-actions {
    border: 0;
    background: transparent;
    font-weight: 600;
    color: #1d1d1d;
    font-size: .9rem;
    padding: .25rem .5rem;
    border-radius: .375rem;
}

.button-table-global-actions:hover {
    background-color: rgba(0, 0, 0, .06);
}

/* 
   Column options popover (".column-options-menu")
   - Matches your current styles; just adds better elevation and padding
*/
.column-options-menu {
    position: absolute;
    inset: auto auto;
    background: #f8f9fa;
    border-radius: .5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    padding: .5rem .75rem;
    display: none;
    z-index: 1000;
    font-weight: 600;
    font-size: .9rem;
}

/* Column header with a help icon: the label still truncates, the icon never shrinks. */
.nova-grid-header-label {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.nova-grid-header-label>.text-truncate {
    min-width: 0;
}

/* The shared nudge assumes a baseline-aligned form label. In this centred row the icon only
   needs a hair of lift to sit on the text's optical centre, and a muted grey keeps it
   subordinate to the column name. */
.nova-grid-header-label>.inline-help-btn--label {
    top: -1px;
    flex: none;
    color: var(--na-text-muted, #6b7585);
    opacity: .7;
}

/* grid.css loads after site.css, so the shared hover state has to be restated here to win. */
.nova-grid-header-label>.inline-help-btn--label:hover,
.nova-grid-header-label>.inline-help-btn--label:focus,
.nova-grid-header-label>.inline-help-btn--label:focus-visible {
    color: var(--bs-primary);
    opacity: 1;
}

/* 
   Sticky column headers (GridWidget.StickyHeader)
   - A plain grid sticks to the page, below a sticky view header (--na-sticky-header-height)
   - An outlined grid scrolls sideways, so it is a scroll container itself: it scrolls inside
     its outline instead, capped at the visible height
*/
table.nova-grid.nova-grid-sticky-header>thead>tr>th {
    position: sticky;
    top: var(--na-sticky-header-height, 0px);
    /* under the sticky view header (z-3): a plain grid's header slides up into it as the table scrolls out */
    z-index: 2;
}

/* site.css lifts a focused field layout to z-index 2, which in a cell would draw over the stuck header.
   One level still lifts its focus ring over the neighbouring cells. */
table.nova-grid.nova-grid-sticky-header>tbody .property-field-layout:focus-within {
    z-index: 1;
}

/* A collapsed border is painted by the table, so it stays behind when the header sticks. Draw the line
   in the cell instead; empty grids keep their borderless header (see the :not(:has(tbody tr)) rule). */
table.nova-grid.nova-grid-sticky-header:has(tbody tr)>thead>tr>th {
    border-bottom-width: 0;
}

table.nova-grid.nova-grid-sticky-header:has(tbody tr)>thead>tr>th::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    border-bottom: var(--cui-border-width, 1px) solid;
    border-bottom-color: inherit;
    pointer-events: none;
}

/* clip cuts off like hidden but is no scroll container, which would hold the header in place.
   :where keeps it below the site.css rules that set visible (focus, sticky scope). */
.property-field-layout:where(:has(table.nova-grid-sticky-header)) {
    overflow: clip;
}

.nova-grid-wrap:has(>table.nova-grid-sticky-header) {
    overflow: auto;
    max-height: calc(100vh - var(--na-sticky-header-height, 0px) - 2rem);
}

.nova-grid-wrap>table.nova-grid-sticky-header>thead>tr>th {
    top: 0;
}

@keyframes fx-valid-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--bs-success-rgb, 25, 135, 84), 0);
        outline-color: transparent;
    }

    40% {
        box-shadow: 0 0 0 .25rem rgba(var(--bs-success-rgb, 25, 135, 84), .12);
        outline-color: rgba(var(--bs-success-rgb, 25, 135, 84), .45);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(var(--bs-success-rgb, 25, 135, 84), 0);
        outline-color: transparent;
    }
}

:where(.form-control, .form-select, textarea).is-valid,
:where(.form-control, .form-select, textarea).is-soft-valid {
    animation: fx-valid-pulse 420ms ease-out;
    outline: 2px solid transparent;
    transition: outline-color 120ms ease-out;
}

:root {
    --fx-green: var(--bs-success, #198754);
    --fx-red: var(--bs-danger, #da4e61);
    --fx-green-wash: rgba(var(--bs-success-rgb, 25, 135, 84), .10);
    --fx-dur: 1200ms;
}

@keyframes fx-cell-bg {
    0% {
        background-color: transparent;
    }

    25% {
        background-color: var(--fx-green-wash);
    }

    100% {
        background-color: transparent;
    }
}

@keyframes fx-cell-ring {
    0% {
        opacity: 0;
        transform: scale(.96);
    }

    35% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.02);
    }
}

@keyframes fx-check-pop {
    0% {
        transform: translate(0, 0) scale(.6);
        opacity: 0;
    }

    40% {
        transform: translate(0, 0) scale(1.05);
        opacity: 1;
    }

    100% {
        transform: translate(0, 0) scale(1);
        opacity: 0;
    }
}

.cell-updated {
    position: relative;
    animation: fx-cell-bg var(--fx-dur) ease-out;
}

.cell-updated::before {
    content: "";
    position: absolute;
    inset: .25rem;
    border-radius: .5rem;
    box-shadow: 0 0 0 2px var(--fx-green) inset;
    opacity: 0;
    pointer-events: none;
    animation: fx-cell-ring var(--fx-dur) ease-out;
}

.cell-updated::after {
    content: "";
    position: absolute;
    top: .35rem;
    right: .45rem;
    width: .8rem;
    height: .8rem;
    opacity: 0;
    background: var(--fx-green);
    mask: url("/assets/icons/check.svg") no-repeat center / contain;
    -webkit-mask: url("/assets/icons/check.svg") no-repeat center / contain;
    pointer-events: none;
    animation: fx-check-pop var(--fx-dur) ease-out;
}

.table-sm td.cell-updated::before {
    inset: .2rem;
    border-radius: .35rem;
}

.cell-update-cancelled {
    position: relative;
    animation: fx-cell-bg var(--fx-dur) ease-out;
}

.cell-update-cancelled::before {
    content: "";
    position: absolute;
    inset: .25rem;
    border-radius: .5rem;
    box-shadow: 0 0 0 2px var(--fx-red) inset;
    opacity: 0;
    pointer-events: none;
    animation: fx-cell-ring var(--fx-dur) ease-out;
}

.cell-update-cancelled::after {
    content: "";
    position: absolute;
    top: .35rem;
    right: .45rem;
    width: .8rem;
    height: .8rem;
    opacity: 0;
    background: var(--fx-red);
    mask: url("/assets/icons/x.svg") no-repeat center / contain;
    -webkit-mask: url("/assets/icons/x.svg") no-repeat center / contain;
    pointer-events: none;
    animation: fx-check-pop var(--fx-dur) ease-out;
}

.table-sm td.cell-update-cancelled::before {
    inset: .2rem;
    border-radius: .35rem;
}

td input[type="number"].w-100::-webkit-outer-spin-button,
td input[type="number"].w-100::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

td input[type="number"].w-100 {
    -moz-appearance: textfield;
}

/* Scoped to your grid instance */
table.nova-grid {
    table-layout: auto;
}

/* Make last column (actions) minimal width + right aligned.
   This targets both header and body cells. */
table.nova-grid thead th:last-child,
table.nova-grid tbody td:last-child {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

/* If the buttons are in a container, this helps pack them right (optional) */
table.nova-grid tbody td:last-child>div {
    display: inline-flex;
    justify-content: flex-end;
    align-items: center;
    gap: .35rem;
}

.nova-grid-header-actions-host .btn,
.nova-grid-header-actions-host button {
    padding: .15rem .35rem !important;
    line-height: 1 !important;
    min-height: auto !important;
    min-width: auto !important;
    border-radius: .35rem !important;
}

.nova-grid-header-actions-host .btn .icon,
.nova-grid-header-actions-host button .icon {
    margin: 0 !important;
}

/* Header last-cell becomes a positioning context and reserves room for the header actions */
th.nova-grid-header-actions-th {
    position: relative;
    padding-right: 2.25rem;
    /* reserve minimal space so text doesn't overlap buttons */
}

/* Host is absolutely positioned to the far right, vertically centered, tight spacing */
th.nova-grid-header-actions-th>.nova-grid-header-actions-host {
    position: absolute;
    top: 50%;
    right: .125rem;
    transform: translateY(-50%);
    white-space: nowrap;
    gap: .25rem;
    line-height: 1;
}

/* Optional: make buttons inside the host compact (covers most bootstrap-ish btns) */
th.nova-grid-header-actions-th>.nova-grid-header-actions-host .btn {
    padding: .15rem .25rem;
    line-height: 1;
}

/* Keep actions column minimal width */
table.nova-grid col.nova-grid-actions-col {
    width: 1%;
}

/* Ensure last column packs tight (works well with the col width above) */
table.nova-grid thead th:last-child,
table.nova-grid tbody td:last-child {
    white-space: nowrap;
    text-align: right;
}

/* Actions with ShowInFirstGridColumn: the first column packs them like the last one */
table.nova-grid.nova-grid-actions-first thead th:first-child,
table.nova-grid.nova-grid-actions-first tbody td:first-child {
    width: 1%;
    white-space: nowrap;
}

table.nova-grid.nova-grid-actions-first tbody td:first-child>div {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

/* Hover-only behavior (enabled via JS-added class) */
table.nova-grid.nova-grid-actions-hover tbody tr td.nova-grid-actions-cell {
    opacity: 0;
}

/* When hidden: prevent interaction with buttons/links, but keep the cell hoverable */
table.nova-grid.nova-grid-actions-hover tbody tr td.nova-grid-actions-cell * {
    pointer-events: none;
}

table.nova-grid.nova-grid-actions-hover tbody tr:hover td.nova-grid-actions-cell,
table.nova-grid.nova-grid-actions-hover tbody tr:focus-within td.nova-grid-actions-cell,
table.nova-grid.nova-grid-actions-hover tbody tr td.nova-grid-actions-cell:hover {
    opacity: 1;
}

table.nova-grid.nova-grid-actions-hover tbody tr:hover td.nova-grid-actions-cell *,
table.nova-grid.nova-grid-actions-hover tbody tr:focus-within td.nova-grid-actions-cell *,
table.nova-grid.nova-grid-actions-hover tbody tr td.nova-grid-actions-cell:hover * {
    pointer-events: auto;
}

table.nova-grid.nova-grid-actions-hover tbody tr:hover td.nova-grid-actions-cell,
table.nova-grid.nova-grid-actions-hover tbody tr:focus-within td.nova-grid-actions-cell,
table.nova-grid.nova-grid-actions-hover tbody tr td.nova-grid-actions-cell:hover {
    opacity: 1;
    pointer-events: auto;
}

/* Make your JS “force show” class actually do something */
table.nova-grid.nova-grid-actions-hover tbody tr.nova-grid-actions-force-show td.nova-grid-actions-cell {
    opacity: 1;
}

table.nova-grid.nova-grid-actions-hover tbody tr.nova-grid-actions-force-show td.nova-grid-actions-cell * {
    pointer-events: auto;
}

.nova-grid-wrap {
    border: 1px solid var(--bs-border-color, #ddd);
    border-radius: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    background: var(--bs-body-bg, #fff);
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.nova-grid-wrap>table.nova-grid {
    width: max-content;
    min-width: 100%;
    max-width: none;
}

table.table.nova-grid {
    table-layout: auto;
}

.nova-grid {
    margin-bottom: 0 !important;
}

table.nova-grid tbody tr:last-child td {
    border-bottom: 0 !important;
}

table.table.nova-grid:not(:has(tbody tr))> :not(caption)>*>* {
    border-bottom-width: 0 !important;
    box-shadow: inset 0 0 0 9999px var(--cui-table-bg-state, var(--cui-table-bg-type, var(--cui-table-accent-bg))) !important;
}











.data-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.data-grid-header,
.data-grid-row {
    display: grid;
    grid-template-columns: var(--grid-columns);
}

.data-grid-header {
    flex: 0 0 auto;
    height: 44px;
    background: var(--grid-header-bg);
    border-bottom: 1px solid var(--grid-border);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #65758b;
}

.data-grid-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.data-grid-row {
    height: var(--row-height);
    border-bottom: 1px solid var(--grid-soft-border);
    cursor: pointer;
    background: #ffffff;
}

.data-grid-row:hover {
    background: var(--grid-hover-bg);
}

.data-grid-row.is-selected {
    background: var(--grid-selected-bg);
    box-shadow: inset 3px 0 0 #321fdb;
}

.data-grid-cell {
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-right: 1px solid var(--grid-soft-border);
    overflow: hidden;
}

.data-grid-cell:last-child {
    border-right: 0;
}

/* 
   Grid search (GridWidget.ShowSearch)
   - Sits in the toolbar row above the table, next to the grid title
   - Filters the rows the client already has, nothing is requested from the server
*/
.nova-grid-search {
    position: relative;
    display: flex;
    align-items: center;
}

.nova-grid-search .nova-grid-search-input {
    width: 14rem;
    max-width: 100%;
    padding-left: 2rem;
    border-radius: 8px;
}

.nova-grid-search .nova-grid-search-icon {
    position: absolute;
    left: .6rem;
    display: inline-flex;
    align-items: center;
    pointer-events: none;
    color: var(--na-text-muted, #6b7585);
}

.nova-grid-search .nova-grid-search-icon svg {
    fill: currentColor;
}

/* Rows the search has ruled out */
table.nova-grid tbody tr.nova-grid-row-hidden {
    display: none !important;
}

table.nova-grid tbody tr.nova-grid-search-empty td {
    text-align: center;
    color: var(--na-text-muted, #6b7585);
}
