/* ==========================================================================
   DHENOVA DESIGN SYSTEM
   Central stylesheet for the Dhenova Ghee CRM admin UI.

   Loaded once (layouts/admin.blade.php + layouts/guest.blade.php) after
   Bootstrap 5 + Bootstrap Icons, so it overrides Bootstrap's defaults
   everywhere those components are used — no per-module CSS needed.

   NOTE ON FILE LOCATION: this project has no Vite/npm build step (Bootstrap
   itself is loaded via CDN, established since the first admin-layout phase —
   node_modules was never installed). So this file lives in public/css/ and
   is linked directly via asset(), rather than resources/css/ which would
   need a build step to become servable.

   Sections:
   1. Font            7. Page Header      13. Badges
   2. Variables        8. Cards           14. Tabs
   3. Body / Reset      9. KPI Cards       15. Modals
   4. Typography      10. Forms           16. Alerts
   5. Sidebar         11. Buttons         17. Pagination / Dropdowns
   6. Header          12. Tables          18. Responsive
                                           19. Business Dashboard
   ========================================================================== */

/* -----------------------------------------------------------------------
   1. FONT
   ----------------------------------------------------------------------- */

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

/* -----------------------------------------------------------------------
   2. VARIABLES
   ----------------------------------------------------------------------- */

:root {
    --dh-primary: #198754;
    --dh-primary-dark: #146c43;
    --dh-primary-soft: #e8f5ee;
    --dh-bg: #f5f7fa;
    --dh-surface: #ffffff;
    --dh-text: #1f2937;
    --dh-muted: #6b7280;
    --dh-border: #e5e7eb;
    --dh-input-border: #dde2e7;
    --dh-placeholder: #9ca3af;

    --dh-success: #198754;
    --dh-warning: #f59e0b;
    --dh-danger: #dc3545;
    --dh-info: #0d6efd;

    --dh-radius-sm: 6px;
    --dh-radius: 8px;
    --dh-radius-lg: 14px;

    --dh-space-1: 4px;
    --dh-space-2: 8px;
    --dh-space-3: 12px;
    --dh-space-4: 16px;
    --dh-space-5: 20px;
    --dh-space-6: 24px;
    --dh-space-8: 32px;

    --dh-shadow-card: 0 2px 8px rgba(16, 24, 40, 0.06);
    --dh-shadow-dropdown: 0 8px 24px rgba(16, 24, 40, 0.10);
    --dh-shadow-modal: 0 12px 40px rgba(16, 24, 40, 0.16);

    --dh-sidebar-width: 258px;
    --dh-sidebar-collapsed-width: 76px;

    /* Business Dashboard analytics accent — used only inside the charts,
       gradient card and trend indicators on /admin/dashboard, never on
       buttons/links/sidebar. The rest of the app keeps its established
       green brand color; this is purely the "data visualization" palette,
       chosen to match the premium analytics look the dashboard asks for
       without re-theming the whole CRM. */
    --dh-chart-indigo: #6366f1;
    --dh-chart-purple: #8b5cf6;
    --dh-chart-indigo-dark: #4f46e5;
    --dh-chart-lavender: #f5f3ff;
    --dh-chart-blue: #3b82f6;
    --dh-chart-amber: #f59e0b;
    --dh-chart-rose: #ef4444;
    --dh-chart-teal: #14b8a6;
}

/* -----------------------------------------------------------------------
   3. BODY / RESET
   ----------------------------------------------------------------------- */

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--dh-bg);
    color: var(--dh-text);
    font-size: 14px;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
}

/* -----------------------------------------------------------------------
   4. TYPOGRAPHY
   ----------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6,
.dh-heading {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    color: var(--dh-text);
}

.h4, h1.h4 { font-size: 28px; line-height: 1.25; }
h2.h6, .h6 { font-size: 16px; }

small, .small { font-size: 12.5px; }

.text-muted { color: var(--dh-muted) !important; }

a { color: var(--dh-primary); }
a:hover { color: var(--dh-primary-dark); }

/* -----------------------------------------------------------------------
   5. SIDEBAR
   ----------------------------------------------------------------------- */

