/* BillBook data table (bb-table). Scoped: only tables inside .bb-table-card are affected.
   Uses the brand variables from app.css. Add class="bb-table-card" to the wrapper and
   class="bb-table" to the <table>; bb-table.js adds the toolbar (density + columns). */

.bb-table-card {
    background: var(--bb-surface);
    border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-xl);
    box-shadow: var(--bb-shadow-xs);
    overflow: hidden;
}

/* ---------- toolbar (DataTables dom) ---------- */
.bb-table-card .dataTables_wrapper { padding: 0; }
.bb-table-card .dataTables_wrapper > :is(.row, .tw-bs-row):first-child {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--bb-space-12);
    margin: 0 !important; padding: var(--bb-space-12) var(--bb-space-16); text-align: left !important;
    border-bottom: 1px solid var(--bb-border); background: var(--bb-surface);
}
.bb-table-card .dataTables_wrapper > :is(.row, .tw-bs-row):first-child > :is([class*="col-"], .bs-col) {
    width: auto; max-width: none; padding: 0; float: none; flex: 0 0 auto;
}
.bb-table-card .dataTables_wrapper > :is(.row, .tw-bs-row):first-child > :is(.col-sm-8, [class*="bs-sm:tw-w-8/12"]) { flex: 1 1 auto; }
.bb-table-card .dataTables_filter { order: -1; }
.bb-table-card .dataTables_filter label { margin: 0; position: relative; }
.bb-table-card .dataTables_filter input {
    width: 280px; max-width: 100%; height: 36px; margin: 0 !important;
    padding: 0 var(--bb-space-12) 0 var(--bb-space-32) !important; border: 1px solid var(--bb-border);
    border-radius: var(--bb-radius-lg); background: var(--bb-surface-raised); font-size: var(--bb-text-base); box-shadow: none;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.bb-table-card .dataTables_filter label::before {
    /* stylelint-disable-next-line scale-unlimited/declaration-strict-value -- icon-font family */
    content: "\f002"; font-family: "Font Awesome 5 Free", FontAwesome; font-weight: 900;
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    font-size: var(--bb-text-sm); color: var(--bb-text-muted); z-index: 1;
}
.bb-table-card .dataTables_length label { margin: 0; font-weight: 500; font-size: var(--bb-text-sm); color: var(--bb-text-muted); }
.bb-table-card .dataTables_length select {
    height: 36px; border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); margin: 0 var(--bb-space-4); background: var(--bb-surface);
}
.bb-table-card .dt-buttons { display: flex; flex-wrap: wrap; gap: var(--bb-space-6); justify-content: flex-start; }
.bb-table-card .dt-buttons .btn, .bb-table-card .dt-buttons .dt-button {
    height: 36px; border-radius: var(--bb-radius-md) !important; border: 1px solid var(--bb-border-strong) !important;
    background: var(--bb-surface) !important; color: var(--bb-text-body) !important; font-size: var(--bb-text-sm); font-weight: 600;
    padding: 0 var(--bb-space-12); box-shadow: none !important; margin: 0 !important;
}
.bb-table-card .dt-buttons .btn:hover, .bb-table-card .dt-buttons .dt-button:hover {
    border-color: var(--bb-border-darker) !important; background: var(--bb-surface-hover) !important;
    color: var(--bb-text) !important;
}

/* custom toolbar controls added by bb-table.js */
.bb-tools { display: flex; gap: var(--bb-space-6); align-items: center; margin-left: auto; }
.bb-tool-btn {
    display: inline-flex; align-items: center; gap: var(--bb-space-6); height: 32px; padding: 0 var(--bb-space-12);
    border: 1px solid var(--bb-border-strong); border-radius: var(--bb-radius-md); background: var(--bb-surface);
    color: var(--bb-text-body); font-size: var(--bb-text-sm); font-weight: 600; cursor: pointer; line-height: 1;
}
.bb-tool-btn:hover, .bb-tool-btn.is-open { background: var(--bb-surface-hover); border-color: var(--bb-border-darker); color: var(--bb-text); }
.bb-cols-wrap { position: relative; }
.bb-cols-menu {
    display: none; position: absolute; right: 0; top: 42px; z-index: 50; width: 230px; max-height: 340px; overflow: auto;
    background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); padding: var(--bb-space-6);
    box-shadow: var(--bb-shadow-lg);
}
.bb-cols-menu.is-open { display: block; }
.bb-cols-menu label { display: flex; align-items: center; gap: var(--bb-space-8); margin: 0; padding: var(--bb-space-8) var(--bb-space-12); border-radius: var(--bb-radius-md); font-size: var(--bb-text-base); font-weight: 500; cursor: pointer; }
.bb-cols-menu label:hover { background: var(--bb-primary-glow); }
.bb-cols-menu input { margin: 0; accent-color: var(--bb-primary); }

/* ---------- table ---------- */
.bb-table.dataTable, .bb-table { border: 0 !important; margin: 0 !important; border-collapse: separate !important; border-spacing: 0; width: 100% !important; }
.bb-table thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--bb-surface-raised) !important; color: var(--bb-text-muted); border: 0 !important;
    border-bottom: 1px solid var(--bb-border) !important;
    font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    padding: var(--bb-space-12) var(--bb-space-16) !important; white-space: nowrap; vertical-align: middle;
}
.bb-table thead th.sorting, .bb-table thead th.sorting_asc, .bb-table thead th.sorting_desc { cursor: pointer; }
.bb-table thead th.sorting_asc, .bb-table thead th.sorting_desc { color: var(--bb-primary-text); }
.bb-table tbody td {
    border: 0 !important; border-bottom: 1px solid var(--bb-border) !important;
    padding: var(--bb-space-12) var(--bb-space-16) !important; vertical-align: middle !important; font-size: var(--bb-text-base); color: var(--bb-text);
    background: var(--bb-surface);
}
.bb-table.table-striped > tbody > tr:nth-of-type(odd) > td { background: var(--bb-surface) !important; }
.bb-table tbody tr { transition: background .12s; }
.bb-table tbody tr:hover > td { background: var(--bb-primary-wash) !important; }
.bb-table tbody tr.selected > td { background: var(--bb-primary-glow) !important; }
.bb-table tbody tr:last-child > td { border-bottom: 0 !important; }
.bb-table tbody tr[data-href] { cursor: pointer; }
.bb-table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--bb-primary); cursor: pointer; }

/* laptop widths (1280-1366 with the sidebar open): tighter cell sides so wide lists keep Name/Due/Action on screen */
@media (max-width: 1366px) {
    .bb-table-card .bb-table thead th, .bb-table-card .bb-table tbody td { padding-left: var(--bb-space-12) !important; padding-right: var(--bb-space-12) !important; }
    .bb-table-card .bb-table thead th { white-space: normal !important; line-height: 1.3; }
}

/* density */
.bb-table-card.is-compact .bb-table tbody td { padding-top: var(--bb-space-6) !important; padding-bottom: var(--bb-space-6) !important; }
.bb-table-card.is-compact .bb-table thead th:first-child { width: 40px; }
.bb-table .product-thumbnail-small { width: 32px; height: 32px; }

/* scroll area */
.bb-table-card .dataTables_scrollBody { border: 0 !important; }
.bb-table-card .dataTables_scrollHead { border-bottom: 0; }
.bb-table-card .dataTables_scrollHeadInner { padding-right: 0 !important; }

/* ---------- cells ---------- */
.bb-table thead th:first-child { width: 40px; }
.bb-table .product-thumbnail-small { width: 44px; height: 44px; object-fit: cover; border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); background: var(--bb-surface-raised); }
.bb-cell-name { font-weight: 600; color: var(--bb-text); }
.bb-cell-sub { display: block; font-size: var(--bb-text-xs); color: var(--bb-text-muted); margin-top: 1px; }
.bb-pill {
    display: inline-flex; align-items: center; gap: var(--bb-space-6); padding: var(--bb-space-4) var(--bb-space-8); border-radius: var(--bb-radius-full);
    font-size: var(--bb-text-xs); font-weight: 600; line-height: 1.4; white-space: nowrap;
    background: var(--bb-surface-raised); color: var(--bb-text-body);
}
.bb-pill::before { content: ""; width: 6px; height: 6px; border-radius: var(--bb-radius-circle); background: currentColor; opacity: .7; }
.bb-pill.is-ok { background: var(--bb-success-bg); color: var(--bb-success-text); }
.bb-pill.is-low { background: var(--bb-warning-bg); color: var(--bb-warning-text); }
.bb-pill.is-out { background: var(--bb-danger-bg); color: var(--bb-danger-text); }
.bb-pill.is-brand { background: var(--bb-primary-tint); color: var(--bb-primary-text); }
.bb-pill.is-plain::before { display: none; }
.bb-money { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.bb-money.is-muted { color: var(--bb-text-muted); font-weight: 500; }
.bb-flag { display: inline-block; margin-left: var(--bb-space-6); padding: 1px var(--bb-space-8); border-radius: var(--bb-radius-md); font-size: var(--bb-text-xs); font-weight: 700; background: var(--bb-surface-raised); color: var(--bb-text-muted); vertical-align: middle; }

/* row actions: quick icons + menu */
.bb-actions { display: inline-flex; align-items: center; gap: var(--bb-space-4); }
.bb-act {
    display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
    border: 1px solid transparent; border-radius: var(--bb-radius-md); background: transparent; color: var(--bb-text-muted);
    font-size: var(--bb-text-base); cursor: pointer; text-decoration: none !important;
}
.bb-act:hover, .bb-actions.open > .bb-act { background: var(--bb-primary-glow); color: var(--bb-primary-text); }
.bb-actions .dropdown-menu { border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); box-shadow: var(--bb-shadow-lg); padding: var(--bb-space-6); min-width: 200px; }
.bb-actions .dropdown-menu > li > a { border-radius: var(--bb-radius-md); padding: var(--bb-space-8) var(--bb-space-12); font-size: var(--bb-text-base); color: var(--bb-text-body); }
.bb-actions .dropdown-menu > li > a:hover { background: var(--bb-primary-glow); color: var(--bb-primary-text); }
.bb-actions .dropdown-menu > li > a .fa, .bb-actions .dropdown-menu > li > a .fas{ width: 18px; color: var(--bb-primary-text); }

/* ---------- footer ---------- */
.bb-table-card .dataTables_wrapper > :is(.row, .tw-bs-row):last-child,
.bb-table-card .dataTables_wrapper .dataTables_info,
.bb-table-card .dataTables_wrapper .dataTables_paginate { font-size: var(--bb-text-sm); }
.bb-table-card .dataTables_info { padding: var(--bb-space-12) var(--bb-space-16) !important; color: var(--bb-text-muted); float: left; }
.bb-table-card .dataTables_paginate { padding: var(--bb-space-8) var(--bb-space-16) !important; float: right; }
.bb-table-card .dataTables_paginate .pagination { margin: 0; }
.bb-table-card .dataTables_paginate .paginate_button a,
.bb-table-card .dataTables_paginate .paginate_button.page-item .page-link { border-radius: var(--bb-radius-md) !important; margin: 0 var(--bb-space-2); border: 1px solid transparent; color: var(--bb-text-body); }
.bb-table-card .dataTables_paginate .paginate_button.active a,
.bb-table-card .dataTables_paginate .paginate_button.active .page-link {
    background: var(--bb-primary) !important; border-color: var(--bb-primary) !important; color: var(--bb-on-primary) !important;
}
.bb-table-card div.dataTables_processing {
    border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); box-shadow: var(--bb-shadow-md);
    color: var(--bb-primary-text); font-weight: 600;
}
.bb-table-card tfoot td { background: var(--bb-surface-raised); border-top: 1px solid var(--bb-border) !important; padding: var(--bb-space-8) var(--bb-space-16) !important; }

/* the old tab chrome around the card */
.bb-tabstrip.bb-tabs { background: transparent; box-shadow: none; margin-bottom: 0; }
.bb-tabstrip.bb-tabs > .tab-content { padding: 0; background: transparent; }

/* image column: image only, no header text */
.bb-table thead th.bb-th-img { width: 52px; padding: 0 !important; }
#product_table tbody td:nth-child(3) { width: 52px; padding-left: var(--bb-space-16) !important; padding-right: 0 !important; }
#product_table tbody td:nth-child(3) > div { justify-content: flex-start; }
#product_table tbody td:nth-child(4) { padding-left: var(--bb-space-12) !important; }
.bb-table .product-thumbnail-small { width: 48px; height: 48px; }
/* a wide table squeezed the image column to a sliver: keep it at thumbnail size */
.bb-table thead th.bb-th-img { min-width: 62px; }
.bb-table .bb-thumb img.product-thumbnail-small { max-width: none; }

/* DataTables sort arrows: the DataTables Bootstrap theme (vendor.css) drew them with the Glyphicons Halflings font, which is gone; same pseudo-element, same box, Font Awesome sort glyphs */
table.dataTable thead .sorting::after, table.dataTable thead .sorting_asc::after, table.dataTable thead .sorting_desc::after,
/* stylelint-disable-next-line scale-unlimited/declaration-strict-value -- icon-font family */
table.dataTable thead .sorting_asc_disabled::after, table.dataTable thead .sorting_desc_disabled::after { font-family: "Font Awesome 5 Free", FontAwesome; font-weight: 900; }
table.dataTable thead .sorting::after { content: "\f0dc"; }
table.dataTable thead .sorting_asc::after { content: "\f0de"; }
table.dataTable thead .sorting_desc::after { content: "\f0dd"; }

/* room for the sort arrows so they never overlap the label */
.bb-table thead th.sorting, .bb-table thead th.sorting_asc, .bb-table thead th.sorting_desc { padding-right: var(--bb-space-24) !important; background-position: right 8px center; }
.bb-table thead th.sorting::after, .bb-table thead th.sorting_asc::after, .bb-table thead th.sorting_desc::after { right: 8px; }

/* category: main + sub */
.bb-cat { display: flex; flex-direction: column; gap: var(--bb-space-4); align-items: flex-start; min-width: 130px; }
.bb-cat-main { display: inline-block; padding: var(--bb-space-2) var(--bb-space-8); border-radius: var(--bb-radius-md); background: var(--bb-primary-tint); color: var(--bb-primary-text); font-size: var(--bb-text-sm); font-weight: 600; line-height: 1.5; }
.bb-cat-sub { font-size: var(--bb-text-sm); color: var(--bb-text-muted); padding-left: var(--bb-space-4); }
.bb-cat-sub i { font-size: var(--bb-text-xs); margin-right: var(--bb-space-4); color: var(--bb-text-muted); }

/* export / print: one menu instead of a row of buttons */
.bb-table-card .dataTables_wrapper > :is(.row, .tw-bs-row):first-child .dt-buttons { display: none !important; }
.bb-exp-wrap { position: relative; display: flex; gap: var(--bb-space-6); align-items: center; }
.bb-tool-strong { background: var(--bb-primary); border-color: var(--bb-primary); color: var(--bb-on-primary); }
.bb-tool-strong:hover, .bb-tool-strong.is-open { background: var(--bb-primary-hover); border-color: var(--bb-primary-hover); color: var(--bb-on-primary); }
.bb-caret { font-size: var(--bb-text-xs); opacity: .85; }
.bb-exp-menu { right: auto; left: 0; width: 250px; }
.bb-exp-item { display: flex; align-items: center; gap: var(--bb-space-12); width: 100%; padding: var(--bb-space-8) var(--bb-space-12); border: 0; border-radius: var(--bb-radius-md); background: transparent; text-align: left; cursor: pointer; }
.bb-exp-item:hover { background: var(--bb-primary-glow); }
.bb-exp-item > i { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--bb-radius-md); background: var(--bb-primary-tint); color: var(--bb-primary-text); font-size: var(--bb-text-md); }
.bb-exp-item b { display: block; font-size: var(--bb-text-base); font-weight: 600; color: var(--bb-text); }
.bb-exp-item small { display: block; font-size: var(--bb-text-xs); color: var(--bb-text-muted); }

