/* =================================================================
   components/app-table.css — .app-table component
   -----------------------------------------------------------------
   A standalone, token-driven data table. Completely independent from
   legacy styles. BEM naming: block .app-table, elements __head,
   __body, __row, __th, __td, modifiers for alignment & density.
   ================================================================= */

/* ========== 1. BASE ========== */

.app-table {
    /* Scope semantic tokens to neutral for the table */
    --bg-tertiary: var(--neutral-50);
    --bg-secondary: var(--neutral-100);
    --border-secondary: var(--neutral-200);
    --border-tertiary: var(--neutral-150);
    --text-secondary: var(--neutral-600);
    --text-tertiary: var(--neutral-500);

    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: var(--font-family-primary);
    font-size: var(--font-body-sm-size);
    line-height: var(--font-body-sm-line-height);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* ========== 2. HEAD ========== */

.app-table__head {
    background: var(--bg-tertiary);
}

.app-table__th {
    padding: var(--spacing-md) var(--spacing-md);
    font-size: var(--font-caption-sm-size);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: var(--font-caption-sm-letter-spacing);
    line-height: var(--font-caption-sm-line-height);
    border-bottom: 1px solid var(--border-secondary);
    white-space: nowrap;
    user-select: none;
    vertical-align: middle;
}

/* Align text and inline icons/buttons within header cells */
.app-table__th .sym {
    vertical-align: middle;
}

.app-table__th .app-btn {
    vertical-align: middle;
}

/* ========== 3. BODY ========== */

/* No hover transition: pinned cells paint their own background, and a fading row lagged behind them. */
.app-table__body .app-table__row {
    font-weight: var(--font-weight-medium);
}

.app-table__body .app-table__row:hover {
    background-color: var(--color-hover-bg);
}

.app-table__td {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--border-tertiary);
    vertical-align: middle;
}

.app-table__body .app-table__row:last-child .app-table__td {
    border-bottom: none;
}

/* ========== 4. FOOT ========== */

.app-table__foot {
    background: var(--bg-tertiary);
}

.app-table__foot .app-table__td {
    padding: var(--spacing-sm) var(--spacing-md);
    font-weight: var(--font-weight-semibold);
    border-bottom: none;
    border-top: 1px solid var(--border-secondary);
}

/* ========== 5. ALIGNMENT ========== */

.app-table__th--right,
.app-table__td--right {
    text-align: right;
}

.app-table__th--center,
.app-table__td--center {
    text-align: center;
}

/* ── Column alignment — apply to th/td in any table ─────────── */
.app-col--left   { text-align: left;   }
.app-col--right  { text-align: right;  }
.app-col--right > .ellipsis  { justify-content: end;  }

.app-col--right input,
.app-col--right select { text-align: inherit; }

.app-col--center {
    text-align: center;
}

/* tables.css makes th > div a flex container, so text-align never reaches a header's text --
   it is a flex item. --right has always had this companion; --center shipped without one and
   every centred header therefore rendered left-aligned over its centred cells. */
.app-col--center > .ellipsis { justify-content: center; }

/* td cells: vertical-align: middle (from table base) + text-align: center (inherited)
   handles inline content. For block/flex children, shrink and center with auto margins. */
td.app-col--center > * {
    width: fit-content;
    margin-inline: auto;
}

/* The status dot (shown in the icons cell when the status column is hidden) is an empty span: fit-content made it 0px wide. */
td.app-col--center > .filter_color {
    width: 10px;
}

/* ── Column sizing ────────────────────────────────────────────
   app-col--hug  : shrinks to content width (icons, flags, checkboxes)
   app-col--fill : greedily takes remaining space
   app-col--xs/sm/md/lg : fixed widths for input columns where
     hug causes circular sizing with width:100% inputs
   ─────────────────────────────────────────────────────────── */
.app-col--hug {
    width: 1px;          /* collapses to minimum; browser expands to fit content */
    white-space: nowrap; /* prevents wrapping that would defeat the hug */
}

/* app-col--actions: hug-width cell with inline icon row */
.app-col--actions {
    width: 1px;
    white-space: nowrap;
}

/* Icon slot — fixed-size box so columns stay aligned even when empty */
.app-col--actions .app-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--icon-size-md);
    height: var(--icon-size-md);
    border-radius: var(--radius-sm);
    color: var(--icon-color-primary);
    cursor: pointer;
    transition: color var(--transition-fast), background-color var(--transition-fast);
    vertical-align: middle;
}

.app-col--actions .app-action:hover {
    color: var(--text-primary);
    background-color: var(--color-hover-bg);
}

.app-col--actions .app-action.is-disabled {
    color: var(--color-disabled-text);
    cursor: default;
    pointer-events: none;
}

/* Empty placeholder — reserves the same space as an icon */
.app-col--actions .app-action--empty {
    visibility: hidden;
}

/* Link led by an icon in a cell ("go to document" rows); replaces the legacy doc_of.png + text. */
.app-table__link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    text-decoration: none;
}

.app-table__link > .sym {
    font-size: var(--icon-size-sm);
}

.app-col--fill { width: 100%;  }
.app-col--xs   { width: 60px;  }
.app-col--sm   { width: 120px; }
.app-col--md   { width: 200px; }
.app-col--lg   { width: 300px; }

/* ========== 6. DENSITY — compact ========== */

.app-table--compact .app-table__th {
    padding: var(--spacing-sm) var(--spacing-md);
}