.admin-sidebar {
    width: var(--dh-sidebar-width);
    background-color: #ffffff !important;
    transition: width .2s ease;
}

/* Desktop only: relative positioning anchors the collapse toggle. Below lg
   the sidebar must keep Bootstrap's fixed offcanvas positioning, otherwise
   the hidden drawer stays in the page flow and pushes content ~2000px down. */
@media (min-width: 992px) {
    .admin-sidebar {
        position: relative !important;
    }
}

@media (max-width: 991.98px) {
    .admin-sidebar {
        max-width: 85vw;
    }
}

/* Bootstrap forces `.offcanvas-lg { background-color: transparent !important; }`
   at >=992px so the offcanvas can behave like a static sidebar. Putting the
   background on the inner .offcanvas-body instead keeps it intact at every
   breakpoint, desktop included. */
.admin-sidebar .offcanvas-body {
    background-color: #ffffff;
    border-right: 1px solid var(--dh-border);
    padding-bottom: var(--dh-space-4);
}

/* Mobile-only header (close button row) — kept white to match the rest
   of the sidebar rather than Bootstrap's default. */
.admin-sidebar .offcanvas-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--dh-border);
}

.admin-sidebar .sidebar-brand {
    color: var(--dh-primary-dark);
    border-bottom: 1px solid var(--dh-border);
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 17px;
    background-color: #ffffff;
}

.sidebar-logo {
    height: 70px;
    width: auto;
}

.admin-sidebar .offcanvas-header .sidebar-logo {
    height: 40px;
}

.sidebar-logo-collapsed {
    display: none;
    font-size: 28px;
    color: var(--dh-primary-dark);
}

/* Small circular handle straddling the sidebar's right edge — always in
   the same spot, so it doesn't compete with the brand/logo for space in
   either state. Desktop only; the mobile drawer keeps its own X button. */
.sidebar-toggle-btn {
    position: absolute;
    top: 24px;
    right: -14px;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--dh-border);
    background-color: #ffffff;
    color: var(--dh-primary-dark);
    align-items: center;
    justify-content: center;
    box-shadow: var(--dh-shadow-dropdown);
    z-index: 1031; /* above Bootstrap's offcanvas (1045 on mobile, irrelevant here since it's d-none <lg) */
    cursor: pointer;
}

.sidebar-toggle-btn:hover {
    background-color: var(--dh-primary-soft);
}

.sidebar-toggle-btn i {
    font-size: 14px;
    transition: transform .2s ease;
}

/* -------- Collapsed state -------- */
/* Scoped to the desktop breakpoint only: the toggle button itself is
   d-none below lg, but the body class persists via localStorage across
   viewport sizes, and the mobile offcanvas drawer must always open full
   width with labels regardless of the desktop collapsed state. */
@media (min-width: 992px) {
    body.sidebar-collapsed .admin-sidebar {
        width: var(--dh-sidebar-collapsed-width);
    }

    body.sidebar-collapsed .sidebar-toggle-btn i {
        transform: rotate(180deg);
    }

    body.sidebar-collapsed .sidebar-brand {
        padding-left: var(--dh-space-2);
        padding-right: var(--dh-space-2);
    }

    body.sidebar-collapsed .sidebar-logo-full {
        display: none;
    }

    body.sidebar-collapsed .sidebar-logo-collapsed {
        display: inline-block;
    }

    body.sidebar-collapsed .sidebar-section-label,
    body.sidebar-collapsed .sidebar-link span {
        display: none;
    }

    body.sidebar-collapsed .sidebar-link {
        justify-content: center;
        padding: 0;
    }

    body.sidebar-collapsed .sidebar-link i {
        margin-right: 0 !important;
    }

    body.sidebar-collapsed .sidebar-link.active::before {
        left: -2px;
    }
}

.sidebar-section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--dh-placeholder);
    padding: var(--dh-space-4) var(--dh-space-3) var(--dh-space-1);
}

.sidebar-section-label:first-of-type {
    padding-top: var(--dh-space-3);
}