/* product name: two lines max, full name on hover */
.bb-table .bb-cell-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; max-width: 260px; word-break: break-word; }
/* WooCommerce marker sits on the thumbnail corner */
.bb-thumb { position: relative; display: inline-block; line-height: 0; }
.bb-wp { position: absolute; right: -5px; bottom: -5px; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--bb-radius-circle); background: var(--bb-info); color: var(--bb-on-fill); font-size: var(--bb-text-xs); line-height: 1; border: 2px solid var(--bb-border); box-sizing: content-box; }

/* ---------- tabs that join the table card ---------- */
.bb-tabstrip.bb-tabs { background: transparent; border: 0; box-shadow: none; margin-bottom: 0; }
.bb-tabstrip.bb-tabs > .nav-tabs {
    display: flex; gap: var(--bb-space-4); margin: 0; padding: var(--bb-space-6) var(--bb-space-12) 0;
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; /* many tabs: one line that scrolls, labels never wrap */
    background: var(--bb-surface) !important; border: 1px solid var(--bb-border) !important; border-bottom: 0 !important;
    border-radius: var(--bb-radius-xl) var(--bb-radius-xl) 0 0;
}
.bb-tabstrip.bb-tabs > .nav-tabs::before, .bb-tabstrip.bb-tabs > .nav-tabs::after { display: none; }
.bb-tabstrip.bb-tabs > .nav-tabs > li {
    float: none; margin: 0 0 -1px; border: 0 !important; border-top: 0 !important; background: transparent; flex-shrink: 0;
}
.bb-tabstrip.bb-tabs > .nav-tabs > li > a {
    display: inline-flex; align-items: center; gap: var(--bb-space-8); margin: 0; padding: var(--bb-space-12) var(--bb-space-16); white-space: nowrap;
    border: 0 !important; border-bottom: 2px solid transparent !important; border-radius: 0;
    background: transparent !important; color: var(--bb-text-muted) !important;
    font-size: var(--bb-text-base); font-weight: 600; transition: color .12s, border-color .12s;
}
.bb-tabstrip.bb-tabs > .nav-tabs > li > a i { font-size: var(--bb-text-base); opacity: .8; }
.bb-tabstrip.bb-tabs > .nav-tabs > li:not(.active) > a:hover { color: var(--bb-primary-text) !important; border-bottom-color: var(--bb-primary-border) !important; }
.bb-tabstrip.bb-tabs > .nav-tabs > li.active > a,
.bb-tabstrip.bb-tabs > .nav-tabs > li.active > a:hover,
.bb-tabstrip.bb-tabs > .nav-tabs > li.active > a:focus {
    color: var(--bb-primary-text) !important; border-bottom-color: var(--bb-primary) !important;
}
.bb-tabstrip.bb-tabs > .nav-tabs > li.active > a i { color: var(--bb-primary-text); opacity: 1; }
.bb-tabstrip.bb-tabs > .tab-content { padding: 0; background: transparent; }
/* the card under the tabs: no gap, square top corners */
.bb-tabstrip.bb-tabs .bb-table-card { border-radius: 0 0 var(--bb-radius-xl) var(--bb-radius-xl); border: 1px solid var(--bb-border) !important; box-shadow: none; }
.bb-tabstrip.bb-tabs > .tab-content > .tab-pane:not(:has(.bb-table-card)) { background: var(--bb-surface); border: 1px solid var(--bb-border); border-top: 0; border-radius: 0 0 var(--bb-radius-xl) var(--bb-radius-xl); padding: var(--bb-space-12); }

/* info-coloured outline buttons inside tables use the brand colour */
.bb-table .tw-dw-btn-info.tw-dw-btn-outline, .bb-table .tw-dw-btn.tw-dw-btn-outline.tw-dw-btn-info {
    border-color: var(--bb-primary-border) !important; color: var(--bb-primary-text) !important; background: var(--bb-primary-wash) !important;
}
.bb-table .tw-dw-btn-info.tw-dw-btn-outline:hover { background: var(--bb-primary) !important; border-color: var(--bb-primary) !important; color: var(--bb-on-primary) !important; }

/* image + name cell (stock report) */
.bb-prod { display: flex; align-items: center; gap: var(--bb-space-12); min-width: 200px; }
.bb-prod .bb-thumb { flex: 0 0 auto; }
.bb-actions.is-single, .bb-table td > .bb-actions { display: inline-flex; }

/* ---------- compact filter bar (components.filters compact) ---------- */
.bb-filters { background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-xl); box-shadow: var(--bb-shadow-xs); margin-bottom: var(--bb-space-12); padding: var(--bb-space-12) var(--bb-space-16); }
.bb-filters-bar { display: flex; align-items: flex-start; gap: var(--bb-space-16); }
.bb-filters-title { flex: 0 0 auto; display: inline-flex; align-items: center; gap: var(--bb-space-8); height: 32px; margin-top: var(--bb-space-2); border-radius: var(--bb-radius-md); font-size: var(--bb-text-sm); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bb-primary-text); }
.bb-filters-main.row { flex: 1 1 auto; min-width: 0; margin: 0; display: block; }
.bb-filters-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bb-space-8); }
/* desktop: the bar is one line; bb-filters.js moves what does not fit under "More" */
@media (min-width: 768px) {
    .bb-filters-row { flex-wrap: nowrap; }
    /* the fields share the line: each grows from its base width (never shrinks below it, so the fit check works) */
    .bb-filters-row > .bb-filter:not(:has(input[type=checkbox])) { flex: 1 0 200px; max-width: 280px; }
    .bb-filters-row > .bb-filter:has(input[id*="date_range"], input[name*="date_range"], input[id*="daterange"]) { flex-basis: 240px; }
}
.bb-filters-row > .bb-filter, .bb-filters-more > .bb-filter { width: 200px; max-width: 100%; padding: 0; float: none; flex: 0 0 auto; }
.bb-filters .bb-field { margin: 0 !important; }
.bb-filters .bb-field > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.bb-filters .select2-container { width: 100% !important; }
.bb-filters .select2-container--default .select2-selection--single { height: 36px; border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); background: var(--bb-surface-raised); display: flex; align-items: center; }
.bb-filters .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 34px; font-size: var(--bb-text-base); color: var(--bb-text-body); padding-left: var(--bb-space-12); padding-right: var(--bb-space-24); }
.bb-filters .select2-container--default .select2-selection--single .select2-selection__arrow { height: 34px; }
.bb-filters .bb-filter.is-active .select2-selection--single { background: var(--bb-primary-wash); border-color: var(--bb-primary); }
.bb-filters .bb-filter.is-active .select2-selection__rendered { color: var(--bb-primary-text); font-weight: 600; }
.bb-more-btn .bb-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 var(--bb-space-6); border-radius: var(--bb-radius-md); background: var(--bb-primary); color: var(--bb-on-primary); font-size: var(--bb-text-xs); font-weight: 700; }
.bb-badge[hidden] { display: none !important; }
.bb-more-btn.is-open i { transform: rotate(45deg); }
.bb-filters-more { display: none; flex-wrap: wrap; align-items: center; gap: var(--bb-space-8); margin-top: var(--bb-space-8); padding-top: var(--bb-space-8); border-top: 1px dashed var(--bb-border); }
.bb-filters-more.is-open { display: flex; }
.bb-filters-more > .bb-filter:has(input[type=checkbox]) { width: auto; }
.bb-filters-more label { margin: 0 !important; min-height: 0 !important; height: 36px; display: inline-flex !important; align-items: center; gap: var(--bb-space-8) !important; padding: 0 var(--bb-space-12); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); background: var(--bb-surface-raised); font-size: var(--bb-text-base); font-weight: 500; color: var(--bb-text-body); cursor: pointer; }
.bb-filters-more .is-active label { background: var(--bb-primary-wash); border-color: var(--bb-primary); color: var(--bb-primary-text); font-weight: 600; }
@media (max-width: 767px) { .bb-filters-bar { flex-direction: column; gap: var(--bb-space-6); } .bb-filters-row > .bb-filter { width: 100%; } }

/* row buttons from controllers (edit / delete / view / etc.) get compact tinted styles in every bb-table */
.bb-table td .tw-dw-btn.tw-dw-btn-xs { height: 32px; min-height: 32px; padding: 0 var(--bb-space-12); border-radius: var(--bb-radius-md); font-size: var(--bb-text-sm); font-weight: 600; gap: var(--bb-space-6); box-shadow: none; }
.bb-table td .tw-dw-btn-outline.tw-dw-btn-primary { border-color: var(--bb-border-strong) !important; color: var(--bb-text-body) !important; background: var(--bb-surface) !important; }
.bb-table td .tw-dw-btn-outline.tw-dw-btn-primary:hover { background: var(--bb-surface-hover) !important; border-color: var(--bb-border-darker) !important; color: var(--bb-text) !important; }
.bb-table td .tw-dw-btn-outline.tw-dw-btn-error { border-color: var(--bb-danger-border) !important; color: var(--bb-danger-text) !important; background: var(--bb-danger-bg) !important; }
.bb-table td .tw-dw-btn-outline.tw-dw-btn-error:hover { background: var(--bb-red-600) !important; border-color: var(--bb-red-600) !important; color: var(--bb-on-fill) !important; }
.bb-table td .tw-dw-btn-outline.tw-dw-btn-success { border-color: var(--bb-success-border) !important; color: var(--bb-success-text) !important; background: var(--bb-success-bg) !important; }
.bb-table td .tw-dw-btn-outline.tw-dw-btn-success:hover { background: var(--bb-green-600) !important; border-color: var(--bb-green-600) !important; color: var(--bb-on-fill) !important; }
.bb-table td .tw-dw-btn-outline.tw-dw-btn-warning { border-color: var(--bb-warning-border) !important; color: var(--bb-warning-text) !important; background: var(--bb-warning-bg) !important; }
.bb-table td .tw-dw-btn-outline.tw-dw-btn-warning:hover { background: var(--bb-yellow-600) !important; border-color: var(--bb-yellow-600) !important; color: var(--bb-on-fill) !important; }
.bb-table td .tw-dw-btn .fa, .bb-table td .tw-dw-btn .fas { font-size: var(--bb-text-sm); }

/* DataTables writes fixed pixel widths on the header cells from its first (empty) render, which can push the table wider than
   its card. Let the browser size the columns instead; columns that need a fixed width opt in with .bb-th-fixed. */
.bb-table-card:not(:has(.dataTables_scroll)) .bb-table thead th:not(.bb-th-img):not(.bb-th-fixed) { width: auto !important; }
.bb-table { table-layout: auto; }
.bb-table td:has(> .tw-dw-btn), .bb-table td:has(> button) { white-space: nowrap; }
.bb-table td .tw-dw-btn { white-space: nowrap; }