.app-table--compact .app-table__td {
    padding: var(--spacing-xs) var(--spacing-md);
}

/* ========== 7. DENSITY — relaxed ========== */

.app-table--relaxed .app-table__th {
    padding: var(--spacing-md) var(--spacing-lg);
}

.app-table--relaxed .app-table__td {
    padding: var(--spacing-md) var(--spacing-lg);
}

/* ========== DENSITY — input grid ========== */
/* A table whose cells are all controls. Each input carries its own padding, border and focus ring,
   so the cell's horizontal padding is dead width twice over — at --compact that is 10px a side,
   which across five columns took 100px out of a 442px table and clipped the values being typed. */

.app-table--inputs .app-table__td,
.app-table--inputs .app-table__th {
    padding-left: var(--spacing-xs);
    padding-right: var(--spacing-xs);
}

/* Columns here are sized by their controls, not their labels, so headers wrap instead of setting
   the width. Swedish "From antal" is 10 characters and Finnish "Alkaen määrästä" is 15 — nowrap
   would let the longest translation decide how much room the field gets. */
.app-table--inputs .app-table__th {
    white-space: normal;
}

/* Auto layout sizes a column to its header, so a column headed "%" collapses to one character and
   clips the value typed into it while a wide neighbour has room to spare. The floor fits a
   thousands-separated amount ("1 234,56") so no field clips what is being typed into it. */
.app-table--inputs .app-input {
    min-width: 4.25rem;
}

/* ========== 8. STRIPED ========== */

.app-table--striped .app-table__body .app-table__row:nth-child(even) {
    background-color: var(--neutral-50);
}

.app-table--striped .app-table__body .app-table__row:nth-child(even):hover {
    background-color: var(--color-hover-bg);
}

/* ========== 9. BORDERLESS ========== */

.app-table--borderless {
    border: none;
    border-radius: 0;
}

.app-table--borderless .app-table__td {
    border-bottom-color: transparent;
}

.app-table--borderless .app-table__th {
    border-bottom-color: var(--border-secondary);
}

/* ========== 9b. GHOST — no chrome, just aligned rows ========== */

.app-table--ghost {
    border: none;
    border-radius: 0;
    background: transparent;
}

.app-table--ghost .app-table__td,
.app-table--ghost .app-table__th {
    border: none;
    background: transparent;
    padding: var(--spacing-xs) var(--spacing-sm);
}

.app-table--ghost .app-table__row:hover .app-table__td {
    background: transparent;
}

/* ========== 10. SORTABLE HEADERS ========== */

.app-table__th--sortable {
    cursor: pointer;
}

.app-table__th--sortable:hover {
    color: var(--text-primary);
    background-color: var(--neutral-100);
}

.app-table__th--sorted-asc::after,
.app-table__th--sorted-desc::after {
    display: inline-block;
    margin-left: var(--spacing-xs);
    font-family: 'Material Symbols Rounded';
    font-size: var(--icon-size-sm);
    vertical-align: middle;
    font-weight: var(--icon-weight);
}

.app-table__th--sorted-asc::after {
    content: 'arrow_upward';
}

.app-table__th--sorted-desc::after {
    content: 'arrow_downward';
}

/* ========== 11. CLICKABLE ROWS ========== */

.app-table--clickable .app-table__body .app-table__row {
    cursor: pointer;
}

.app-table--clickable .app-table__body .app-table__row:active {
    background-color: var(--neutral-100);
}

/* ========== 12. SELECTED ROW ========== */

.app-table__row.is-selected {
    background-color: var(--accent-light);
}

.app-table__row.is-selected:hover {
    background-color: var(--accent-100);
}

/* ========== 12b. SETTLED ROW ==========
   A row the user can no longer act on because it records something already carried out — the
   summary of depreciation already posted, at the head of an asset's depreciation plan. Quieter
   than the plan rows below it and not hoverable, since there is nothing to hover towards.
   Replaces a hardcoded #D4D4D4 that predates the tokens. */

.app-table__row.is-settled .app-table__td {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.app-table__body .app-table__row.is-settled:hover .app-table__td {
    background-color: var(--bg-tertiary);
}

/* ========== 13. EMPTY STATE ========== */

.app-table__empty {
    padding: var(--spacing-3xl) var(--spacing-md);
    text-align: center;
    color: var(--text-tertiary);
    font-style: italic;
}

/* ========== 14. INLINE INPUTS ========== */

.app-table__td .app-input {
    width: 100%;
}

/* ========== 15. CELL WIDTHS ========== */

.app-table__th--narrow,
.app-table__td--narrow {
    width: 80px;
}

.app-table__th--medium,
.app-table__td--medium {
    width: 120px;
}

.app-table__th--wide,
.app-table__td--wide {
    width: 200px;
}

/* ========== 16. RESPONSIVE SCROLL WRAPPER ========== */

.app-table-wrap {
    width: 100%;
    overflow-x: auto;
}

/* Vertical scroll frame — a capped list that scrolls inside a bordered frame. The frame draws the
   border, so the table inside loses its own (its overflow: hidden would also swallow a sticky
   header). --table-wrap-max-h sets the height; pair with .app-table--sticky-head. */
.app-table-wrap--scroll-y {
    max-height: var(--table-wrap-max-h, 360px);
    overflow-y: auto;
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
}

.app-table-wrap--scroll-y > .app-table {
    border: 0;
    border-radius: 0;
    overflow: visible;
}

.app-table--sticky-head .app-table__th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-tertiary);
}