.sidebar-link {
    color: #374151;
    border-radius: var(--dh-radius);
    height: 44px;
    padding: 0 var(--dh-space-3);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    position: relative;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar-link i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-link:hover {
    background-color: var(--dh-primary-soft);
    color: var(--dh-primary-dark);
}

.sidebar-link.active {
    background-color: var(--dh-primary-soft) !important;
    color: var(--dh-primary-dark) !important;
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 3px;
    background-color: var(--dh-primary);
}

@media (min-width: 992px) {
    .admin-layout {
        display: flex;
    }
    .admin-content {
        flex: 1;
        min-width: 0;
    }
}

/* -----------------------------------------------------------------------
   6. HEADER
   ----------------------------------------------------------------------- */

.admin-topbar {
    height: 64px;
    flex-wrap: nowrap;
}

/* Compact icon buttons in the topbar so the menu toggle, brand, bell and
   avatar always fit on one row on phones instead of wrapping over the page. */
.admin-topbar .btn {
    min-height: 40px;
    padding: 6px 10px;
}

.admin-topbar-title {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dh-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--dh-primary-soft);
    color: var(--dh-primary-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

/* -------- Notification bell + dropdown -------- */

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 5px;
    line-height: 1;
    min-width: 17px;
}

.notification-panel {
    width: min(400px, calc(100vw - 20px));
    max-width: 400px;
    padding: 0;
    border: 1px solid var(--dh-border);
    border-radius: var(--dh-radius-lg);
    box-shadow: var(--dh-shadow-dropdown);
    overflow: hidden;
}

.notification-panel-header {
    border-bottom: 1px solid var(--dh-border);
    background-color: var(--dh-surface);
}

.notification-panel-header .btn-link {
    color: var(--dh-primary);
    font-size: 12.5px;
    font-weight: 500;
}

.notification-panel-body {
    max-height: 380px;
    overflow-y: auto;
}

.notification-panel-footer {
    border-top: 1px solid var(--dh-border);
    background-color: var(--dh-surface);
}

.notification-panel-footer a {
    color: var(--dh-primary);
}

.notification-item {
    color: var(--dh-text);
    border-bottom: 1px solid var(--dh-border);
    transition: background-color .1s ease;
}

.notification-item:last-child {
    border-bottom: 0;
}

.notification-item:hover {
    background-color: var(--dh-bg);
}

.notification-item-unread {
    background-color: var(--dh-primary-soft);
}

.notification-item-unread:hover {
    background-color: var(--dh-primary-soft);
    filter: brightness(0.98);
}

.notification-item-title {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--dh-text);
}

.notification-item-unread .notification-item-title {
    font-weight: 700;
}

.notification-item-message {
    font-size: 12.5px;
    white-space: pre-line;
}

.notification-item-time {
    font-size: 11px;
    margin-top: 2px;
}

.notification-icon {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.min-w-0 {
    min-width: 0;
}

/* -----------------------------------------------------------------------
   7. PAGE HEADER / BREADCRUMBS
   ----------------------------------------------------------------------- */

.breadcrumb {
    font-size: 12.5px;
    --bs-breadcrumb-divider-color: var(--dh-placeholder);
}

.breadcrumb-item a {
    color: var(--dh-muted);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--dh-primary);
}

.breadcrumb-item.active {
    color: var(--dh-text);
    font-weight: 500;
}

main .h4 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 26px;
}

/* -----------------------------------------------------------------------
   8. CARDS
   ----------------------------------------------------------------------- */

.card {
    background-color: var(--dh-surface);
    border: 1px solid var(--dh-border);
    border-radius: var(--dh-radius-lg);
    box-shadow: var(--dh-shadow-card);
}

.card-header {
    border-bottom: 1px solid var(--dh-border);
    border-radius: var(--dh-radius-lg) var(--dh-radius-lg) 0 0 !important;
    padding: var(--dh-space-4) var(--dh-space-5);
}

.card-header h2,
.card-header .h6 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.card-body {
    padding: var(--dh-space-5);
}

/* -----------------------------------------------------------------------
   9. KPI CARDS
   ----------------------------------------------------------------------- */

.kpi-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.kpi-value {
    font-family: 'Poppins', sans-serif;
    font-size: 24px;
    font-weight: 600;
    color: var(--dh-text);
    line-height: 1.2;
}

