/**
 * Clean table headers + Table Settings / freeze panes (SLS).
 * Loaded from includes/header.php — do not copy into page <style> blocks.
 */

/* ——— Clean header chrome (default on .sls-table-clean) ——— */
:where(table.sls-table-clean thead th) {
    white-space: nowrap;
    vertical-align: middle;
}

:where(table.sls-table-clean thead th .sort-link),
:where(table.sls-table-clean thead th .ja-sort),
:where(table.sls-table-clean thead th .fp-ledger-th-sort) {
    /* inline-flex (not block flex) keeps the filter chevron on the same line */
    display: inline-flex !important;
    align-items: center;
    gap: 0.25rem;
    max-width: calc(100% - 1.6rem);
    vertical-align: middle;
}

/* Hide decorative column-type icons (keep sort indicator + menu chevron) */
:where(table.sls-table-clean:not(.sls-show-col-icons) thead th .sort-link > i.fas:not(.sort-dir-icon):not(.sls-sort-ind)),
:where(table.sls-table-clean:not(.sls-show-col-icons) thead th > i.fas:not(.sort-dir-icon):not(.sls-col-drag-handle)) {
    display: none !important;
}

/* Idle sort arrows hidden — only show when this column is actively sorted */
:where(table.sls-table-clean:not(.sls-show-idle-sort) thead th .sls-sort-ind[data-filled="0"]) {
    display: none !important;
}

:where(table.sls-table-clean:not(.sls-show-idle-sort) thead th .sort-dir-icon.fa-sort) {
    display: none !important;
}

:where(table.sls-table-clean thead th .sls-sort-ind[data-filled="1"]),
:where(table.sls-table-clean thead th .sort-dir-icon.fa-sort-up),
:where(table.sls-table-clean thead th .sort-dir-icon.fa-sort-down) {
    display: inline-flex;
}

/* Drag handles: hidden unless enabled; then hover-reveal */
:where(table.sls-table-clean:not(.sls-show-drag) thead th .sls-col-drag-handle) {
    display: none !important;
}

:where(table.sls-table-clean.sls-show-drag thead th .sls-col-drag-handle) {
    opacity: 0;
    width: 0;
    margin: 0 !important;
    overflow: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, width 0.12s ease;
}

:where(table.sls-table-clean.sls-show-drag thead th:hover .sls-col-drag-handle),
:where(table.sls-table-clean.sls-show-drag thead th:focus-within .sls-col-drag-handle),
:where(table.sls-table-clean.sls-show-drag.sls-drag-always thead th .sls-col-drag-handle) {
    opacity: 1;
    width: 1.1rem;
    margin-inline-end: 0.25rem !important;
    pointer-events: auto;
}

/* Menu chevron sits inline with the label — single trailing control */
:where(table.sls-table-clean thead th .sls-col-menu-btn) {
    vertical-align: middle;
    margin-inline-start: 0.15rem;
}

:where(table.sls-table-clean thead th.sls-col-menu-host) {
    white-space: nowrap;
}

/* ——— Sticky header / freeze panes ——— */

/* Fixed box scroll (opt-in). Default is whole-page scroll. */
.sls-table-scroll.sls-contained-scroll {
    max-height: min(70vh, 720px);
    overflow: auto;
    /* Both axes must overflow for Chrome’s 4-way middle-click autoscroll glyph. */
    overscroll-behavior: contain;
}

/*
 * Keep column intrinsic widths so the table can exceed the wrap.
 * Tailwind `w-full` would otherwise shrink columns until scrollWidth == clientWidth
 * (vertical-only middle-click; cannot reach first/last columns).
 */
.sls-table-scroll > table.sls-table-clean,
.sls-table-scroll > table#studentsTable,
.sls-table-scroll > table#employeesTable,
.sls-table-scroll > table#hrLeaveRosterTable {
    width: max-content !important;
    min-width: 100%;
    max-width: none;
}

/*
 * Freeze header + Fixed table scroll: pin the whole scroll box under the app
 * site header when the page scrolls, so the frozen row never slides underneath
 * the app bar. Inside the box, th still stick at top: 0.
 */
.sls-table-scroll.sls-contained-scroll.sls-freeze-header {
    /* Beat Tailwind `.relative` on the same node */
    position: sticky !important;
    top: var(--sls-sticky-table-top, 0px) !important;
    z-index: 30;
    max-height: min(
        70vh,
        720px,
        calc(100dvh - var(--sls-sticky-table-top, 0px) - 12px)
    );
    background: #fff;
}