/* ---------- small panel (filter-like card) + stat cards (stock history) ---------- */
.bb-panel { background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-xl); box-shadow: var(--bb-shadow-xs); padding: var(--bb-space-16) var(--bb-space-16) var(--bb-space-2); margin-bottom: var(--bb-space-12); }
.bb-panel label { font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bb-text-muted); }
.bb-stats { display: grid; grid-template-columns: minmax(200px, 1fr) 2fr 2fr; gap: var(--bb-space-12); margin-bottom: var(--bb-space-12); }
@media (max-width: 991px) { .bb-stats { grid-template-columns: 1fr; } }
.bb-stat, .bb-stat-group { background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-xl); box-shadow: var(--bb-shadow-xs); padding: var(--bb-space-16) var(--bb-space-16); }
.bb-stat-current { display: flex; flex-direction: column; justify-content: center; gap: var(--bb-space-4); background: linear-gradient(135deg, var(--bb-primary), var(--bb-primary-hover)); border: 0; color: var(--bb-on-primary); }
.bb-stat-label { font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .9; }
.bb-stat-value { font-size: var(--bb-text-4xl); font-weight: 700; line-height: 1.1; }
.bb-stat-value small { font-size: var(--bb-text-md); font-weight: 600; opacity: .9; }
.bb-stat-sub { font-size: var(--bb-text-sm); opacity: .9; }
.bb-stat-title { display: flex; align-items: center; gap: var(--bb-space-8); margin-bottom: var(--bb-space-8); font-size: var(--bb-text-sm); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.bb-stat-group.is-in .bb-stat-title { color: var(--bb-success-text); }
.bb-stat-group.is-out .bb-stat-title { color: var(--bb-danger-text); }
.bb-stat-row { display: flex; justify-content: space-between; gap: var(--bb-space-12); padding: var(--bb-space-6) 0; border-top: 1px solid var(--bb-border); font-size: var(--bb-text-base); color: var(--bb-text-body); }
.bb-stat-row b { color: var(--bb-text); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- row action: main button + menu (products) ---------- */
.bb-actions .bb-act-main, .bb-actions .bb-act-more { display: inline-flex; align-items: center; justify-content: center; height: 32px; border: 1px solid var(--bb-border-strong); background: var(--bb-surface); color: var(--bb-text-body) !important; font-size: var(--bb-text-sm); font-weight: 600; cursor: pointer; text-decoration: none !important; transition: background .12s, color .12s, border-color .12s; }
.bb-actions .bb-act-main { gap: var(--bb-space-6); padding: 0 var(--bb-space-12); border-radius: var(--bb-radius-md) 0 0 var(--bb-radius-md); }
.bb-actions .bb-act-more { width: 32px; margin-left: -1px; border-radius: 0 var(--bb-radius-md) var(--bb-radius-md) 0; font-size: var(--bb-text-sm); }
.bb-actions .bb-act-main:hover, .bb-actions .bb-act-more:hover, .bb-actions.open > .bb-act-more { background: var(--bb-surface-hover); border-color: var(--bb-border-darker); color: var(--bb-text) !important; }
.bb-actions .dropdown-menu { min-width: 230px; }
.bb-actions .dropdown-menu > .divider { margin: var(--bb-space-6) var(--bb-space-4); background: var(--bb-surface-raised); }
.bb-actions .dropdown-menu > li > a.bb-menu-danger, .bb-actions .dropdown-menu > li > a.bb-menu-danger i { color: var(--bb-danger-text); }
.bb-actions .dropdown-menu > li > a.bb-menu-danger:hover { background: var(--bb-danger-bg); color: var(--bb-danger-text); }
/* Delete stays red in every row menu: the generic table-menu rules (.bb-table td .btn-group .dropdown-menu > li > a) are more specific */
.dropdown-menu > li > a.bb-menu-danger, .dropdown-menu > li > a.bb-menu-danger i { color: var(--bb-danger-text) !important; }
.dropdown-menu > li > a.bb-menu-danger:hover, .dropdown-menu > li > a.bb-menu-danger:focus { background: var(--bb-danger-bg) !important; }
.bb-actions .dropdown-menu > li > a.bb-menu-ok, .bb-actions .dropdown-menu > li > a.bb-menu-ok i { color: var(--bb-success-text); }
.bb-actions .dropdown-menu > li > a.bb-menu-ok:hover { background: var(--bb-success-bg); color: var(--bb-success-text); }

/* ---------- checkboxes + selection ---------- */
.bb-table input[type=checkbox], .bb-filters-more input[type=checkbox] {
    -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin: 0; vertical-align: middle; cursor: pointer;
    border: 1.5px solid var(--bb-border); border-radius: var(--bb-radius-sm); background: var(--bb-surface); position: relative; transition: background .12s, border-color .12s, box-shadow .12s;
}
.bb-table input[type=checkbox]:hover { border-color: var(--bb-primary); }
.bb-table input[type=checkbox]:focus-visible { outline: 0; box-shadow: var(--bb-shadow-ring); }
.bb-table input[type=checkbox]:checked, .bb-table input[type=checkbox]:indeterminate { background-color: var(--bb-primary); border-color: var(--bb-primary); }
.bb-table input[type=checkbox]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-6.5'/%3E%3C/svg%3E"); background-size: 100% 100%; }
.bb-table input[type=checkbox]:indeterminate { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M4 8h8'/%3E%3C/svg%3E"); background-size: 100% 100%; }
.bb-table td:first-child, .bb-table th:first-child { }
.bb-sel { display: inline-flex; align-items: center; gap: var(--bb-space-6); height: 36px; padding: 0 var(--bb-space-6) 0 var(--bb-space-12); border-radius: var(--bb-radius-lg); background: var(--bb-primary-tint); color: var(--bb-primary-text); font-size: var(--bb-text-sm); font-weight: 600; }
.bb-sel[hidden] { display: none !important; }
.bb-sel-clear { height: 24px; padding: 0 var(--bb-space-8); border: 0; border-radius: var(--bb-radius-md); background: transparent; color: var(--bb-primary-text); font-size: var(--bb-text-sm); font-weight: 700; text-decoration: underline; cursor: pointer; }
.bb-sel-clear:hover { background: color-mix(in srgb, var(--bb-surface) 60%, transparent); }
/* bulk-action bar: only while rows are selected */
.bb-table-card:not(.has-selection) tfoot:has(.bb-bulk-bar), .bb-table-card:not(.has-selection) .dataTables_scrollFoot:has(.bb-bulk-bar) { display: none; }
.bb-table-card.has-selection tfoot:has(.bb-bulk-bar) td, .bb-table-card.has-selection .dataTables_scrollFoot:has(.bb-bulk-bar) td { background: var(--bb-primary-wash); border-top: 1px solid var(--bb-primary-border) !important; }
.bb-bulk-bar .bb-bulk-count { color: var(--bb-primary-text); margin-left: var(--bb-space-2); }
/* while rows are selected the bar floats at the bottom of the window, so a long list need not be scrolled to its end */
.bb-table-card.has-selection .bb-bulk-bar { position: fixed; left: 50%; bottom: 48px; transform: translateX(-50%); z-index: 1040; max-width: calc(100vw - 32px); padding: var(--bb-space-8) var(--bb-space-16) !important; border-radius: var(--bb-radius-lg); background: var(--bb-surface); border: 1px solid var(--bb-primary-border); box-shadow: var(--bb-shadow-lg); }
.bb-table-card.has-selection tfoot:has(.bb-bulk-bar) td, .bb-table-card.has-selection .dataTables_scrollFoot:has(.bb-bulk-bar) td { padding: 0 !important; height: 0; border: 0 !important; background: transparent; }

/* selected rows: soft brand tint (overrides the old DataTables inset box-shadow selection colour) */
.bb-table tbody tr.selected > td, .bb-table tbody tr.selected > th, .bb-table tbody tr.selected:hover > td {
    box-shadow: none !important; background-color: var(--bb-primary-glow) !important; color: inherit !important;
}
/* stylelint-disable-next-line scale-unlimited/declaration-strict-value -- one-off edge accent */
.bb-table tbody tr.selected > td:first-child { box-shadow: var(--bb-shadow-inset-edge) !important; }
.bb-table tbody tr.selected, .bb-table tbody tr.selected:hover { background: transparent !important; }
.bb-table tbody tr.selected > td, .bb-table tbody tr.selected:hover > td { background-color: var(--bb-primary-tint) !important; }

/* ---------- generic cell patterns used across the app's tables ---------- */
/* status labels (payment status, shipping status ...) become tinted pills */
.bb-table .bb-badge-pill { display: inline-flex; align-items: center; gap: var(--bb-space-6); padding: var(--bb-space-4) var(--bb-space-8); border-radius: var(--bb-radius-full); font-size: var(--bb-text-xs); font-weight: 600; line-height: 1.4; color: var(--bb-text-body) !important; background: var(--bb-surface-raised) !important; border: 0; text-shadow: none; white-space: nowrap; }
.bb-table .bb-badge-pill.bg-green, .bb-table .bb-badge-pill.bg-success { color: var(--bb-success-text) !important; background: var(--bb-success-bg) !important; }
.bb-table .bb-badge-pill.bg-yellow, .bb-table .bb-badge-pill.bg-orange, .bb-table .bb-badge-pill.bg-warning { color: var(--bb-warning-text) !important; background: var(--bb-warning-bg) !important; }
.bb-table .bb-badge-pill.bg-red, .bb-table .bb-badge-pill.bg-danger, .bb-table .bb-badge-pill.label-danger { color: var(--bb-danger-text) !important; background: var(--bb-danger-bg) !important; }
.bb-table .bb-badge-pill.bg-info, .bb-table .bb-badge-pill.bg-aqua, .bb-table .bb-badge-pill.bg-light-blue, .bb-table .bb-badge-pill.bg-blue { color: var(--bb-primary-text) !important; background: var(--bb-primary-tint) !important; }
.bb-table .bb-badge-pill.label-round { padding: var(--bb-space-4) var(--bb-space-8); }
.bb-table td a:has(> .bb-badge-pill) { text-decoration: none; }

/* controller-generated "Actions" dropdown (button-group + caret): compact brand pill, same menu style as the product menu */
.bb-table td .btn-group > .tw-dw-btn.dropdown-toggle { height: 32px; min-height: 32px; padding: 0 var(--bb-space-12); border-radius: var(--bb-radius-md); border: 1px solid var(--bb-border-strong) !important; background: var(--bb-surface) !important; color: var(--bb-text-body) !important; font-size: var(--bb-text-sm); font-weight: 600; gap: var(--bb-space-6); box-shadow: none; }
.bb-table td .btn-group > .tw-dw-btn.dropdown-toggle:hover, .bb-table td .btn-group.open > .tw-dw-btn.dropdown-toggle { background: var(--bb-surface-hover) !important; border-color: var(--bb-border-darker) !important; color: var(--bb-text) !important; }
.bb-table td .btn-group .dropdown-menu { border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); box-shadow: var(--bb-shadow-lg); padding: var(--bb-space-6); min-width: 220px; }
.bb-table td .btn-group .dropdown-menu > li > a { border-radius: var(--bb-radius-md); padding: var(--bb-space-8) var(--bb-space-12); font-size: var(--bb-text-base); color: var(--bb-text-body); }
.bb-table td .btn-group .dropdown-menu > li > a:hover { background: var(--bb-primary-glow); color: var(--bb-primary-text); }
.bb-table td .btn-group .dropdown-menu > li > a i { width: 18px; color: var(--bb-primary-text); }
.bb-table td .btn-group .dropdown-menu > li > a.delete-sale, .bb-table td .btn-group .dropdown-menu > li > a.delete-sale i, .bb-table td .btn-group .dropdown-menu > li > a.delete_purchase, .bb-table td .btn-group .dropdown-menu > li > a.delete_purchase i { color: var(--bb-danger-text); }
.bb-table td .btn-group .dropdown-menu > .divider { margin: var(--bb-space-6) var(--bb-space-4); background: var(--bb-surface-raised); }

/* totals row in the footer */
.bb-table tfoot tr.footer-total td, .bb-table-card .dataTables_scrollFoot tr.footer-total td { background: var(--bb-surface-raised) !important; border-top: 1px solid var(--bb-border) !important; color: var(--bb-text); font-size: var(--bb-text-base) !important; font-weight: 700; padding: var(--bb-space-12) var(--bb-space-16) !important; text-align: left !important; white-space: nowrap; }
.bb-table-card .dataTables_scrollFoot { background: var(--bb-surface-raised); }

/* numbers read better when tabular */
.bb-table td .final-total, .bb-table td .total-paid, .bb-table td .payment_due { font-variant-numeric: tabular-nums; }
.bb-table td .final-total { font-weight: 700; }
.bb-table td .payment_due { font-weight: 600; }

/* compact filter bar: text inputs (date range) and generic reset */
.bb-filters input.bb-control { height: 36px; border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); background: var(--bb-surface-raised); font-size: var(--bb-text-base); padding: 0 var(--bb-space-12); box-shadow: none; }
.bb-filters .bb-filter.is-active input.bb-control { background: var(--bb-primary-wash); border-color: var(--bb-primary); color: var(--bb-primary-text); font-weight: 600; }
.bb-filters label br { display: none; }
.bb-filters .checkbox, .bb-filters .checkbox label { margin: 0 !important; padding: 0; min-height: 0; }

/* plain text links directly inside cells (parent sale, invoice, contact ...) use the brand colour */
.bb-table td > a:not([class*="tw-dw-btn"]):not(.bb-act):not(.bb-act-main):not(:has(> .bb-badge-pill)) { color: var(--bb-primary-text); font-weight: 600; text-decoration: none; }
.bb-table td > a:not([class*="tw-dw-btn"]):not(.bb-act):not(.bb-act-main):not(:has(> .bb-badge-pill)):hover { color: var(--bb-primary-hover); text-decoration: underline; }

/* ---------- import pages (upload card, steps) ---------- */
.bb-import-grid { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; gap: var(--bb-space-12); margin-bottom: var(--bb-space-4); }
@media (max-width: 991px) { .bb-import-grid { grid-template-columns: 1fr; } }
.bb-panel { padding-bottom: var(--bb-space-16); }
.bb-panel-title { font-size: var(--bb-text-sm); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bb-text-muted); margin-bottom: var(--bb-space-12); }
.bb-section-title { margin: var(--bb-space-8) var(--bb-space-2) var(--bb-space-8); }
.bb-dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--bb-space-6); padding: var(--bb-space-24) var(--bb-space-16); margin: 0; border: 2px dashed var(--bb-primary-border); border-radius: var(--bb-radius-lg); background: var(--bb-primary-wash); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.bb-dropzone:hover, .bb-dropzone.has-file { border-color: var(--bb-primary); background: var(--bb-primary-tint); }
.bb-dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.bb-dropzone-icon { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--bb-radius-lg); background: var(--bb-surface); color: var(--bb-primary-text); font-size: var(--bb-text-2xl); box-shadow: var(--bb-shadow-xs); }
.bb-dropzone-title { font-size: var(--bb-text-base); font-weight: 700; color: var(--bb-text); text-transform: none; letter-spacing: 0; }
.bb-dropzone-file { text-transform: none; letter-spacing: 0; font-size: var(--bb-text-sm); color: var(--bb-text-muted); word-break: break-all; }
.bb-dropzone.has-file .bb-dropzone-file { color: var(--bb-primary-text); font-weight: 600; }
.bb-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--bb-space-12); }
.bb-steps li { display: flex; align-items: center; gap: var(--bb-space-12); padding: var(--bb-space-12) var(--bb-space-12); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); background: var(--bb-surface-raised); font-size: var(--bb-text-base); color: var(--bb-text-body); }
.bb-steps li > span { flex: 0 0 auto; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--bb-radius-circle); background: var(--bb-primary); color: var(--bb-on-primary); font-size: var(--bb-text-sm); font-weight: 700; }

/* check-filter chips: same look whether they sit on the main bar or under More */
.bb-filters .bb-chip { width: auto !important; max-width: none; padding: 0; float: none; flex: 0 0 auto; }
.bb-filters .bb-chip .bb-field { margin: 0 !important; }
.bb-filters .bb-chip label { margin: 0 !important; min-height: 0 !important; height: 36px; display: inline-flex !important; align-items: center; gap: var(--bb-space-8) !important; padding: 0 var(--bb-space-12); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); background: var(--bb-surface-raised); font-size: var(--bb-text-base); font-weight: 500; color: var(--bb-text-body); cursor: pointer; }
.bb-filters .bb-chip label strong { font-weight: 600; }
.bb-filters .bb-chip.is-active label { background: var(--bb-primary-wash); border-color: var(--bb-primary); color: var(--bb-primary-text); }
/* chip labels must stay visible (the generic rule above hides select labels) */
.bb-filters .bb-field > .bb-chip-label, .bb-filters .bb-chip .bb-field > label, .bb-filters-more .bb-field > label:has(input[type=checkbox]) { position: static !important; width: auto !important; height: 36px !important; overflow: visible !important; clip: auto !important; }

/* justified tab strips (e.g. contact detail): equal-width tabs inside the flex strip */
.bb-tabstrip.bb-tabs > .nav-tabs.nav-justified > li { display: block; flex: 1 1 0; width: auto; }
.bb-tabstrip.bb-tabs > .nav-tabs.nav-justified > li > a { justify-content: center; width: 100%; }

/* ---------- contact detail hero ---------- */
.bb-contact-switch { min-width: 280px; }
.bb-contact-switch .select2-container { width: 100% !important; }
.bb-contact-hero { background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-xl); box-shadow: var(--bb-shadow-xs); padding: var(--bb-space-20); margin-bottom: var(--bb-space-12); }
.bb-contact-main { display: flex; align-items: center; gap: var(--bb-space-16); flex-wrap: wrap; }
.bb-avatar-lg { flex: 0 0 auto; width: 64px; height: 64px; border-radius: var(--bb-radius-xl); display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--bb-primary), var(--bb-primary-hover)); color: var(--bb-on-primary); font-size: var(--bb-text-3xl); font-weight: 700; letter-spacing: .02em; }
.bb-contact-id { flex: 1 1 320px; min-width: 0; }
.bb-contact-name { margin: 0 0 var(--bb-space-6); font-size: var(--bb-text-3xl); font-weight: 700; line-height: 1.2; color: var(--bb-text); display: flex; flex-wrap: wrap; align-items: center; gap: var(--bb-space-8); }
.bb-contact-meta { display: flex; flex-wrap: wrap; gap: var(--bb-space-6) var(--bb-space-16); font-size: var(--bb-text-base); color: var(--bb-text-body); }
.bb-contact-meta span { display: inline-flex; align-items: center; gap: var(--bb-space-6); }
.bb-contact-meta i { color: var(--bb-primary-text); width: 14px; text-align: center; }
.bb-contact-actions { display: flex; gap: var(--bb-space-8); flex-wrap: wrap; margin-left: auto; }
.bb-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--bb-space-12); margin-top: var(--bb-space-16); }
.bb-kpi { display: flex; flex-direction: column; gap: var(--bb-space-4); padding: var(--bb-space-12) var(--bb-space-16); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); background: var(--bb-surface-raised); }
.bb-kpi-label { font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bb-text-muted); }
.bb-kpi-value { font-size: var(--bb-text-2xl); font-weight: 700; line-height: 1.15; color: var(--bb-text); font-variant-numeric: tabular-nums; }
.bb-kpi.is-ok { background: var(--bb-success-bg); border-color: var(--bb-success-border); }
.bb-kpi.is-ok .bb-kpi-value { color: var(--bb-success-text); }
.bb-kpi.is-out { background: var(--bb-danger-bg); border-color: var(--bb-danger-border); }
.bb-kpi.is-out .bb-kpi-value { color: var(--bb-danger-text); }
.bb-contact-more { margin-top: var(--bb-space-16); border-top: 1px solid var(--bb-border); padding-top: var(--bb-space-12); }
.bb-contact-more summary { cursor: pointer; font-size: var(--bb-text-sm); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bb-primary-text); list-style: none; display: inline-flex; align-items: center; gap: var(--bb-space-8); }
.bb-contact-more summary::-webkit-details-marker { display: none; }
.bb-contact-more[open] summary i { transform: rotate(90deg); }
.bb-contact-more summary i { font-size: var(--bb-text-xs); transition: transform .15s; }
.bb-detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--bb-space-12) var(--bb-space-20); margin-top: var(--bb-space-12); }
.bb-detail-grid div { display: flex; flex-direction: column; gap: var(--bb-space-2); }
.bb-detail-grid span { font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--bb-text-muted); }
.bb-detail-grid b { font-size: var(--bb-text-base); font-weight: 600; color: var(--bb-text); word-break: break-word; }