/* =================================================================
   18. LEGACY NOVUS TABLE OVERRIDES
   -----------------------------------------------------------------
   Opt-in reskin for legacy .novus_list_table pages. Add the parent
   class .app-list to the page container to activate these overrides.
   Existing novus class names are preserved for JS compatibility.
   ================================================================= */

/* --- Container --- */

.app-list {
    width: 100%;
}

/* --- Table base --- */

.app-list .novus_list_table {
    /* Scope semantic tokens to neutral for the novus table */
    --bg-tertiary: var(--neutral-50);
    --bg-secondary: var(--neutral-100);
    --border-secondary: var(--neutral-200);
    --border-tertiary: var(--neutral-150);
    --text-secondary: var(--neutral-600);
    --text-tertiary: var(--neutral-500);

    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    font-family: var(--font-family-primary);
    font-size: var(--font-body-sm-size);
    line-height: var(--font-body-sm-line-height);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* --- Header row --- */

.app-list thead > .novus_table_row,
:where(.app-table .app-list__detail-panel) > .novus_edit_table thead > .novus_table_row,
:where(.app-card) > .novus_edit_table thead > .novus_table_row {
    background: var(--bg-tertiary);
    font-size: var(--font-caption-sm-size);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: var(--font-caption-sm-letter-spacing);
    line-height: var(--font-caption-sm-line-height);
    height: auto;
    border-bottom: none;
}

.app-list thead > .novus_table_row th,
:where(.app-table .app-list__detail-panel) > .novus_edit_table thead > .novus_table_row th,
:where(.app-card) > .novus_edit_table thead > .novus_table_row th {
    padding: var(--spacing-md) var(--spacing-md);
    border-bottom: 1px solid var(--border-secondary);
    user-select: none;
    height: auto;
    font-size: inherit;
    vertical-align: middle !important;
    line-height: var(--font-caption-sm-line-height);
}

/* --- Checkbox alignment --- */

.app-list .novus_table_row .checkbox_container,
.app-list .novus_table_row .app-checkbox__option {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    width: 100%;
}

/* --- Body rows --- */

.app-list tbody > .novus_table_row,
:where(.app-table .app-list__detail-panel) > .novus_edit_table tbody > .novus_table_row,
:where(.app-card) > .novus_edit_table tbody > .novus_table_row {
    font-size: var(--font-body-sm-size);
    font-weight: var(--font-weight-medium);
    background-color: var(--bg-primary);
    height: auto;
    border-bottom: none;
}

.app-list tbody > .novus_table_row td,
:where(.app-table .app-list__detail-panel) > .novus_edit_table tbody > .novus_table_row td,
:where(.app-card) > .novus_edit_table tbody > .novus_table_row td {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--border-tertiary);
    vertical-align: middle;
    height: auto;
}

.app-list tbody > .novus_table_row:last-child td,
:where(.app-table .app-list__detail-panel) > .novus_edit_table tbody > .novus_table_row:last-child td,
:where(.app-card) > .novus_edit_table tbody > .novus_table_row:last-child td {
    border-bottom: none;
}

/* --- Summation row --- */

.app-list tfoot > .novus_table_row td {
    padding: var(--spacing-sm) var(--spacing-md);
    border-top: 1px solid var(--border-secondary);
    background: var(--bg-tertiary);
    font-weight: var(--font-weight-semibold);
    vertical-align: middle;
    height: auto;
}

/* --- Hover --- */

/* The accent hover, not --bg-tertiary: that is the zebra tint, so an odd row showed no hover at all. */
.app-list tbody > .novus_table_row:hover,
.app-list tbody > .novus_table_row.hovered {
    background-color: var(--color-hover-bg);
}

/* --- Zebra striping --- */

.app-list tbody > .novus_table_row.odd {
    background-color: var(--neutral-50);
}

.app-list tbody > .novus_table_row.odd:hover,
.app-list tbody > .novus_table_row.odd.hovered {
    background-color: var(--color-hover-bg);
}

/* --- Full row colouring (.app-list--status-colors, list setting "Radfärg: heltäckande färg"): rows take their status
   ramp's tint (purple, pink and colour vision deficiency have no token: mixed from tables.css). Deficiency tints are
   stronger and greys plain so every status pair survives simulated protan/deutan/tritan vision. Pins are painted too. */