.kpi-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--dh-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* Phones show KPI cards two per row, so stack the icon above the figures. */
@media (max-width: 575.98px) {
    .kpi-card .card-body {
        flex-direction: column;
        align-items: flex-start !important;
        gap: var(--dh-space-2);
        padding: var(--dh-space-3);
    }
    .kpi-card .kpi-icon {
        width: 36px;
        height: 36px;
        margin-right: 0 !important;
    }
    .kpi-card .kpi-icon .fs-4 {
        font-size: 1.1rem !important;
    }
    .kpi-card .kpi-label {
        font-size: 11px;
    }
    .kpi-card .kpi-value {
        font-size: 18px;
        word-break: break-word;
    }
}

/* -----------------------------------------------------------------------
   10. FORMS
   ----------------------------------------------------------------------- */

.form-label {
    font-weight: 500;
    font-size: 13.5px;
    color: var(--dh-text);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    min-height: 44px;
    border-radius: var(--dh-radius);
    border: 1px solid var(--dh-input-border);
    font-size: 14px;
    padding: 8px 14px;
    color: var(--dh-text);
}

textarea.form-control {
    min-height: auto;
}

.form-control::placeholder {
    color: var(--dh-placeholder);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--dh-primary);
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.12);
}

.form-control:disabled,
.form-control[readonly] {
    background-color: #f9fafb;
    color: var(--dh-muted);
}

.form-check-input:checked {
    background-color: var(--dh-primary);
    border-color: var(--dh-primary);
}

.form-check-input:focus {
    border-color: var(--dh-primary);
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.12);
}

.input-group-text {
    background-color: #f9fafb;
    border: 1px solid var(--dh-input-border);
    color: var(--dh-muted);
    font-weight: 500;
    border-radius: var(--dh-radius);
}

.input-group .form-control,
.input-group .form-select {
    border-radius: var(--dh-radius);
}

.invalid-feedback {
    font-size: 12.5px;
}

/* -----------------------------------------------------------------------
   11. BUTTONS
   ----------------------------------------------------------------------- */

.btn {
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    font-size: 14px;
    border-radius: var(--dh-radius);
    padding: 10px 18px;
    line-height: 1.3;
}

.btn-sm {
    min-height: 32px;
    padding: 6px 12px;
    font-size: 13px;
}

.btn:not(.btn-sm) {
    min-height: 42px;
}

.btn-success {
    background-color: var(--dh-primary);
    border-color: var(--dh-primary);
}

.btn-success:hover,
.btn-success:active {
    background-color: var(--dh-primary-dark) !important;
    border-color: var(--dh-primary-dark) !important;
}

.btn-outline-secondary {
    border-color: var(--dh-input-border);
    color: var(--dh-text);
}

.btn-outline-secondary:hover {
    background-color: #f9fafb;
    border-color: var(--dh-input-border);
    color: var(--dh-text);
}

.btn-outline-success {
    color: var(--dh-primary-dark);
    border-color: var(--dh-primary);
}

.btn-outline-success:hover {
    background-color: var(--dh-primary);
    border-color: var(--dh-primary);
}

.btn-outline-danger {
    color: var(--dh-danger);
    border-color: #f3c6cb;
    background-color: #fdf2f3;
}

.btn-outline-danger:hover {
    background-color: var(--dh-danger);
    border-color: var(--dh-danger);
}

.btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.18);
}

/* -----------------------------------------------------------------------
   12. TABLES
   ----------------------------------------------------------------------- */

.table {
    font-size: 13.5px;
    margin-bottom: 0;
    --bs-table-hover-bg: #f9fafb;
}

.table > :not(caption) > * > * {
    padding: 14px 16px;
    vertical-align: middle;
}

.table thead th,
.table thead.table-light th {
    background-color: #f9fafb !important;
    color: var(--dh-muted);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--dh-border);
}

.table > tbody > tr {
    border-bottom: 1px solid var(--dh-border);
}

.table > tbody > tr:last-child {
    border-bottom: none;
}

.list-group-item {
    border-color: var(--dh-border);
    padding: var(--dh-space-3) var(--dh-space-5);
    font-size: 13.5px;
}

