/* 
 * MODERN THEME - Hospital Management System
 * Style: Glassmorphism, Soft UI, Modern Medical
 * Font: Poppins (Headings), Inter (Body)
 */

@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700&family=Source+Sans+Pro:wght@300;400;600;700&display=swap');

:root {
    /* Color Palette - Medical Tech */
    --primary: #4361ee;
    --primary-dark: #3f37c9;
    --primary-light: #4895ef;
    --secondary: #4cc9f0;
    --success: #2ec4b6;
    --danger: #ef233c;
    --warning: #ffb703;
    --info: #3a0ca3;
    
    /* Backgrounds */
    --bg-body: #f0f5fa;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    
    /* Text */
    --text-main: #2b2d42;
    --text-muted: #8d99ae;
    
    /* Effects */
    --shadow-sm: 0 2px 4px rgba(67, 97, 238, 0.05);
    --shadow-md: 0 5px 15px rgba(67, 97, 238, 0.08);
    --shadow-lg: 0 15px 35px rgba(67, 97, 238, 0.1);
    --shadow-hover: 0 20px 40px rgba(67, 97, 238, 0.15);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body {
    font-family: 'Open Sans', 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    font-size: 0.9375rem;
}

h1, h2, h3, h4, h5, h6, .navbar-brand {
    font-family: 'Source Sans Pro', 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

/* Modern Cards */
.card {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 0.25rem 0.375rem -0.0625rem rgba(20, 20, 20, 0.1), 0 0.125rem 0.25rem -0.0625rem rgba(20, 20, 20, 0.06);
    transition: var(--transition);
    background: var(--bg-card);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(20, 20, 20, 0.1);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid #eef1f5;
    padding: 1.1rem 1.5rem;
    font-weight: 600;
    font-family: 'Source Sans Pro', 'Open Sans', sans-serif;
}

.card-body {
    padding: 1.5rem;
}

/* Buttons */
.btn {
    border-radius: 0.638rem;
    padding: 0.55rem 1.15rem;
    font-weight: 600;
    font-family: 'Source Sans Pro', 'Open Sans', sans-serif;
    font-size: 0.875rem;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background-image: linear-gradient(310deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 6px rgba(67, 97, 238, 0.18);
}

.btn-primary:hover, .btn-primary:focus {
    background-image: linear-gradient(310deg, var(--primary-light), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 7px 14px rgba(67, 97, 238, 0.25);
    color: #fff;
}

.btn-success {
    background-image: linear-gradient(310deg, var(--success), #20a094);
    color: #fff;
    box-shadow: 0 4px 6px rgba(46, 196, 182, 0.18);
}

.btn-success:hover, .btn-success:focus {
    transform: translateY(-1px);
    box-shadow: 0 7px 14px rgba(46, 196, 182, 0.25);
    color: #fff;
}

.btn-danger {
    background-image: linear-gradient(310deg, var(--danger), #c81e33);
    color: #fff;
}

.btn-warning {
    background-image: linear-gradient(310deg, var(--warning), #e0a000);
    color: #fff;
}

.btn-outline-primary {
    border: 1px solid var(--primary);
    color: var(--primary);
    background: #fff;
}

.btn-outline-primary:hover, .btn-outline-primary:focus {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    transform: translateY(-1px);
}

/* Form Elements */
label, .form-label, .col-form-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #525772;
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    border-radius: 7px;
    border: 1px solid #e2e8f0;
    height: 36px;
    padding: 0 0.75rem;
    font-size: 14px;
    color: var(--text-main);
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control::placeholder {
    font-size: 14px;
    color: var(--text-muted);
}

textarea.form-control {
    height: auto;
    min-height: 90px;
    padding: 0.6rem 0.75rem;
}

.form-control:focus, .form-select:focus {
    background-color: #fff;
    border-color: var(--primary);
    box-shadow: none;
    outline: none;
}

.form-control:disabled, .form-select:disabled,
.form-control[readonly] {
    background-color: #f6f8fb;
    opacity: 1;
}

.input-group-text {
    border-radius: 7px;
    font-size: 14px;
}

/* Sidebar Styling */
.sidebar {
    background: var(--bg-sidebar) !important;
    border-right: none;
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.sidebar .nav-link {
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.8rem 1.2rem;
    margin-bottom: 0.3rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.sidebar .nav-link i {
    width: 17px;
    text-align: center;
    margin-right: 10px;
    font-size: .9rem;
    transition: var(--transition);
}

.sidebar .nav-link:hover {
    color: var(--primary);
    background-color: rgba(67, 97, 238, 0.05);
    transform: translateX(5px);
}

.sidebar .nav-link.active {
    color: white;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}

.sidebar .nav-link.active i {
    color: white;
}

/* ══════════════════════════════════════════════════
   IMAGE ICON SYSTEM (dual-tone PNG)
   Drop PNG files in assets/icons/ and reference them by
   filename. Each icon is a small <img> that renders at a
   consistent size and tints/animates on hover & active.

   USAGE (no PHP change needed):
     <img class="nav-icon" src="assets/icons/icon_patients.png" alt="">
   Or via the helper span + CSS variable:
     <span class="nav-icon" style="--icon: icon_patients;"></span>
   ══════════════════════════════════════════════════ */

.nav-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    margin-right: 10px;
    flex: 0 0 auto;
    vertical-align: middle;
    transition: transform .2s ease, opacity .2s ease, filter .2s ease;
}

/* The span variant pulls the PNG from the CSS variable */
span.nav-icon {
    display: inline-block;
    background-image: var(--icon-url);
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

/* Slightly larger version for module group headers */
.nav-icon-lg {
    width: 24px;
    height: 24px;
}

/* Small version for buttons / toolbars */
.nav-icon-sm {
    width: 16px;
    height: 16px;
    margin-right: 6px;
}

/* Hover + active micro-interactions (keeps the PNG colors) */
.sidebar .nav-link:hover .nav-icon,
.btn-toggle:hover .nav-icon,
.btn-toggle[aria-expanded="true"] .nav-icon {
    transform: scale(1.08);
}

/* Active row: lift the icon slightly and brighten */
.sidebar .nav-link.active .nav-icon {
    transform: scale(1.06);
    filter: brightness(1.15) drop-shadow(0 1px 2px rgba(0,0,0,.15));
}

/* Fallback: if the PNG is missing the browser shows a broken
   image; hide it so the layout never breaks. Provide a
   background tint instead so the slot still looks intentional. */
.nav-icon[src=""] {
    display: none;
}

/* Page-title icon (32px PNG beside the <h1>/<h2> heading).
   Usage:
     <h2 class="page-title"><img class="page-icon" src="assets/icons/icon_patients.png" alt="">Patients</h2> */
.page-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    margin-right: 10px;
    flex: 0 0 auto;
    vertical-align: middle;
}

.page-title {
    display: flex;
    align-items: center;
}

/* Sidebar Toggle Buttons (Accordion) */
.btn-toggle {
    color: var(--text-muted);
    background-color: transparent;
    border: none;
    font-weight: 600;
    padding: 0.5rem 1rem;
    position: relative;
    transition: var(--transition);
}

.btn-toggle:hover, .btn-toggle[aria-expanded="true"] {
    color: var(--primary);
    background-color: rgba(67, 97, 238, 0.05);
}

.btn-toggle::after {
    width: 1.25em;
    line-height: 0;
    content: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='rgba%280,0,0,.5%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 14l6-6-6-6'/%3e%3c/svg%3e");
    transition: transform .35s ease;
    transform-origin: .5em 50%;
    position: absolute;
    right: 1rem;
}

.btn-toggle[aria-expanded="true"]::after {
    transform: rotate(90deg);
}

.btn-toggle-nav a {
    padding: .5rem 1.25rem .5rem 2.5rem; /* Indented for hierarchy */
    font-size: .9rem;
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.5rem;
}

/* Stats Cards with Gradients */
.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
}

.bg-gradient-success {
    background: linear-gradient(135deg, var(--success) 0%, #20a094 100%) !important;
}

.bg-gradient-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #fb8500 100%) !important;
}

.bg-gradient-info {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--info) 100%) !important;
}

/* Tables */
.table-responsive {
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table thead th {
    background-color: #f8f9fa;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #edf2f7;
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    color: var(--text-main);
    border-bottom: 1px solid #edf2f7;
}

.table-hover tbody tr:hover {
    background-color: rgba(67, 97, 238, 0.02);
}

/* Badges & Pagination */
.badge {
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.35em 0.65em;
}

.pagination .page-link {
    border: none;
    border-radius: 0.5rem;
    margin: 0 2px;
    color: var(--text-muted);
    font-size: 0.85rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 6px rgba(67, 97, 238, 0.25);
}

/* ══════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════ */

.modal-content {
    border: none;
    border-radius: 0.938rem;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid #eef1f5;
    padding: 1.1rem 1.4rem;
    background-color: #fff;
}

.modal-header .modal-title {
    font-family: 'Source Sans Pro', 'Open Sans', sans-serif;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-main);
}

.modal-body {
    padding: 1.4rem;
    background-color: #f9fbfd;
}

.modal-footer {
    border-top: 1px solid #eef1f5;
    padding: 0.9rem 1.4rem;
    background-color: #fff;
}

.modal-backdrop.show {
    opacity: 0.4;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* ══════════════════════════════════════════════════
   CHARTS (Chart.js)
   ══════════════════════════════════════════════════ */

.chart-container {
    position: relative;
    width: 100%;
}

canvas {
    max-width: 100%;
}

/* Tooltip / legend polish applied via CSS where the canvas is not used */
.chartjs-tooltip,
.chart-tooltip {
    border-radius: 0.5rem !important;
    font-family: 'Open Sans', sans-serif !important;
    font-size: 12px !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15) !important;
}

/* Utilities */
.text-primary-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.shadow-soft {
    box-shadow: var(--shadow-lg) !important;
}

.rounded-xl {
    border-radius: var(--radius-lg) !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Mobile Fixes */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
}

.invoice-bilingual {
    display: inline-block;
    line-height: 1.15;
}

.invoice-arabic {
    display: block;
    font-size: 0.75em;
    line-height: 1.1;
    font-family: Tahoma, Arial, sans-serif;
    opacity: 0.9;
}

.invoice-arabic--badge {
    font-size: 0.7em;
    opacity: 1;
}

/* ══════════════════════════════════════════════════
   GLOBAL COMMAND PALETTE
   ══════════════════════════════════════════════════ */

.command-palette-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    animation: cmdFadeIn 0.15s ease-out;
}

.command-palette-overlay.open {
    display: flex;
}

@keyframes cmdFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cmdSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.command-palette-modal {
    width: 640px;
    max-width: calc(100vw - 32px);
    max-height: 70vh;
    background: #ffffff;
    border-radius: var(--radius-lg, 20px);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cmdSlideIn 0.15s ease-out;
}

.command-palette-input-wrapper {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #edf2f7;
    gap: 12px;
}

.command-palette-input-wrapper .cmd-icon {
    color: var(--text-muted, #8d99ae);
    font-size: 18px;
    flex-shrink: 0;
}

.command-palette-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    color: var(--text-main, #2b2d42);
    background: transparent;
    padding: 0;
    line-height: 1.4;
}

.command-palette-input-wrapper input::placeholder {
    color: var(--text-muted, #8d99ae);
}

.command-palette-shortcut-hint {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #f0f5fa;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #8d99ae);
    letter-spacing: 0.3px;
    font-family: 'Inter', sans-serif;
}

.command-palette-shortcut-hint kbd {
    display: inline-block;
    padding: 2px 5px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    background: #fff;
    border: 1px solid #dce3ed;
    border-radius: 4px;
    color: var(--text-main, #2b2d42);
    line-height: 1;
}

/* ── Empty state ── */
.command-palette-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted, #8d99ae);
}

.command-palette-empty .empty-icon {
    font-size: 36px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.command-palette-empty p {
    margin: 0;
    font-size: 14px;
}

/* ── Results list ── */
.command-palette-results {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    overscroll-behavior: contain;
}

.command-palette-results:empty {
    padding: 0;
}

/* Category heading */
.cmd-category-header {
    padding: 10px 20px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted, #8d99ae);
    font-family: 'Poppins', sans-serif;
}

.cmd-category-header:not(:first-child) {
    margin-top: 4px;
}

/* Result item */
.cmd-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-main, #2b2d42);
    transition: background 0.1s;
    outline: none;
    line-height: 1.3;
}

.cmd-result-item:hover,
.cmd-result-item.highlighted {
    background: #f0f5fa;
}

.cmd-result-item .cmd-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f0f5fa;
    color: var(--primary, #4361ee);
    font-size: 14px;
    flex-shrink: 0;
}

.cmd-result-item .cmd-item-text {
    flex: 1;
    min-width: 0;
}

.cmd-result-item .cmd-item-label {
    font-weight: 500;
    color: var(--text-main, #2b2d42);
}

.cmd-result-item .cmd-item-category {
    font-size: 12px;
    color: var(--text-muted, #8d99ae);
    margin-top: 1px;
}

.cmd-result-item .cmd-item-arrow {
    flex-shrink: 0;
    color: var(--text-muted, #8d99ae);
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.15s;
}

.cmd-result-item:hover .cmd-item-arrow,
.cmd-result-item.highlighted .cmd-item-arrow {
    opacity: 1;
}

/* Highlight search matches */
.cmd-result-item mark {
    background: rgba(67, 97, 238, 0.12);
    color: var(--primary, #4361ee);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 500;
}

/* ── Responsive ── */
@media (max-width: 576px) {
    .command-palette-overlay {
        padding-top: 0;
        align-items: flex-start;
    }

    .command-palette-modal {
        width: 100%;
        max-width: 100vw;
        max-height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }
}

/* ── Focus-visible for accessibility ── */
.cmd-result-item:focus-visible {
    outline: 2px solid var(--primary, #4361ee);
    outline-offset: -2px;
}

.command-palette-input-wrapper input:focus-visible {
    outline: none;
}

/* ----------------------------------------------------------------
   Hide native number-input steppers (up/down spinner arrows).
   Prevents accidental value changes from mis-clicks or mouse-wheel
   scrolling over amount/qty fields. Fields still accept typed input.
   ---------------------------------------------------------------- */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ══════════════════════════════════════════════════
   Phase A — Dashboard parity additions
   ══════════════════════════════════════════════════ */

/* KPI cards: click-through affordance + sparkline */
.kpi-clickable {
    transition: transform .15s ease, box-shadow .15s ease;
    cursor: pointer;
}
.kpi-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(20, 30, 60, .18);
}
.kpi-go {
    opacity: 0;
    transition: opacity .15s ease, transform .15s ease;
}
.kpi-clickable:hover .kpi-go {
    opacity: 1;
    transform: translateX(2px);
}
.kpi-spark {
    width: 100%;
    height: 28px;
    margin-top: 10px;
    display: block;
    overflow: visible;
}

/* Generic progress bars (attendance, income-by-module) */
.bar-track {
    height: 8px;
    background: #eef1f7;
    border-radius: 6px;
    overflow: hidden;
}
.bar-fill {
    display: block;
    height: 100%;
    background: var(--success, #2ec4b6);
    border-radius: 6px;
    transition: width .3s ease;
}
.bar-fill-primary {
    background: var(--primary, #4361ee);
}

/* Activity-log module badges */
.log-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 20px;
    display: inline-block;
    white-space: nowrap;
}
.log-badge.b-finance { background: #e8f0fe; color: #1a56db; }
.log-badge.b-auth { background: #f3f4f6; color: #4b5563; }
.log-badge.b-clinical { background: #fef3e2; color: #b45309; }


/* ==========================================================================
   Phase C4 — Dark Mode overrides (activated by html[data-theme="dark"])
   Bootstrap 5.3 already flips via data-bs-theme; these cover the custom theme.
   ========================================================================== */
html[data-theme="dark"],
html[data-bs-theme="dark"]{
    --bg-body: #0f1419;
    --bg-card: #1a2029;
    --bg-sidebar: #151b23;
    --text-main: #e6edf3;
    --text-muted: #a7b3c0;
    --shadow-sm: 0 2px 4px rgba(0,0,0,.35);
    --shadow-md: 0 5px 15px rgba(0,0,0,.45);
    --shadow-lg: 0 15px 35px rgba(0,0,0,.55);
    --shadow-hover: 0 20px 40px rgba(0,0,0,.6);
}
html[data-theme="dark"] body,
html[data-bs-theme="dark"] body{
    background-color: var(--bg-body) !important;
    color: var(--text-main);
}
html[data-theme="dark"] .card,
html[data-bs-theme="dark"] .card,
html[data-theme="dark"] .modal-content,
html[data-bs-theme="dark"] .modal-content,
html[data-theme="dark"] .dropdown-menu,
html[data-bs-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .offcanvas,
html[data-bs-theme="dark"] .offcanvas{
    background-color: var(--bg-card);
    color: var(--text-main);
    border-color: #2a3441;
}
html[data-theme="dark"] .table,
html[data-bs-theme="dark"] .table{
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-main);
    --bs-table-border-color: #2a3441;
    --bs-table-hover-bg: #222b36;
    --bs-table-hover-color: var(--text-main);
    color: var(--text-main);
}
html[data-theme="dark"] .table thead th,
html[data-bs-theme="dark"] .table thead th{
    background-color: #151b23;
    color: var(--text-muted);
    border-color: #2a3441;
}
html[data-theme="dark"] .text-dark,
html[data-bs-theme="dark"] .text-dark,
html[data-theme="dark"] .link-dark,
html[data-bs-theme="dark"] .link-dark{
    color: var(--text-main) !important;
}
html[data-theme="dark"] .text-muted,
html[data-bs-theme="dark"] .text-muted{ color: var(--text-muted) !important; }
html[data-theme="dark"] .bg-white,
html[data-bs-theme="dark"] .bg-white{ background-color: var(--bg-card) !important; }
html[data-theme="dark"] .bg-light,
html[data-bs-theme="dark"] .bg-light{ background-color: #151b23 !important; }
html[data-theme="dark"] hr,
html[data-bs-theme="dark"] hr{ border-color: #2a3441; opacity: 1; }
html[data-theme="dark"] .border,
html[data-bs-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-bs-theme="dark"] .border-top,
html[data-theme="dark"] .border-bottom,
html[data-bs-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-start,
html[data-bs-theme="dark"] .border-start,
html[data-theme="dark"] .border-end,
html[data-bs-theme="dark"] .border-end{ border-color: #2a3441 !important; }
html[data-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-bs-theme="dark"] .form-select,
html[data-theme="dark"] select:not(.select2-hidden-accessible),
html[data-bs-theme="dark"] select:not(.select2-hidden-accessible){
    background-color: #0f1419;
    color: var(--text-main);
    border-color: #2a3441;
}
html[data-theme="dark"] .form-control::placeholder,
html[data-bs-theme="dark"] .form-control::placeholder{ color: #6b7785; }
/* Native <option> popups ignore the select's own bg on most platforms and
   default to white -> light option text became invisible. Pin option colours. */
html[data-theme="dark"] select option,
html[data-bs-theme="dark"] select option,
html[data-theme="dark"] .form-select option,
html[data-bs-theme="dark"] .form-select option,
html[data-theme="dark"] .form-control option,
html[data-bs-theme="dark"] .form-control option{
    background-color: #151b23;
    color: var(--text-main, #e6edf3);
}
html[data-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-bs-theme="dark"] .form-select:focus{
    background-color: #0f1419;
    color: var(--text-main);
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(67,97,238,.25);
}
html[data-theme="dark"] .input-group-text,
html[data-bs-theme="dark"] .input-group-text{
    background-color: #151b23; color: var(--text-muted); border-color: #2a3441;
}
/* Form labels + check labels: base rule sets #525772 (dark navy) which is
   ~2:1 on the dark background — unreadable. This covers every .form-label /
   <label> on every dark-mode page (added 2026-10-12). */
html[data-theme="dark"] label,
html[data-bs-theme="dark"] label,
html[data-theme="dark"] .form-label,
html[data-bs-theme="dark"] .form-label,
html[data-theme="dark"] .col-form-label,
html[data-bs-theme="dark"] .col-form-label,
html[data-theme="dark"] .form-check-label,
html[data-bs-theme="dark"] .form-check-label{
    color: var(--text-main, #e6edf3) !important;
}
html[data-theme="dark"] .form-label.text-muted,
html[data-bs-theme="dark"] .form-label.text-muted,
html[data-theme="dark"] label.text-muted,
html[data-bs-theme="dark"] label.text-muted{ color: var(--text-muted, #a7b3c0) !important; }
html[data-theme="dark"] label .text-muted,
html[data-bs-theme="dark"] label .text-muted{ color: var(--text-muted, #a7b3c0) !important; }
/* Select2 (used on appointments_add, cases, ot/booking, radiology/booking,
   payments, hr/loans, documents…). The plugin ships its own white widget CSS
   that the generic .form-select overrides never reach, so the closed control
   was white-on-white and the open list white with dark text. */
html[data-theme="dark"] .select2-container .select2-selection--single,
html[data-bs-theme="dark"] .select2-container .select2-selection--single,
html[data-theme="dark"] .select2-container .select2-selection--multiple,
html[data-bs-theme="dark"] .select2-container .select2-selection--multiple{
    background-color: #0f1419 !important;
    border-color: #2a3441 !important;
    color: var(--text-main, #e6edf3) !important;
}
html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered,
html[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__rendered,
html[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__rendered{
    color: var(--text-main, #e6edf3) !important;
}
html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__placeholder,
html[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__placeholder{
    color: #8fa0b3 !important;
}
html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow b,
html[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow b{
    border-color: #aab6c4 transparent transparent transparent !important;
}
html[data-theme="dark"] .select2-dropdown,
html[data-bs-theme="dark"] .select2-dropdown{
    background-color: #1a2029 !important;
    border-color: #2a3441 !important;
    color: var(--text-main, #e6edf3) !important;
}
html[data-theme="dark"] .select2-results__option,
html[data-bs-theme="dark"] .select2-results__option{
    background-color: #1a2029 !important;
    color: var(--text-main, #e6edf3) !important;
}
html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
html[data-bs-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected]:hover,
html[data-bs-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected]:hover{
    background-color: var(--primary, #4361ee) !important;
    color: #fff !important;
}
html[data-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"],
html[data-bs-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"]{
    background-color: #222b36 !important;
    color: var(--text-main, #e6edf3) !important;
}
html[data-theme="dark"] .select2-search--dropdown .select2-search__field,
html[data-bs-theme="dark"] .select2-search--dropdown .select2-search__field{
    background-color: #0f1419 !important;
    color: var(--text-main, #e6edf3) !important;
    border-color: #2a3441 !important;
}
html[data-theme="dark"] .select2-search--dropdown .select2-search__field::placeholder,
html[data-bs-theme="dark"] .select2-search--dropdown .select2-search__field::placeholder{ color: #6b7785 !important; }
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice,
html[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice{
    background-color: #222b36 !important;
    border-color: #2a3441 !important;
    color: var(--text-main, #e6edf3) !important;
}
html[data-theme="dark"] .sidebar,
html[data-bs-theme="dark"] .sidebar,
html[data-theme="dark"] .nav-link.link-dark,
html[data-bs-theme="dark"] .nav-link.link-dark{ color: var(--text-main) !important; }
html[data-theme="dark"] .nav-link.link-dark:hover,
html[data-bs-theme="dark"] .nav-link.link-dark:hover{ background-color: #222b36; }
html[data-theme="dark"] .nav-link.link-dark.active,
html[data-bs-theme="dark"] .nav-link.link-dark.active{ background-color: rgba(67,97,238,.18); color: #7f9bff !important; }
html[data-theme="dark"] .page-title,
html[data-bs-theme="dark"] .page-title{ color: var(--text-main); }
html[data-theme="dark"] .log-badge.b-finance  ,
html[data-bs-theme="dark"] .log-badge.b-finance{ background:#16305a; color:#9dc2ff; }
html[data-theme="dark"] .log-badge.b-auth     ,
html[data-bs-theme="dark"] .log-badge.b-auth{ background:#2a3441; color:#c2ccd6; }
html[data-theme="dark"] .log-badge.b-clinical,
html[data-bs-theme="dark"] .log-badge.b-clinical{ background:#3d2c12; color:#f3c884; }
html[data-theme="dark"] .dropdown-item,
html[data-bs-theme="dark"] .dropdown-item{ color: var(--text-main); }
html[data-theme="dark"] .dropdown-item:hover,
html[data-bs-theme="dark"] .dropdown-item:hover{ background-color: #222b36; color: #fff; }
html[data-theme="dark"] .dropdown-header,
html[data-bs-theme="dark"] .dropdown-header{ color: var(--text-muted); }
html[data-theme="dark"] .command-palette-trigger,
html[data-bs-theme="dark"] .command-palette-trigger{ background:#151b23 !important; border-color:#2a3441 !important; color: var(--text-muted) !important; }
html[data-theme="dark"] .btn-outline-secondary,
html[data-bs-theme="dark"] .btn-outline-secondary{ color:#c2ccd6; border-color:#3a4553; }
html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-bs-theme="dark"] .btn-outline-secondary:hover{ background:#2a3441; color:#fff; }
html[data-theme="dark"] .modal-header,
html[data-bs-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-bs-theme="dark"] .modal-footer{ border-color:#2a3441; }
html[data-theme="dark"] .page-link,
html[data-bs-theme="dark"] .page-link{ background-color:#151b23; border-color:#2a3441; color:#c2ccd6; }
html[data-theme="dark"] .page-item.active .page-link,
html[data-bs-theme="dark"] .page-item.active .page-link{ background-color: var(--primary); border-color: var(--primary); }
html[data-theme="dark"] ::-webkit-scrollbar,
html[data-bs-theme="dark"] ::-webkit-scrollbar{ width: 11px; height: 11px; }
html[data-theme="dark"] ::-webkit-scrollbar-track,
html[data-bs-theme="dark"] ::-webkit-scrollbar-track{ background: #0f1419; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb,
html[data-bs-theme="dark"] ::-webkit-scrollbar-thumb{ background: #2f3a48; border-radius: 6px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover,
html[data-bs-theme="dark"] ::-webkit-scrollbar-thumb:hover{ background: #3d4a5a; }
/* ---- Dark-mode contrast & readability fixes (icons, text, KPI cards) ---- */

/* 1. KPI gradient cards: remove the milky glass overlay so the gradient + white text stay crisp */
html[data-theme="dark"] .glass-card,
html[data-bs-theme="dark"] .glass-card{
    background: inherit;          /* let the gradient show through */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid rgba(255,255,255,.10);
}
html[data-theme="dark"] .bg-gradient-primary.glass-card,
html[data-bs-theme="dark"] .bg-gradient-primary.glass-card{ background: linear-gradient(135deg, #4361ee 0%, #3a2fc0 100%) !important; }
html[data-theme="dark"] .bg-gradient-success.glass-card,
html[data-bs-theme="dark"] .bg-gradient-success.glass-card{ background: linear-gradient(135deg, #06b894 0%, #0a8f78 100%) !important; }
html[data-theme="dark"] .bg-gradient-info.glass-card    ,
html[data-bs-theme="dark"] .bg-gradient-info.glass-card{ background: linear-gradient(135deg, #2f86ff 0%, #17a2b8 100%) !important; }
/* Warning/Users card: darken the orange so white text passes contrast */
html[data-theme="dark"] .bg-gradient-warning.glass-card,
html[data-bs-theme="dark"] .bg-gradient-warning.glass-card{ background: linear-gradient(135deg, #b45309 0%, #92400e 100%) !important; }

/* 2. KPI icon circles used .bg-white.bg-opacity-25 -> dark mode turned them dark. Keep them light-on-gradient. */
html[data-theme="dark"] .bg-white.bg-opacity-25,
html[data-bs-theme="dark"] .bg-white.bg-opacity-25,
html[data-theme="dark"] .bg-white.bg-opacity-10,
html[data-bs-theme="dark"] .bg-white.bg-opacity-10{
    background-color: rgba(255,255,255,.22) !important;
}
html[data-theme="dark"] .glass-card .bg-white,
html[data-bs-theme="dark"] .glass-card .bg-white,
html[data-theme="dark"] [class*="bg-gradient-"] .bg-white,
html[data-bs-theme="dark"] [class*="bg-gradient-"] .bg-white{
    background-color: rgba(255,255,255,.22) !important;
    color: #fff !important;
}

/* 3. KPI labels/text on the colored cards must stay white and legible */
html[data-theme="dark"] [class*="bg-gradient-"] .card-title,
html[data-bs-theme="dark"] [class*="bg-gradient-"] .card-title,
html[data-theme="dark"] [class*="bg-gradient-"] h2,
html[data-bs-theme="dark"] [class*="bg-gradient-"] h2,
html[data-theme="dark"] [class*="bg-gradient-"] .text-white-50,
html[data-bs-theme="dark"] [class*="bg-gradient-"] .text-white-50{
    color: rgba(255,255,255,.92) !important;
}
html[data-theme="dark"] [class*="bg-gradient-"] .text-white-50,
html[data-bs-theme="dark"] [class*="bg-gradient-"] .text-white-50{ color: rgba(255,255,255,.78) !important; }

/* 4. Sidebar category labels (CLINICAL, LABORATORY, ...): were too faint */
html[data-theme="dark"] .sidebar .btn-toggle,
html[data-bs-theme="dark"] .sidebar .btn-toggle,
html[data-theme="dark"] .sidebar .text-uppercase.text-muted,
html[data-bs-theme="dark"] .sidebar .text-uppercase.text-muted,
html[data-theme="dark"] .sidebar .btn-toggle.text-muted,
html[data-bs-theme="dark"] .sidebar .btn-toggle.text-muted{
    color: #aab6c4 !important;
}
html[data-theme="dark"] .sidebar .btn-toggle:hover,
html[data-bs-theme="dark"] .sidebar .btn-toggle:hover{ color: #e6edf3 !important; }
html[data-theme="dark"] .sidebar .text-muted,
html[data-bs-theme="dark"] .sidebar .text-muted{ color: #aab6c4 !important; }

/* 4b. Submenu collapse arrows: the base rule paints the chevron with a
   hardcoded black SVG stroke (rgba(0,0,0,.5)), which is invisible on the
   dark sidebar. Swap in a light stroke for dark mode (and keep the
   "expanded" hover state bright). */
html[data-theme="dark"] .btn-toggle::after,
html[data-bs-theme="dark"] .btn-toggle::after{
    content: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='rgba%28255,255,255,.65%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 14l6-6-6-6'/%3e%3c/svg%3e");
}
html[data-theme="dark"] .btn-toggle:hover::after,
html[data-bs-theme="dark"] .btn-toggle:hover::after,
html[data-theme="dark"] .btn-toggle[aria-expanded="true"]::after,
html[data-bs-theme="dark"] .btn-toggle[aria-expanded="true"]::after{
    content: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='rgba%2880,140,255,.95%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 14l6-6-6-6'/%3e%3c/svg%3e");
}
/* Dropdown toggles elsewhere (sidebar user menu, mobile menu accordions)
   use Bootstrap's caret/chevron which is also black by default. */
html[data-theme="dark"] .sidebar .dropdown-toggle::after,
html[data-bs-theme="dark"] .sidebar .dropdown-toggle::after{
    border-top-color: #aab6c4;
}

/* 5. Quick Actions: buttons are .btn-outline-* -> dark mode left them dark-on-dark. Brighten icon+text.
   NOTE: the base rules (.btn-outline-primary etc. above) set background:#fff, which the earlier
   dark overrides forgot to reset — so light-coloured labels sat on a white pill (unreadable).
   Every dark rule below must force background:transparent until hover. */
html[data-theme="dark"] .btn-outline-primary,
html[data-bs-theme="dark"] .btn-outline-primary{ color:#8fa6ff !important; border-color:#3a4a8a !important; background:transparent !important; }
html[data-theme="dark"] .btn-outline-primary:hover,
html[data-bs-theme="dark"] .btn-outline-primary:hover{ background:#243056 !important; color:#fff !important; }
html[data-theme="dark"] .btn-outline-success,
html[data-bs-theme="dark"] .btn-outline-success{ color:#34d399 !important; border-color:#1f6f5a !important; background:transparent !important; }
html[data-theme="dark"] .btn-outline-success:hover,
html[data-bs-theme="dark"] .btn-outline-success:hover{ background:#123528 !important; color:#fff !important; }
html[data-theme="dark"] .btn-outline-info,
html[data-bs-theme="dark"] .btn-outline-info{ color:#38bdf8 !important; border-color:#1e5f7a !important; background:transparent !important; }
html[data-theme="dark"] .btn-outline-info:hover,
html[data-bs-theme="dark"] .btn-outline-info:hover{ background:#12303d !important; color:#fff !important; }
html[data-theme="dark"] .btn-outline-warning,
html[data-bs-theme="dark"] .btn-outline-warning{ color:#fbbf24 !important; border-color:#7a5a12 !important; background:transparent !important; }
html[data-theme="dark"] .btn-outline-warning:hover,
html[data-bs-theme="dark"] .btn-outline-warning:hover{ background:#3a2c0a !important; color:#fff !important; }
html[data-theme="dark"] .btn-outline-danger,
html[data-bs-theme="dark"] .btn-outline-danger{ color:#f87171 !important; border-color:#7a2a2a !important; background:transparent !important; }
html[data-theme="dark"] .btn-outline-danger:hover,
html[data-bs-theme="dark"] .btn-outline-danger:hover{ background:#3a1616 !important; color:#fff !important; }
html[data-theme="dark"] .btn-outline-secondary,
html[data-bs-theme="dark"] .btn-outline-secondary{ color:#c2ccd6 !important; border-color:#3a4553 !important; }
html[data-theme="dark"] .btn-outline-dark,
html[data-bs-theme="dark"] .btn-outline-dark{ color:#cbd5e1 !important; border-color:#3a4553 !important; }
html[data-theme="dark"] .btn-outline-dark:hover,
html[data-bs-theme="dark"] .btn-outline-dark:hover{ background:#2a3441 !important; color:#fff !important; }
html[data-theme="dark"] .btn-outline-light,
html[data-bs-theme="dark"] .btn-outline-light{ color:#e6edf3 !important; border-color:#3a4553 !important; }
html[data-theme="dark"] .btn-light,
html[data-bs-theme="dark"] .btn-light{ background:#1f2733 !important; border-color:#2a3441 !important; color:#e6edf3 !important; }
html[data-theme="dark"] .btn-light:hover,
html[data-bs-theme="dark"] .btn-light:hover{ background:#26303d !important; }
html[data-theme="dark"] .btn-light i.text-muted,
html[data-bs-theme="dark"] .btn-light i.text-muted{ color:#8fa0b0 !important; }
html[data-theme="dark"] .border-dashed,
html[data-bs-theme="dark"] .border-dashed{ border-color:#3a4553 !important; }

/* 8. Text-muted inside colored cards must stay light (badge/subtext) */
html[data-theme="dark"] .glass-card .text-muted,
html[data-bs-theme="dark"] .glass-card .text-muted,
html[data-theme="dark"] [class*="bg-gradient-"] .text-muted,
html[data-bs-theme="dark"] [class*="bg-gradient-"] .text-muted{ color: rgba(255,255,255,.80) !important; }

/* 9. "vs last month" subtext on KPI cards: keep light */
html[data-theme="dark"] .kpi-clickable .small,
html[data-bs-theme="dark"] .kpi-clickable .small{ color: rgba(255,255,255,.88) !important; }

/* 10. Section headers above cards (Module Summaries etc.) */
html[data-theme="dark"] h5.text-muted,
html[data-bs-theme="dark"] h5.text-muted,
html[data-theme="dark"] .module-summaries-title,
html[data-bs-theme="dark"] .module-summaries-title{ color: #aab6c4 !important; }

/* 11. Modals (e.g. Customize Shortcuts): ensure labels/headings are light, not dark-on-dark */
html[data-theme="dark"] .modal-content,
html[data-bs-theme="dark"] .modal-content,
html[data-theme="dark"] .modal-body,
html[data-bs-theme="dark"] .modal-body,
html[data-theme="dark"] .modal-header,
html[data-bs-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-bs-theme="dark"] .modal-footer{ color: var(--text-main); }
html[data-theme="dark"] .modal .form-check-label,
html[data-bs-theme="dark"] .modal .form-check-label,
html[data-theme="dark"] .modal .form-check-label .small,
html[data-bs-theme="dark"] .modal .form-check-label .small,
html[data-theme="dark"] .modal label,
html[data-bs-theme="dark"] .modal label{ color: var(--text-main) !important; }
html[data-theme="dark"] .modal .text-muted,
html[data-bs-theme="dark"] .modal .text-muted{ color: var(--text-muted) !important; }
html[data-theme="dark"] .modal-title,
html[data-bs-theme="dark"] .modal-title{ color: var(--text-main); }
html[data-theme="dark"] .modal .btn-default,
html[data-bs-theme="dark"] .modal .btn-default,
html[data-theme="dark"] .modal .btn-secondary,
html[data-bs-theme="dark"] .modal .btn-secondary{ background:#2a3441 !important; border-color:#3a4553 !important; color:#e6edf3 !important; }
html[data-theme="dark"] .form-check-input,
html[data-bs-theme="dark"] .form-check-input{ background-color:#0f1419; border-color:#3a4553; }
html[data-theme="dark"] .form-check-input:checked,
html[data-bs-theme="dark"] .form-check-input:checked{ background-color: var(--primary); border-color: var(--primary); }

/* 11b. Modal surfaces (2026-10-12):
   Base theme hardcodes .modal-header{background:#fff}, .modal-body{background:#f9fbfd},
   .modal-footer{background:#fff} (see MODALS section ~line 453). Only .modal-content was
   overridden, so every modal kept a WHITE body/header/footer while labels went light
   => light-on-white, unreadable. Override all three surfaces + the BS5.3 vars so
   Bootstrap's own modal dark variables can't reintroduce white. */
html[data-theme="dark"] .modal-content,
html[data-bs-theme="dark"] .modal-content{
    --bs-modal-bg: var(--bg-card);
    --bs-modal-color: var(--text-main);
    --bs-modal-border-color: #2a3441;
    --bs-modal-header-bg: #151b23;
    --bs-modal-footer-bg: #151b23;
    --bs-modal-header-border-color: #2a3441;
    --bs-modal-footer-border-color: #2a3441;
    background-color: var(--bg-card) !important;
    color: var(--text-main);
}
html[data-theme="dark"] .modal-header,
html[data-bs-theme="dark"] .modal-header{
    background-color: #151b23 !important;
    border-bottom: 1px solid #2a3441 !important;
    color: var(--text-main);
}
html[data-theme="dark"] .modal-body,
html[data-bs-theme="dark"] .modal-body{
    background-color: var(--bg-body) !important;
    color: var(--text-main);
}
html[data-theme="dark"] .modal-footer,
html[data-bs-theme="dark"] .modal-footer{
    background-color: #151b23 !important;
    border-top: 1px solid #2a3441 !important;
    color: var(--text-main);
}
html[data-theme="dark"] .modal-backdrop.show,
html[data-bs-theme="dark"] .modal-backdrop.show{ opacity: .6; }
/* Injected alert boxes + light cards inside modals (e.g. success token card). */
html[data-theme="dark"] .modal .card.bg-light,
html[data-bs-theme="dark"] .modal .card.bg-light,
html[data-theme="dark"] .modal .bg-light,
html[data-bs-theme="dark"] .modal .bg-light{ background-color:#1a2029 !important; }
html[data-theme="dark"] .modal hr,
html[data-bs-theme="dark"] .modal hr{ border-color:#2a3441 !important; }
html[data-theme="dark"] .modal .btn-close,
html[data-bs-theme="dark"] .modal .btn-close{ filter: invert(1) grayscale(1) brightness(1.6); }

/* 6. KPI sparkline stroke: keep visible on colored cards */
html[data-theme="dark"] .kpi-spark polyline,
html[data-bs-theme="dark"] .kpi-spark polyline{ stroke: rgba(255,255,255,.9) !important; }

/* 7. Generic icon readability on dark cards/lists */
html[data-theme="dark"] .card i.text-success,
html[data-bs-theme="dark"] .card i.text-success,
html[data-theme="dark"] .card .text-success,
html[data-bs-theme="dark"] .card .text-success{ color: #34d399 !important; }
html[data-theme="dark"] .card i.text-danger,
html[data-bs-theme="dark"] .card i.text-danger,
html[data-theme="dark"] .card .text-danger,
html[data-bs-theme="dark"] .card .text-danger{ color: #f87171 !important; }
html[data-theme="dark"] .card i.text-primary,
html[data-bs-theme="dark"] .card i.text-primary,
html[data-theme="dark"] .card .text-primary,
html[data-bs-theme="dark"] .card .text-primary{ color: #7f9bff !important; }
html[data-theme="dark"] .card i.text-warning,
html[data-bs-theme="dark"] .card i.text-warning,
html[data-theme="dark"] .card .text-warning,
html[data-bs-theme="dark"] .card .text-warning{ color: #fbbf24 !important; }
html[data-theme="dark"] .card i.text-info,
html[data-bs-theme="dark"] .card i.text-info,
html[data-theme="dark"] .card .text-info,
html[data-bs-theme="dark"] .card .text-info{ color: #38bdf8 !important; }

/* 12. Dual-tone PNG menu icons (black + teal) vanish on dark background.
   invert flips black strokes -> white; hue-rotate(180) keeps the teal accent
   teal (not orange); brightness(1.6) restores its vibrancy on dark. */
html[data-theme="dark"] .sidebar .nav-icon,
html[data-bs-theme="dark"] .sidebar .nav-icon,
html[data-theme="dark"] .sidebar .nav-icon-lg,
html[data-bs-theme="dark"] .sidebar .nav-icon-lg,
html[data-theme="dark"] .sidebar .nav-icon-sm,
html[data-bs-theme="dark"] .sidebar .nav-icon-sm,
html[data-theme="dark"] .navbar .nav-icon,
html[data-bs-theme="dark"] .navbar .nav-icon,
html[data-theme="dark"] .nav-icon,
html[data-bs-theme="dark"] .nav-icon{
    filter: invert(1) hue-rotate(180deg) brightness(1.6);
}
/* Active/hover states previously used brightness(1.15); keep them consistent
   with the inverted base so the icon doesn't flip back to dark on hover. */
html[data-theme="dark"] .sidebar .nav-link.active .nav-icon,
html[data-bs-theme="dark"] .sidebar .nav-link.active .nav-icon{
    filter: invert(1) hue-rotate(180deg) brightness(1.8) drop-shadow(0 1px 2px rgba(0,0,0,.4));
}

/* Keep print output always light, regardless of screen theme */
@media print {
    html[data-theme="dark"] body,
    html[data-bs-theme="dark"] body{ background: #fff !important; color: #000 !important; }
    html[data-theme="dark"] .card,
    html[data-bs-theme="dark"] .card{ background: #fff !important; color: #000 !important; }
}

/* ============================================================
   13. Icon/text visibility sweep for dark mode (2026-10-11)
   The same dual-tone PNGs (black strokes + teal accent) are used
   NOT only in the sidebar but also as page-title icons, the header
   avatar, etc. Those outside .sidebar/.navbar were missed by the
   block above and render near-black on the dark surface => invisible.
   Apply the identical inversion to every remaining dual-tone PNG.
   ============================================================ */
html[data-theme="dark"] .page-icon,
html[data-bs-theme="dark"] .page-icon,
html[data-theme="dark"] .page-title img,
html[data-bs-theme="dark"] .page-title img,
html[data-theme="dark"] .card-header img,
html[data-bs-theme="dark"] .card-header img,
html[data-theme="dark"] .modal-header img,
html[data-bs-theme="dark"] .modal-header img,
html[data-theme="dark"] .widget-icon,
html[data-bs-theme="dark"] .widget-icon,
html[data-theme="dark"] .stat-icon,
html[data-bs-theme="dark"] .stat-icon,
html[data-theme="dark"] .header-avatar,
html[data-bs-theme="dark"] .header-avatar,
html[data-theme="dark"] .user-avatar,
html[data-bs-theme="dark"] .user-avatar,
html[data-theme="dark"] .profile-avatar,
html[data-bs-theme="dark"] .profile-avatar,
html[data-theme="dark"] img[src*="icon_user_avatar"],
html[data-bs-theme="dark"] img[src*="icon_user_avatar"],
html[data-theme="dark"] img[src*="assets/icons/"],
html[data-bs-theme="dark"] img[src*="assets/icons/"]{
    filter: invert(1) hue-rotate(180deg) brightness(1.6);
}
/* Real uploaded profile photos must NOT be inverted — reset any
   inherited filter for them (they live under /uploads/). */
html[data-theme="dark"] img[src*="uploads/profile_photos/"],
html[data-bs-theme="dark"] img[src*="uploads/profile_photos/"]{
    filter: none !important;
}

/* --- Header (top navbar) background in dark mode -------------
   Base rule sets navbar to rgba(255,255,255,.9). In dark mode that
   leaves a bright white bar across the top while the rest of the
   app is dark. Force a dark translucent surface and keep its text
   and small icon controls light. */
html[data-theme="dark"] .navbar,
html[data-bs-theme="dark"] .navbar{
    background: rgba(21, 27, 35, 0.92) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.5);
    border-bottom: 1px solid #2a3441;
}
html[data-theme="dark"] .navbar .navbar-brand,
html[data-bs-theme="dark"] .navbar .navbar-brand,
html[data-theme="dark"] .navbar .nav-link,
html[data-bs-theme="dark"] .navbar .nav-link,
html[data-theme="dark"] .navbar .dropdown-toggle,
html[data-bs-theme="dark"] .navbar .dropdown-toggle,
html[data-theme="dark"] .navbar span,
html[data-bs-theme="dark"] .navbar span,
html[data-theme="dark"] .navbar i,
html[data-bs-theme="dark"] .navbar i{
    color: #e6edf3;
}
html[data-theme="dark"] .navbar .text-muted,
html[data-bs-theme="dark"] .navbar .text-muted,
html[data-theme="dark"] .navbar .small,
html[data-bs-theme="dark"] .navbar .small{
    color: #9aa8b8 !important;
}
/* Header controls that were styled for a light bar */
html[data-theme="dark"] .navbar .btn-icon,
html[data-bs-theme="dark"] .navbar .btn-icon{
    color: #e6edf3;
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.12);
}
html[data-theme="dark"] .navbar .btn-icon:hover,
html[data-bs-theme="dark"] .navbar .btn-icon:hover{
    background: rgba(255,255,255,.14);
    color: #fff;
}
/* Search input inside the header */
html[data-theme="dark"] .navbar .form-control,
html[data-bs-theme="dark"] .navbar .form-control,
html[data-theme="dark"] .navbar .search-input,
html[data-bs-theme="dark"] .navbar .search-input{
    background-color: rgba(255,255,255,.06) !important;
    border-color: rgba(255,255,255,.12) !important;
    color: #e6edf3 !important;
}
html[data-theme="dark"] .navbar .form-control::placeholder,
html[data-bs-theme="dark"] .navbar .form-control::placeholder{
    color: #8fa0b3 !important;
}
/* The Ctrl+K / keyboard hint badges on a now-dark bar */
html[data-theme="dark"] .navbar .badge.bg-light,
html[data-bs-theme="dark"] .navbar .badge.bg-light{
    background-color: rgba(255,255,255,.10) !important;
    color: #c2ccd6 !important;
    border-color: rgba(255,255,255,.15) !important;
}

/* ============================================================
   14. Page-local white panels (2026-10-11)
   Several list pages (patients, appointments, invoices, payments,
   laboratory, appointments_today) declare their own .filter-bar { background:#fff } inside a page-local <style>. That stays white
   in dark mode, so grey outline buttons placed on it (e.g. the
   "Filters" button) become near-invisible (1.6:1). Override with a
   higher-specificity dark rule. */
html[data-theme="dark"] .filter-bar,
html[data-bs-theme="dark"] .filter-bar,
html[data-theme="dark"] .actions-bar,
html[data-bs-theme="dark"] .actions-bar,
html[data-theme="dark"] .appointment-card,
html[data-bs-theme="dark"] .appointment-card,
html[data-theme="dark"] .dashboard-header,
html[data-bs-theme="dark"] .dashboard-header{
    background: var(--bg-card, #1a2029) !important;
    box-shadow: 0 2px 10px rgba(0,0,0,.35) !important;
    color: var(--text-main, #e6edf3);
}
/* appointments_today.php additionally wraps the whole page in
   .clinic-dashboard { background:#f8f9fa } — that is the white the user
   sees. It also hardcodes .doc-title{color:#333} and .token-box{#f1f3f5}. */
html[data-theme="dark"] .clinic-dashboard,
html[data-bs-theme="dark"] .clinic-dashboard{
    background-color: var(--bg-body, #0f1419) !important;
}
html[data-theme="dark"] .doc-title,
html[data-bs-theme="dark"] .doc-title{ color: var(--text-main, #e6edf3) !important; }
html[data-theme="dark"] .token-box,
html[data-bs-theme="dark"] .token-box{
    background: #222b36 !important;
    color: #e6edf3 !important;
}
html[data-theme="dark"] .appointment-card.status-in_progress,
html[data-bs-theme="dark"] .appointment-card.status-in_progress{
    background-color: #2a2412 !important;
}
/* Outline buttons sitting on dark surfaces: brighten the "secondary"
   variant so its label stays legible (was rgb(194,204,214) on white). */
html[data-theme="dark"] .btn-outline-secondary,
html[data-bs-theme="dark"] .btn-outline-secondary{
    color: #c2ccd6 !important;
    border-color: #3a4757 !important;
}
html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-bs-theme="dark"] .btn-outline-secondary:hover,
html[data-theme="dark"] .btn-outline-secondary:focus,
html[data-bs-theme="dark"] .btn-outline-secondary:focus{
    background-color: #2a3441 !important;
    color: #fff !important;
    border-color: #4a5a6d !important;
}
/* Print/label helpers that some pages paint white */
html[data-theme="dark"] .noprint,
html[data-bs-theme="dark"] .noprint{ background: transparent !important; }

/* ============================================================
   15. Dental Chart / Odontogram (patients/tabs/dental_chart.php)
   The SVG tooth numbers (.tooth-label fill:#666) and the two jaw
   headings (inline fill="#333") are dark-on-dark in dark mode;
   the tooth-details modal's meta/history blocks are hardcoded light.
   CSS beats SVG presentation attributes, so the inline fill="#333"
   on <text> is overridden here without editing the SVG markup.
   ============================================================ */
html[data-theme="dark"] #dentalChartSvg .tooth-label,
html[data-bs-theme="dark"] #dentalChartSvg .tooth-label,
html[data-theme="dark"] #dentalChartSvg text,
html[data-bs-theme="dark"] #dentalChartSvg text{
    fill: #c2ccd6 !important;
}
/* Keep the "healthy" tooth swatch visibly white (it represents a tooth). */
html[data-theme="dark"] #dentalChartSvg .tooth.healthy,
html[data-bs-theme="dark"] #dentalChartSvg .tooth.healthy{ fill: #ffffff !important; stroke: #6b7683 !important; }
html[data-theme="dark"] #dentalChartSvg line,
html[data-bs-theme="dark"] #dentalChartSvg line{ stroke: #2a3441 !important; }
html[data-theme="dark"] .tooth-meta,
html[data-bs-theme="dark"] .tooth-meta{ color: #aab6c4 !important; }
html[data-theme="dark"] .tooth-history-list,
html[data-bs-theme="dark"] .tooth-history-list{
    background: #151b23 !important;
    border-color: #2a3441 !important;
}
html[data-theme="dark"] .tooth-history-item,
html[data-bs-theme="dark"] .tooth-history-item{ border-bottom-color: #2a3441 !important; }
html[data-theme="dark"] .tooth-history-notes,
html[data-bs-theme="dark"] .tooth-history-notes{ color: var(--text-main) !important; }

/* ============================================================
   MOBILE BOTTOM NAVIGATION (.mobile-nav)
   ------------------------------------------------------------
   includes/footer.php renders a mobile-only bottom bar
   (Home / Appointments / Patients / Profile). Its SCSS/CSS was
   living in assets/css/custom.css — a file that is NOT linked on
   any page — so the bar rendered completely UNSTYLED: transparent,
   position:static, links stacked vertically. This restores the
   intended fixed bottom bar and themes it for dark mode.
   Only visible < 768px via the .mobile-only utility.
   ============================================================ */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    border-top: 1px solid var(--bs-border-color, #e9ecef);
    z-index: 1030;
}
.mobile-nav-item {
    text-align: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    line-height: 1.2;
    flex: 1 1 0;
}
.mobile-nav-item i {
    font-size: 20px;
    display: block;
    margin-bottom: 4px;
}
.mobile-nav-item.active { color: var(--primary); }

/* Dark mode: the bottom bar follows the app theme. */
html[data-theme="dark"] .mobile-nav,
html[data-bs-theme="dark"] .mobile-nav{
    background: var(--bg-sidebar) !important;
    border-top: 1px solid #2a3441 !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.45) !important;
}
html[data-theme="dark"] .mobile-nav-item,
html[data-bs-theme="dark"] .mobile-nav-item{ color: var(--text-muted) !important; }
html[data-theme="dark"] .mobile-nav-item.active,
html[data-bs-theme="dark"] .mobile-nav-item.active{ color: var(--primary-light) !important; }

/* ============================================================
   Header gap fill: desktop sidebar-collapse toggle + home shortcut
   (added 2026-10-13). The navbar's left edge was empty on desktop
   because the hamburger + brand are d-lg-none. This cluster fills it.
   ============================================================ */

/* Control cluster sits at the start of the collapsed navbar on desktop. */
.hms-nav-controls {
    flex-shrink: 0;
}

/* Light-mode base for the two new icon buttons (matches the outline
   style of the existing theme/bell/info controls). No filled background —
   stays consistent with the other outline icons in the header. */
.navbar .hms-sidebar-toggle,
.navbar .hms-home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--text-muted, #6b7280);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    line-height: 1;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.navbar .hms-sidebar-toggle:hover,
.navbar .hms-home-link:hover {
    color: var(--primary, #14b8a6);
    background: rgba(20, 184, 166, .08);
    border-color: rgba(20, 184, 166, .18);
}
/* Icon centred inside the box, no stray offsets. */
.navbar .hms-home-link img.nav-icon {
    display: block;
    margin: 0 auto;
    width: 20px;
    height: 20px;
    object-fit: contain;
    opacity: .85;
}
.navbar .hms-home-link:hover img.nav-icon { opacity: 1; }
/* Home gets a subtle active mark when already on the dashboard (outline
   style only — no filled tint, so it doesn't read as a "pressed" button). */
.navbar .hms-home-link.is-current {
    color: var(--primary, #14b8a6);
    border-color: rgba(20, 184, 166, .28);
}
.navbar .hms-sidebar-toggle:focus-visible,
.navbar .hms-home-link:focus-visible {
    outline: 2px solid var(--primary, #14b8a6);
    outline-offset: 2px;
}

/* ---- Collapsed (rail) state ---- */
/* Applied by JS as a class on <html>. Sidebar narrows to an icon rail and
   the main column widens to reclaim the freed space. */
html.hms-sidebar-collapsed #sidebarMenu {
    width: 76px !important;
    padding-left: .5rem !important;
    padding-right: .5rem !important;
    overflow-x: hidden;
}
html.hms-sidebar-collapsed #sidebarMenu .hms-rail-hide {
    display: none !important;
}
html.hms-sidebar-collapsed #sidebarMenu a,
html.hms-sidebar-collapsed #sidebarMenu .nav-link {
    justify-content: center;
}
html.hms-sidebar-collapsed #sidebarMenu .nav-link {
    padding-left: .5rem;
    padding-right: .5rem;
}
html.hms-sidebar-collapsed #sidebarMenu hr { opacity: .06; }

/* Reflow of the Bootstrap grid column that holds the sidebar is handled by
   the "SIDEBAR ↔ MAIN-CONTENT GAP" block near the end of this file, which
   sets both the margin-left and the width/flex for the normal AND collapsed
   states. Nothing to duplicate here. */

/* Keep the new controls hidden in dark mode from inheriting a light bg
   (the dark-theme .navbar .btn-icon rules already cover .btn-icon; these
   two are not .btn-icon so give them a matching dark treatment). */
html[data-theme="dark"] .navbar .hms-sidebar-toggle,
html[data-bs-theme="dark"] .navbar .hms-sidebar-toggle,
html[data-theme="dark"] .navbar .hms-home-link,
html[data-bs-theme="dark"] .navbar .hms-home-link {
    color: #e6edf3;
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.12);
}
html[data-theme="dark"] .navbar .hms-sidebar-toggle:hover,
html[data-bs-theme="dark"] .navbar .hms-sidebar-toggle:hover,
html[data-theme="dark"] .navbar .hms-home-link:hover,
html[data-bs-theme="dark"] .navbar .hms-home-link:hover {
    background: rgba(255,255,255,.14);
    color: #fff;
}

/* On desktop the sidebar is position:fixed (0–280px). The main column now
   carries a matching margin-left (see the sidebar/main-content gap block
   above), so the navbar inside it already starts clear of the rail — the
   control cluster needs NO extra offset. (Earlier a +31px nudge compensated
   for the old mismatched column start; that workaround is retired here.) */
@media (min-width: 992px) {
    .hms-nav-controls { margin-left: 0; }
    html.hms-sidebar-collapsed .hms-nav-controls { margin-left: 0; }
}

/* Ctrl+K chips inside the navbar search trigger.
   Root cause of the "invisible Ctrl+K": Bootstrap's global
   `kbd { color:#fff; background:#212529 }` set the text to white while the
   inline style only overrode the background to #fff -> white on white.
   Set BOTH colour and background explicitly here (class beats the element rule). */
.navbar .cmd-kbd,
.navbar kbd.hms-kbd {
    display: inline-block;
    font-family: 'Inter', sans-serif;
    background: #fff;
    color: #4b5563;
    border: 1px solid #dce3ed;
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    box-shadow: none;
}

/* Keep the hint chips visible when the search trigger is hovered/focused
   (Bootstrap's .btn hover can wash them out). */
.navbar .command-palette-trigger:hover .hms-kbd,
.navbar .command-palette-trigger:focus .hms-kbd {
    color: #374151;
    border-color: #cbd5e1;
}

/* Keep the "Search..." label readable on hover/focus.
   BUG: the trigger is .btn-outline-secondary. A theme rule flips the
   BUTTON to a dark fill on :hover/:focus (background var(--text-muted),
   color var(--bg-card)=white). But the label is a plain <span> with its
   OWN colour (slate #64748b) which the button's `color` does not inherit
   over — so dark slate text on a dark slate fill = invisible. Force the
   span to inherit the button's hover colour instead. */
.navbar .command-palette-trigger:hover > span,
.navbar .command-palette-trigger:focus > span,
.navbar .command-palette-trigger:hover > .search-label,
.navbar .command-palette-trigger:focus > .search-label {
    color: var(--bg-card) !important;
}
/* Same treatment for the leading magnifier icon, if it is a font icon
   (it currently inherits, but pin it so a future colour rule cannot
   reintroduce the same clash). */
.navbar .command-palette-trigger:hover > i,
.navbar .command-palette-trigger:focus > i {
    color: var(--bg-card) !important;
}

/* Dark theme: the dark-themed .btn-outline-secondary:hover already sets
   color:#fff; make the span follow it too. */
html[data-theme="dark"] .navbar .command-palette-trigger:hover > span,
html[data-bs-theme="dark"] .navbar .command-palette-trigger:hover > span,
html[data-theme="dark"] .navbar .command-palette-trigger:focus > span,
html[data-bs-theme="dark"] .navbar .command-palette-trigger:focus > span,
html[data-theme="dark"] .navbar .command-palette-trigger:hover > i,
html[data-bs-theme="dark"] .navbar .command-palette-trigger:hover > i {
    color: #fff !important;
}

/* ============================================================
   MOBILE MENU — icon colour consistency (added 2026-10-13)
   ------------------------------------------------------------
   BUG: mobile_menu.php mixes two blues on its Font Awesome icons.
   Top-level links (Dashboard, Notice Board, Blood Bank, User Guide,
   Change Password, Logout) inherit the app --primary = #4361ee, while
   9 nested accordion headers carry Bootstrap's `text-primary`
   (#0d6efd) — a visibly different blue. The desktop sidebar uses PNG
   icons with one baked-in colour, so mobile looked inconsistent.
   FIX: scope to the mobile menu page (body.hms-mobile-menu) and force
   every menu-row icon to the app --primary, overriding Bootstrap's
   .text-primary. Header chrome icons (logo / moon / close, in the top
   bar) are excluded — they are not menu rows.
   Scoped by body class so the unrelated .accordion-button pages
   (legacy_profile_view, saas_hub packages) are NOT touched.
   ============================================================ */
body.hms-mobile-menu .menu-item > i.fas,
body.hms-mobile-menu .submenu-item > i.fas,
body.hms-mobile-menu .accordion-button > i.fas,
body.hms-mobile-menu .accordion-body i.fas,
body.hms-mobile-menu a.menu-item i.fas {
    color: var(--primary, #4361ee) !important;
}

/* Dark theme: use the app's lighter primary so contrast holds on the
   dark surface. */
html[data-theme="dark"] body.hms-mobile-menu .menu-item > i.fas,
html[data-bs-theme="dark"] body.hms-mobile-menu .menu-item > i.fas,
html[data-theme="dark"] body.hms-mobile-menu .accordion-button > i.fas,
html[data-bs-theme="dark"] body.hms-mobile-menu .accordion-button > i.fas,
html[data-theme="dark"] body.hms-mobile-menu .accordion-body i.fas,
html[data-bs-theme="dark"] body.hms-mobile-menu .accordion-body i.fas {
    color: var(--primary-light, #7f9bff) !important;
}

/* ============================================================
   SIDEBAR ↔ MAIN-CONTENT GAP (rewritten 2026-10-13)
   ------------------------------------------------------------
   ROOT CAUSE: the sidebar (#sidebarMenu) is position:fixed, 280px wide,
   so it is REMOVED FROM FLOW. The Bootstrap grid column that holds it
   (.col-md-3 / .col-lg-2) therefore collapses, and the main column
   (.col-md-9 / .col-lg-10) begins at x≈212px — i.e. UNDER the sidebar.
   The visible result: the main content's left edge sits flush against
   the sidebar's right edge, with NO breathing room. On a wide monitor
   the two read as one slab.

   FIX: push the main column clear of the fixed sidebar with a left
   MARGIN equal to the sidebar width + a gutter, and keep a readable
   left padding inside the content wrapper. Scoped to the shell pattern
   (.col-md-9.col-lg-10) so unrelated grids are untouched.

   Widths: sidebar 280px (76px when collapsed via html.hms-sidebar-collapsed).
   ============================================================ */
@media (min-width: 992px) {
    /* Main column clears the fixed sidebar. `!important` because Bootstrap's
       grid `.col-*` sets width/flex and we are overriding the auto margin. */
    .container-fluid > .row > .col-md-9.col-lg-10 {
        margin-left: 280px !important;
        width: calc(100% - 280px) !important;
        flex: 0 0 calc(100% - 280px) !important;
        max-width: calc(100% - 280px);
    }
    /* The content wrapper that FOLLOWS the navbar. Left padding = the
       visible gap between sidebar edge and content; other sides stay
       modest so wide monitors keep reclaiming space. */
    .navbar + .p-4 { padding: 20px 20px 20px 24px !important; }

    /* Collapsed rail (76px) — reclaim the freed horizontal space. */
    html.hms-sidebar-collapsed .container-fluid > .row > .col-md-9.col-lg-10 {
        margin-left: 76px !important;
        width: calc(100% - 76px) !important;
        flex: 0 0 calc(100% - 76px) !important;
        max-width: calc(100% - 76px);
    }
}

/* Larger screens: keep the same gap (it is now a real margin, not padding
   that can be squeezed). Nudge the inner inset down slightly so big panels
   still use the width. */
@media (min-width: 1600px) {
    .navbar + .p-4 { padding: 18px 18px 18px 24px !important; }
}
@media (min-width: 1920px) {
    .navbar + .p-4 { padding: 16px 16px 16px 24px !important; }
}

/* Nested rows inside the content use Bootstrap .row gutters (12px each side).
   Trim the horizontal gutter a touch to match the outer padding so the
   alignment stays visually consistent. */
@media (min-width: 992px) {
    .navbar + .p-4 > .row,
    .navbar + .p-4 > .d-flex + .row {
        --bs-gutter-x: 16px;
    }
}