.app-list--status-colors .novus_list_table > tbody > tr:is(.overdue, .expired, .notstarted) { --row-tint: var(--accent-100); }
.app-list--status-colors .novus_list_table > tbody > tr:is(.finalpayed, .created, .billed, .finished, .ended, .ongoing, .green) { --row-tint: var(--green-200); }
.app-list--status-colors .novus_list_table > tbody > tr:is(.unposted, .workinprogress, .active, .not_applied, .unpostedoverdue, .unpostedpaypend, .yellow) { --row-tint: var(--yellow-100); }
.app-list--status-colors .novus_list_table > tbody > tr:is(.paypend, .invoiced, .paypendred, .paypendwhite, .blue) { --row-tint: var(--blue-100); }
.app-list--status-colors .novus_list_table > tbody > tr.violet { --row-tint: var(--blue-200); }
.app-list--status-colors .novus_list_table > tbody > tr:is(.cancel, .grey) { --row-tint: var(--neutral-100); }
.app-list--status-colors .novus_list_table > tbody > tr.grey_dark { --row-tint: var(--neutral-200); }
.app-list--status-colors .novus_list_table > tbody > tr.paypendoverdue { --row-tint: color-mix(in srgb, #ef22d4 18%, var(--bg-primary)); }
.app-list--status-colors .novus_list_table > tbody > tr.debtcollection { --row-tint: color-mix(in srgb, #ecb1e2 18%, var(--bg-primary)); }

.app-list--status-colors .novus_list_table > tbody > tr:is(.overdue, .expired, .notstarted).color_deficiency { --row-tint: color-mix(in srgb, #ff5000 40%, var(--bg-primary)); }
.app-list--status-colors .novus_list_table > tbody > tr:is(.finalpayed, .created, .billed, .finished, .ended, .ongoing, .green).color_deficiency { --row-tint: color-mix(in srgb, #009292 40%, var(--bg-primary)); }
.app-list--status-colors .novus_list_table > tbody > tr:is(.unposted, .workinprogress, .active, .not_applied, .unpostedoverdue, .unpostedpaypend, .yellow).color_deficiency { --row-tint: color-mix(in srgb, #ffea00 40%, var(--bg-primary)); }
.app-list--status-colors .novus_list_table > tbody > tr:is(.paypend, .invoiced, .paypendred, .paypendwhite).color_deficiency { --row-tint: color-mix(in srgb, #00dcff 40%, var(--bg-primary)); }
.app-list--status-colors .novus_list_table > tbody > tr:is(.cancel, .grey).color_deficiency { --row-tint: #e0e0e0; }
.app-list--status-colors .novus_list_table > tbody > tr.grey_dark.color_deficiency { --row-tint: #bababa; }

/* Dots tables.css gave no colour vision deficiency variant (project, offer and asset statuses), matching the row tints above. */
.filter_color:is(.active, .yellow).color_deficiency { background-color: #ffea00; }
.filter_color:is(.ended, .green).color_deficiency { background-color: #009292; }

.app-list--status-colors .novus_list_table > tbody > tr.novus_table_row:is(.overdue, .expired, .notstarted, .finalpayed, .created, .billed, .finished, .ended, .ongoing, .unposted, .workinprogress, .active, .not_applied, .unpostedoverdue, .unpostedpaypend, .paypend, .invoiced, .paypendred, .paypendwhite, .cancel, .paypendoverdue, .debtcollection, .yellow, .green, .violet, .blue, .grey, .grey_dark) > td {
    --row-hover: linear-gradient(transparent, transparent);
    background-color: var(--row-tint);
    background-image: var(--row-hover);
}

/* With the zebra setting on (the PHP's odd/even classes, not TableKit's rowodd/roweven which every list gets), even rows are lighter. */
.app-list--status-colors .novus_list_table > tbody > tr.novus_table_row:is(.overdue, .expired, .notstarted, .finalpayed, .created, .billed, .finished, .ended, .ongoing, .unposted, .workinprogress, .active, .not_applied, .unpostedoverdue, .unpostedpaypend, .paypend, .invoiced, .paypendred, .paypendwhite, .cancel, .paypendoverdue, .debtcollection, .yellow, .green, .violet, .blue, .grey, .grey_dark).even > td {
    background-color: color-mix(in oklab, var(--row-tint) 60%, var(--bg-primary));
}

.app-list--status-colors .novus_list_table > tbody > tr.novus_table_row:is(.overdue, .expired, .notstarted, .finalpayed, .created, .billed, .finished, .ended, .ongoing, .unposted, .workinprogress, .active, .not_applied, .unpostedoverdue, .unpostedpaypend, .paypend, .invoiced, .paypendred, .paypendwhite, .cancel, .paypendoverdue, .debtcollection, .yellow, .green, .violet, .blue, .grey, .grey_dark).color_deficiency.even > td {
    background-color: color-mix(in srgb, var(--row-tint) 70%, var(--bg-primary));
}

.app-list--status-colors .novus_list_table > tbody > tr.novus_table_row:is(.overdue, .expired, .notstarted, .finalpayed, .created, .billed, .finished, .ended, .ongoing, .unposted, .workinprogress, .active, .not_applied, .unpostedoverdue, .unpostedpaypend, .paypend, .invoiced, .paypendred, .paypendwhite, .cancel, .paypendoverdue, .debtcollection, .yellow, .green, .violet, .blue, .grey, .grey_dark):is(:hover, .hovered) > td {
    --row-hover: linear-gradient(rgb(0 0 0 / 0.06), rgb(0 0 0 / 0.06));
}

/* Highlighted row (.app-list__row--highlight): the row a trace link points at, one step stronger than a status
   tint. The account statement report preview still marks it the legacy way (.statement-full-color + paypend). */
.novus_list_table > tbody > tr.novus_table_row.app-list__row--highlight > td,
.statement-full-color > tbody > tr.novus_table_row.paypend > td {
    background-color: var(--blue-200);
    background-image: none;
}

.novus_list_table > tbody > tr.novus_table_row.app-list__row--highlight:is(:hover, .hovered) > td,
.statement-full-color > tbody > tr.novus_table_row.paypend:is(:hover, .hovered) > td {
    background-image: linear-gradient(rgb(0 0 0 / 0.06), rgb(0 0 0 / 0.06));
}

/* --- Ellipsis cells — cap width so long text truncates instead of stretching the table --- */

.app-list .novus_table_row td.ellipsis,
.app-list td {
    max-width: 40vw;
    overflow: hidden;
    white-space: nowrap;
}

/* A click tooltip (custom_tooltip.js) is built inside its cell, so the clipping above cut it to a sliver */
.app-list td:has(.custom_tooltip_container) {
    overflow: visible;
}

/* The table's scroll wrapper clips below the last rows, so their tooltips open upwards */
.app-list tbody > tr:nth-last-child(-n+2) .custom_tooltip_container > .custom_tooltip {
    top: auto;
    bottom: calc(100% + var(--spacing-xs));
}

/* --- Inactive / disabled row --- */

.app-list tbody > .novus_table_row.contact_inactive {
    opacity: 0.55;
}

/* --- Total row --- */

/* Legacy-skin counterpart to .app-table__foot above. tbody's last row drops its bottom border,
   so the totals row is what carries the separating line. */
.app-list tfoot > .novus_table_row td {
    padding: var(--spacing-sm) var(--spacing-md);
    border-top: 1px solid var(--border-secondary);
    font-weight: var(--font-weight-semibold);
    vertical-align: middle;
    height: auto;
}

/* --- Expandable detail row ---
   A row a page opens under another one (assistant tasks, incoming-document coding rows): the table
   inside becomes a card on a grey ground. The <tr> (or the <div> between calendar weeks) takes
   app-list__detail-row, the element wrapping the table takes app-list__detail-panel. Applies inside a
   list page's .app-list and inside a standalone .app-table (the bank-match rows) alike. */
.app-list tbody > .app-list__detail-row > td,
.app-table tbody > .app-list__detail-row > td,
.app-list div.app-list__detail-row {
    background-color: var(--bg-tertiary);
}
:is(.app-list, .app-table) .app-list__detail-panel {
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
}
:is(.app-list, .app-table) .app-list__detail-row .app-list__detail-panel > table {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-md);
    border-collapse: separate;
    box-shadow: none;
}
/* No overflow: hidden on the card - it would clip a dropdown in its cells; the corner cells round instead. */
:is(.app-list, .app-table) .app-list__detail-row .app-list__detail-panel > table > tbody > tr:last-child > td:first-child {
    border-bottom-left-radius: var(--radius-md);
}
:is(.app-list, .app-table) .app-list__detail-row .app-list__detail-panel > table > tbody > tr:last-child > td:last-child {
    border-bottom-right-radius: var(--radius-md);
}
/* A legacy edit table draws a cell grid; show row lines only, as in the list above it. */
:is(.app-list, .app-table) .app-list__detail-row .app-list__detail-panel > .novus_edit_table .novus_table_row td,
.app-card > .novus_edit_table .novus_table_row td {
    border-width: 0 0 1px;
    border-color: var(--border-tertiary);
}
:is(.app-list, .app-table) .app-list__detail-row .app-list__detail-panel > table > thead > tr,
:is(.app-list, .app-table) .app-list__detail-row .app-list__detail-panel > table > thead th,
.app-card > .novus_edit_table > thead > tr,
.app-card > .novus_edit_table > thead th {
    background: transparent;
}

/* A legacy edit table placed straight in an app-card: the card draws the frame, so the table's own goes. */
.app-card > .novus_edit_table {
    border: none;
    border-radius: 0;
}

/* --- Action bar --- */

.app-list .novus_action_bar {
    border-top: none;
}

.app-list .novus_action_bar .novus_action_button {
    font-family: var(--font-family-primary);
    font-size: var(--font-body-sm-size);
}

/* Inputs in the bar size by their size attribute instead of the 100% an .app-input gets */
.app-list .novus_action_bar .app-input {
    width: auto;
}

/* --- Header / footer blocks --- */

.app-list .novus_table_header_block,
.app-list .novus_table_footer_block {
    font-family: var(--font-family-primary);
    font-size: var(--font-body-sm-size);
    color: var(--text-secondary);
}

/* The export icon sits at the right edge and --scroll/--pinned clip overflow, so its menu opens leftwards. */
.app-list .novus_table_header_block .novus_filter_select_list {
    left: auto;
    right: 0;
}

/* Without pagination there is no header block, so the filter bar's sibling is
   the table on old pages and the scroll wrapper on migrated ones. */
.app-list .main_list_filter + .novus_list_table,
.app-list .main_list_filter + .app-table-wrap--scroll {
    margin-top: var(--spacing-xl);
}

/* Same gap, one shape further out: a page whose filter bar sits OUTSIDE .app-list is beyond the
   reach of the rule above, so an unpaginated list lands flush against the bar. Keyed on the
   wrapper being the list's first child, which is exactly the no-header-block case — a list with
   pagination has the header block there instead and is untouched. */
.main_list_filter ~ .app-list > .app-table-wrap--scroll:first-child {
    margin-top: var(--spacing-xl);
}

/* --- Icon vertical alignment in cells --- */

/* The sort indicator is appended into the flex `th > div`; without this the glyph is squeezed
   to zero width as soon as the header text fills the column. */
.app-list .novus_table_row th > div > .sym {
    flex-shrink: 0;
}

/* The sort indicator is an 18px svg, so the sorted column's div outgrows its 12px
   line-height neighbours and vertical-align: middle lifts its text ~3px out of line.
   A floor equal to the indicator keeps every header on one baseline, sorted or not. */
.app-list .novus_table_row th > div {
    min-height: 18px;
}

.app-list .novus_table_row td .sym {
    vertical-align: middle;
}

/* .sym is a flex box; inside cell text an info icon dropped to its own line (Edit User →
   Integrations, the ? next to Agera Pay and Edeklarera). */
.app-table__td .sym.app-info-icon {
    display: inline-flex;
    vertical-align: middle;
}

/* Write-off icon turns green once the row has a saved write-off */
.app-list .app-action .sym.write_off_saved {
    color: var(--success);
}

/* --- Inline inputs (mirrors §14 for legacy tables) --- */

.app-list .novus_td_with_input,
:where(.app-table .app-list__detail-panel) > .novus_edit_table .novus_td_with_input,
:where(.app-card) > .novus_edit_table .novus_td_with_input {
    padding: var(--spacing-xs) var(--spacing-md);
}

/* ========== ROW HEIGHT MODIFIERS ==========
   Applied via JS from list settings. Maps short/medium/tall
   to explicit heights on body cells and inline inputs.
   =========================================== */

.app-list--rows-short tbody > .novus_table_row td,
.app-list--rows-short tfoot > .novus_table_row td {
    height: 25px;
    padding-top: var(--spacing-xs);
    padding-bottom: var(--spacing-xs);
}
.app-list--rows-short tbody .novus_table_input,
.app-list--rows-short .novus_small_table_input,
.app-list--rows-short tbody .novus_table_row .app-input--sm {
    height: 20px;
}

.app-list--rows-medium tbody > .novus_table_row td,
.app-list--rows-medium tfoot > .novus_table_row td,
:where(.app-table .app-list__detail-panel) > .novus_edit_table tbody > .novus_table_row td,
:where(.app-card) > .novus_edit_table tbody > .novus_table_row td {
    height: 35px;
    padding-top: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
}
.app-list--rows-medium tbody .novus_table_input,
.app-list--rows-medium .novus_small_table_input {
    height: 25px;
}

.app-list--rows-tall tbody > .novus_table_row td,
.app-list--rows-tall tfoot > .novus_table_row td {
    height: 50px;
    padding-top: var(--spacing-md);
    padding-bottom: var(--spacing-md);
}
.app-list--rows-tall tbody .novus_table_input,
.app-list--rows-tall .novus_small_table_input {
    height: 30px;
}

/* ========== EMBEDDED CELL INPUTS ==========
   Briox.Select and the row builders put borderless inputs straight into cells. Inside a migrated
   table they need to read as editable — the legacy background and focus rules for them are
   commented out in stylesheets/lists.css, so a cell gave no affordance at all.
   Scoped to .app-table so legacy tables are untouched. background-color, not the shorthand, so a
   select.app-input keeps its chevron image. */

.app-table .novus_table_input_embed:not([readonly]):not(:disabled) {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.app-table .novus_table_input_embed:not([readonly]):not(:disabled):hover {
    background-color: var(--bg-tertiary);
}

.app-table .novus_table_input_embed:focus {
    background-color: var(--bg-primary);
    box-shadow: inset 0 0 0 1px var(--color-focus-ring);
    border-radius: var(--radius-sm);
}

/* Validation state on an embedded input (SIE import sets .error_input from JS): the embedded-cell
   counterpart of .app-input--error. The legacy embed has border: none !important, so the cue is
   the background tint. */
.app-table .novus_table_input_embed.app-input.error_input:not(:disabled) {
    background-color: color-mix(in srgb, var(--error) 18%, var(--bg-primary));
}

/* A <select> with width:100% has no intrinsic width, so under auto table layout its cell collapses
   to the arrow (48px on the SIE import action column). A floor for the longest action label keeps
   the control readable without pinning a column width. */
.app-table select.novus_table_input_embed.app-input {
    min-width: 130px;
}

/* A right-aligned amount input in a cell keeps room for a normal amount under auto layout. */
.app-table td.app-col--right > input.app-input,
.novus_list_table td.app-col--right > input.app-input {
    min-width: 6.5rem;
}

/* A narrow select in a cell (a currency code) must not be squeezed below its three letters and arrow. */
.app-table select.app-input--narrow {
    min-width: 4.5rem;
}

.app-table .novus_td_with_select:focus-within {
    background: var(--bg-tertiary);
}

/* ── Scroll wrapper ─────────────────────────────────────────── */

.app-table-wrap--scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: thin;
    scrollbar-color: var(--neutral-200) transparent;
}

.app-table-wrap--scroll::-webkit-scrollbar {
    height: 8px;
}

.app-table-wrap--scroll::-webkit-scrollbar-track {
    background: transparent;
}

.app-table-wrap--scroll::-webkit-scrollbar-thumb {
    background: var(--neutral-200);
    border-radius: var(--radius-full, 9999px);
}

.app-table-wrap--scroll::-webkit-scrollbar-thumb:hover {
    background: var(--neutral-400);
}

/* ── .app-list--scroll — horizontal scroll + hug ───────────── */
/* Constrain the container so the scroll wrapper scrolls, not the page.
   contain: inline-size prevents max-content from inflating ancestor
   flex items (whose min-width:auto defaults to content size). */

.app-list--scroll,
.app-list--pinned {
    max-width: 100%;
    overflow: hidden;
    contain: inline-size;
}

/* Table: auto layout, hug content, no overflow clipping */
.app-list--scroll .novus_list_table,
.app-list--pinned .novus_list_table {
    table-layout: auto;
    width: max-content;
    min-width: 100%;
    overflow: visible;
    border-radius: 0;
}

/* New app-table variant */
.app-table--scroll,
.app-table--pinned {
    table-layout: auto;
    width: max-content;
    min-width: 100%;
    overflow: visible;
    border-radius: 0;
}

/* The .app-list variants take their containment from .app-list itself. An
   app-table has no such container, so the scroller must contain itself —
   without this the wrapper grows with the max-content table and the page
   scrolls sideways instead of the wrapper. */
.app-table-wrap--scroll:has(> .app-table--scroll),
.app-table-wrap--scroll:has(> .app-table--pinned) {
    max-width: 100%;
    min-width: 0;
    contain: inline-size;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-sm);
}

.app-table-wrap--scroll > .app-table--scroll,
.app-table-wrap--scroll > .app-table--pinned {
    border: none;
}

/* A wrapper hosted in a card body contains itself the same way; the card supplies the chrome.
   The body is a flex item whose automatic minimum is its content's min-content, so without this a
   wide table widened the card, the section and the page instead of scrolling (SIE import accounts
   grid, 801px in a 749px card). */
.app-card__body > .app-table-wrap--scroll {
    max-width: 100%;
    min-width: 0;
    contain: inline-size;
}

/* Headers hug content — same as the .app-list variants */
.app-table--scroll thead th,
.app-table--pinned thead th {
    white-space: nowrap;
}

/* Headers hug content — no wrapping, columns size to their label */
.app-list--scroll thead > .novus_table_row th,
.app-list--pinned thead > .novus_table_row th {
    white-space: nowrap;
}

/* Move border + border-radius to the scroll wrapper.
   margin-bottom separates the scrollbar from the pagination text.
   Native scrollbar stays — the proxy is an additional floating helper. */
.app-list--scroll .app-table-wrap--scroll,
.app-list--pinned .app-table-wrap--scroll {
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-sm);
}

/* Breathing room for the scrollbar, only while there is one — pin_columns.js sets the class.
   Unconditional padding showed as a blank strip under the totals row on every non-overflowing list. */
.app-list--scroll .app-table-wrap--scroll.is-scrollable,
.app-list--pinned .app-table-wrap--scroll.is-scrollable {
    padding-bottom: var(--spacing-xs);
}

/* ── Fixed proxy scrollbar ──────────────────────────────────────
   A thin scrollable div fixed to the bottom of the viewport.
   Visible only when the real scrollbar is below the fold.
   JS syncs scrollLeft bidirectionally with the real scroll wrapper
   and toggles visibility via IntersectionObserver. */

.app-table-proxy-scroll {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    overflow-x: auto;
    overflow-y: hidden;
    height: 14px;
    background: var(--bg-primary);
    border-top: 1px solid var(--neutral-150);
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.06);
    scrollbar-width: thin;
    scrollbar-color: var(--neutral-300) transparent;
    transition: opacity var(--transition-fast);
}

.app-table-proxy-scroll.is-hidden {
    opacity: 0;
    pointer-events: none;
}

/* A Briox.Modal backdrop sits inside .container (z-index 80), below this bar on <body>, so the bar
   stayed bright on top of it. Nothing to scroll while a modal is open, so hide it then. */
body:has(.common_modal_overlay.show) .app-table-proxy-scroll {
    opacity: 0;
    pointer-events: none;
}

.app-table-proxy-scroll::-webkit-scrollbar {
    height: 8px;
}

.app-table-proxy-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.app-table-proxy-scroll::-webkit-scrollbar-thumb {
    background: var(--neutral-300);
    border-radius: var(--radius-full, 9999px);
}

.app-table-proxy-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--neutral-400);
}

.app-table-proxy-scroll__spacer {
    height: 1px;
}

/* Remove the table's own border — the wrapper provides it */
.app-list--scroll .app-table-wrap--scroll .novus_list_table,
.app-list--pinned .app-table-wrap--scroll .novus_list_table {
    border: none;
}

/* ── Pinned cell ────────────────────────────────────────────
   Cannot use `background: inherit` — table cells inherit
   transparent from <tr>. Must set explicit backgrounds. */

.app-col--pin {
    position: sticky;
    z-index: 2;
    background-color: var(--bg-primary);
    white-space: nowrap;
}

/* Header cells: header bg + higher z-index */
thead .app-col--pin,
thead > .novus_table_row .app-col--pin {
    z-index: 3;
    background-color: var(--bg-tertiary);
}

/* Body cells: primary bg */
tbody .app-col--pin,
tbody > .novus_table_row .app-col--pin {
    background-color: var(--bg-primary);
}

/* ── Hover ──────────────────────────────────────────────────── */

/* Pinned cells must stay opaque, and the hover token is translucent in the dark theme: lay it over the base. */
.app-table__body .app-table__row:hover .app-col--pin,
tbody > .novus_table_row:hover .app-col--pin,
tbody > .novus_table_row.hovered .app-col--pin {
    background: linear-gradient(var(--color-hover-bg), var(--color-hover-bg)), var(--bg-primary);
}

/* ── Zebra striping ─────────────────────────────────────────── */

.app-table--striped .app-table__body .app-table__row:nth-child(even) .app-col--pin,
tbody > .novus_table_row.odd .app-col--pin {
    background-color: var(--neutral-50);
}

tbody > .novus_table_row.odd:hover .app-col--pin,
tbody > .novus_table_row.odd.hovered .app-col--pin {
    background: linear-gradient(var(--color-hover-bg), var(--color-hover-bg)), var(--bg-primary);
}

/* ── Shadow on last pinned column ───────────────────────────
   Applied via JS as [data-pin-last] on the rightmost pinned
   cell per row. Indicates scroll affordance. */

/* A box-shadow, not an ::after: an element never clips its own shadow, so the
   cell keeps the overflow:hidden that .ellipsis needs. */
.app-col--pin[data-pin-last] {
    box-shadow: 6px 0 6px -6px rgba(0, 0, 0, 0.18);
}

/* Hide shadow when not scrolled */
.app-table-wrap--scroll.is-at-start .app-col--pin[data-pin-last] {
    box-shadow: none;
}

/* The frozen block overlays the scroll area instead of making room in it, so an
   uncapped pinned text column swallows the columns behind it. */
.app-col--pin.ellipsis {
    max-width: 320px;
}

/* ── Columns pinned to the right edge ───────────────────────
   For a column that must stay reachable rather than identify the
   row — a trailing action column on a table too wide to fit.
   `right` offsets come from pin_columns.js, same as `left` above. */

.app-col--pin-end {
    position: sticky;
    z-index: 2;
    background-color: var(--bg-primary);
    white-space: nowrap;
}

thead .app-col--pin-end,
thead > .novus_table_row .app-col--pin-end {
    z-index: 3;
    background-color: var(--bg-tertiary);
}

/* Mirror of [data-pin-last]: the shadow falls on the group's left edge,
   so it is the leftmost cell that carries it. */
.app-col--pin-end[data-pin-first] {
    overflow: visible !important;
}

.app-col--pin-end[data-pin-first]::before {
    content: '';
    position: absolute;
    top: 0;
    left: -6px;
    bottom: 0;
    width: 6px;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.06), transparent);
    pointer-events: none;
}

/* Hide shadow when scrolled all the way right */
.app-table-wrap--scroll.is-at-end .app-col--pin-end[data-pin-first]::before {
    opacity: 0;
}

/* Every pinned cell is its own z-index: 2 layer, so a dropdown opened in one is painted under the
   next rows' pinned cells; lift the cell holding the open list above them. */
.app-col--pin:has(.novus_filter_select_list.visible),
.app-col--pin-end:has(.novus_filter_select_list.visible) {
    z-index: 4;
}

/* ── Event lists (crm/cpnl) ─────────────────────────────────
   The subject column holds a heading plus an expandable message
   body, so it neither hugs nor ellipsises like a text cell. */

.app-list .novus_list_table .event_subject_cell {
    vertical-align: top;
    min-width: 220px;
}

.app-list .novus_list_table .event_message {
    word-wrap: break-word;
    white-space: normal;
}

/* Done / not-done tick in the last column */
.app-list .novus_list_table .event_status--done {
    color: var(--color-success);
}

.app-list .novus_list_table .event_status--open {
    color: var(--text-tertiary);
}

/* ── Labels in table cells ──────────────────────────────────
   The legacy bundle carries `td label { float: right; margin-right: 10px }` — an element
   selector, so no app-* class outranks it on float, and a design-system checkbox label inside a
   cell shrink-wraps against the right edge instead of sitting with its column. Only visible where
   the column is wide; app-col--hug cells hid it. */

.app-table__td .app-radio-group__option,
.app-table__th .app-radio-group__option,
.app-table__td .app-checkbox__option,
.app-table__th .app-checkbox__option,
.app-list .novus_list_table td .app-radio-group__option,
.app-list .novus_list_table th .app-radio-group__option,
.app-list .novus_list_table td .app-checkbox__option,
.app-list .novus_list_table th .app-checkbox__option {
    float: none;
    margin-right: 0;
}

/* td.app-col--center > * centres a flex child with margin-inline: auto; the margin-right: 0 above
   outranks it, so restore the right auto margin or the checkbox sits at the cell's right edge. */
.app-table__td.app-col--center > .app-checkbox__option,
.app-table__td.app-col--center > .app-radio-group__option {
    margin-right: auto;
}


/* ── #client_list: let a migrated list out of the legacy height ──
   `#client_list .novus_table_row { height: 50px }` in assistant.css was written for the assistant
   task lists, and clientmanager inherited it by sharing the table id. An id beats any number of
   classes, so .app-list's own `height: auto` never got a say and clientoverview was pinned at the
   `tall` 50px whatever the row-height setting said. The media-query twin carries !important, hence
   the !important here; both are scoped so client_task_overview and client_task_detail_list, which
   are not migrated, keep exactly what they had. */

.app-list #client_list > thead > .novus_table_row,
.app-list #client_list > tbody > .novus_table_row {
    height: auto !important;
}

.app-list #client_list > thead > .novus_table_row > th {
    vertical-align: middle;
    padding-bottom: var(--spacing-md);
}

/* A Material Symbol in a column header defaults to --icon-size-md (20px) while the header's own
   text line is 12px, so the column carrying it grows taller than the rest of the row — 4px on
   clientoverview's sorted column. The shared PHP indicator
   (common_sorted_column_indicator.htm) is an 18px inline svg and does not, which is the look to
   match. .sym and .app-info-icon have equal specificity and .sym loads later, so the class alone
   cannot fix it; this needs to outrank both. */

.app-list thead .novus_table_row th .sym {
    font-size: var(--icon-size-sm);
    line-height: var(--icon-size-sm);
}