.list-group-flush > .list-group-item:last-child {
    border-bottom: 0;
}

/* -----------------------------------------------------------------------
   13. BADGES (soft status badges)
   ----------------------------------------------------------------------- */

.badge {
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    font-size: 12px;
    border-radius: var(--dh-radius-sm);
    padding: 5px 10px;
}

/* Soft variants used by <x-status-badge>. Bootstrap's own `.text-bg-*`
   badges (used sparingly, e.g. one-off admin pages) are also softened so
   nothing on the site still looks like a solid stock Bootstrap badge. */
.badge.text-bg-success, .badge-dh-success {
    background-color: #e8f5ee !important;
    color: var(--dh-primary-dark) !important;
}
.badge.text-bg-danger, .badge-dh-danger {
    background-color: #fdecee !important;
    color: #a3222f !important;
}
.badge.text-bg-warning, .badge-dh-warning {
    background-color: #fef3e2 !important;
    color: #92600a !important;
}
.badge.text-bg-secondary, .badge-dh-secondary {
    background-color: #f1f2f4 !important;
    color: #4b5563 !important;
}
.badge.text-bg-info, .badge-dh-info {
    background-color: #e7f1ff !important;
    color: #0a4fb0 !important;
}

/* -----------------------------------------------------------------------
   14. TABS
   ----------------------------------------------------------------------- */

.nav-tabs {
    border-bottom: 1px solid var(--dh-border);
    gap: var(--dh-space-2);
}

.nav-tabs .nav-link {
    font-weight: 500;
    font-size: 14px;
    color: var(--dh-muted);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 10px 4px;
    margin-right: var(--dh-space-4);
}

.nav-tabs .nav-link:hover {
    color: var(--dh-primary-dark);
    border-color: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--dh-primary-dark);
    background: transparent;
    border-bottom-color: var(--dh-primary);
}

/* -----------------------------------------------------------------------
   15. MODALS
   ----------------------------------------------------------------------- */

.modal-content {
    border: none;
    border-radius: var(--dh-radius-lg);
    box-shadow: var(--dh-shadow-modal);
}

.modal-header {
    border-bottom: 1px solid var(--dh-border);
    padding: var(--dh-space-5);
}

.modal-title {
    font-weight: 600;
    font-size: 17px;
}

.modal-body {
    padding: var(--dh-space-5);
}

.modal-footer {
    border-top: 1px solid var(--dh-border);
    padding: var(--dh-space-4) var(--dh-space-5);
}

/* -----------------------------------------------------------------------
   16. ALERTS
   ----------------------------------------------------------------------- */

.alert {
    border: 1px solid transparent;
    border-radius: var(--dh-radius);
    font-size: 13.5px;
    padding: var(--dh-space-3) var(--dh-space-4);
}

.alert-success {
    background-color: #e8f5ee;
    border-color: #c7e6d5;
    color: var(--dh-primary-dark);
}

.alert-danger {
    background-color: #fdecee;
    border-color: #f6c7cd;
    color: #a3222f;
}

.alert-warning {
    background-color: #fef3e2;
    border-color: #fbdfa8;
    color: #92600a;
}

.alert-info, .alert-secondary {
    background-color: #f1f2f4;
    border-color: #e2e4e8;
    color: #4b5563;
}

/* -----------------------------------------------------------------------
   17. PAGINATION / DROPDOWNS
   ----------------------------------------------------------------------- */

.pagination {
    gap: 4px;
}

.page-link {
    border-radius: var(--dh-radius) !important;
    border: 1px solid var(--dh-border);
    color: var(--dh-text);
    font-weight: 500;
    font-size: 13.5px;
    margin-left: 0 !important;
}

.page-item.active .page-link {
    background-color: var(--dh-primary);
    border-color: var(--dh-primary);
}

.page-link:hover {
    background-color: var(--dh-primary-soft);
    color: var(--dh-primary-dark);
}

.dropdown-menu {
    border: 1px solid var(--dh-border);
    border-radius: var(--dh-radius-lg);
    box-shadow: var(--dh-shadow-dropdown);
    padding: var(--dh-space-2);
}

