/* ===========================================================================================================
   stable-theme.css - stable web apps brand and UI guide v2 (BMS 2.0, 15 October 2026) on plain Bootstrap 5.3.
   Loaded after bootstrap.min.css. Section numbers refer to the guide. The two StableVision portals ship the
   same file; keep them identical. App-specific rules live in sv-portal.css and use these tokens.
   =========================================================================================================== */

/* ---------- 4/5. Type, shape, tokens ---------- */
:root, [data-bs-theme=light], [data-bs-theme=dark] {
    --bs-font-sans-serif: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --bs-font-monospace: Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --bs-body-font-size: 13px;
    --bs-body-line-height: 1.4285714286;
    --bs-border-radius-lg: 10px;
    --bms-control-height: 40px;
    --bms-font-size-sm: 13px;
    --main-color: #00A1D6;
}
:root, [data-bs-theme=light] {
    --bms-bg-surface: #fff;
    --bms-bg-surface-secondary: #f8f9fa;
    --bms-bg-forms: #fff;
    --bms-active-bg: #e9ecef;
    --bms-secondary: var(--bs-gray-500);
    --bms-shadow-card: 0 0 1px rgba(33, 37, 41, .125), 0 1px 3px rgba(33, 37, 41, .2);
    --sv-disabled-bg: #e9ecef;
    --sv-addon-bg: #f8f9fa;
    --sv-hover-tint: rgba(108, 117, 125, .08);
    --main-color-row-highlight: #f0f9fd;
}
[data-bs-theme=dark] {
    --bms-bg-surface: #212529;
    --bms-bg-surface-secondary: #343a40;
    --bms-bg-forms: #212529;
    --bms-active-bg: #343a40;
    --bms-secondary: var(--bs-gray-400);
    --bms-shadow-card: 0 0 1px rgba(222, 226, 230, .125), 0 1px 3px rgba(222, 226, 230, .2);
    --sv-disabled-bg: #343a40;
    --sv-addon-bg: #2b3035;
    --bs-light: #343a40;
    --bs-light-rgb: 52, 58, 64;
    --main-color-row-highlight: rgba(var(--bs-primary-rgb), .18);
}

body { background-color: var(--bs-tertiary-bg); }
html { overflow-y: scroll; overflow-x: hidden; }

h1, .h1 { font-size: 1.5rem; }
h2, .h2 { font-size: 1.25rem; }
h3, .h3 { font-size: 1rem; }
h4, .h4 { font-size: .875rem; }
h5, .h5 { font-size: .8125rem; }
h6, .h6 { font-size: .75rem; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 600; }

.text-secondary { color: var(--bms-secondary) !important; }

/* Controls take the 13px body size (Bootstrap's default is 16px); icon sizes keep the scale the pages were drawn with. */
.btn { --bs-btn-font-size: var(--bs-body-font-size); }
.btn-sm { --bs-btn-font-size: 12px; }
.form-control, .form-select, .input-group-text, .dropdown-menu, .nav-link, .pagination, .list-group-item, .popover, .tooltip { font-size: var(--bs-body-font-size); }
.form-control-sm, .form-select-sm { font-size: 12px; }
.pagination { --bs-pagination-font-size: var(--bs-body-font-size); }
.pagination-sm { --bs-pagination-font-size: 12px; }
.fs-1 { font-size: 1.5rem !important; }
.fs-2 { font-size: 1.25rem !important; }
.fs-3 { font-size: 1rem !important; }
.fs-4 { font-size: .875rem !important; }
.fs-5 { font-size: .75rem !important; }
.fs-6 { font-size: .625rem !important; }
.page-title { margin: 0; font-size: 18px; font-weight: 600; line-height: 28px; }

/* Links: text links take the link colour; controls never do (8.8). */
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.btn:hover, .nav-link:hover, .dropdown-item:hover, .list-group-item:hover, .page-link:hover, .badge:hover { text-decoration: none; }
.bi-pencil-square.text-primary { color: var(--bs-link-color) !important; }