/*
 * Fixed table scroll OFF: table grows with the page (no capped max-height) so
 * vertical scrolling is the document — this is what makes the toggle meaningful
 * vs Fixed ON. Keep overflow-x:auto so wide tables still get native middle-click
 * left/right. overflow-y:clip avoids a second vertical scrollbar (clip does not
 * turn into a Y scrollport the way max-height + overflow:auto did).
 */
.sls-table-scroll:not(.sls-contained-scroll) {
    position: relative !important;
    top: auto !important;
    max-height: none !important;
    height: auto !important;
    overflow-x: auto;
    overflow-y: clip;
    overscroll-behavior-x: contain;
    background: #fff;
}
html[data-theme="dark"] .sls-table-scroll:not(.sls-contained-scroll) {
    background: var(--color-card, #1e293b);
}

/* Page-mode freeze header: stick under the app bar while the document scrolls. */
.sls-table-scroll:not(.sls-contained-scroll) table.sls-table-clean.sls-sticky-header thead th,
.sls-table-scroll:not(.sls-contained-scroll).sls-freeze-header table.sls-table-clean thead th {
    top: var(--sls-sticky-table-top, 0px) !important;
}

/*
 * Fixed OFF + freeze header: MUST keep overflow-x:auto (same as base Fixed OFF).
 * Clipping X used to protect sticky titles but killed Chrome/Edge native
 * middle-click left/right (BUG-001). Native H scrollport + max-content table
 * is required; sticky th still uses top: var(--sls-sticky-table-top).
 */
.sls-table-scroll.sls-page-hpan:not(.sls-contained-scroll),
.sls-table-scroll.sls-freeze-header:not(.sls-contained-scroll) {
    overflow-x: auto;
    overflow-y: clip;
}

/*
 * Custom H-scrollbar under the table (page-mode freeze).
 * Native overflow scrollbars in a 14px box end up with clientHeight:0 so
 * clicks fall through — use an explicit track + thumb instead.
 */
.sls-table-hpan-bar {
    display: block;
    position: relative;
    width: 100%;
    height: 16px;
    margin-top: 8px;
    margin-bottom: 4px;
    overflow: hidden;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
    z-index: 40;
    isolation: isolate;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
}
.sls-table-hpan-bar[hidden] {
    display: none !important;
}
.sls-table-hpan-thumb {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 0;
    min-width: 40px;
    border-radius: 6px;
    background: #64748b;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    cursor: grab;
    pointer-events: auto;
    touch-action: none;
}
.sls-table-hpan-thumb:hover {
    background: #475569;
}
.sls-table-hpan-thumb.is-dragging,
.sls-table-hpan-bar.is-dragging .sls-table-hpan-thumb {
    cursor: grabbing;
    background: #334155;
}
/* Legacy spacer from older native-overflow builds */
.sls-table-hpan-spacer {
    display: none !important;
}
html[data-theme="dark"] .sls-table-hpan-bar {
    background: #1e293b;
    border-color: #334155;
}
html[data-theme="dark"] .sls-table-hpan-thumb {
    background: #94a3b8;
}
html[data-theme="dark"] .sls-table-hpan-thumb:hover,
html[data-theme="dark"] .sls-table-hpan-thumb.is-dragging,
html[data-theme="dark"] .sls-table-hpan-bar.is-dragging .sls-table-hpan-thumb {
    background: #cbd5e1;
}
.sls-table-scroll.sls-page-hpan:not(.sls-contained-scroll) > table.sls-table-clean {
    will-change: margin-inline-start;
}

/*
 * Middle-click = browser native only (Chrome/Edge circle glyph).
 * Fixed ON  → overflow:auto both axes (4-way).
 * Fixed OFF → overflow-x:auto (L/R) + page vertical scroll.
 * Never ship custom middle-pan handlers or glyphs — kill leftovers.
 */
#slsTableMiddlePanGlyph,
.sls-table-middle-pan-glyph {
    display: none !important;
}

/* Infinite-scroll sentinel (inside pane when fixed scroll is on) */
.sls-infinite-scroll-trigger {
    height: 28px;
    width: 100%;
    flex-shrink: 0;
    pointer-events: none;
}
.sls-infinite-scroll-trigger.is-loading {
    position: relative;
}
.sls-infinite-scroll-trigger.is-loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid #e2e8f0;
    border-top-color: #0d9488;
    border-radius: 999px;
    animation: sls-infinite-spin 0.7s linear infinite;
}
@keyframes sls-infinite-spin {
    to { transform: rotate(360deg); }
}