/* statement / report heading bars: brand colour instead of the old AdminLTE blue */
.blue-heading { background-color: var(--bb-primary-hover) !important; color: var(--bb-on-primary) !important; }
.table-pdf thead tr { background-color: var(--bb-primary-hover) !important; color: var(--bb-on-primary); }

/* ---------- ledger tab toolbar ---------- */
.bb-ledger-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--bb-space-12); padding: var(--bb-space-16) var(--bb-space-4) var(--bb-space-12); border-bottom: 1px solid var(--bb-border); margin-bottom: var(--bb-space-16); }
.bb-lt-field { display: flex; flex-direction: column; gap: var(--bb-space-4); min-width: 200px; }
.bb-lt-field.bb-lt-grow { flex: 1 1 220px; }
.bb-lt-field > label { margin: 0; font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bb-text-muted); }
.bb-lt-field .bb-control { height: 36px; border-radius: var(--bb-radius-lg); background: var(--bb-surface-raised); border: 1px solid var(--bb-border); font-size: var(--bb-text-base); box-shadow: none; }
.bb-lt-field .select2-container { width: 100% !important; }
.bb-lt-field .select2-container--default .select2-selection--single { height: 36px; border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); background: var(--bb-surface-raised); }
.bb-lt-field .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 34px; font-size: var(--bb-text-base); }
.bb-lt-field .select2-container--default .select2-selection--single .select2-selection__arrow { height: 34px; }
.bb-lt-actions { display: flex; gap: var(--bb-space-6); margin-left: auto; }
.bb-segmented { display: inline-flex; padding: var(--bb-space-4); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); background: var(--bb-surface-raised); }
.bb-segmented > .btn { height: 32px; padding: 0 var(--bb-space-12); border: 0 !important; border-radius: var(--bb-radius-md) !important; background: transparent !important; box-shadow: none !important; color: var(--bb-text-body); font-size: var(--bb-text-sm) !important; font-weight: 600; line-height: 32px; }
.bb-segmented > .btn.active { background: var(--bb-surface) !important; color: var(--bb-primary-text) !important; box-shadow: var(--bb-shadow-xs) !important; }
.bb-segmented > .btn input { position: absolute; opacity: 0; pointer-events: none; }
.bb-ledger-surface { padding: 0 var(--bb-space-4) var(--bb-space-8); }
.bb-segmented > .btn:focus, .bb-segmented > .btn:active, .bb-segmented > .btn.focus { outline: 0 !important; }

.bb-kpi.is-brand { background: linear-gradient(135deg, var(--bb-primary), var(--bb-primary-hover)); border: 0; }
.bb-kpi.is-brand .bb-kpi-label, .bb-kpi.is-brand .bb-kpi-value { color: var(--bb-on-fill); }
/* static tables inside the contact tabs: no inner scroll box, light pagination */
#contact_payments_div .pagination { margin: var(--bb-space-12) 0 0; }
.bb-kpis.bb-kpis-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 0 0 var(--bb-space-12); }
.bb-kpis .bb-kpi-value:empty::before { content: "\2014"; color: var(--bb-text-muted); }
/* labels placed directly in a filter column are only for screen readers (the label is shown inside the select) */
.bb-filters .bb-filter > label:not(.bb-chip label) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
/* filter inputs wrapped in a Bootstrap bb-igroup (date ranges): drop the addon icon, keep one rounded field */
.bb-filters .bb-igroup { display: block !important; width: 100%; }
.bb-filters .bb-iaddon { display: none !important; }
.bb-filters .bb-igroup .bb-control { float: none; width: 100%; border-radius: var(--bb-radius-lg) !important; }
.bb-filters .bb-field .bb-igroup:not(.file-caption-main) > .bb-iaddon { display: none !important; }
.bb-filters .bb-field .bb-igroup:not(.file-caption-main) > .bb-control { border-radius: var(--bb-radius-lg) !important; width: 100% !important; }

/* ---------- payment accounts: card view ---------- */
.bb-acct-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--bb-space-12); padding: var(--bb-space-16) var(--bb-space-16) 0; }
.bb-acct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: var(--bb-space-16); padding: var(--bb-space-16) var(--bb-space-16) var(--bb-space-16); }
.bb-view-table .bb-acct-grid, .bb-view-table .bb-acct-kpis { display: none; }
.bb-view-cards table.dataTable, .bb-view-cards .dataTables_scroll { display: none; }
.bb-acct-card { position: relative; display: flex; flex-direction: column; gap: var(--bb-space-12); padding: var(--bb-space-16); background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-xl); box-shadow: var(--bb-shadow-xs); transition: box-shadow .15s, border-color .15s, transform .15s; }
.bb-acct-card:hover { border-color: var(--bb-primary-border); box-shadow: var(--bb-shadow-md); transform: translateY(-1px); }
.bb-acct-card.is-closed { opacity: .72; background: var(--bb-surface-raised); }
.bb-acct-top { display: flex; align-items: center; gap: var(--bb-space-12); }
.bb-acct-icon { flex: 0 0 auto; width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--bb-radius-lg); background: linear-gradient(135deg, var(--bb-primary), var(--bb-primary-hover)); color: var(--bb-on-primary); font-size: var(--bb-text-xl); }
.bb-acct-id { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.bb-acct-id b { font-size: var(--bb-text-lg); font-weight: 700; color: var(--bb-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-acct-id span { font-size: var(--bb-text-sm); color: var(--bb-text-muted); text-transform: capitalize; }
.bb-acct-bal { display: flex; flex-direction: column; gap: var(--bb-space-2); padding: var(--bb-space-12) var(--bb-space-12); border-radius: var(--bb-radius-lg); background: var(--bb-surface-raised); }
.bb-acct-bal small { font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bb-text-muted); }
.bb-acct-bal strong { font-size: var(--bb-text-3xl); font-weight: 700; line-height: 1.15; color: var(--bb-text); font-variant-numeric: tabular-nums; }
.bb-acct-bal strong.is-pos { color: var(--bb-success-text); }
.bb-acct-bal strong.is-neg { color: var(--bb-danger-text); }
.bb-acct-meta { display: flex; flex-wrap: wrap; gap: var(--bb-space-4) var(--bb-space-16); font-size: var(--bb-text-sm); color: var(--bb-text-body); }
.bb-acct-meta i { color: var(--bb-primary-text); width: 12px; text-align: center; }
.bb-acct-note { margin: 0; font-size: var(--bb-text-sm); color: var(--bb-text-muted); line-height: 1.4; }
.bb-acct-foot { display: flex; gap: var(--bb-space-6); margin-top: auto; padding-top: var(--bb-space-4); }
.bb-card-btn { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: var(--bb-space-6); height: 36px; padding: 0 var(--bb-space-16); border: 1px solid var(--bb-border-strong); border-radius: var(--bb-radius-md); background: var(--bb-surface); color: var(--bb-text-body) !important; font-size: var(--bb-text-md); font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.bb-card-btn:hover { border-color: var(--bb-border-darker); background: var(--bb-surface-hover); color: var(--bb-text) !important; }
.bb-card-btn.is-primary { flex: 2 1 auto; background: var(--bb-primary); border-color: var(--bb-primary); color: var(--bb-on-primary) !important; }
.bb-card-btn.is-primary:hover { background: var(--bb-primary-hover); border-color: var(--bb-primary-hover); color: var(--bb-on-primary) !important; }
.bb-acct-more .dropdown-menu { min-width: 170px; padding: var(--bb-space-6); border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); box-shadow: var(--bb-shadow-lg); }
.bb-acct-menu-item { display: flex; align-items: center; gap: var(--bb-space-12); width: 100%; padding: var(--bb-space-8) var(--bb-space-12); border: 0; border-radius: var(--bb-radius-md); background: transparent; color: var(--bb-text-body) !important; font-size: var(--bb-text-base); text-align: left; cursor: pointer; }
.bb-acct-menu-item i { width: 16px; color: var(--bb-primary-text); }
.bb-acct-menu-item:hover { background: var(--bb-primary-glow); }
.bb-acct-menu-item.is-danger, .bb-acct-menu-item.is-danger i { color: var(--bb-danger-text) !important; }
.bb-acct-menu-item.is-danger:hover { background: var(--bb-danger-bg); }
.bb-acct-menu-item.is-ok, .bb-acct-menu-item.is-ok i { color: var(--bb-success-text) !important; }
.bb-acct-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: var(--bb-space-6); padding: var(--bb-space-40) var(--bb-space-16); color: var(--bb-text-muted); text-align: center; }
.bb-acct-empty i { font-size: var(--bb-text-4xl); color: var(--bb-primary-border); }
.bb-acct-empty b { color: var(--bb-text); }
.bb-view-toggle { margin-right: var(--bb-space-4); }
/* accounts page: filter bar sits right above the joined tab card, like Products */
#bb-acct-filters .bb-filters { margin-bottom: var(--bb-space-12); }
.bb-step-no { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: var(--bb-space-6); border-radius: var(--bb-radius-circle); background: var(--bb-primary); color: var(--bb-on-primary); font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: 0; }
.bb-step-card p { margin: 0 0 var(--bb-space-12); font-size: var(--bb-text-base); line-height: 1.5; }

/* ---------- sale details pop-up (sale_pos/show) ---------- */
.bb-detail { border: 0; border-radius: var(--bb-radius-xl); overflow: hidden; }
.bb-detail .modal-header { background: var(--bb-surface); border-bottom: 1px solid var(--bb-border); padding: var(--bb-space-16) var(--bb-space-20); }
.bb-detail .modal-title { font-size: var(--bb-text-lg); font-weight: 700; color: var(--bb-text); }
.bb-detail .modal-body { padding: var(--bb-space-20) var(--bb-space-20); background: var(--bb-surface); font-size: var(--bb-text-base); color: var(--bb-text-body); }
.bb-detail h4 { margin: var(--bb-space-20) 0 var(--bb-space-8); font-size: var(--bb-text-sm); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bb-primary-text); }
.bb-detail :is(.row, .tw-bs-row) > :is([class*="col-"], .bs-col) > b, .bb-detail :is(.row, .tw-bs-row) > :is([class*="col-"], .bs-col) > strong { color: var(--bb-text); }
.bb-info-card { position: relative; z-index: 0; padding-top: var(--bb-space-16) !important; padding-bottom: var(--bb-space-16) !important; padding-left: var(--bb-space-24) !important; padding-right: var(--bb-space-24) !important; line-height: 1.75; margin-bottom: var(--bb-space-12); }
.bb-info-card::before { content: ""; position: absolute; top: 0; bottom: 0; left: 7px; right: 7px; background: var(--bb-surface-raised); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); z-index: -1; }
.bb-detail .table > thead > tr > th { background: var(--bb-surface-raised); border-bottom: 1px solid var(--bb-border) !important; font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--bb-text-muted); padding: var(--bb-space-8) var(--bb-space-12); }
.bb-detail .table > tbody > tr > td, .bb-detail .table > tbody > tr > th { border-top: 1px solid var(--bb-border); padding: var(--bb-space-8) var(--bb-space-12); vertical-align: middle; }
.bb-detail .table-striped > tbody > tr:nth-of-type(odd) > td { background: var(--bb-primary-tint); }
.bb-detail table.bb-sum-table { border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); overflow: hidden; background: var(--bb-surface); }
.bb-detail table.bb-sum-table > tbody > tr > td, .bb-detail table.bb-sum-table > tbody > tr > th { background: transparent; }
.bb-detail table.bb-sum-table > tbody > tr:last-child > td, .bb-detail table.bb-sum-table > tbody > tr:last-child > th { font-weight: 700; }
.bb-detail .bb-note { background: var(--bb-primary-tint); border: 1px solid var(--bb-primary-border); border-radius: var(--bb-radius-lg); color: var(--bb-text-body); box-shadow: none; }
.bb-detail .bb-badge-pill { display: inline-flex; align-items: center; padding: var(--bb-space-4) var(--bb-space-8); border-radius: var(--bb-radius-full); font-size: var(--bb-text-xs); font-weight: 600; line-height: 1.4; color: var(--bb-text-body) !important; background: var(--bb-surface-raised) !important; border: 0; text-shadow: none; }
.bb-detail .bb-badge-pill.bg-green, .bb-detail .bb-badge-pill.bg-success { color: var(--bb-success-text) !important; background: var(--bb-success-bg) !important; }
.bb-detail .bb-badge-pill.bg-yellow, .bb-detail .bb-badge-pill.bg-orange, .bb-detail .bb-badge-pill.bg-warning { color: var(--bb-warning-text) !important; background: var(--bb-warning-bg) !important; }
.bb-detail .bb-badge-pill.bg-red, .bb-detail .bb-badge-pill.bg-danger { color: var(--bb-danger-text) !important; background: var(--bb-danger-bg) !important; }
.bb-detail .bb-badge-pill.bg-info, .bb-detail .bb-badge-pill.bg-aqua, .bb-detail .bb-badge-pill.bg-light-blue, .bb-detail .bb-badge-pill.bg-blue { color: var(--bb-primary-text) !important; background: var(--bb-primary-tint) !important; }
.bb-detail .modal-footer { background: var(--bb-surface-raised); border-top: 1px solid var(--bb-border); padding: var(--bb-space-12) var(--bb-space-20); }
.bb-detail .modal-footer .tw-dw-btn { height: 36px; min-height: 36px; border-radius: var(--bb-radius-lg); font-size: var(--bb-text-base); font-weight: 600; box-shadow: none; }
.bb-detail .modal-footer .tw-dw-btn-primary { background: var(--bb-primary) !important; border: 1px solid var(--bb-primary) !important; color: var(--bb-on-primary) !important; }
.bb-detail .modal-footer .tw-dw-btn-neutral { background: var(--bb-surface) !important; border: 1px solid var(--bb-border) !important; color: var(--bb-text-body) !important; }
@media print { .bb-info-card::before { border-color: var(--bb-border-strong); } }
/* line-item table inside the pop-up (shared partial adds the old grey utility classes) */
.bb-detail table.bg-gray { background: var(--bb-surface) !important; border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); overflow: hidden; }
.bb-detail table tr.bg-green, .bb-detail table tr.bg-gray { background: transparent !important; }
.bb-detail table tr.bg-green > td, .bb-detail table tr.bg-gray > td { background: transparent !important; color: inherit !important; }