/* ---------- 8.3 Cards ---------- */
.card {
    box-shadow: var(--bms-shadow-card);
}
.card-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    min-height: 3.25rem;
    padding: .75rem 1rem;
    background: transparent;
}
.card-footer { background: transparent; }
.card-title { margin: 0; font-size: 1rem; font-weight: 600; }
.card-header .card-title { margin: 0; }
.card-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.card-sm > .card-body { padding: .75rem; }
.card-table { margin-bottom: 0; }
.card-table tr > :first-child { padding-left: 1rem; }
.card-table tr > :last-child { padding-right: 1rem; }
.card > .table-responsive:last-child > .card-table,
.card > .card-table:last-child { border-bottom-left-radius: var(--bs-border-radius-lg); border-bottom-right-radius: var(--bs-border-radius-lg); }
.card-table > :last-child > tr:last-child > * { border-bottom-width: 0; }
.row-cards { --bs-gutter-x: 1rem; --bs-gutter-y: 1rem; }
.row-deck > [class*=col] { display: flex; align-items: stretch; }
.row-deck > [class*=col] > .card { flex: 1 1 auto; }
.subheader {
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bms-secondary);
}

/* ---------- 8.1 Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
}
.btn:not(.btn-sm):not(.btn-lg):not(.btn-link) {
    --bs-btn-padding-y: .5625rem;
    --bs-btn-padding-x: 1rem;
    min-height: var(--bms-control-height);
}
.btn-link { --bs-btn-color: var(--bs-link-color); }
.btn:disabled, .btn.disabled, fieldset:disabled .btn { opacity: .65; }
.btn-icon { padding-left: .5rem !important; padding-right: .5rem !important; }
.btn-icon:not(.btn-sm) { min-width: var(--bms-control-height); }
.btn-check:checked + .btn-light, .btn-light.active {
    color: #fff;
    background-color: var(--bs-secondary);
    border-color: var(--bs-secondary);
}
i.icon { display: inline-flex; align-items: center; justify-content: center; }

/* Tabler's colour utilities, at Bootstrap colours (distance bands, chart text). */
.bg-red { background-color: #dc3545 !important; color: #fff; }
.bg-orange { background-color: #fd7e14 !important; color: #fff; }
.bg-yellow { background-color: #ffc107 !important; color: #000; }
.bg-green { background-color: #198754 !important; color: #fff; }
.bg-teal { background-color: #20c997 !important; color: #fff; }
.bg-blue { background-color: #0d6efd !important; color: #fff; }
.bg-azure { background-color: #0dcaf0 !important; color: #000; }
.bg-purple { background-color: #6f42c1 !important; color: #fff; }
.text-red { color: #dc3545 !important; }
.text-orange { color: #fd7e14 !important; }
.text-yellow { color: #e0a800 !important; }
.text-green { color: #198754 !important; }
.text-teal { color: #20c997 !important; }
.text-blue { color: #0d6efd !important; }
.text-azure { color: #0aa2c0 !important; }
.text-purple { color: #6f42c1 !important; }
.mt-n1 { margin-top: -.25rem !important; }
.py-6 { padding-top: 3rem !important; padding-bottom: 3rem !important; }
.w-1 { width: 1% !important; white-space: nowrap; }
.hidden { display: none !important; }
.progress-sm { height: .25rem; }

/* ---------- 8.4 Forms ---------- */
.form-control:not(.form-control-sm):not(.form-control-lg):not(textarea):not([type=color]),
.form-select:not(.form-select-sm):not(.form-select-lg) {
    min-height: var(--bms-control-height);
}
.form-label { font-weight: 500; }
.form-control:disabled, .form-control[readonly]:not(.form-control-plaintext), .form-select:disabled { background-color: var(--sv-disabled-bg); }
.input-group-text { background-color: var(--sv-addon-bg); }
.form-control::placeholder { color: var(--bs-body-color); opacity: 1; }
.form-control.is-invalid, .form-select.is-invalid, textarea.form-control.is-invalid { background-image: none; padding-right: .75rem; }
.bms-label-required::after { content: " *"; color: var(--bs-danger); font-weight: 600; }
[data-bs-theme=light] .form-check-input:not(:checked) { border-color: var(--bs-gray-400); }
.form-check-description { display: block; color: var(--bms-secondary); font-size: .8125rem; }

/* Icon in a field: icon left; an addon that is the last child sits right. */
.input-icon { position: relative; }
.input-icon .form-control:not(:last-child), .input-icon .form-select:not(:last-child) { padding-right: 2.5rem; }
.input-icon .form-control:not(:first-child), .input-icon .form-select:not(:first-child) { padding-left: 2.5rem; }
.input-icon-addon {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    color: var(--bms-secondary);
    pointer-events: none;
    z-index: 5;
}
.input-icon-addon:last-child { left: auto; right: 0; }

/* Tenant status picker (Admin): a group of light buttons, the chosen one grey. */
.form-selectgroup { display: inline-flex; flex-wrap: wrap; gap: .5rem; }
.form-selectgroup-item { position: relative; margin: 0; }
.form-selectgroup-input { position: absolute; opacity: 0; pointer-events: none; }
.form-selectgroup-label {
    display: inline-flex;
    align-items: center;
    min-height: var(--bms-control-height);
    padding: .5625rem 1rem;
    border-radius: var(--bs-border-radius);
    background: var(--bs-light);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    cursor: pointer;
}
.form-selectgroup-input:checked + .form-selectgroup-label { background: var(--bs-secondary); border-color: var(--bs-secondary); color: #fff; }
.form-selectgroup-input:focus-visible + .form-selectgroup-label { box-shadow: 0 0 0 .25rem rgba(var(--bs-primary-rgb), .25); }

/* ---------- Tables (8.6) ---------- */
.table {
    --bs-table-border-color: var(--bs-border-color);
    --bs-table-bg: transparent;
    margin-bottom: 0;
}
.table > :not(caption) > * > * { padding: .5rem .75rem; }
.table-vcenter > :not(caption) > * > * { vertical-align: middle; }
table.dataTable thead th, .table thead th { color: var(--bs-body-color); font-weight: 600; white-space: nowrap; }
table.dataTable > tbody > tr > td { height: 3rem; padding-top: .25rem; padding-bottom: .25rem; }
table.dataTable td .btn.btn-link.p-1 { padding: .125rem .25rem !important; line-height: 1; min-height: 0; }
table.dataTable > :not(caption) > tr > :not(:first-child) { border-left: 1px solid var(--bs-border-color-translucent); }
table.dataTable > tbody > tr.selected > td { background: var(--main-color-row-highlight); }

th.bms-col-w-sm, td.bms-col-w-sm { width: 110px !important; min-width: 110px; white-space: nowrap; }
th.bms-col-w-md, td.bms-col-w-md { width: 140px !important; min-width: 140px; white-space: nowrap; }
th.bms-col-w-lg, td.bms-col-w-lg { width: 200px !important; min-width: 200px; white-space: nowrap; }
th.bms-col-w-xl, td.bms-col-w-xl { width: 260px !important; min-width: 260px; white-space: normal; overflow-wrap: anywhere; }
th.bms-col-flex, td.bms-col-flex { width: 100%; min-width: 180px; white-space: normal !important; overflow-wrap: anywhere; }
th.bms-status-col, td.bms-status-col { width: 110px !important; min-width: 110px; text-align: center !important; white-space: nowrap; }
th.bms-actions-col, td.bms-actions-col { width: 92px !important; min-width: 92px; text-align: center !important; white-space: nowrap; }
th.bms-actions-col-wide, td.bms-actions-col-wide { width: 128px !important; min-width: 128px; }
@media (max-width: 767.98px) {
    table.bms-rt .bms-rt-secondary { display: none; }
    table.bms-rt :is(.bms-col-w-sm, .bms-col-w-md, .bms-col-w-lg, .bms-col-w-xl, .bms-col-flex) { width: auto !important; min-width: 0; }
}

/* Sort arrows: two 4px triangles at the right of the header. */
.card table.dataTable thead :is(th.sorting, th.sorting_asc, th.sorting_desc) {
    background-image: none;
    cursor: pointer;
    position: relative;
    padding-right: 1.3rem !important;
    user-select: none;
}
.card table.dataTable thead :is(th.sorting, th.sorting_asc, th.sorting_desc)::before,
.card table.dataTable thead :is(th.sorting, th.sorting_asc, th.sorting_desc)::after {
    content: "";
    position: absolute;
    right: .55rem;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: .35;
}
.card table.dataTable thead :is(th.sorting, th.sorting_asc, th.sorting_desc)::before { top: calc(50% - 6px); border-bottom: 4px solid var(--bms-secondary); }
.card table.dataTable thead :is(th.sorting, th.sorting_asc, th.sorting_desc)::after { bottom: calc(50% - 6px); border-top: 4px solid var(--bms-secondary); }
.card table.dataTable thead th.sorting_asc::before, .card table.dataTable thead th.sorting_desc::after { opacity: 1; }
:root:not([data-bs-theme=dark]) .card table.dataTable thead :is(th.sorting, th.sorting_asc, th.sorting_desc)::before,
:root:not([data-bs-theme=dark]) .card table.dataTable thead :is(th.sorting, th.sorting_asc, th.sorting_desc)::after { opacity: .5; }
:root:not([data-bs-theme=dark]) .card table.dataTable thead th.sorting_asc::before { opacity: 1; border-bottom-color: color-mix(in srgb, var(--bms-secondary) 95%, #000); }
:root:not([data-bs-theme=dark]) .card table.dataTable thead th.sorting_desc::after { opacity: 1; border-top-color: color-mix(in srgb, var(--bms-secondary) 95%, #000); }

/* Grid footer: [page size] ... [N Record(s)] [pagination]. */
.bs5-table-footer { padding: .5rem 1rem; margin: 0; border-top: 1px solid var(--bs-border-color); }
.bs5-table-footer .dataTables_length select { display: inline-block; width: auto; min-height: 0; margin-right: .5rem; }
.bs5-table-footer .dataTables_info { color: var(--bs-body-color); }
.card .dataTables_paginate .pagination { margin: 0; }
.card .dataTables_paginate a, .card .dataTables_paginate .page-link { color: var(--bs-body-color); background: transparent; border-color: transparent; cursor: pointer; }
.card .dataTables_paginate a.current, .card .dataTables_paginate a:hover, .card .dataTables_paginate li.active a,
.card .dataTables_paginate .page-item.active .page-link { background: var(--bms-active-bg); border-color: var(--bms-active-bg); color: var(--bs-body-color); }
.card .dataTables_paginate .page-item.disabled .page-link { color: var(--bms-secondary); background: transparent; }

/* ---------- 8.7 Sub menus ---------- */
.bms-tab-nav { position: sticky; top: 16px; }
.bms-tab-nav .list-group-item { color: var(--bs-body-color); }
.bms-tab-nav .list-group-item.active, .bms-tab-nav .list-group-item.active:hover {
    color: var(--bs-body-color);
    background: var(--bms-active-bg);
    border-color: var(--bs-border-color);
    font-weight: 400;
}
.bms-tab-nav .list-group-item-action:not(.active):hover { color: var(--bs-emphasis-color); background: var(--sv-hover-tint); }

/* ---------- 8.8 Tabs ---------- */
.nav-tabs .nav-link { color: var(--bs-gray-500); }
.nav-tabs .nav-link.active { color: var(--bs-body-color); }

/* ---------- Status dots, avatars, empty states ---------- */
.status { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; color: var(--bs-secondary-color); }
.status-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; flex: none; }
.status-dot-animated { animation: sv-status-pulse 1.4s ease-in-out infinite; }
@keyframes sv-status-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.status-green { color: var(--bs-success); }
.status-red { color: var(--bs-danger); }
.status-yellow { color: #e0a800; }
.status-secondary { color: var(--bms-secondary); }
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--bs-border-radius);
    font-weight: 600;
    flex: none;
}
.avatar-md { width: 3rem; height: 3rem; font-size: 1.1rem; }
.avatar-rounded { border-radius: 50%; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; text-align: center; }
.empty-icon { font-size: 2.5rem; line-height: 1; margin-bottom: 1rem; color: var(--bms-secondary); }
.empty-title { font-size: 1rem; font-weight: 600; margin-bottom: .25rem; }
.empty-subtitle { color: var(--bms-secondary); }
.empty-action { margin-top: 1.25rem; }
.modal-blur { backdrop-filter: blur(4px); }

/* ---------- 6. App shell: side menu ---------- */
.bms-sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(10, 20, 40, .5); z-index: 1059; }
.bms-sidebar-backdrop.open { display: block; }
.bms-sidebar {
    background: #212529;
    color: #fff;
    width: 240px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 16px rgba(0, 0, 0, .15);
}
.bms-sidebar-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #495057; }
.bms-sidebar-brand { display: flex; align-items: center; min-width: 0; flex: 1; min-height: 58px; box-sizing: border-box; color: #fff; }
.bms-sidebar-brand:hover { text-decoration: none; color: #fff; }
.bms-sidebar-lock-toggle {
    flex: none;
    width: 28px;
    height: 28px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: rgba(255, 255, 255, .65);
    cursor: pointer;
}
.bms-sidebar-lock-toggle:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.bms-sidebar-lock-toggle .bms-lock-icon-locked { display: none; }
.bms-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .25) transparent;
}
.bms-sidebar-menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.bms-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #c2c7d0;
    padding: 9px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    white-space: nowrap;
}
.bms-nav-link span { flex: 1; }
.bms-nav-link:hover, .bms-nav-link.active { color: #fff; background: rgba(255, 255, 255, .1); text-decoration: none; }
.bms-nav-link:focus-visible, .bms-user-btn:focus-visible, .bms-topbar-toggle:focus-visible { box-shadow: inset 0 0 0 2px #fff; outline: none; }
.bms-icon { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; opacity: .9; }
/* The group chevron is a small inline SVG: give it a fixed size or it grows to fill the row and squeezes the label out. */
.bms-nav-chevron { font-size: 12px; opacity: .6; transition: transform .15s; flex-shrink: 0; margin-left: auto; }
svg.bms-nav-chevron { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bms-sidebar-section.open > .bms-nav-link .bms-nav-chevron { transform: rotate(180deg); }
.bms-sidebar-submenu { list-style: none; margin: 2px 0 4px; padding: 0; display: none; flex-direction: column; gap: 1px; }
.bms-sidebar-section.open > .bms-sidebar-submenu { display: flex; }
.bms-nav-sublink { padding-left: 34px; font-weight: 500; font-size: 13px; }
.bms-sidebar-footer { padding: 10px; border-top: 1px solid rgba(255, 255, 255, .1); flex-shrink: 0; position: relative; }
.bms-user-btn {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
}
.bms-user-btn:hover { background: rgba(255, 255, 255, .07); }
.bms-user-btn .bms-user-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bms-avatar-chip {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--main-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.bms-user-menu {
    display: none;
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 100%;
    margin-bottom: 6px;
    background: var(--bms-bg-surface);
    color: var(--bs-emphasis-color);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(16, 24, 40, .1), 0 2px 4px rgba(16, 24, 40, .06);
    border: 1px solid var(--bs-border-color);
    overflow: hidden;
    z-index: 1061;
}
.bms-user-menu.open { display: block; }
.bms-user-menu a, .bms-user-menu button {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 10px 14px;
    font-size: 13.5px;
    color: var(--bs-body-color);
    display: block;
}
.bms-user-menu a:hover, .bms-user-menu button:hover { background: var(--bms-bg-surface-secondary); text-decoration: none; }
.bms-version-tag { display: block; font-size: 11px; color: rgba(255, 255, 255, .55); padding: 6px 8px 2px; }
.bms-topbar {
    display: none;
    background: #212529;
    color: #fff;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    height: 50px;
    position: sticky;
    top: 0;
    z-index: 1050;
    box-shadow: 0 8px 16px rgba(0, 0, 0, .15);
    flex-shrink: 0;
}
.bms-topbar-toggle {
    display: flex;
    background: none;
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
    font-size: 18px;
}
.bms-topbar-toggle:hover { background: rgba(255, 255, 255, .08); }
.bms-main-col { margin-left: 240px; min-height: 100vh; }
.bms-main-col > main { padding: 1rem !important; }

/* Desktop: a 64px icon rail that widens to 240px on hover (or stays open when locked). */
@media (min-width: 992px) {
    :root { --bms-sidebar-collapsed-width: 64px; }
    .bms-sidebar { width: var(--bms-sidebar-collapsed-width); overflow: hidden; transition: width .15s ease; }
    .bms-sidebar:hover { width: 240px; }
    .bms-main-col { margin-left: var(--bms-sidebar-collapsed-width); }
    .bms-nav-link span, .bms-user-btn .bms-user-name, .bms-version-tag {
        flex: none;
        width: 0;
        opacity: 0;
        overflow: hidden;
        white-space: nowrap;
        transition: opacity .1s ease;
    }
    .bms-sidebar:hover :is(.bms-nav-link span, .bms-user-btn .bms-user-name, .bms-version-tag) { flex: 1; width: auto; opacity: 1; }
    .bms-nav-chevron { opacity: 0; transition: opacity .1s ease; }
    .bms-sidebar:hover .bms-nav-chevron { opacity: 1; }
    /* Collapsed rail: no sub-menus until it opens (hover) or is locked open. */
    html:not(.sv-sidebar-locked):not(.bms-sidebar-locked-init) .bms-sidebar:not(:hover) .bms-sidebar-submenu { display: none !important; }
    .bms-sidebar-lock-toggle { opacity: 0; pointer-events: none; transition: opacity .1s ease; }
    .bms-sidebar:hover .bms-sidebar-lock-toggle { opacity: 1; pointer-events: auto; }
    html.bms-sidebar-locked-init .bms-sidebar, html.bms-sidebar-locked-init .bms-sidebar *, html.bms-sidebar-locked-init .bms-main-col { transition: none !important; }
    html.bms-sidebar-locked-init .bms-sidebar { width: 240px; }
    html.bms-sidebar-locked-init .bms-sidebar :is(.bms-nav-link span, .bms-user-btn .bms-user-name, .bms-version-tag) { flex: 1; width: auto; opacity: 1; }
    html.bms-sidebar-locked-init .bms-sidebar :is(.bms-nav-chevron, .bms-sidebar-lock-toggle) { opacity: 1; }
}
/* Phones: the menu becomes a 50px top bar; the menu slides over the page. */
@media (max-width: 991.98px) {
    .bms-topbar { display: flex; }
    .bms-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .bms-main-col { margin-left: 0; }
    .bms-main-col > main { padding: .5rem !important; }
}

/* ---------- 7.1 Page heading ---------- */
.breadcrumb { --bs-breadcrumb-margin-bottom: .5rem; font-size: 13px; }
.sv-page-header { min-height: var(--bms-control-height); margin-bottom: 1rem; }

/* ---------- 8.5 Date stepper ---------- */
.bms-datestep {
    display: flex;
    height: var(--bms-control-height);
    align-items: stretch;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bms-bg-surface);
}
.bms-datestep .btn-icon { border: 0; border-radius: 0; padding: 0 .5rem; height: auto; min-height: 0; }
.bms-datestep__field {
    position: relative;
    display: flex;
    flex: 1;
    align-items: center;
    gap: .45rem;
    padding: .3rem .75rem;
    border-left: 1px solid var(--bs-border-color);
    border-right: 1px solid var(--bs-border-color);
    min-width: 12rem;
}
.bms-datestep__field .sv-date-field { position: absolute; inset: 0; }
.bms-datestep .btn-icon:disabled { opacity: .35; }
.bms-datestep__input.form-control { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; cursor: pointer; min-height: 0; }
.bms-controlvalue { font-size: var(--bms-font-size-sm); font-weight: 600; white-space: nowrap; color: var(--bs-body-color); }
.bms-fixedlabel { display: inline-grid; justify-items: start; }
.bms-fixedlabel > * { grid-area: 1 / 1; }
.bms-fixedlabel__sizer { display: grid; visibility: hidden; pointer-events: none; user-select: none; white-space: nowrap; }
.bms-fixedlabel__sizer > span { grid-area: 1 / 1; white-space: nowrap; }

/* ---------- flatpickr ---------- */
.flatpickr-calendar { font-family: inherit; font-size: 13px; border-radius: var(--bs-border-radius) !important; }
.flatpickr-day.today { border-color: var(--bs-primary) !important; }
.flatpickr-weekday { color: var(--bms-secondary) !important; }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.today.selected { background: var(--bs-primary); border-color: var(--bs-primary); color: #fff; }
[data-bs-theme=dark] .flatpickr-calendar { background: #212529; box-shadow: 0 0 0 1px #495057, 0 4px 16px rgba(0, 0, 0, .4); }
[data-bs-theme=dark] .flatpickr-calendar.arrowTop::after { border-bottom-color: #212529; }
[data-bs-theme=dark] .flatpickr-calendar.arrowTop::before { border-bottom-color: #495057; }
[data-bs-theme=dark] .flatpickr-calendar.arrowBottom::after { border-top-color: #212529; }
[data-bs-theme=dark] .flatpickr-calendar.arrowBottom::before { border-top-color: #495057; }
[data-bs-theme=dark] :is(.flatpickr-months .flatpickr-month, .flatpickr-current-month .flatpickr-monthDropdown-months, .flatpickr-current-month input.cur-year, .flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month) { color: #dee2e6; fill: #dee2e6; background: transparent; }
[data-bs-theme=dark] .flatpickr-current-month .flatpickr-monthDropdown-months option { background: #212529; }
[data-bs-theme=dark] .flatpickr-day { color: #dee2e6; }
[data-bs-theme=dark] .flatpickr-day:hover, [data-bs-theme=dark] .flatpickr-day:focus { background: #343a40; border-color: #343a40; }
[data-bs-theme=dark] :is(.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay, .flatpickr-day.flatpickr-disabled, .flatpickr-day.flatpickr-disabled:hover) { color: #6c757d; background: transparent; border-color: transparent; }

/* ---------- SweetAlert2 in dark mode ---------- */
:root[data-bs-theme=dark] {
    --swal2-background: #212529;
    --swal2-color: #dee2e6;
    --swal2-footer-border-color: #495057;
    --swal2-input-background: #212529;
    --swal2-input-border: 1px solid #495057;
    --swal2-close-button-color: #adb5bd;
}
[data-bs-theme=dark] .swal2-popup { background: #212529; color: #dee2e6; }
[data-bs-theme=dark] :is(.swal2-title, .swal2-html-container) { color: #dee2e6; }

/* ---------- Record summary (label above value) ---------- */
.bms-summary-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .02em; color: var(--bms-secondary); margin-bottom: .125rem; }
.bms-summary-value { font-weight: 600; word-break: break-word; }