.dropdown-item {
    border-radius: var(--dh-radius-sm);
    font-size: 13.5px;
    padding: 8px 12px;
}

.dropdown-item:hover, .dropdown-item:focus {
    background-color: var(--dh-primary-soft);
    color: var(--dh-primary-dark);
}

.dropdown-item.text-danger:hover {
    background-color: #fdecee;
    color: #a3222f !important;
}

/* -----------------------------------------------------------------------
   18. RESPONSIVE
   ----------------------------------------------------------------------- */

@media (max-width: 767.98px) {
    main.p-3 { padding: var(--dh-space-4) !important; }
    .h4, h1.h4 { font-size: 22px; }
    .card-body { padding: var(--dh-space-4); }

    /* Card headers with a title plus badges/buttons wrap instead of overflowing. */
    .card-header.d-flex {
        flex-wrap: wrap;
        gap: var(--dh-space-2);
    }
    .card-header .badge {
        white-space: normal;
        text-align: left;
    }

    /* Wide tables scroll inside their .table-responsive wrapper rather than
       squeezing every column into a few characters per line. */
    .table-responsive > .table th,
    .table-responsive > .table td {
        white-space: nowrap;
    }
}

/* Line-item entry tables (sales, purchases, stock issues/transfers): on phones
   each row becomes a card with labelled fields in two columns instead of a
   ~1100px-wide table. Labels come from data-label, which the admin layout
   copies from the table's <th> text (including rows added later by JS). */
@media (max-width: 575.98px) {
    .table-stack-sm thead {
        display: none;
    }
    .table-stack-sm,
    .table-stack-sm tbody,
    .table-stack-sm tr,
    .table-stack-sm td {
        display: block;
        width: 100%;
    }
    .table-stack-sm tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--dh-space-3);
        padding: var(--dh-space-3);
        margin-bottom: var(--dh-space-3);
        border: 1px solid var(--dh-border);
        border-radius: var(--dh-radius);
        background-color: #ffffff;
    }
    .table-responsive > .table-stack-sm td,
    .table-stack-sm td {
        min-width: 0;
        padding: 0;
        border: 0;
        white-space: normal;
    }
    .table-stack-sm td:first-child,
    .table-stack-sm td[colspan] {
        grid-column: 1 / -1;
    }
    .table-stack-sm td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: var(--dh-space-1);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: .03em;
        text-transform: uppercase;
        color: var(--dh-muted);
    }
    .table-stack-sm td[data-label=""]::before {
        display: none;
    }
    /* The trailing remove-row button spans the card's full width. */
    .table-stack-sm td[data-label=""]:last-child:not(:first-child) {
        grid-column: 1 / -1;
        text-align: right;
    }
}

/* -----------------------------------------------------------------------
   19. BUSINESS DASHBOARD
   ----------------------------------------------------------------------- */

/* -------- Header / date filter -------- */

.dash-greeting {
    font-size: 22px;
}

.dash-filter-bar {
    background-color: var(--dh-surface);
    border: 1px solid var(--dh-border);
    border-radius: var(--dh-radius-lg);
    padding: var(--dh-space-2) var(--dh-space-3);
}

.dash-filter-bar .form-select {
    min-height: 38px;
    font-size: 13.5px;
    border: none;
    font-weight: 500;
}

.dash-filter-bar .form-control {
    min-height: 38px;
    font-size: 13.5px;
}

/* -------- Generic widget card chrome -------- */

.dash-card {
    height: 100%;
}

.dash-card .card-header {
    background-color: var(--dh-surface);
}

.dash-card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 0;
}

.dash-card-subtitle {
    font-size: 12px;
    color: var(--dh-muted);
}

.dash-link {
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.dash-pill-group {
    background-color: #f3f4f6;
    border-radius: 999px;
    padding: 2px;
    display: inline-flex;
    gap: 2px;
}

.dash-pill {
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 11px;
    border-radius: 999px;
    color: var(--dh-muted);
    text-decoration: none;
    line-height: 1.4;
}

.dash-pill.active {
    background-color: var(--dh-surface);
    color: var(--dh-chart-indigo-dark);
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
}

/* -------- KPI widgets -------- */

.dash-kpi-card .card-body {
    padding: var(--dh-space-4) var(--dh-space-5);
}

.dash-kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--dh-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.dash-kpi-value {
    font-family: 'Poppins', sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--dh-text);
    line-height: 1.2;
}