/* ---------- Add / Edit sale forms (scoped; markup and ids are untouched) ---------- */
:is(#add_sell_form, #edit_sell_form) .bb-sheet, :is(#add_sell_form, #edit_sell_form) .tw-bg-white { border-radius: var(--bb-radius-xl); }
:is(#add_sell_form, #edit_sell_form) .bb-field { margin-bottom: var(--bb-space-16); }
:is(#add_sell_form, #edit_sell_form) label { font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--bb-text-muted); margin-bottom: var(--bb-space-6); }
:is(#add_sell_form, #edit_sell_form) label small, :is(#add_sell_form, #edit_sell_form) label .text-muted { text-transform: none; letter-spacing: 0; }
:is(#add_sell_form, #edit_sell_form) .bb-control:not(textarea):not([multiple]) { height: 38px; border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); background: var(--bb-surface-raised); font-size: var(--bb-text-base); box-shadow: none; }
:is(#add_sell_form, #edit_sell_form) textarea.bb-control { border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); background: var(--bb-surface-raised); font-size: var(--bb-text-base); box-shadow: none; }
:is(#add_sell_form, #edit_sell_form) .select2-container--default .select2-selection--single { height: 38px; border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); background: var(--bb-surface-raised); }
:is(#add_sell_form, #edit_sell_form) .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 36px; font-size: var(--bb-text-base); }
:is(#add_sell_form, #edit_sell_form) .select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; }
:is(#add_sell_form, #edit_sell_form) .bb-iaddon { background: var(--bb-primary-wash); border: 1px solid var(--bb-border); color: var(--bb-primary-text); border-radius: var(--bb-radius-lg) 0 0 var(--bb-radius-lg); min-width: 38px; }
:is(#add_sell_form, #edit_sell_form) .bb-iaddon:last-child { border-radius: 0 var(--bb-radius-lg) var(--bb-radius-lg) 0; }
:is(#add_sell_form, #edit_sell_form) .bb-igroup .bb-control:not(:first-child):not(:last-child) { border-radius: 0; }
:is(#add_sell_form, #edit_sell_form) .bb-igroup .bb-control:first-child { border-radius: var(--bb-radius-lg) 0 0 var(--bb-radius-lg); }
:is(#add_sell_form, #edit_sell_form) .bb-igroup .bb-control:last-child { border-radius: 0 var(--bb-radius-lg) var(--bb-radius-lg) 0; }
:is(#add_sell_form, #edit_sell_form) .bb-igroup .select2-container--default .select2-selection--single { border-radius: 0; }
/* product table */
:is(#add_sell_form, #edit_sell_form) #pos_table { border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); overflow: hidden; border-collapse: separate; border-spacing: 0; }
:is(#add_sell_form, #edit_sell_form) #pos_table > thead > tr > th { background: var(--bb-surface-raised); border: 0 !important; border-bottom: 1px solid var(--bb-border) !important; font-size: var(--bb-text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bb-text-muted); padding: var(--bb-space-12) var(--bb-space-8); }
:is(#add_sell_form, #edit_sell_form) #pos_table > tbody > tr > td { border: 0 !important; border-top: 1px solid var(--bb-border) !important; padding: var(--bb-space-8); vertical-align: middle; background: var(--bb-surface) !important; }
:is(#add_sell_form, #edit_sell_form) .table-bordered { border-color: var(--bb-border); }
/* item search + totals */
:is(#add_sell_form, #edit_sell_form) #search_product { border-radius: var(--bb-radius-lg) !important; height: 40px; }
:is(#add_sell_form, #edit_sell_form) .pos_product_div, :is(#add_sell_form, #edit_sell_form) .pos_form_totals { font-variant-numeric: tabular-nums; }
:is(#add_sell_form, #edit_sell_form) b, :is(#add_sell_form, #edit_sell_form) strong { color: var(--bb-text); }
/* actions */
:is(#add_sell_form, #edit_sell_form) .tw-dw-btn-lg { height: 44px; min-height: 44px; border-radius: var(--bb-radius-lg); padding: 0 var(--bb-space-24); font-size: var(--bb-text-md); font-weight: 700; box-shadow: none; }
:is(#add_sell_form, #edit_sell_form) .tw-dw-btn-primary { background: var(--bb-primary) !important; border-color: var(--bb-primary) !important; color: var(--bb-on-primary) !important; }
:is(#add_sell_form, #edit_sell_form) .tw-dw-btn-success { background: var(--bb-surface) !important; border: 1px solid var(--bb-primary-border) !important; color: var(--bb-primary-text) !important; }
:is(#add_sell_form, #edit_sell_form) .tw-dw-btn-success:hover { background: var(--bb-primary-wash) !important; }
/* business-location picker above the sale forms (it sits outside the form element) */
#select_location_id { height: 38px; border-radius: 0; border: 1px solid var(--bb-border); background: var(--bb-surface-raised); font-size: var(--bb-text-base); box-shadow: none; }
.bb-igroup:has(> #select_location_id) { max-width: 360px; }
.bb-igroup:has(> #select_location_id) > .bb-iaddon { background: var(--bb-primary-wash); border: 1px solid var(--bb-border); color: var(--bb-primary-text); min-width: 38px; }
.bb-igroup:has(> #select_location_id) > .bb-iaddon:first-child { border-radius: var(--bb-radius-lg) 0 0 var(--bb-radius-lg); }
.bb-igroup:has(> #select_location_id) > .bb-iaddon:last-child { border-radius: 0 var(--bb-radius-lg) var(--bb-radius-lg) 0; }

/* POS header date chip: brand colour instead of the old purple */
.tw-bg-\[\#646EE4\] { background-color: var(--bb-primary-hover) !important; }

/* a table card that sits inside another card (panel, tab box): no second frame */
.bb-table-card.bb-flat { border: 0; border-radius: 0; box-shadow: none; background: transparent; }

/* one shape for every row-action button, whatever its colour class */
.bb-table td .tw-dw-btn-xs, .bb-table td .btn-xs, .bb-table td a.btn-sm, .bb-table td button.btn-sm {
    display: inline-flex; align-items: center; justify-content: center; height: 30px; min-height: 30px; padding: 0 var(--bb-space-12);
    border-radius: var(--bb-radius-md); font-size: var(--bb-text-sm); font-weight: 600; gap: var(--bb-space-6); line-height: 1; box-shadow: none; white-space: nowrap; width: auto;
    margin: 0 var(--bb-space-2) var(--bb-space-2) 0; text-decoration: none !important; transition: background .12s, color .12s, border-color .12s;
}
.bb-table td .tw-dw-btn-outline.tw-dw-btn-accent, .bb-table td .tw-dw-btn-outline.tw-dw-btn-secondary,
.bb-table td .tw-dw-btn-outline.tw-dw-btn-info, .bb-table td .btn-xs.btn-primary, .bb-table td .btn-xs.btn-info, .bb-table td .btn-xs.btn-default {
    border: 1px solid var(--bb-primary-border) !important; color: var(--bb-primary-text) !important; background: var(--bb-primary-wash) !important;
}
.bb-table td .tw-dw-btn-outline.tw-dw-btn-accent:hover, .bb-table td .tw-dw-btn-outline.tw-dw-btn-secondary:hover,
.bb-table td .btn-xs.btn-primary:hover, .bb-table td .btn-xs.btn-info:hover, .bb-table td .btn-xs.btn-default:hover {
    background: var(--bb-primary) !important; border-color: var(--bb-primary) !important; color: var(--bb-on-primary) !important;
}
.bb-table td .btn-xs.btn-danger { border: 1px solid var(--bb-danger-border) !important; color: var(--bb-danger-text) !important; background: var(--bb-danger-bg) !important; }
.bb-table td .btn-xs.btn-danger:hover { background: var(--bb-red-600) !important; border-color: var(--bb-red-600) !important; color: var(--bb-on-fill) !important; }
.bb-table td .tw-dw-btn-xs[disabled], .bb-table td .btn-xs[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.bb-table td .tw-dw-btn-xs.tw-w-max { width: auto !important; }
.bb-table-card { overflow-x: auto; }
/* the card markup also carries Tailwind tw-overflow-hidden, which beat the rule above and clipped wide tables; scroll instead */
.bb-table-card.tw-overflow-hidden { overflow-x: auto; }
.bb-sec-head { display: flex; align-items: center; justify-content: space-between; gap: var(--bb-space-12); margin: var(--bb-space-4) 0 var(--bb-space-12); }
.bb-sec-head .bb-panel-title { margin: 0; }
.bb-sec-head:empty { display: none; }
.bb-sec-tools, .bb-sec-tools .bb-head-tools { display: inline-flex; align-items: center; gap: var(--bb-space-8); flex-wrap: wrap; justify-content: flex-end; float: none; margin: 0; padding: 0; }
.bb-sec-tools .tw-float-right, .bb-sec-tools .pull-right, .bb-sec-tools .m-5 { float: none !important; margin: 0 !important; }
.bb-sec-tools .btn, .bb-sec-tools a.tw-dw-btn, .bb-sec-tools button.tw-dw-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--bb-space-6); width: auto !important; height: 36px; padding: 0 var(--bb-space-16) !important; border-radius: var(--bb-radius-lg); font-size: var(--bb-text-base); font-weight: 600; line-height: 1; text-decoration: none; }
.bb-sec-tools .btn[class*="bg-primary"], .bb-sec-tools .btn-primary, .bb-sec-tools .tw-dw-btn-primary { background: var(--bb-primary) !important; border: 1px solid var(--bb-primary) !important; color: var(--bb-on-primary) !important; }
.bb-sec-tools .btn[class*="bg-primary"]:hover, .bb-sec-tools .btn-primary:hover, .bb-sec-tools .tw-dw-btn-primary:hover { background: var(--bb-primary-hover) !important; border-color: var(--bb-primary-hover) !important; }
.bb-sec-tools .btn[class*="sky-"], .bb-sec-tools .btn-default, .bb-sec-tools .btn-info { background: var(--bb-surface) !important; border: 1px solid var(--bb-border) !important; color: var(--bb-text-body) !important; }
.bb-sec-tools .btn-group-toggle .btn.active, .bb-sec-tools .btn-group .btn.active { background: var(--bb-primary-wash) !important; border-color: var(--bb-primary-border) !important; color: var(--bb-primary-text) !important; }
.bb-sec-tools .btn-group { display: inline-flex; }
.bb-table-card + .bb-sec-head, .bb-table-card + .bb-panel-title { margin-top: var(--bb-space-24); }
/* Accounting boxes: table boxes are unframed (the table card is the frame); others become a plain card */
.bb-acc-card { margin-bottom: var(--bb-space-16); }
.bb-acc-card:not(:has(.bb-table-card)) { background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-xl); padding: var(--bb-space-16); box-shadow: var(--bb-shadow-xs); }
.bb-acc-card:not(:has(.bb-table-card)) > .bb-sec-head { margin-top: 0; }
.bb-acc-card .content, .bb-acc-card .card, .bb-acc-card .card-body { padding: 0; margin: 0; border: 0; box-shadow: none; background: transparent; }
.bb-acc-foot { margin-top: var(--bb-space-12); }
:is(.row, .tw-bs-row) > .bb-acc-card { margin-left: var(--bb-space-8); margin-right: var(--bb-space-8); } /* undoes the row bleed, so the box sits on the page gutter */
@media (max-width: 640px) { :is(.row, .tw-bs-row) > .bb-acc-card { margin-left: var(--bb-page-gutter); margin-right: var(--bb-page-gutter); } }
.bb-acc-card .bb-sec-head { margin-top: 0; }

/* AdminLTE small-boxes (module dashboards) re-skinned as soft stat cards */
.bb-tile, .bb-tile.bg-red, .bb-tile.bg-aqua, .bb-tile.bg-green, .bb-tile.bg-yellow, .bb-tile.bg-blue, .bb-tile.bg-light-blue, .bb-tile.bg-orange {
    position: relative; overflow: hidden; background: var(--bb-surface) !important; color: var(--bb-text) !important;
    border: 1px solid var(--bb-border); border-left: 4px solid var(--bb-primary); border-radius: var(--bb-radius-xl);
    box-shadow: var(--bb-shadow-xs); margin-bottom: var(--bb-space-16);
}
.bb-tile > .bb-tile-inner { padding: var(--bb-space-16) var(--bb-space-16) var(--bb-space-12); }
.bb-tile h3, .bb-tile h4, .bb-tile h3 span, .bb-tile h4 span, .bb-tile h4 strong { color: var(--bb-text) !important; font-size: var(--bb-text-3xl); font-weight: 700; margin: 0 0 var(--bb-space-2); }
.bb-tile p { color: var(--bb-text-muted) !important; font-size: var(--bb-text-sm); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin: 0; }
.bb-tile .bb-tile-icon, .bb-tile:hover .bb-tile-icon { color: var(--bb-primary-wash) !important; font-size: var(--bb-text-5xl); top: 8px; right: 12px; }
.bb-tile > .bb-tile-foot, .bb-tile > .bb-tile-foot:hover { background: var(--bb-primary-wash) !important; color: var(--bb-primary-text) !important; font-size: var(--bb-text-sm); font-weight: 600; padding: var(--bb-space-8) var(--bb-space-12); border-top: 1px solid var(--bb-primary-border); }
.bb-tile h3, .bb-tile h4, .bb-tile h3 *, .bb-tile h4 * { font-family: inherit !important; }
/* tab panes that start with a lone Add button row (Repair job sheets / invoices etc.) */
.bb-tabs .tab-pane > :is(.row, .tw-bs-row):first-child:has(> :is([class*="col-"], .bs-col) > a.tw-dw-btn, > :is([class*="col-"], .bs-col) > button.tw-dw-btn) {
    margin: 0; padding: var(--bb-space-12) var(--bb-space-12); background: var(--bb-surface); border: 1px solid var(--bb-border); border-top: 0; display: flex; justify-content: flex-end;
}
.bb-tabs .tab-pane > :is(.row, .tw-bs-row):first-child > :is([class*="col-"], .bs-col) { width: auto; float: none; padding: 0; }
.bb-tabs .tab-pane > :is(.row, .tw-bs-row):first-child .tw-dw-btn { display: inline-flex; align-items: center; gap: var(--bb-space-6); height: 36px; min-height: 36px; padding: 0 var(--bb-space-16); border-radius: var(--bb-radius-lg); font-size: var(--bb-text-base); float: none !important; margin: 0 !important; background: var(--bb-primary); border-color: var(--bb-primary); color: var(--bb-on-primary); }
.bb-tabs .tab-pane > :is(.row, .tw-bs-row):first-child .tw-dw-btn svg { width: 16px; height: 16px; }
.bb-tabs .tab-pane > :is(.row, .tw-bs-row):first-child .mb-12, .bb-tabs .tab-pane > :is(.row, .tw-bs-row):first-child > :is([class*="col-"], .bs-col) { margin: 0 !important; padding: 0 !important; min-height: 0; }

/* Bootstrap-coloured buttons on pages and in pop-ups share one palette:
   primary = solid brand, success/info/warning/default = soft brand outline, danger = soft red */
:is(.content, .modal-content) .btn:not(.tw-dw-btn):not(.close):not(.btn-link):not(.btn-group-toggle .btn) { border-radius: var(--bb-radius-lg); font-weight: 600; box-shadow: none; }
:is(.content, .modal-content) .btn-primary, :is(.content, .modal-content) .btn-primary:focus { background: var(--bb-primary) !important; border: 1px solid var(--bb-primary) !important; color: var(--bb-on-primary) !important; }
:is(.content, .modal-content) .btn-primary:hover, :is(.content, .modal-content) .btn-primary:active { background: var(--bb-primary-hover) !important; border-color: var(--bb-primary-hover) !important; }
:is(.content, .modal-content) :is(.btn-success, .btn-info, .btn-warning) { background: var(--bb-primary-wash) !important; border: 1px solid var(--bb-primary-border) !important; color: var(--bb-primary-text) !important; }
:is(.content, .modal-content) :is(.btn-success, .btn-info, .btn-warning):hover { background: var(--bb-primary) !important; border-color: var(--bb-primary) !important; color: var(--bb-on-primary) !important; }
:is(.content, .modal-content) .btn-default { background: var(--bb-surface) !important; border: 1px solid var(--bb-border) !important; color: var(--bb-text-body) !important; }
:is(.content, .modal-content) .btn-default:hover { background: var(--bb-surface-raised) !important; border-color: var(--bb-border) !important; }
:is(.content, .modal-content) .btn-danger { background: var(--bb-danger-bg) !important; border: 1px solid var(--bb-danger-border) !important; color: var(--bb-danger-text) !important; }
:is(.content, .modal-content) .btn-danger:hover { background: var(--bb-red-600) !important; border-color: var(--bb-red-600) !important; color: var(--bb-on-fill) !important; }

/* Tailwind-coloured buttons (green / sky / yellow solid) follow the same palette as Bootstrap ones */
:is(.content, .modal-content) :is(.btn, a.btn, button.btn):is([class*="tw-bg-green-5"], [class*="tw-bg-green-6"], [class*="tw-bg-green-7"], [class*="tw-bg-sky-5"], [class*="tw-bg-sky-6"], [class*="tw-bg-yellow-5"], [class*="tw-bg-yellow-6"]) {
    background: var(--bb-primary-wash) !important; border: 1px solid var(--bb-primary-border) !important; color: var(--bb-primary-text) !important; border-radius: var(--bb-radius-lg); font-weight: 600;
}
:is(.content, .modal-content) :is(.btn, a.btn, button.btn):is([class*="tw-bg-green-5"], [class*="tw-bg-green-6"], [class*="tw-bg-green-7"], [class*="tw-bg-sky-5"], [class*="tw-bg-sky-6"], [class*="tw-bg-yellow-5"], [class*="tw-bg-yellow-6"]):hover {
    background: var(--bb-primary) !important; border-color: var(--bb-primary) !important; color: var(--bb-on-primary) !important;
}
:is(.content, .modal-content) :is(.btn, a.btn, button.btn):is([class*="tw-bg-red-5"], [class*="tw-bg-red-6"], [class*="tw-bg-red-7"]) { background: var(--bb-danger-bg) !important; border: 1px solid var(--bb-danger-border) !important; color: var(--bb-danger-text) !important; border-radius: var(--bb-radius-lg); font-weight: 600; }
:is(.content, .modal-content) :is(.btn, a.btn, button.btn):is([class*="tw-bg-red-5"], [class*="tw-bg-red-6"], [class*="tw-bg-red-7"]):hover { background: var(--bb-red-600) !important; border-color: var(--bb-red-600) !important; color: var(--bb-on-fill) !important; }
/* info-box icons (CRM / HMS dashboards) in the brand tint */
.bb-iconstat-icon, .bb-iconstat-icon.bg-aqua, .bb-iconstat-icon.bg-yellow, .bb-iconstat-icon.bg-green, .bb-iconstat-icon.bg-red, .bb-iconstat-icon.bg-light-blue, .bb-iconstat-icon.bg-blue { background: var(--bb-primary-wash) !important; color: var(--bb-primary-text) !important; border: 1px solid var(--bb-primary-border); }

/* leftover AdminLTE colour helpers on buttons, neutral modal Close buttons, info alerts */
:is(.content, .modal-content) .btn:is(.bg-purple, .bg-navy, .bg-maroon, .bg-teal, .bg-olive, .bg-orange, .bg-aqua, .bg-light-blue) { background: var(--bb-surface) !important; border: 1px solid var(--bb-border) !important; color: var(--bb-text-body) !important; }
.modal-footer .tw-dw-btn-neutral, .modal-footer .tw-dw-btn.tw-dw-btn-neutral { background: var(--bb-surface) !important; border: 1px solid var(--bb-border) !important; color: var(--bb-text-body) !important; }
.modal-footer .tw-dw-btn-neutral:hover { background: var(--bb-surface-raised) !important; border-color: var(--bb-border) !important; }
.content .alert-info { background: var(--bb-primary-wash); border: 1px solid var(--bb-primary-border); color: var(--bb-primary-text); border-radius: var(--bb-radius-lg); }
.bb-igroup > .bb-ibtn { width: auto; flex: 0 0 auto; }

/* ── Amount columns: right aligned in header, rows and the totals row, so figures line up ───────────── */
.bb-table th.bb-num, .bb-table td.bb-num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bb-table-card .dataTables_scrollFoot tr.footer-total td.footer_purchase_total, .bb-table tfoot tr.footer-total td.footer_purchase_total,
.bb-table-card .dataTables_scrollFoot tr.footer-total td.footer_sale_total, .bb-table tfoot tr.footer-total td.footer_sale_total,
.bb-table-card .dataTables_scrollFoot tr.footer-total td.footer_total_paid, .bb-table tfoot tr.footer-total td.footer_total_paid,
.bb-table-card .dataTables_scrollFoot tr.footer-total td.footer_total_remaining, .bb-table tfoot tr.footer-total td.footer_total_remaining,
.bb-table-card .dataTables_scrollFoot tr.footer-total td.footer_total_sell_return_due, .bb-table tfoot tr.footer-total td.footer_total_sell_return_due { text-align: right !important; }
/* empty tables: a calm, centred message instead of a cramped single line */
.bb-table-card td.dataTables_empty { text-align: center !important; padding: var(--bb-space-32) var(--bb-space-16) !important; color: var(--bb-text-muted); font-size: var(--bb-text-base); font-weight: 600; }

/* compact filter bar: every control the same 36px pill, whatever markup the filter partial brings */
.bb-filters .bb-control:not(textarea) { height: 36px; padding: 0 var(--bb-space-12); border-radius: var(--bb-radius-lg); border: 1px solid var(--bb-border); background: var(--bb-surface-raised); font-size: var(--bb-text-base); color: var(--bb-text-body); box-shadow: none; }
.bb-filters .bb-control[readonly] { cursor: pointer; background: var(--bb-surface-raised); }
.bb-filters .bb-control:focus, .bb-filters .select2-container--open .select2-selection--single { border-color: var(--bb-primary); box-shadow: var(--bb-shadow-ring); background: var(--bb-surface); }
.bb-filters .select2-selection__placeholder, .bb-filters .select2-selection__rendered { color: var(--bb-text-body); }
.bb-filters .select2-container--default .select2-selection--single .select2-selection__arrow b { border-top-color: var(--bb-gray-400); }
.bb-filters-row > .bb-filter:has(.checkbox), .bb-filters-main .bb-filter:has(.checkbox) { width: auto !important; margin: 0 !important; }
.bb-filters .checkbox { margin: 0; min-height: 0; padding: 0; }
.bb-filters .checkbox label { padding-left: var(--bb-space-12) !important; }
.bb-filters label br { display: none; }
.bb-filters label [class*="icheckbox"], .bb-filters label [class*="iradio"] { margin: 0 !important; flex-shrink: 0; position: relative; top: 0; }
.bb-filters label:has(input:checked), .bb-filters label:has([class*="icheckbox"].checked) { background: var(--bb-primary-wash); border-color: var(--bb-primary); color: var(--bb-primary-text); font-weight: 600; }
.bb-filters .bb-filters-main .checkbox label { height: 36px; display: inline-flex !important; align-items: center; gap: var(--bb-space-8) !important; border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); background: var(--bb-surface-raised); font-size: var(--bb-text-base); font-weight: 500; color: var(--bb-text-body); margin: 0 !important; cursor: pointer; }

/* variation templates: values as chips */
.bb-vt-name { font-weight: 700; color: var(--bb-text); }
.bb-vals { display: flex; flex-wrap: wrap; gap: var(--bb-space-6); max-width: 560px; }
.bb-vals span { padding: var(--bb-space-2) var(--bb-space-8); border-radius: var(--bb-radius-full); background: var(--bb-surface-raised); border: 1px solid var(--bb-border); color: var(--bb-text-body); font-size: var(--bb-text-sm); font-weight: 600; }
.bb-vals span.is-more { background: var(--bb-primary-tint); border-color: var(--bb-primary-border-soft); color: var(--bb-primary-text); cursor: help; }
.bb-locked { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--bb-radius-md); color: var(--bb-text-label); cursor: help; }

/* "used by" pill + the list of products it opens */
button.bb-used-btn { border: 0; cursor: pointer; font-family: inherit; }
button.bb-used-btn i { font-size: var(--bb-text-xs); margin-left: var(--bb-space-2); }
button.bb-used-btn:hover { background: var(--bb-primary); color: var(--bb-on-primary); }
.bb-used-pop { position: absolute; z-index: 100001; width: 290px; max-height: 320px; overflow: auto; padding: var(--bb-space-6); background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-xl); box-shadow: var(--bb-shadow-lg); }
.bb-used-load { padding: var(--bb-space-12); font-size: var(--bb-text-sm); color: var(--bb-text-muted); text-align: center; }
.bb-used-list a { display: flex; flex-direction: column; gap: 1px; padding: var(--bb-space-8) var(--bb-space-12); border-radius: var(--bb-radius-md); text-decoration: none !important; }
.bb-used-list a b { font-size: var(--bb-text-base); font-weight: 600; color: var(--bb-text); }
.bb-used-list a small { font-size: var(--bb-text-xs); color: var(--bb-text-muted); }
.bb-used-list a:hover { background: var(--bb-primary-tint); }
.bb-used-list a:hover b { color: var(--bb-primary-text); }

/* categories: parents in bold, sub-categories hanging underneath */
.bb-cat { display: inline-flex; align-items: center; gap: var(--bb-space-8); }
.bb-cat b { font-weight: 700; color: var(--bb-text); }
.bb-cat-sub { padding: 1px var(--bb-space-8); border-radius: var(--bb-radius-full); background: var(--bb-surface-raised); border: 1px solid var(--bb-border); color: var(--bb-text-muted); font-size: var(--bb-text-xs); font-weight: 600; }
.bb-cat-child { padding-left: var(--bb-space-24); position: relative; color: var(--bb-text-body); font-weight: 500; }
.bb-cat-line { position: absolute; left: 6px; top: -14px; width: 10px; height: 26px; border-left: 2px solid var(--bb-border-strong); border-bottom: 2px solid var(--bb-border-strong); border-bottom-left-radius: var(--bb-radius-md); }
.bb-cat-desc { color: var(--bb-text-muted); font-size: var(--bb-text-base); }

/* brands: logo tile next to the name */
.bb-brand { display: flex; align-items: center; gap: var(--bb-space-12); }
.bb-brand b { font-weight: 700; color: var(--bb-text); }
.bb-brand-mark { width: 40px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--bb-radius-lg); overflow: hidden; background: var(--bb-surface); border: 1px solid var(--bb-border); }
.bb-brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: var(--bb-space-4); }
.bb-brand-mark.is-letter { border: 0; background: linear-gradient(135deg, var(--bb-primary-tint), color-mix(in srgb, var(--bb-accent) 30%, transparent)); color: var(--bb-primary-text); font-size: var(--bb-text-lg); font-weight: 700; }

/* categories: fold / unfold the sub-categories under each main category */
.bb-cat-toggle { width: 24px; height: 24px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: var(--bb-radius-md); background: transparent; color: var(--bb-text-muted); cursor: pointer; }
.bb-cat-toggle i { font-size: var(--bb-text-xs); transition: transform .12s; }
.bb-cat-toggle:not(.is-none):hover { background: var(--bb-primary-tint); color: var(--bb-primary-text); }
.bb-cat-toggle.is-none { cursor: default; }
#category_table tbody tr.is-parent { background: var(--bb-surface); }
#category_table tbody tr.is-child { background: var(--bb-surface-raised); }
#category_table tbody tr.bb-cat-hidden { display: none; }
.war-duration { display: grid; grid-template-columns: 1fr 1.4fr; gap: var(--bb-space-8); }
.war-duration .select2-container { width: 100% !important; }

/* category manager (tree) */
.tx-stats { display: flex; flex-wrap: wrap; gap: var(--bb-space-12); margin-bottom: var(--bb-space-12); }
.tx-stats > div { flex: 1 1 130px; max-width: 200px; padding: var(--bb-space-12) var(--bb-space-16); background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-xl); }
.tx-stats b { display: block; font-size: var(--bb-text-3xl); font-weight: 700; color: var(--bb-text); font-variant-numeric: tabular-nums; line-height: 1.15; }
.tx-stats span { font-size: var(--bb-text-sm); font-weight: 600; color: var(--bb-text-muted); }
.tx-stats .is-warn { background: var(--bb-warning-bg); border-color: var(--bb-warning-border); }
.tx-stats .is-warn b { color: var(--bb-warning-text); }
.tx-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--bb-space-12); margin-bottom: var(--bb-space-12); }
.tx-search { position: relative; flex: 1 1 280px; max-width: 420px; }
.tx-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--bb-text-label); pointer-events: none; }
.tx-search input { width: 100%; height: 40px; padding: 0 var(--bb-space-16) 0 var(--bb-space-40); border: 1px solid var(--bb-border-input); border-radius: var(--bb-radius-lg); background: var(--bb-surface); font-size: var(--bb-text-md); }
.tx-search input:focus { outline: 0; border-color: var(--bb-primary); box-shadow: var(--bb-shadow-ring); }
.tx-bar-btns { display: flex; gap: var(--bb-space-8); }
.tx-bar-btns button { height: 36px; padding: 0 var(--bb-space-12); display: inline-flex; align-items: center; gap: var(--bb-space-6); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); background: var(--bb-surface); color: var(--bb-text-muted); font-size: var(--bb-text-base); font-weight: 600; cursor: pointer; }
.tx-bar-btns button:hover { background: var(--bb-primary-tint); color: var(--bb-primary-text); border-color: var(--bb-primary-border-soft); }
.tx-list { display: grid; gap: var(--bb-space-12); }
.tx-loading, .tx-empty { padding: var(--bb-space-40) var(--bb-space-16); text-align: center; color: var(--bb-text-muted); background: var(--bb-surface); border: 1px dashed var(--bb-border-strong); border-radius: var(--bb-radius-xl); display: flex; flex-direction: column; align-items: center; gap: var(--bb-space-4); }
.tx-empty i { font-size: var(--bb-text-4xl); color: var(--bb-primary-text); opacity: .7; }
.tx-empty b { color: var(--bb-text); }
.tx-group { background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-xl); box-shadow: var(--bb-shadow-xs); overflow: hidden; }
.tx-group.is-open { border-color: var(--bb-primary-border-soft); }
.tx-row { display: flex; align-items: center; gap: var(--bb-space-12); padding: var(--bb-space-12) var(--bb-space-16); }
.tx-main { cursor: default; }
.tx-main:hover { background: var(--bb-primary-tint); }
.tx-chev { flex-shrink: 0; }
.tx-chev.is-none { display: inline-block; width: 32px; flex-shrink: 0; }
.tx-tile { width: 38px; height: 38px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--bb-radius-lg); font-size: var(--bb-text-lg); font-weight: 700; color: var(--bb-primary-text); background: linear-gradient(135deg, var(--bb-primary-tint), color-mix(in srgb, var(--bb-accent) 30%, transparent)); }
.tx-name { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.tx-name b { font-size: var(--bb-text-md); font-weight: 700; color: var(--bb-text); }
.tx-name small { font-size: var(--bb-text-sm); color: var(--bb-text-muted); font-weight: 600; }
.tx-name em { font-style: normal; font-size: var(--bb-text-sm); color: var(--bb-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 520px; }
.tx-meta { display: flex; gap: var(--bb-space-6); flex-wrap: wrap; justify-content: flex-end; }
.tx-actions { display: flex; gap: var(--bb-space-4); flex-shrink: 0; }
.tx-act span { display: none; }
@media (hover: hover) and (min-width: 900px) {
    .tx-actions .tx-act:not(.tx-add-sub) { opacity: .0; transition: opacity .12s; }
    .tx-row:hover .tx-act, .tx-act:focus-visible { opacity: 1; }
    .tx-act.tx-add-sub span { display: inline; }
}
.tx-subs { border-top: 1px solid var(--bb-border); background: var(--bb-surface-raised); padding: var(--bb-space-4) 0; }
.tx-sub { padding-left: var(--bb-space-48); position: relative; }
.tx-sub:hover { background: var(--bb-surface); }
.tx-line { position: absolute; left: 31px; top: -18px; width: 14px; height: 36px; border-left: 2px solid var(--bb-border-strong); border-bottom: 2px solid var(--bb-border-strong); border-bottom-left-radius: var(--bb-radius-md); }
.tx-sub .tx-name b { font-weight: 600; font-size: var(--bb-text-md); }
@media (max-width: 767px) { .tx-meta { display: none; } .tx-row { padding: var(--bb-space-12); } }

/* payment status: a clear coloured pill with an icon (sales, purchases and the accounting lists) */
.bb-status { display: inline-flex; align-items: center; gap: var(--bb-space-6); height: 26px; padding: 0 var(--bb-space-12) 0 var(--bb-space-8); border-radius: var(--bb-radius-full); font-size: var(--bb-text-sm); font-weight: 700; line-height: 1; white-space: nowrap; border: 1px solid transparent; }
.bb-status i { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--bb-radius-circle); font-size: var(--bb-text-xs); color: var(--bb-on-fill); }
.bb-status.is-paid { background: var(--bb-success-bg); color: var(--bb-success-text); border-color: var(--bb-success-border); }
.bb-status.is-paid i { background: var(--bb-green-500); }
.bb-status.is-partial { background: var(--bb-warning-bg); color: var(--bb-warning-text); border-color: var(--bb-warning-border); }
.bb-status.is-partial i { background: var(--bb-yellow-500); }
.bb-status.is-due { background: var(--bb-danger-bg); color: var(--bb-danger-text); border-color: var(--bb-danger-border); }
.bb-status.is-due i { background: var(--bb-red-500); }
.bb-status.is-overdue, .bb-status.is-partial-overdue { background: var(--bb-red-700); color: var(--bb-on-fill); border-color: var(--bb-red-700); }
.bb-status.is-overdue i, .bb-status.is-partial-overdue i { background: var(--bb-on-ink-a20); }
.bb-status.is-info { background: var(--bb-primary-tint); color: var(--bb-primary-text); border-color: transparent; }
.bb-status.is-info i { background: var(--bb-primary); }
a.payment-status-label:hover .bb-status { filter: brightness(.96); box-shadow: var(--bb-shadow-sm); }

/* product name / photo open the quick view */
a.bb-cell-name.view-product { color: var(--bb-text); text-decoration: none; cursor: pointer; }
a.bb-cell-name.view-product:hover { color: var(--bb-primary-text); text-decoration: underline; }
a.bb-thumb-link { display: inline-flex; cursor: pointer; }

/* sales list: customer and invoice number are links */
a.bb-link-contact, a.bb-link-invoice { color: var(--bb-text); font-weight: 600; text-decoration: none; }
a.bb-link-invoice { color: var(--bb-primary-text); font-weight: 700; }
a.bb-link-contact:hover, a.bb-link-invoice:hover { color: var(--bb-primary-hover); text-decoration: underline; }

/* ---- printing a page with a list on it (report pages' Print button, Ctrl+P) ----
   Only the table is printed: no toolbar, search, page-size or pager, and no action / checkbox / image columns
   (bb-table.js tags those cells .bb-no-print). The totals row prints once, at the end, not on every page. */
@media print {
    .dataTables_length, .dataTables_filter, .dataTables_paginate, .dataTables_processing, .dt-buttons,
    .bb-tools, .bb-bulk-bar, .bb-sel { display: none !important; }
    table.dataTable th.not-export, table.dataTable .bb-no-print { display: none !important; }
    table.dataTable tfoot { display: table-row-group; }
    .dataTables_scrollBody { overflow: visible !important; height: auto !important; max-height: none !important; }
    table.dataTable tr { break-inside: avoid; }
    /* the list's own Print view: the theme makes body 100% tall, which plus its margin added a blank page */
    html, body.dt-print-view { height: auto !important; min-height: 0 !important; }
}

/* printable copy of a pop-up (documents/print/*): hidden on screen, printed by the pop-up's Print button (bb-doc.js) */
.modal .bb-print-doc { display: none; }

/* ---------- Documents: business header on prints, A4 / A5 menu next to Print buttons (public/js/bb-doc.js) ---------- */
.bb-doc-print-hd { display: none; }
@media print {
    .bb-doc-print-hd { display: block; margin: 0 0 var(--bb-space-12); }
    /* the doc header carries the page title, so the on-screen page header is not printed twice */
    body:has(.bb-doc-print-hd) .bb-ph { display: none !important; }
    /* an old receipt left in #receipt_section is not part of a report print */
    body:has(.bb-doc-print-hd) #receipt_section { display: none !important; }
    /* the old "Business - Report" print heading on report pages, same reason */
    body:has(.bb-doc-print-hd) #scrollable-container .print_section > h2 { display: none !important; }

    /* Paper is black and grey: the brand / status colours of the screen design turn neutral when printed
       (report cards, detail pop-ups, status pills). Documents keep the business's own logo colours only. */
    :root {
        --bb-primary: var(--bb-gray-950); --bb-primary-hover: var(--bb-gray-950); --bb-primary-text: var(--bb-gray-950); --bb-accent: var(--bb-gray-600);
        --bb-primary-tint: var(--bb-gray-100); --bb-primary-pale: var(--bb-gray-100); --bb-primary-wash: var(--bb-gray-150); --bb-primary-glow: transparent;
        --bb-primary-border: var(--bb-gray-300); --bb-primary-border-soft: var(--bb-gray-250); --bb-primary-border-warm: var(--bb-gray-300);
        --bb-secondary: var(--bb-gray-800); --bb-sky: var(--bb-gray-600);
        --bb-surface-raised: var(--bb-gray-100); --bb-surface-hover: var(--bb-gray-100); --bb-background: #ffffff;
        --bb-border: var(--bb-gray-250); --bb-border-strong: var(--bb-gray-300); --bb-border-input: var(--bb-gray-300); --bb-border-darker: var(--bb-gray-300);
        --bb-text: var(--bb-gray-950); --bb-text-body: var(--bb-gray-800); --bb-text-muted: var(--bb-gray-600); --bb-text-faint: var(--bb-gray-600); --bb-text-label: var(--bb-gray-500);
        --bb-danger: var(--bb-gray-950); --bb-danger-bg: var(--bb-gray-100); --bb-danger-bg-dark: var(--bb-gray-150); --bb-danger-border: var(--bb-gray-300); --bb-danger-text: var(--bb-gray-950); --bb-danger-dark: var(--bb-gray-950);
        --bb-success: var(--bb-gray-950); --bb-success-bg: var(--bb-gray-100); --bb-info: var(--bb-gray-950); --bb-info-bg: var(--bb-gray-100); --bb-warning: var(--bb-gray-950); --bb-warning-bg: var(--bb-gray-100);
    }
    .bb-detail .sd-head { background: none !important; }
    .bb-detail .sd-kpi, .bb-detail .sd-kpi.is-main, .bb-detail .sd-kpi.is-due, .rp-kpi, .rp-card { background: var(--bb-surface) !important; border-color: var(--bb-gray-300) !important; }
    .bb-detail .sd-kpi b, .bb-detail .sd-kpi > small, .bb-detail b.is-gain, .bb-detail .sd-kpi.is-due b { color: var(--bb-gray-950) !important; }
    .bb-status, .sd-pill, .bb-badge-pill, .bb-badge-count { background: var(--bb-surface) !important; color: var(--bb-gray-950) !important; border: 0.75pt solid var(--bb-gray-400) !important; }
}
/* Print + paper size = one split button (public/js/bb-doc.js). Print first, the A4/A5 toggle joined on its right. */
.bb-pp { position: relative; display: inline-flex; align-items: stretch; gap: 0; vertical-align: middle; }
.bb-pp.bb-pp > * { order: 0 !important; margin: 0 !important; transform: none !important; box-shadow: none !important; }
.bb-pp.bb-pp > .bb-pp-toggle { order: 1 !important; }
.bb-pp.bb-pp > :first-child { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.bb-pp-toggle { display: inline-flex; align-items: center; gap: var(--bb-space-4); padding: 0 var(--bb-space-12); border: 1px solid var(--bb-border-input); border-left-width: 0;
    border-radius: 0 var(--bb-radius-md) var(--bb-radius-md) 0; background: var(--bb-surface); color: var(--bb-text); font-size: var(--bb-text-sm); font-weight: 600; cursor: pointer; }
.bb-pp-toggle:hover { background: var(--bb-surface-hover); }
.bb-pp-primary .bb-pp-toggle { background: var(--bb-primary); border-color: var(--bb-primary); color: var(--bb-on-primary);
    border-left: 1px solid color-mix(in srgb, var(--bb-on-fill) 35%, transparent); }
.bb-pp-primary .bb-pp-toggle:hover { background: var(--bb-primary-hover); }
/* the primary action stays last in a pop-up footer, after Close */
.modal-footer .bb-pp { order: 2; }
.bb-pp-menu { display: none; position: fixed; z-index: 2000; min-width: 130px; padding: var(--bb-space-4);
    background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); box-shadow: var(--bb-shadow-md); }
.bb-pp-menu.open { display: flex; flex-direction: column; color: var(--bb-text); }
.bb-pp-menu button { all: unset; box-sizing: border-box; padding: var(--bb-space-6) var(--bb-space-12); border-radius: var(--bb-radius-md); font-size: var(--bb-text-base); font-weight: 600; cursor: pointer; white-space: nowrap; }
.bb-pp-menu button:hover { background: var(--bb-primary-tint); color: var(--bb-primary-text); }

/* ---------- Report pages printed (html.bb-rprint is set by bb-doc.js while printing) ----------
   Same look as the documents: flat boxes instead of screen cards, compact grey-header tables that fit the page width
   (text wraps, money does not), no sort arrows / pagers / links. */
@media print {
    html.bb-rprint #scrollable-container, html.bb-rprint section.content { padding: 0 !important; margin: 0 !important; }
    html.bb-rprint #scrollable-container :is(.row, .tw-bs-row) { margin-left: 0 !important; margin-right: 0 !important; }
    html.bb-rprint #scrollable-container :is([class*="col-"], .bs-col) { padding-left: 0 !important; padding-right: 0 !important; }
    html.bb-rprint .rp-note-page, html.bb-rprint .dataTables_info, html.bb-rprint .rp-card-foot a,
    html.bb-rprint .rp-legend, html.bb-rprint .rh-links { display: none !important; }
    html.bb-rprint .rp-kpis { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: var(--bb-space-6) !important; margin: 0 0 var(--bb-space-12) !important; }
    html.bb-rprint .rp-kpi { padding: var(--bb-space-6) var(--bb-space-8) !important; border: 0.75pt solid var(--bb-gray-300) !important; border-radius: 0 !important; background: var(--bb-surface) !important; box-shadow: none !important; }
    html.bb-rprint .rp-kpi > span { font-size: var(--bb-text-xs) !important; font-weight: 700 !important; letter-spacing: .4px; text-transform: uppercase; color: var(--bb-gray-600) !important; }
    html.bb-rprint .rp-kpi > b { margin-top: 1px !important; font-size: var(--bb-text-md) !important; color: var(--bb-gray-950) !important; }
    html.bb-rprint .rp-kpi > small { min-height: 0 !important; font-size: var(--bb-text-xs) !important; color: var(--bb-gray-600) !important; }
    html.bb-rprint .rp-card, html.bb-rprint .bb-table-card { margin: 0 0 var(--bb-space-12) !important; border: 0.75pt solid var(--bb-gray-300) !important; border-radius: 0 !important; box-shadow: none !important; overflow: visible !important; background: var(--bb-surface) !important; }
    html.bb-rprint .rp-card-head { padding: var(--bb-space-4) var(--bb-space-8) !important; background: var(--bb-gray-150) !important; border-bottom: 0.75pt solid var(--bb-gray-300) !important; font-size: var(--bb-text-sm) !important; }
    html.bb-rprint .rp-card-foot { padding: var(--bb-space-4) var(--bb-space-8) !important; font-size: var(--bb-text-xs) !important; }
    html.bb-rprint .rp-grid { display: block !important; }
    html.bb-rprint .rp-note { font-size: var(--bb-text-xs) !important; color: var(--bb-gray-600) !important; }
    html.bb-rprint .dataTables_wrapper, html.bb-rprint .table-responsive, html.bb-rprint .rp-scroll,
    html.bb-rprint .dataTables_scroll, html.bb-rprint .dataTables_scrollHead, html.bb-rprint .dataTables_scrollBody { overflow: visible !important; width: 100% !important; }

    html.bb-rprint #scrollable-container table:not(.doc-hd) {
        width: 100% !important; max-width: 100% !important; margin: 0 !important; border-collapse: collapse !important; table-layout: auto !important; }
    html.bb-rprint #scrollable-container table:not(.doc-hd) th {
        padding: var(--bb-space-4) var(--bb-space-6) !important; font-size: var(--bb-text-xs) !important; font-weight: 700 !important; letter-spacing: .3px; text-transform: uppercase;
        color: var(--bb-gray-950) !important; background: var(--bb-gray-150) !important; background-image: none !important; border: 0 !important; border-bottom: 1pt solid var(--bb-gray-950) !important;
        white-space: normal !important; vertical-align: bottom !important; height: auto !important; width: auto !important; min-width: 0 !important; }
    html.bb-rprint table th::before, html.bb-rprint table th::after { display: none !important; content: none !important; }
    html.bb-rprint #scrollable-container table:not(.doc-hd) td {
        padding: var(--bb-space-4) var(--bb-space-6) !important; font-size: var(--bb-text-xs) !important; line-height: 1.3 !important; color: var(--bb-gray-900) !important; background: var(--bb-surface) !important;
        border: 0 !important; border-top: 0.5pt solid var(--bb-gray-250) !important; white-space: normal !important; overflow-wrap: break-word; word-break: normal !important;
        vertical-align: top !important; height: auto !important; width: auto !important; min-width: 0 !important; }
    html.bb-rprint table td.bb-num, html.bb-rprint table th.bb-num, html.bb-rprint table .bb-money, html.bb-rprint table td.text-right,
    html.bb-rprint table .display_currency, html.bb-rprint table td.rp-amt { white-space: nowrap !important; overflow-wrap: normal; }
    html.bb-rprint table tfoot td, html.bb-rprint table tfoot th, html.bb-rprint table tr.footer-total td, html.bb-rprint table tr.rp-total td {
        padding: var(--bb-space-4) var(--bb-space-6) !important; font-size: var(--bb-text-xs) !important; font-weight: 700 !important; color: var(--bb-gray-950) !important;
        background: var(--bb-gray-150) !important; border-top: 1pt solid var(--bb-gray-950) !important; }
    html.bb-rprint .bb-prod, html.bb-rprint .bb-cat, html.bb-rprint .tx-name { min-width: 0 !important; }
    /* tables that scroll sideways on screen (scrollX) are split into header / body / footer tables with pixel widths;
       on paper only the body table prints, with its own (sizing) header and footer shown, so the columns line up and fit */
    html.bb-rprint .dataTables_scrollHead, html.bb-rprint .dataTables_scrollFoot { display: none !important; }
    html.bb-rprint .dataTables_scrollBody table { width: 100% !important; }
    html.bb-rprint .dataTables_scrollBody thead tr, html.bb-rprint .dataTables_scrollBody tfoot tr { height: auto !important; visibility: visible !important; }
    html.bb-rprint .dataTables_scrollBody thead th, html.bb-rprint .dataTables_scrollBody tfoot td, html.bb-rprint .dataTables_scrollBody tfoot th {
        height: auto !important; padding-top: var(--bb-space-4) !important; padding-bottom: var(--bb-space-4) !important; }
    html.bb-rprint .dataTables_scrollBody .dataTables_sizing { height: auto !important; overflow: visible !important; }
    html.bb-rprint .bb-status, html.bb-rprint .bb-table .bb-badge-pill { height: auto !important; padding: 0 !important; border: 0 !important; font-size: var(--bb-text-xs) !important; background: none !important; }
    html.bb-rprint .bb-status::before, html.bb-rprint .bb-status i { display: none !important; }
    html.bb-rprint a { color: var(--bb-gray-950) !important; text-decoration: none !important; }
}
@media print {
    /* many columns (10+): smaller text, and amounts may wrap after the currency symbol so the table still fits */
    html.bb-rprint #scrollable-container table:not(.doc-hd):has(> thead > tr > th:nth-child(10)) th { font-size: var(--bb-text-xs) !important; padding: var(--bb-space-4) var(--bb-space-4) !important; }
    html.bb-rprint #scrollable-container table:not(.doc-hd):has(> thead > tr > th:nth-child(10)) td { font-size: var(--bb-text-xs) !important; padding: var(--bb-space-2) var(--bb-space-4) !important; }
    html.bb-rprint #scrollable-container table:not(.doc-hd):has(> thead > tr > th:nth-child(10)) :is(td.bb-num, .bb-money, td.text-right, .display_currency, td.rp-amt) { white-space: normal !important; }
}

/* ---------- Row height standard: every body row is one or two lines ----------
   Cells stay on one line (the card scrolls sideways when the table is wider than the screen). Long text is
   clamped to two lines with the full text in its tooltip (.bb-clamp), and a date with a time shows the time
   under the date (.bb-dt). bb-table.js applies both after every draw; Blade can use the same classes. */
.bb-table tbody td { white-space: nowrap; }
.bb-table .bb-clamp {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    white-space: normal; line-height: 1.35; min-width: 150px; max-width: 280px; overflow-wrap: anywhere;
}
/* a name with a sub-line under it: the name keeps to one line so the cell stays at two */
.bb-table td:has(.bb-cell-sub) .bb-cell-name { -webkit-line-clamp: 1; }
.bb-dt { display: inline-flex; flex-direction: column; line-height: 1.3; white-space: nowrap; vertical-align: middle; }
.bb-dt-t { font-size: var(--bb-text-xs); color: var(--bb-text-muted); font-variant-numeric: tabular-nums; }
.bb-dt-d { font-variant-numeric: tabular-nums; }
/* product category: category over sub-category as plain text (no bubbles), same shape as a date over its time */
.bb-table .bb-cat:has(> .bb-cat-main) { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; padding: 0; background: none; border: 0; border-radius: 0; line-height: 1.3; }
.bb-table .bb-cat-main { padding: 0; background: none; border-radius: 0; font-size: var(--bb-text-base); font-weight: 600; line-height: 1.3; color: var(--bb-text); }
.bb-table .bb-cat:has(> .bb-cat-main) .bb-cat-sub { padding: 0; border: 0; background: none; border-radius: 0; font-size: var(--bb-text-xs); font-weight: 500; color: var(--bb-text-muted); }
.bb-table .bb-cat:has(> .bb-cat-main) .bb-cat-sub i { display: none; }
/* filter bar: a date range needs room for "01-01-2026 - 31-12-2026" */
.bb-filters-row > .bb-filter:has(input[id*="date_range"], input[name*="date_range"], input[id*="daterange"]),
.bb-filters-more > .bb-filter:has(input[id*="date_range"], input[name*="date_range"], input[id*="daterange"]) { width: 240px; }
@media (max-width: 767px) { .bb-filters-row > .bb-filter:has(input[id*="date_range"], input[name*="date_range"], input[id*="daterange"]) { width: 100%; } }
/* row action buttons sit on one line (previously they wrapped into a stack) */
.bb-table td:last-child:has(.tw-dw-btn-xs, .btn-xs) { white-space: nowrap; min-width: 0; max-width: none; }
/* footer totals: several counts in one cell sit side by side instead of a stack */
.bb-table tfoot td, .bb-table-card .dataTables_scrollFoot td { white-space: nowrap; }

/* phones and small tablets: toolbar buttons show icons only, the toolbar and pagination never push the page wider */
@media (max-width: 767px) {
    .bb-table-card .dataTables_wrapper > :is(.row, .tw-bs-row):first-child { padding: var(--bb-space-12) var(--bb-space-12); gap: var(--bb-space-8); }
    /* toolbar: search + rows-per-page on one line, the tool buttons under them */
    .bb-table-card .dataTables_wrapper > :is(.row, .tw-bs-row):first-child > :is(.col-sm-3, [class*="bs-sm:tw-w-3/12"]) { order: -1; flex: 1 1 0; min-width: 0; }
    .bb-table-card .dataTables_wrapper > :is(.row, .tw-bs-row):first-child > :is(.col-sm-8, [class*="bs-sm:tw-w-8/12"]):not(:has(> :not(.dt-buttons))) { display: none; }
    .bb-table-card .dataTables_filter label, .bb-table-card .dataTables_filter input { width: 100% !important; }
    .bb-table-card .dataTables_length .bb-len-t { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .bb-table-card .dataTables_length select { font-size: var(--bb-text-base); margin: 0 !important; }
    .bb-tools { flex: 1 1 100%; flex-wrap: wrap; margin-left: 0; }
    .bb-tools .bb-tool-btn > span:not(.bb-sel-n) { display: none; }
    .bb-tools .bb-sel > span { display: inline; }
    .bb-table-card .dataTables_info { float: none !important; text-align: center; padding: var(--bb-space-8) var(--bb-space-12) 0 !important; }
    .bb-table-card .dataTables_paginate { float: none !important; text-align: center; padding: var(--bb-space-8) var(--bb-space-8) var(--bb-space-12) !important; }
    .bb-table-card .dataTables_paginate .pagination { display: flex; flex-wrap: nowrap; justify-content: center; }
    .bb-table-card .dataTables_paginate .paginate_button:not(.active):not(.previous):not(.next) { display: none; }
    .bb-table tbody td { padding: var(--bb-space-12) var(--bb-space-12) !important; }
}

@media print {
    .bb-dt { display: inline; }
    .bb-dt-t { font-size: inherit; color: inherit; }
    .bb-table .bb-clamp { display: inline; -webkit-line-clamp: unset; max-width: none; overflow: visible; }
}

/* a bb-table-card inside Bootstrap's .table-responsive: the card already scrolls, so drop the wrapper's own
   border (a light frame on phones) and scroll box */
.table-responsive:has(> .bb-table-card) { border: 0 !important; overflow: visible; margin-bottom: 0; }

/* ---------- Filters on phones: one slim row (date range + "Filters" button), tap to open the rest ---------- */
.bb-f-chev, .bb-filters-title .bb-f-count, .bb-filters-title .bb-f-count[hidden] { display: none !important; }
@media (max-width: 767px) {
    .bb-filters { padding: var(--bb-space-8) var(--bb-space-12); }
    .bb-filters-bar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--bb-space-8); }
    .bb-filters-main.row { order: 1; flex: 1 1 0; min-width: 0; }
    .bb-filters-title {
        order: 2; cursor: pointer; user-select: none; height: 32px; margin-top: 0; padding: 0 var(--bb-space-12); gap: var(--bb-space-6); letter-spacing: .04em;
        border: 1px solid var(--bb-border); border-radius: var(--bb-radius-md); background: var(--bb-surface-raised);
    }
    .bb-filters.has-count .bb-filters-title { border-color: var(--bb-primary); background: var(--bb-primary-wash); }
    .bb-filters-title .bb-f-count:not([hidden]) { display: inline-flex !important; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 var(--bb-space-6); border-radius: var(--bb-radius-md); background: var(--bb-primary); color: var(--bb-on-primary); font-size: var(--bb-text-xs); letter-spacing: 0; }
    .bb-f-chev { display: inline-block !important; font-size: var(--bb-text-xs); transition: transform .15s; }
    /* next to a date range the button is icon + count only, so the dates are not cut */
    .bb-filters:not(.is-open) .bb-filters-bar:has(.bb-date-col) .bb-filters-title { gap: var(--bb-space-6); padding: 0 var(--bb-space-12); }
    .bb-filters:not(.is-open) .bb-filters-bar:has(.bb-date-col) .bb-filters-title-t { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .bb-filters-title > i.fa-sliders-h { font-size: var(--bb-text-md); }
    .bb-filters .bb-more-btn { display: none !important; }
    .bb-filters-row > .bb-date-col { width: 100% !important; }
    /* closed: only the date range (if the page has one) and the Filters button */
    .bb-filters:not(.is-open) .bb-filters-row > :not(.bb-date-col), .bb-filters:not(.is-open) .bb-filters-more { display: none !important; }
    .bb-filters:not(.is-open) .bb-filters-main:not(:has(.bb-date-col)) { display: none; }
    .bb-filters:not(.is-open) .bb-filters-bar:not(:has(.bb-date-col)) .bb-filters-title { flex: 1 1 auto; justify-content: center; }
    /* open: title on top, every filter full width, "More" filters shown in the same list */
    .bb-filters.is-open .bb-filters-title { order: 0; flex: 1 1 100%; justify-content: space-between; }
    .bb-filters.is-open .bb-filters-main.row { flex: 1 1 100%; }
    .bb-filters.is-open .bb-filters-row > .bb-filter, .bb-filters.is-open .bb-filters-more > .bb-filter { width: 100%; }
    .bb-filters.is-open .bb-filters-more { display: flex; flex-direction: column; align-items: stretch; margin-top: var(--bb-space-8); padding-top: 0; border-top: 0; }
    .bb-filters.is-open .bb-f-chev { transform: rotate(180deg); }
    /* open: one list, Reset last */
    .bb-filters.is-open :is(.bb-filters-main, .bb-filters-main > form):has(> .bb-filters-row) { display: flex; flex-direction: column; gap: var(--bb-space-8); }
    .bb-filters.is-open .bb-filters-row, .bb-filters.is-open .bb-filters-more { display: contents; }
    .bb-filters.is-open .bb-reset { order: 99; align-self: flex-start; }
    /* an empty table: the message sits at the left edge, not in the middle of a table wider than the screen */
    .bb-table-card td.dataTables_empty { text-align: left !important; padding: var(--bb-space-24) var(--bb-space-16) !important; }
}

/* Split button rebuilt by bb-table.js from old action cells: a <button> menu entry looks like a link entry */
.bb-actions .dropdown-menu > li > button {
    display: flex; align-items: center; gap: var(--bb-space-4); width: 100%; padding: var(--bb-space-8) var(--bb-space-12); border: 0; border-radius: var(--bb-radius-md); background: none;
    font: inherit; font-size: var(--bb-text-base); line-height: 1.42857; text-align: left; white-space: nowrap; color: var(--bb-text-body); cursor: pointer;
}
.bb-actions .dropdown-menu > li > button:hover { background: var(--bb-primary-glow); color: var(--bb-primary-text); }
.bb-actions .dropdown-menu > li > button .fa, .bb-actions .dropdown-menu > li > button .fas { width: 18px; color: var(--bb-primary-text); }
.bb-actions .dropdown-menu > li > button.bb-menu-danger, .bb-actions .dropdown-menu > li > button.bb-menu-danger i { color: var(--bb-danger-text); }
.bb-actions .dropdown-menu > li > button.bb-menu-danger:hover { background: var(--bb-danger-bg); }
.bb-actions .dropdown-menu > li > a { display: flex; align-items: center; gap: var(--bb-space-4); white-space: nowrap; }
.bb-actions button.bb-act-main { font-family: inherit; }
.bb-actions .bb-act-more.is-solo { width: auto; gap: var(--bb-space-6); padding: 0 var(--bb-space-12); margin-left: 0; border-radius: var(--bb-radius-md); font-size: var(--bb-text-sm); }
.bb-actions .bb-act-more.is-solo i { font-size: var(--bb-text-xs); }
/* a date with a button next to it (e.g. "Add follow up") */
.bb-dt-side { display: inline-flex; align-items: center; gap: var(--bb-space-12); white-space: nowrap; }

/* resources/views/contact/index.blade.php */
    .ct-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--bb-space-12); margin-bottom: var(--bb-space-16); }
    .ct-kpi { position: relative; display: flex; flex-direction: column; gap: var(--bb-space-2); padding: var(--bb-space-12) var(--bb-space-16); overflow: hidden; background: var(--bb-surface); border: 1px solid var(--bb-border); border-radius: var(--bb-radius-lg); box-shadow: var(--bb-shadow-xs); }
    .ct-kpi::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--k); }
    .ct-kpi-v { font-size: var(--bb-text-2xl); font-weight: 700; letter-spacing: -0.02em; color: var(--bb-text); font-variant-numeric: tabular-nums; line-height: 1.3; overflow-wrap: anywhere; }
    .ct-kpi-l { font-size: var(--bb-text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--bb-text-muted); }
    .ct-kpi-s { font-size: var(--bb-text-xs); font-weight: 500; color: var(--bb-text-body); }

    /* table: fixed row height, every cell at most two single lines */
    #contact_table tbody td { height: 60px; padding-top: 0 !important; padding-bottom: 0 !important; vertical-align: middle; }
    #contact_table thead th { white-space: nowrap; }
    .ct-ent { display: flex; align-items: center; gap: var(--bb-space-12); min-width: 0; }
    .ct-ent-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
    a.ct-ent-link { color: inherit; text-decoration: none; border-radius: var(--bb-radius-md); margin: -4px -6px; padding: 4px 6px; transition: background 0.12s; }
    a.ct-ent-link:hover, a.ct-ent-link:focus-visible { background: var(--bb-primary-tint); text-decoration: none; outline: 0; }
    a.ct-ent-link:hover .ct-name, a.ct-ent-link:focus-visible .ct-name { color: var(--bb-primary-text); }
    .ct-avatar { width: 34px; height: 34px; border-radius: var(--bb-radius-md); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: var(--bb-text-base); font-weight: 700; color: var(--av); background: var(--bb-surface-raised); border: 1px solid var(--bb-border); }
    .ct-avatar::before { content: attr(data-l); }
    .ct-name { display: block; max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--bb-text-base); font-weight: 700; line-height: 1.25; color: var(--bb-text); }
    .ct-sub { display: block; max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--bb-text-xs); font-weight: 500; line-height: 1.25; color: var(--bb-text-muted); }
    .ct-link { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; font-size: var(--bb-text-sm); font-weight: 600; color: var(--bb-text); }
    .ct-link:hover { color: var(--bb-primary-text); text-decoration: none; }
    .ct-tel { font-variant-numeric: tabular-nums; }
    .ct-none { color: var(--bb-text-body); }
    .ct-pill { display: inline-flex; align-items: center; font-size: var(--bb-text-xs); font-weight: 700; border-radius: var(--bb-radius-full); padding: var(--bb-space-2) var(--bb-space-8); white-space: nowrap; }
    .ct-pill-info { background: var(--bb-info-bg); color: var(--bb-info-text); }
    .ct-pill-off { background: var(--bb-danger-bg); color: var(--bb-danger-text); margin-left: var(--bb-space-4); }
    .ct-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
    .ct-amt.is-due { color: var(--bb-danger-text); }
    .ct-amt.is-zero { color: var(--bb-text-body); font-weight: 700; }

    @media (max-width: 700px) { .ct-kpis { grid-template-columns: 1fr; gap: var(--bb-space-8); } }