/* Kill any leftover fixed-header clones from older builds */
.sls-page-freeze-header {
    display: none !important;
}

/*
 * Boards like .hr-surface use overflow:hidden which traps position:sticky.
 * For page-mode freeze we must open them to visible so th sticks to the viewport.
 * (overflow:clip still acts as a sticky containing block in Chromium.)
 */
.sls-sticky-overflow-fix {
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
}

/*
 * Freeze header = native position:sticky on the REAL <th> cells.
 * Same cells as the columns → titles can never drift off their columns.
 * Page scroll: stick below the app bar. Contained scroll: stick to box top.
 * border-collapse:separate is required for sticky <th> in Chromium.
 */
table.sls-table-clean.sls-sticky-header {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

/*
 * Freeze header row metrics — Students gold standard for every module.
 * Measured on #studentsTable with Freeze header + Compact density (~57px).
 */
table.sls-table-clean.sls-sticky-header > thead > tr > th,
table.sls-table-clean.sls-sticky-header thead th,
table.sls-table-clean.sls-sticky-header thead th[data-col],
.sls-table-scroll.sls-freeze-header table.sls-table-clean > thead > tr > th,
.sls-table-scroll.sls-freeze-header table.sls-table-clean thead th,
.sls-table-scroll.sls-freeze-header table.sls-table-clean thead th[data-col],
#studentsTable.sls-sticky-header thead th,
#studentsTable.sls-sticky-header thead th[data-col],
#employeesTable.sls-sticky-header thead th,
#employeesTable.sls-sticky-header thead th[data-col],
#ubApplicantsTable.sls-sticky-header thead th,
#jaApplicantsTable.sls-sticky-header thead th {
    position: sticky !important;
    z-index: 20;
    background: var(--sls-table-header-bg, #f8fafc) !important;
    background-clip: padding-box;
    /* Opaque top lip so translucent glass never bleeds through the freeze seam */
    box-shadow:
        0 -8px 0 0 var(--sls-table-header-bg, #f8fafc),
        inset 0 -2px 0 var(--sls-table-accent, #e2e8f0);
    /* Keep header chrome visible while stuck (no vertical clip from row overflow) */
    overflow: visible;
    box-sizing: border-box;
    min-height: 3.55rem; /* Students freeze header height */
    height: 3.55rem;
    padding-top: 0.55rem !important;
    padding-bottom: 0.55rem !important;
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.25rem;
    vertical-align: middle;
    white-space: nowrap;
}

/* Compact density must not shrink the freeze header below Students metrics */
table.sls-table-clean.sls-sticky-header.sls-density-compact > thead > tr > th,
table.sls-table-clean.sls-sticky-header.sls-density-compact thead th,
.sls-table-scroll.sls-freeze-header table.sls-table-clean.sls-density-compact thead th {
    min-height: 3.55rem !important;
    height: 3.55rem !important;
    padding-top: 0.55rem !important;
    padding-bottom: 0.55rem !important;
}

/*
 * Fixed ON: freeze header sticks to the box top (0).
 * Fixed OFF: see rule above — sticks under the app bar via --sls-sticky-table-top.
 */
.sls-table-scroll.sls-contained-scroll.sls-freeze-header table.sls-table-clean thead th,
.sls-table-scroll.sls-contained-scroll.sls-freeze-header table.sls-table-clean thead th[data-col],
.sls-table-scroll.sls-contained-scroll table.sls-table-clean.sls-sticky-header thead th {
    top: 0 !important;
}

table.sls-table-clean.sls-sticky-header thead th.sls-freeze-col,
table.sls-table-clean.sls-sticky-header thead th[data-col].sls-freeze-col,
.sls-table-scroll.sls-freeze-header table.sls-table-clean thead th.sls-freeze-col,
.sls-table-scroll.sls-freeze-header table.sls-table-clean thead th[data-col].sls-freeze-col {
    z-index: 22;
}

/* Checkbox / first freeze col in sticky header needs both axes */
table.sls-table-clean.sls-sticky-header thead th.col-select,
table.sls-table-clean.sls-sticky-header thead .col-select {
    z-index: 23 !important;
    background: var(--sls-table-header-bg, #f8fafc) !important;
}

/* Opaque pane fill — sticky cells must paint their own solid bg or scrolled
   columns show through (dark mode especially forced td { background: transparent }). */
table.sls-table-clean th.sls-freeze-col,
table.sls-table-clean td.sls-freeze-col,
table.sls-table-clean th[data-col].sls-freeze-col {
    position: sticky !important;
    z-index: 3;
    background-color: var(--color-card, #ffffff) !important;
    background-image: none !important;
    box-shadow: 2px 0 0 var(--color-border, #e2e8f0);
}

table.sls-table-clean thead th.sls-freeze-col,
table.sls-table-clean thead th[data-col].sls-freeze-col {
    background-color: var(--sls-table-header-bg, #f8fafc) !important;
    z-index: 6;
}

html[dir="rtl"] table.sls-table-clean th.sls-freeze-col,
html[dir="rtl"] table.sls-table-clean td.sls-freeze-col {
    box-shadow: -2px 0 0 var(--color-border, #e2e8f0);
}

html[data-theme="dark"] table.sls-table-clean th.sls-freeze-col,
html[data-theme="dark"] table.sls-table-clean td.sls-freeze-col,
html[data-theme="dark"] table.sls-table-clean th[data-col].sls-freeze-col {
    background-color: var(--color-card, var(--sls-dark-surface, #1e293b)) !important;
    background-image: none !important;
    box-shadow: 2px 0 0 var(--color-border, var(--sls-dark-border, #334155));
}

html[data-theme="dark"] table.sls-table-clean thead th.sls-freeze-col,
html[data-theme="dark"] table.sls-table-clean thead th[data-col].sls-freeze-col {
    background-color: var(--sls-table-header-bg, #1e293b) !important;
}

html[dir="rtl"][data-theme="dark"] table.sls-table-clean th.sls-freeze-col,
html[dir="rtl"][data-theme="dark"] table.sls-table-clean td.sls-freeze-col {
    box-shadow: -2px 0 0 var(--color-border, var(--sls-dark-border, #334155));
}

/* Freeze totals / footer row (Table Settings toggle) — page or contained scroll */
table.sls-table-clean.sls-freeze-totals > tfoot,
table.sls-table-clean.sls-freeze-totals tfoot,
.sls-table-scroll.sls-freeze-totals table.sls-table-clean > tfoot,
.sls-table-scroll.sls-freeze-totals table.sls-table-clean tfoot {
    position: sticky !important;
    bottom: 0;
    z-index: 15;
}

table.sls-table-clean.sls-freeze-totals tfoot td,
table.sls-table-clean.sls-freeze-totals tfoot th,
.sls-table-scroll.sls-freeze-totals table.sls-table-clean tfoot td,
.sls-table-scroll.sls-freeze-totals table.sls-table-clean tfoot th {
    position: sticky !important;
    bottom: 0;
    z-index: 16;
    background: #f1f5f9;
    box-shadow: 0 -4px 10px rgba(15, 23, 42, 0.06);
}

table.sls-table-clean:not(.sls-freeze-totals) > tfoot,
table.sls-table-clean:not(.sls-freeze-totals) tfoot,
.sls-table-scroll:not(.sls-freeze-totals) table.sls-table-clean > tfoot,
.sls-table-scroll:not(.sls-freeze-totals) table.sls-table-clean tfoot {
    position: static !important;
    bottom: auto !important;
}

table.sls-table-clean:not(.sls-freeze-totals) tfoot td,
table.sls-table-clean:not(.sls-freeze-totals) tfoot th,
.sls-table-scroll:not(.sls-freeze-totals) table.sls-table-clean tfoot td,
.sls-table-scroll:not(.sls-freeze-totals) table.sls-table-clean tfoot th {
    position: static !important;
    bottom: auto !important;
    box-shadow: none;
}

/* Frozen totals cells that are also freeze-columns keep a solid fill */
table.sls-table-clean.sls-freeze-totals tfoot td.sls-freeze-col {
    z-index: 5;
    background-color: #f1f5f9 !important;
}

html[data-theme="dark"] table.sls-table-clean.sls-freeze-totals tfoot td.sls-freeze-col {
    background-color: var(--sls-dark-surface-raised, #26334a) !important;
}

/* Density */
:where(table.sls-table-clean.sls-density-compact td),
:where(table.sls-table-clean.sls-density-compact th) {
    padding-top: 0.35rem !important;
    padding-bottom: 0.35rem !important;
}

:where(table.sls-table-clean.sls-zebra tbody tr:nth-child(even) td) {
    background: #f8fafc;
}

table.sls-table-clean.sls-zebra tbody tr:nth-child(even) td.sls-freeze-col {
    background-color: color-mix(in srgb, var(--sls-table-header-bg, #f8fafc) 70%, var(--color-card, #fff)) !important;
}

/*
 * Wrap cell text must beat Tailwind `whitespace-nowrap` on <table>/<td>
 * (finance ledgers, UB cells, etc.) — :where() alone loses that fight.
 */
table.sls-table-clean.sls-wrap-text,
table.sls-table-clean.sls-wrap-text td,
table.sls-table-clean.sls-wrap-text th {
    white-space: normal !important;
    word-break: break-word;
}

table.sls-table-clean:not(.sls-wrap-text) td {
    white-space: nowrap;
}

/* Gridlines (Table Settings) */
table.sls-table-clean {
    --sls-grid-color: #e2e8f0;
}

table.sls-table-clean.sls-grid-cols th,
table.sls-table-clean.sls-grid-cols td {
    border-inline-end: 1px solid var(--sls-grid-color);
}

table.sls-table-clean.sls-grid-cols th:last-child,
table.sls-table-clean.sls-grid-cols td:last-child {
    border-inline-end: 0;
}

table.sls-table-clean.sls-grid-rows th,
table.sls-table-clean.sls-grid-rows td {
    border-bottom: 1px solid var(--sls-grid-color);
}

table.sls-table-clean.sls-grid-rows tbody tr:last-child td {
    border-bottom-color: var(--sls-grid-color);
}

table.sls-table-clean:not(.sls-grid-cols) th,
table.sls-table-clean:not(.sls-grid-cols) td {
    border-inline-end: 0 !important;
}

table.sls-table-clean:not(.sls-grid-rows) tbody td,
table.sls-table-clean:not(.sls-grid-rows) tbody th {
    border-bottom: 0 !important;
}

/* Hide column filter / options chevron */
table.sls-table-clean.sls-hide-col-filter thead th .sls-col-menu-btn {
    display: none !important;
}

/* ——— Focus Cell (Excel-style cross-hair) ——— */
table.sls-table-clean.sls-focus-cell {
    --sls-focus-color: #93c5fd;
}

table.sls-table-clean.sls-focus-cell tbody tr.sls-focus-row > td {
    background-color: color-mix(in srgb, var(--sls-focus-color) 32%, transparent) !important;
}

/* Sibling family blocks (UB / Bus): keep the cross-hair wash across the whole group */
table.sls-table-clean.sls-focus-cell tbody tr.sls-focus-family > td {
    background-color: color-mix(in srgb, var(--sls-focus-color) 32%, transparent) !important;
}

table.sls-table-clean.sls-focus-cell tbody td.sls-focus-col {
    background-color: color-mix(in srgb, var(--sls-focus-color) 32%, transparent) !important;
}

table.sls-table-clean.sls-focus-cell tbody td.sls-focus-active {
    background-color: color-mix(in srgb, var(--sls-focus-color) 55%, #fff) !important;
    outline: 2px solid var(--sls-focus-color);
    outline-offset: -2px;
    position: relative;
    z-index: 1;
}

table.sls-table-clean.sls-focus-cell tbody tr.sls-focus-row > td.sls-freeze-col,
table.sls-table-clean.sls-focus-cell tbody td.sls-focus-col.sls-freeze-col {
    background-color: color-mix(in srgb, var(--sls-focus-color) 40%, var(--color-card, #fff)) !important;
}

html[data-theme="dark"] table.sls-table-clean.sls-focus-cell tbody tr.sls-focus-row > td.sls-freeze-col,
html[data-theme="dark"] table.sls-table-clean.sls-focus-cell tbody td.sls-focus-col.sls-freeze-col {
    background-color: color-mix(in srgb, var(--sls-focus-color) 40%, var(--color-card, #1e293b)) !important;
}

/* ——— Colored table styles ——— */
table.sls-table-clean {
    --sls-table-accent: #94a3b8;
    --sls-table-header-bg: #f8fafc;
    --sls-table-header-fg: #0f172a;
    --sls-table-header-line: #e2e8f0;
}

table.sls-table-clean.sls-style-teal {
    --sls-table-accent: #0d9488;
    --sls-table-header-bg: #f0fdfa;
    --sls-table-header-fg: #134e4a;
    --sls-table-header-line: #99f6e4;
}
table.sls-table-clean.sls-style-sky {
    --sls-table-accent: #0284c7;
    --sls-table-header-bg: #f0f9ff;
    --sls-table-header-fg: #0c4a6e;
    --sls-table-header-line: #7dd3fc;
}
table.sls-table-clean.sls-style-indigo {
    --sls-table-accent: #4f46e5;
    --sls-table-header-bg: #eef2ff;
    --sls-table-header-fg: #312e81;
    --sls-table-header-line: #a5b4fc;
}
table.sls-table-clean.sls-style-slate {
    --sls-table-accent: #475569;
    --sls-table-header-bg: #f1f5f9;
    --sls-table-header-fg: #0f172a;
    --sls-table-header-line: #cbd5e1;
}
table.sls-table-clean.sls-style-rose {
    --sls-table-accent: #e11d48;
    --sls-table-header-bg: #fff1f2;
    --sls-table-header-fg: #881337;
    --sls-table-header-line: #fda4af;
}
table.sls-table-clean.sls-style-amber {
    --sls-table-accent: #d97706;
    --sls-table-header-bg: #fffbeb;
    --sls-table-header-fg: #78350f;
    --sls-table-header-line: #fcd34d;
}
table.sls-table-clean.sls-style-emerald {
    --sls-table-accent: #059669;
    --sls-table-header-bg: #ecfdf5;
    --sls-table-header-fg: #064e3b;
    --sls-table-header-line: #6ee7b7;
}

.sls-table-scroll.sls-freeze-header table.sls-table-clean thead th,
.sls-table-scroll.sls-freeze-header table.sls-table-clean thead th[data-col],
table.sls-table-clean thead th {
    background: var(--sls-table-header-bg);
    color: var(--sls-table-header-fg);
    box-shadow: inset 0 -2px 0 var(--sls-table-accent);
}

.sls-table-scroll.sls-freeze-header table.sls-table-clean thead th.sls-freeze-col,
table.sls-table-clean thead th.sls-freeze-col {
    background-color: var(--sls-table-header-bg) !important;
}

table.sls-table-clean.sls-zebra tbody tr:nth-child(even) td {
    background: color-mix(in srgb, var(--sls-table-header-bg) 70%, #fff);
}

/* ——— Table Settings dropdown ——— */
.sls-table-settings {
    position: relative;
    display: inline-block;
}

.sls-table-settings__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.sls-table-settings__menu {
    display: none;
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 6px);
    z-index: 10050;
    min-width: 300px;
    max-width: min(360px, calc(100vw - 16px));
    max-height: min(560px, calc(100vh - 16px));
    overflow: auto;
    padding: 0.5rem 0;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.16);
    font-size: 0.8125rem;
    color: #0f172a;
}

.sls-table-settings.open > .sls-table-settings__menu {
    display: block !important;
}

.sls-table-settings__title {
    margin: 0;
    padding: 0.25rem 0.85rem 0.45rem;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}

.sls-table-settings__hint {
    margin: 0;
    padding: 0 0.85rem 0.5rem;
    font-size: 0.72rem;
    line-height: 1.35;
    color: #94a3b8;
    font-weight: 500;
}

.sls-table-settings__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0.85rem;
}

.sls-table-settings__row:hover {
    background: #f8fafc;
}

.sls-table-settings__label {
    font-weight: 600;
    color: #0f172a;
    line-height: 1.25;
}

.sls-table-settings__sub {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    color: #94a3b8;
    margin-top: 0.1rem;
}

.sls-table-settings__control {
    flex-shrink: 0;
}

.sls-table-settings__select {
    min-width: 5.5rem;
    padding: 0.3rem 0.45rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.45rem;
    font: inherit;
    font-weight: 600;
    background: #fff;
    color: #0f172a;
}

.sls-table-settings__toggle {
    position: relative;
    width: 2.4rem;
    height: 1.3rem;
    border-radius: 999px;
    border: 0;
    background: #cbd5e1;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease;
}

.sls-table-settings__toggle[aria-pressed="true"] {
    background: #0d9488;
}

.sls-table-settings__toggle::after {
    content: '';
    position: absolute;
    top: 0.15rem;
    inset-inline-start: 0.15rem;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
    transition: inset-inline-start 0.15s ease;
}

.sls-table-settings__toggle[aria-pressed="true"]::after {
    inset-inline-start: calc(100% - 1.15rem);
}

.sls-table-settings__divider {
    height: 1px;
    margin: 0.35rem 0;
    background: #e2e8f0;
}

.sls-table-settings__reset {
    display: block;
    width: calc(100% - 1.7rem);
    margin: 0.35rem 0.85rem 0.15rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background: #f8fafc;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    color: #0f172a;
}

.sls-table-settings__reset:hover {
    background: #f0fdfa;
    border-color: #99f6e4;
    color: #0f766e;
}

.sls-table-settings__swatches {
    display: grid;
    grid-template-columns: repeat(6, 1.35rem);
    gap: 0.35rem;
    padding: 0 0.85rem 0.55rem;
}

.sls-table-settings__swatch {
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 0.3rem;
    border: 1px solid rgba(15, 23, 42, 0.12);
    padding: 0;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.sls-table-settings__swatch.is-on {
    outline: 2px solid #0f172a;
    outline-offset: 1px;
}

.sls-table-settings__styles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    padding: 0 0.85rem 0.55rem;
}

.sls-table-settings__style {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #fff;
    cursor: pointer;
    font: inherit;
    text-align: start;
    color: #0f172a;
}

.sls-table-settings__style:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.sls-table-settings__style.is-on {
    border-color: #0d9488;
    background: #f0fdfa;
    box-shadow: 0 0 0 1px #99f6e4;
}

.sls-table-settings__style-bar {
    width: 0.7rem;
    height: 1.15rem;
    border-radius: 0.2rem;
    flex-shrink: 0;
}

.sls-table-settings__style-name {
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
}

/*
 * Sticky headers use background: var(--sls-table-header-bg) !important.
 * Light tokens are set on table.sls-table-clean; without dark token overrides
 * the freeze row stays #f8fafc while dark remaps .text-slate-* on sort links
 * → unreadable light-on-light headers (Qualification / JA / Students / etc.).
 */
html[data-theme="dark"] table.sls-table-clean {
    --sls-grid-color: #334155;
    --sls-table-accent: #64748b;
    --sls-table-header-bg: #1e293b;
    --sls-table-header-fg: #f1f5f9;
    --sls-table-header-line: #334155;
}
html[data-theme="dark"] table.sls-table-clean.sls-style-teal {
    --sls-table-accent: #2dd4bf;
    --sls-table-header-bg: #123f46;
    --sls-table-header-fg: #a5e9e4;
    --sls-table-header-line: rgba(68, 238, 205, 0.38);
}
html[data-theme="dark"] table.sls-table-clean.sls-style-sky {
    --sls-table-accent: #38bdf8;
    --sls-table-header-bg: #0f2744;
    --sls-table-header-fg: #bae6fd;
    --sls-table-header-line: rgba(56, 189, 248, 0.35);
}
html[data-theme="dark"] table.sls-table-clean.sls-style-indigo {
    --sls-table-accent: #818cf8;
    --sls-table-header-bg: #1e1b4b;
    --sls-table-header-fg: #c7d2fe;
    --sls-table-header-line: rgba(129, 140, 248, 0.35);
}
html[data-theme="dark"] table.sls-table-clean.sls-style-slate {
    --sls-table-accent: #94a3b8;
    --sls-table-header-bg: #1e293b;
    --sls-table-header-fg: #f1f5f9;
    --sls-table-header-line: rgba(148, 163, 184, 0.28);
}
html[data-theme="dark"] table.sls-table-clean.sls-style-rose {
    --sls-table-accent: #fb7185;
    --sls-table-header-bg: #3a182a;
    --sls-table-header-fg: #fecdd3;
    --sls-table-header-line: rgba(251, 113, 133, 0.35);
}
html[data-theme="dark"] table.sls-table-clean.sls-style-amber {
    --sls-table-accent: #fbbf24;
    --sls-table-header-bg: #3a3827;
    --sls-table-header-fg: #fde68a;
    --sls-table-header-line: rgba(240, 199, 66, 0.38);
}
html[data-theme="dark"] table.sls-table-clean.sls-style-emerald {
    --sls-table-accent: #34d399;
    --sls-table-header-bg: #11403c;
    --sls-table-header-fg: #a7f3d0;
    --sls-table-header-line: rgba(80, 226, 168, 0.38);
}

html[data-theme="dark"] table.sls-table-clean.sls-sticky-header > thead > tr > th,
html[data-theme="dark"] table.sls-table-clean.sls-sticky-header thead th,
html[data-theme="dark"] table.sls-table-clean.sls-sticky-header thead th[data-col],
html[data-theme="dark"] .sls-table-scroll.sls-freeze-header table.sls-table-clean > thead > tr > th,
html[data-theme="dark"] .sls-table-scroll.sls-freeze-header table.sls-table-clean thead th,
html[data-theme="dark"] .sls-table-scroll.sls-freeze-header table.sls-table-clean thead th[data-col],
html[data-theme="dark"] #studentsTable.sls-sticky-header thead th,
html[data-theme="dark"] #employeesTable.sls-sticky-header thead th,
html[data-theme="dark"] #ubApplicantsTable.sls-sticky-header thead th,
html[data-theme="dark"] #jaApplicantsTable.sls-sticky-header thead th,
html[data-theme="dark"] table.sls-table-clean.sls-sticky-header thead th.col-select,
html[data-theme="dark"] table.sls-table-clean.sls-sticky-header thead .col-select {
    background: var(--sls-table-header-bg, #1e293b) !important;
    color: var(--sls-table-header-fg, #f1f5f9) !important;
    box-shadow:
        0 -8px 0 0 var(--sls-table-header-bg, #1e293b),
        inset 0 -2px 0 var(--sls-table-accent, #334155);
}

html[data-theme="dark"] .sls-table-scroll.sls-freeze-header table.sls-table-clean thead th {
    background: var(--sls-table-header-bg, #1e293b);
    color: var(--sls-table-header-fg, #f1f5f9);
    box-shadow: inset 0 -1px 0 var(--color-border, #334155);
}

html[data-theme="dark"] table.sls-table-clean thead th .sort-link,
html[data-theme="dark"] table.sls-table-clean thead th .ja-sort,
html[data-theme="dark"] table.sls-table-clean thead th a.sort-link,
html[data-theme="dark"] #jaApplicantsTable thead th .sort-link,
html[data-theme="dark"] #jaApplicantsTable thead th .ja-sort,
html[data-theme="dark"] #ubApplicantsTable thead th .sort-link,
html[data-theme="dark"] #studentsTable thead th .sort-link,
html[data-theme="dark"] #employeesTable thead th .sort-link {
    color: var(--sls-table-header-fg, #e2e8f0) !important;
}

html[data-theme="dark"] table.sls-table-clean thead th .sort-link:hover,
html[data-theme="dark"] table.sls-table-clean thead th .ja-sort:hover,
html[data-theme="dark"] #jaApplicantsTable thead th .sort-link:hover,
html[data-theme="dark"] #studentsTable thead th .sort-link:hover {
    color: #5eead4 !important;
}

html[data-theme="dark"] table.sls-table-clean thead th .text-slate-400,
html[data-theme="dark"] table.sls-table-clean thead th .text-slate-500,
html[data-theme="dark"] table.sls-table-clean thead th .sort-dir-icon,
html[data-theme="dark"] table.sls-table-clean thead th .sls-col-menu-btn {
    color: #94a3b8 !important;
}

html[data-theme="dark"] table.sls-table-clean.sls-zebra tbody tr:nth-child(even) td:not(.sls-freeze-col) {
    background: color-mix(in srgb, var(--sls-table-header-bg, #1e293b) 55%, var(--color-card, #0f172a));
}

html[data-theme="dark"] table.sls-table-clean.sls-zebra tbody tr:nth-child(even) td.sls-freeze-col {
    background-color: color-mix(in srgb, var(--sls-table-header-bg, #1e293b) 55%, var(--color-card, #1e293b)) !important;
}

html[data-theme="dark"] .sls-table-settings__menu {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

html[data-theme="dark"] .sls-table-settings__row:hover {
    background: rgba(148, 163, 184, 0.08);
}

html[data-theme="dark"] .sls-table-settings__label {
    color: #e2e8f0;
}

html[data-theme="dark"] .sls-table-settings__select,
html[data-theme="dark"] .sls-table-settings__reset {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

html[data-theme="dark"] .sls-table-settings__toggle {
    background: #475569;
}

html[data-theme="dark"] .sls-table-settings__toggle[aria-pressed="true"] {
    background: #0d9488;
}

html[data-theme="dark"] .sls-table-settings__divider {
    background: #334155;
}