.dash-kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--dh-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.dash-trend {
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    padding: 2px 8px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.dash-trend-up { background-color: #e8f5ee; color: var(--dh-primary-dark); }
.dash-trend-down { background-color: #fdecee; color: #a3222f; }
.dash-trend-none, .dash-trend-flat { background-color: #f1f2f4; color: #6b7280; }

/* Chart.js sizes a `responsive: true` canvas to fill its immediate parent —
   without an explicitly height-locked wrapper (position: relative + a
   fixed height, same trick as .dash-chart-wrap below) the canvas and its
   auto-sizing parent feed off each other and the chart grows without
   bound. */
.dash-sparkline-wrap {
    position: relative;
    width: 100%;
    height: 40px;
}

/* -------- Chart cards -------- */

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

.dash-chart-wrap.dash-chart-tall { height: 280px; }
.dash-chart-wrap.dash-chart-md { height: 220px; }

.dash-donut-wrap {
    position: relative;
    width: 100%;
    max-width: 220px;
    height: 220px;
    margin: 0 auto;
}

.dash-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.dash-donut-center .value {
    font-family: 'Poppins', sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--dh-text);
    line-height: 1.1;
}

.dash-donut-center .label {
    font-size: 11.5px;
    color: var(--dh-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.dash-legend {
    display: flex;
    flex-direction: column;
    gap: var(--dh-space-2);
}

.dash-legend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.dash-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    flex-shrink: 0;
}

/* -------- Gradient feature card (Business Performance) -------- */

.dash-gradient-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--dh-radius-lg);
    background: linear-gradient(135deg, var(--dh-chart-indigo) 0%, var(--dh-chart-purple) 100%);
    color: #ffffff;
    border: none;
    height: 100%;
}

.dash-gradient-card::before,
.dash-gradient-card::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

.dash-gradient-card::before {
    width: 220px;
    height: 220px;
    top: -90px;
    right: -70px;
}

.dash-gradient-card::after {
    width: 140px;
    height: 140px;
    bottom: -60px;
    left: -40px;
    background: rgba(255, 255, 255, 0.06);
}

.dash-gradient-card .card-body {
    position: relative;
    z-index: 1;
}

.dash-gradient-label {
    font-size: 12.5px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.dash-gradient-metric-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--dh-radius);
    background-color: rgba(255, 255, 255, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.dash-gradient-value {
    font-family: 'Poppins', sans-serif;
    font-size: 21px;
    font-weight: 700;
    color: #ffffff;
}

.dash-gradient-divider {
    border-color: rgba(255, 255, 255, 0.18);
}

/* -------- Ranking / progress bars (Warehouses, Top Products) -------- */

.dash-rank-row + .dash-rank-row {
    margin-top: var(--dh-space-4);
}

.dash-rank-label {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--dh-text);
}

.dash-rank-meta {
    font-size: 12px;
    color: var(--dh-muted);
}

.dash-progress {
    height: 8px;
    border-radius: 999px;
    background-color: #f1f2f4;
    overflow: hidden;
}

.dash-progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--dh-chart-indigo), var(--dh-chart-purple));
}

.dash-progress-bar.is-amber { background: linear-gradient(90deg, #fbbf24, var(--dh-chart-amber)); }
.dash-progress-bar.is-teal { background: linear-gradient(90deg, #2dd4bf, var(--dh-chart-teal)); }

/* -------- Alert lists (Low Stock / Out of Stock) -------- */

.dash-alert-item {
    display: flex;
    align-items: center;
    gap: var(--dh-space-3);
    padding: var(--dh-space-3) 0;
    border-bottom: 1px solid var(--dh-border);
}

.dash-alert-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.dash-alert-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dash-alert-dot.is-critical { background-color: var(--dh-danger); }
.dash-alert-dot.is-warning { background-color: var(--dh-warning); }

.dash-empty-state {
    text-align: center;
    color: var(--dh-muted);
    padding: var(--dh-space-6) var(--dh-space-4);
}

.dash-empty-state i {
    font-size: 30px;
    display: block;
    margin-bottom: var(--dh-space-2);
    color: #c7cbd1;
}

/* -------- Timeline (Recent Activity) -------- */

.dash-timeline {
    position: relative;
    padding-left: 26px;
}

.dash-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background-color: var(--dh-border);
}

.dash-timeline-item {
    position: relative;
    padding-bottom: var(--dh-space-4);
}

.dash-timeline-item:last-child {
    padding-bottom: 0;
}

.dash-timeline-dot {
    position: absolute;
    left: -26px;
    top: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--dh-chart-lavender);
    color: var(--dh-chart-indigo-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    border: 2px solid var(--dh-surface);
    box-shadow: 0 0 0 1px var(--dh-border);
}

.dash-timeline-text {
    font-size: 13.5px;
    color: var(--dh-text);
}

.dash-timeline-time {
    font-size: 11.5px;
    color: var(--dh-muted);
}

/* -------- Cash flow snapshot -------- */

.dash-flow-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--dh-space-3) 0;
    border-bottom: 1px solid var(--dh-border);
}

.dash-flow-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.dash-flow-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--dh-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    margin-right: var(--dh-space-3);
}

/* -------- Quick actions -------- */

.dash-quick-actions {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--dh-space-3);
}

.dash-quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: var(--dh-space-4) var(--dh-space-2);
    border: 1px solid var(--dh-border);
    border-radius: var(--dh-radius);
    text-decoration: none;
    color: var(--dh-text);
    font-size: 12.5px;
    font-weight: 500;
    text-align: center;
    transition: border-color .15s ease, background-color .15s ease;
}

.dash-quick-action:hover {
    border-color: var(--dh-chart-indigo);
    background-color: var(--dh-chart-lavender);
    color: var(--dh-chart-indigo-dark);
}

.dash-quick-action-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--dh-chart-lavender);
    color: var(--dh-chart-indigo-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
}

/* -------- Compact table rows (Recent Sales) -------- */

.dash-table-compact td, .dash-table-compact th {
    padding: 12px 14px !important;
}

@media (max-width: 991.98px) {
    .dash-quick-actions {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 575.98px) {
    .dash-quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
    .dash-gradient-value { font-size: 18px; }
}

/* -----------------------------------------------------------------------
   20. ROLES & PERMISSIONS
   ----------------------------------------------------------------------- */

.permission-module-card {
    border: 1px solid var(--dh-border);
    border-radius: var(--dh-radius);
    height: 100%;
}

.permission-module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--dh-space-3) var(--dh-space-4);
    border-bottom: 1px solid var(--dh-border);
    background-color: #f9fafb;
    border-radius: var(--dh-radius) var(--dh-radius) 0 0;
}

.permission-module-header .form-switch {
    display: flex;
    align-items: center;
    gap: 6px;
}

.permission-module-body {
    padding: var(--dh-space-3) var(--dh-space-4);
    display: flex;
    flex-wrap: wrap;
    gap: var(--dh-space-2) var(--dh-space-4);
}

.permission-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    margin-bottom: 0;
    cursor: pointer;
    min-width: 90px;
}

.permission-check input[disabled] {
    cursor: not-allowed;
}

/* -------- Role / Settings cards -------- */

.settings-card {
    display: flex;
    align-items: flex-start;
    gap: var(--dh-space-3);
    padding: var(--dh-space-5);
    height: 100%;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}

a.settings-card:hover {
    border-color: var(--dh-chart-indigo);
    box-shadow: var(--dh-shadow-dropdown);
}

.settings-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--dh-radius);
    background-color: var(--dh-chart-lavender);
    color: var(--dh-chart-indigo-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.role-stat {
    text-align: center;
    padding: var(--dh-space-4);
    border: 1px solid var(--dh-border);
    border-radius: var(--dh-radius);
}

.role-stat .value {
    font-family: 'Poppins', sans-serif;
    font-size: 24px;
    font-weight: 700;
}

.role-stat .label {
    font-size: 12px;
    color: var(--dh-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}
