/* ============================================================================
   BREnt ERP -- premium enterprise design system for the new MVC/Razor Views
   UI (Views/Shared/_Layout.cshtml). Inspired by Dynamics 365 / SAP Business
   One / NetSuite / Zoho: a deep indigo/blue corporate palette, generous
   whitespace, soft shadows, rounded cards, and a collapsible multi-level
   sidebar. Built entirely on CSS custom properties + Bootstrap 5.3's native
   `data-bs-theme` dark mode -- no separate dark stylesheet to keep in sync.
   ========================================================================= */

:root {
    --brent-font: "Inter", "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;

    /* Corporate palette -- deep indigo primary (Dynamics 365-inspired), slate neutrals */
    --brent-primary: #4f46e5;
    --brent-primary-dark: #3730a3;
    --brent-primary-light: #eef2ff;
    --brent-secondary: #64748b;
    --brent-success: #16a34a;
    --brent-danger: #dc2626;
    --brent-warning: #d97706;
    --brent-info: #0891b2;

    --brent-body-bg: #f4f6fb;
    --brent-surface: #ffffff;
    --brent-border: #e5e9f0;
    --brent-text: #1e2433;
    --brent-text-muted: #6b7280;

    --brent-sidebar-bg: #10162b;
    --brent-sidebar-bg-active: #1c2444;
    --brent-sidebar-text: #b6bdd6;
    --brent-sidebar-text-active: #ffffff;
    --brent-sidebar-width: 268px;
    --brent-sidebar-width-collapsed: 78px;
    --brent-topbar-height: 64px;

    --brent-radius: 0.65rem;
    --brent-radius-sm: 0.45rem;
    --brent-shadow-sm: 0 1px 2px rgba(16, 22, 43, 0.06);
    --brent-shadow: 0 2px 10px rgba(16, 22, 43, 0.07);
    --brent-shadow-lg: 0 10px 30px rgba(16, 22, 43, 0.12);
}

[data-bs-theme="dark"] {
    --brent-body-bg: #0f1220;
    --brent-surface: #171b2e;
    --brent-border: #2a3050;
    --brent-text: #e7e9f2;
    --brent-text-muted: #9aa1bd;
    --brent-primary-light: #22265a;
    --brent-sidebar-bg: #0a0e1c;
    --brent-sidebar-bg-active: #1c2444;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--brent-font);
    background-color: var(--brent-body-bg);
    color: var(--brent-text);
    padding-top: var(--brent-topbar-height);
    font-size: 0.9rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

a {
    text-decoration: none;
}

/* ---------------------------------------------------------------------- */
/* Top navbar                                                              */
/* ---------------------------------------------------------------------- */

.app-topbar {
    height: var(--brent-topbar-height);
    background-color: var(--brent-surface);
    border-bottom: 1px solid var(--brent-border);
    box-shadow: var(--brent-shadow-sm);
    z-index: 1030;
}

.app-topbar .navbar-brand {
    color: var(--brent-text);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.app-topbar .navbar-brand .brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--brent-radius-sm);
    background: linear-gradient(135deg, var(--brent-primary), var(--brent-primary-dark));
    color: #fff;
    margin-right: 0.5rem;
}

.topbar-search {
    max-width: 360px;
}

.topbar-search .form-control {
    background-color: var(--brent-body-bg);
    border-color: var(--brent-border);
}

.topbar-icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--brent-text-muted);
    background: transparent;
    border: none;
    position: relative;
    transition: background-color 0.15s ease;
}

.topbar-icon-btn:hover {
    background-color: var(--brent-primary-light);
    color: var(--brent-primary);
}

.topbar-icon-btn .badge-dot {
    position: absolute;
    top: 6px;
    right: 7px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--brent-danger);
    border: 2px solid var(--brent-surface);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brent-primary), var(--brent-primary-dark));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    object-fit: cover;
}

/* ---------------------------------------------------------------------- */
/* Sidebar                                                                 */
/* ---------------------------------------------------------------------- */

.app-shell {
    display: flex;
    min-height: calc(100vh - var(--brent-topbar-height));
}

.app-sidebar {
    width: var(--brent-sidebar-width);
    flex-shrink: 0;
    position: fixed;
    top: var(--brent-topbar-height);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1020;
    background-color: var(--brent-sidebar-bg);
    transition: width 0.2s ease, left 0.2s ease;
    scrollbar-width: thin;
}

.app-sidebar::-webkit-scrollbar {
    width: 6px;
}

.app-sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.app-content {
    flex-grow: 1;
    margin-left: var(--brent-sidebar-width);
    width: 100%;
    transition: margin-left 0.2s ease;
}

body.sidebar-collapsed .app-sidebar {
    width: var(--brent-sidebar-width-collapsed);
}

body.sidebar-collapsed .app-content {
    margin-left: var(--brent-sidebar-width-collapsed);
}

body.sidebar-collapsed .app-sidebar .nav-section-label,
body.sidebar-collapsed .app-sidebar .nav-link-text,
body.sidebar-collapsed .app-sidebar .nav-chevron,
body.sidebar-collapsed .app-sidebar .sidebar-brand-text {
    display: none !important;
}

body.sidebar-collapsed .app-sidebar .collapse {
    display: none !important;
}

.sidebar-section {
    padding: 0.9rem 1rem 0.35rem;
}

.nav-section-label {
    text-transform: uppercase;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: rgba(182, 189, 214, 0.6);
}

.app-sidebar .nav-link {
    color: var(--brent-sidebar-text);
    border-radius: var(--brent-radius-sm);
    padding: 0.55rem 0.85rem;
    margin: 0.1rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.86rem;
    font-weight: 500;
    white-space: nowrap;
}

.app-sidebar .nav-link .nav-icon {
    width: 1.15rem;
    text-align: center;
    flex-shrink: 0;
}

.app-sidebar .nav-link .nav-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.15s ease;
}

.app-sidebar .nav-link[aria-expanded="true"] .nav-chevron {
    transform: rotate(90deg);
}

.app-sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.app-sidebar .nav-link.active {
    background-color: var(--brent-primary);
    color: #fff;
    box-shadow: var(--brent-shadow);
}

.app-sidebar .nav.flex-column .collapse .nav-link {
    padding-left: 2.4rem;
    font-size: 0.82rem;
}

.app-sidebar .nav-link.active .nav-icon,
.app-sidebar .nav-link:hover .nav-icon {
    color: #fff;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        left: calc(-1 * var(--brent-sidebar-width));
        width: var(--brent-sidebar-width);
    }

    .app-sidebar.show {
        left: 0;
    }

    .app-content, body.sidebar-collapsed .app-content {
        margin-left: 0;
    }
}

/* ---------------------------------------------------------------------- */
/* Breadcrumb                                                              */
/* ---------------------------------------------------------------------- */

.app-breadcrumb-bar {
    background-color: var(--brent-surface);
    border-bottom: 1px solid var(--brent-border);
    padding: 0.75rem 1.5rem;
}

.app-breadcrumb-bar .breadcrumb {
    margin-bottom: 0;
    font-size: 0.82rem;
}

.app-breadcrumb-bar h1 {
    font-size: 1.25rem;
    margin-bottom: 0;
}

/* ---------------------------------------------------------------------- */
/* Cards, KPI tiles, toolbars                                              */
/* ---------------------------------------------------------------------- */

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

.card-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.kpi-card {
    border-radius: var(--brent-radius);
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: var(--brent-surface);
    border: 1px solid var(--brent-border);
    box-shadow: var(--brent-shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--brent-shadow);
}

.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--brent-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.kpi-label {
    font-size: 0.78rem;
    color: var(--brent-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-trend {
    font-size: 0.75rem;
    font-weight: 600;
}

.quick-action-tile {
    border-radius: var(--brent-radius);
    border: 1px solid var(--brent-border);
    background-color: var(--brent-surface);
    padding: 1rem;
    text-align: center;
    color: var(--brent-text);
    transition: all 0.15s ease;
    display: block;
}

.quick-action-tile:hover {
    border-color: var(--brent-primary);
    box-shadow: var(--brent-shadow);
    color: var(--brent-primary);
}

.quick-action-tile i {
    font-size: 1.4rem;
    color: var(--brent-primary);
}

/* ---------------------------------------------------------------------- */
/* DataTables / tables polish                                              */
/* ---------------------------------------------------------------------- */

table.dataTable {
    width: 100% !important;
}

table.dataTable thead th {
    background-color: var(--brent-surface);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brent-text-muted);
    border-bottom: 2px solid var(--brent-border) !important;
}

/* Sticky headers are handled by the DataTables FixedHeader extension (see
   the `fixedHeader` option in initServerDataTable, site.js), not raw CSS
   `position: sticky` on <th> -- that approach broke row/column alignment
   (headers detaching and overlapping the first data row) because sticky
   positioning on individual table cells isn't reliably supported for a
   plain, non fixed-layout table across browsers. FixedHeader's cloned
   header row picks up this table's Bootstrap styling automatically via
   fixedHeader.bootstrap5's CSS (loaded in _Layout.cshtml), so no extra
   rules are needed here. */
.fixedHeader-floating {
    z-index: 1015 !important; /* stay below the app topbar (z-index 1030) and sidebar (1020), matching --brent-topbar-height offset */
}

div.dt-buttons {
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.dt-button {
    border-radius: var(--brent-radius-sm) !important;
}

/* Belt-and-braces visibility fix for the Excel/PDF/Print/Columns toolbar
   buttons (see initServerDataTable in site.js) -- explicit color/border/
   background so the icon+label is always legible regardless of how the
   DataTables Buttons extension's own default button styling resolves in a
   given browser/theme. */
.dt-icon-button.btn-outline-secondary {
    color: var(--brent-secondary) !important;
    border-color: var(--brent-border) !important;
    background-color: var(--brent-surface) !important;
    display: inline-flex !important;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.dt-icon-button.btn-outline-secondary:hover {
    color: #fff !important;
    background-color: var(--brent-secondary) !important;
    border-color: var(--brent-secondary) !important;
}

.dt-icon-button i {
    font-size: 0.95rem;
    line-height: 1;
}

/* Opt-in bulk-actions toolbar (see initBulkActions in site.js) -- a slim
   bar that appears above a grid once at least one row checkbox is ticked. */
.bulk-actions-bar {
    background-color: var(--brent-primary-light);
    border: 1px solid var(--brent-primary);
    border-radius: var(--brent-radius-sm);
    padding: 0.5rem 0.85rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

input.row-select,
input.select-all {
    width: 1.05rem;
    height: 1.05rem;
    cursor: pointer;
}

/* Data Migration wizard step indicator (Views/DataMigration/Index.cshtml) --
   plain Bootstrap nav-pills, just tinted/sized to match this app's palette
   rather than Bootstrap's default pill colors. */
.migration-step-nav .nav-link {
    border-radius: var(--brent-radius-sm);
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brent-text-muted);
    background-color: transparent;
}

.migration-step-nav .nav-link.active {
    color: #fff;
    background-color: var(--brent-primary);
}

.migration-step-nav .nav-link:not(.active):hover {
    background-color: var(--brent-primary-light);
}

/* ---------------------------------------------------------------------- */
/* Forms -- floating labels, Select2, Flatpickr                           */
/* ---------------------------------------------------------------------- */

.form-floating > .select2-container {
    padding-top: 0;
}

.select2-container .select2-selection--single {
    height: calc(3.5rem) !important;
    padding: 1rem 0.75rem 0.25rem !important;
    display: flex;
    align-items: center;
}

.form-floating .select2-container + label {
    z-index: 5;
}

.flatpickr-input {
    background-color: var(--brent-surface) !important;
}

/* ---------------------------------------------------------------------- */
/* Loading bar + skeletons                                                 */
/* ---------------------------------------------------------------------- */

#ajaxLoadingBar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, var(--brent-primary), var(--brent-info));
    z-index: 2000;
    transition: width 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

#ajaxLoadingBar.active {
    opacity: 1;
}

.skeleton {
    display: inline-block;
    position: relative;
    overflow: hidden;
    background-color: var(--brent-border);
    border-radius: var(--brent-radius-sm);
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    animation: skeleton-shimmer 1.4s infinite;
}

@keyframes skeleton-shimmer {
    100% {
        transform: translateX(100%);
    }
}

.skeleton-text {
    height: 0.9rem;
    width: 100%;
    margin-bottom: 0.4rem;
}

.fade-in-up {
    animation: fadeInUp 0.25s ease both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------------------------------------------------------------------- */
/* Auth pages (Login / Forgot / Reset password)                           */
/* ---------------------------------------------------------------------- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 20%, rgba(79, 70, 229, 0.35), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(8, 145, 178, 0.3), transparent 45%),
        var(--brent-sidebar-bg);
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background-color: var(--brent-surface);
    border-radius: var(--brent-radius);
    box-shadow: var(--brent-shadow-lg);
    padding: 2.25rem;
}

.password-strength-bar {
    height: 5px;
    border-radius: 3px;
    background-color: var(--brent-border);
    overflow: hidden;
}

.password-strength-bar > div {
    height: 100%;
    width: 0%;
    transition: width 0.2s ease, background-color 0.2s ease;
}

.profile-avatar-lg {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--brent-surface);
    box-shadow: var(--brent-shadow);
}

/* ---------------------------------------------------------------------- */
/* Misc                                                                    */
/* ---------------------------------------------------------------------- */

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

.badge-soft-primary { background-color: var(--brent-primary-light); color: var(--brent-primary); }
.badge-soft-success { background-color: #dcfce7; color: var(--brent-success); }
.badge-soft-danger { background-color: #fee2e2; color: var(--brent-danger); }
.badge-soft-warning { background-color: #fef3c7; color: var(--brent-warning); }

[data-bs-theme="dark"] .badge-soft-success { background-color: #0d2818; }
[data-bs-theme="dark"] .badge-soft-danger { background-color: #2d1414; }
[data-bs-theme="dark"] .badge-soft-warning { background-color: #2c220a; }

/* ---------------------------------------------------------------------- */
/* Detail view -- compact, professional read-only field layout used by     */
/* every module's _Details.cshtml partial (replaces the old <dl class=     */
/* "row"> definition-list look with a Stripe/Linear-style stacked          */
/* label-above-value grid). Slightly smaller type than the app's default   */
/* body text, on purpose -- this is a dense information surface, not       */
/* prose.                                                                   */
/* ---------------------------------------------------------------------- */

.detail-view {
    font-size: 0.8125rem;
    line-height: 1.5;
    letter-spacing: 0.01em;
    color: var(--brent-text);
}

.detail-view-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--brent-border);
}

.detail-view-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: var(--brent-radius-sm);
    background-color: var(--brent-primary-light);
    color: var(--brent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.detail-view-heading {
    min-width: 0;
}

.detail-view-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--brent-text);
    margin: 0;
    overflow-wrap: anywhere;
}

.detail-view-subtitle {
    font-size: 0.78rem;
    color: var(--brent-text-muted);
    margin: 0.15rem 0 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.9rem 1.5rem;
}

.detail-item-full {
    grid-column: 1 / -1;
}

.detail-item-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brent-text-muted);
    margin-bottom: 0.2rem;
}

.detail-item-label i {
    font-size: 0.78rem;
    color: var(--brent-text-muted);
}

.detail-item-value {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--brent-text);
    overflow-wrap: anywhere;
}

.detail-empty {
    color: var(--brent-text-muted);
    font-style: italic;
    font-weight: 400;
}

@media (max-width: 480px) {
    .detail-view-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------------------------------------------------------------------- */
/* BR ENTERPRISE branding -- navy / corporate red / white / light grey     */
/* (overrides the earlier indigo tokens; see wwwroot/images/br-logo.png)    */
/* ---------------------------------------------------------------------- */
:root {
    --brent-primary: #c8102e;
    --brent-primary-dark: #a30d25;
    --brent-primary-light: #fde8ec;
    --brent-navy: #0b2a5b;
    --brent-sidebar-bg: #0b1f4b;
    --brent-sidebar-bg-active: #12306a;
    --brent-body-bg: #f3f5f9;
    --bs-primary: #c8102e;
    --bs-primary-rgb: 200, 16, 46;
    --bs-link-color: #0b2a5b;
    --bs-link-hover-color: #c8102e;
}

[data-bs-theme="dark"] {
    --brent-primary-light: #3a1620;
    --brent-sidebar-bg: #07122b;
}

.btn-primary {
    --bs-btn-bg: #c8102e;
    --bs-btn-border-color: #c8102e;
    --bs-btn-hover-bg: #a30d25;
    --bs-btn-hover-border-color: #a30d25;
    --bs-btn-active-bg: #8c0b20;
    --bs-btn-active-border-color: #8c0b20;
    --bs-btn-disabled-bg: #c8102e;
    --bs-btn-disabled-border-color: #c8102e;
    --bs-btn-focus-shadow-rgb: 200, 16, 46;
}

.btn-outline-primary {
    --bs-btn-color: #0b2a5b;
    --bs-btn-border-color: #0b2a5b;
    --bs-btn-hover-bg: #0b2a5b;
    --bs-btn-hover-border-color: #0b2a5b;
    --bs-btn-active-bg: #0b2a5b;
    --bs-btn-active-border-color: #0b2a5b;
}

.form-control:focus, .form-select:focus {
    border-color: #0b2a5b;
    box-shadow: 0 0 0 0.2rem rgba(11, 42, 91, 0.15);
}

.app-topbar .navbar-brand .br-logo {
    height: 44px;
    width: auto;
    display: block;
}

.app-sidebar .nav-link.active {
    background-color: #c8102e;
}

.app-sidebar .nav-section-label {
    color: #8fa0c8;
}

.card-header {
    font-weight: 600;
}

/* ====================================================================== */
/* BR ENTERPRISE GLOBAL DESIGN SYSTEM -- one set of control dimensions    */
/* for every page. Floating-label forms (.form-floating) keep Bootstrap's */
/* taller floating layout; everything else uses --br-control-height.      */
/* ====================================================================== */
:root {
    --br-primary: #142B50;
    --br-secondary: #D71920;
    --br-background: #F4F6FA;
    --br-surface: #FFFFFF;
    --br-border: #D8DFE9;
    --br-text: #17243B;
    --br-muted: #64748B;
    --br-success: #138a36;
    --br-warning: #d97706;
    --br-danger: #D71920;

    --br-control-height: 42px;
    --br-control-radius: 6px;
    --br-control-font-size: 14px;
    --br-control-padding-x: 12px;
    --br-card-radius: 10px;
    --br-section-gap: 16px;
}

[data-bs-theme="dark"] {
    --br-surface: #171b2e;
    --br-border: #2a3050;
    --br-text: #e7e9f2;
    --br-muted: #9aa1bd;
}

/* ---- Text / number / date / select controls ---- */
.form-control:not(.form-control-sm):not(.form-control-lg):not(textarea),
.form-select:not(.form-select-sm):not(.form-select-lg),
.input-group:not(.input-group-sm):not(.input-group-lg) > .form-control,
.input-group:not(.input-group-sm):not(.input-group-lg) > .form-select,
.input-group:not(.input-group-sm):not(.input-group-lg) > .input-group-text {
    height: var(--br-control-height);
    min-height: var(--br-control-height);
    font-size: var(--br-control-font-size);
    padding-top: 0;
    padding-bottom: 0;
    padding-left: var(--br-control-padding-x);
    border-radius: var(--br-control-radius);
    border-color: var(--br-border);
    line-height: 1.5;
}

.form-select:not(.form-select-sm):not(.form-select-lg) {
    padding-right: 2.25rem;
}

/* Floating-label forms keep Bootstrap's own taller layout */
.form-floating > .form-control,
.form-floating > .form-select {
    height: calc(3.5rem + 2px);
    min-height: calc(3.5rem + 2px);
    padding-top: 1.625rem;
    padding-bottom: 0.625rem;
}

textarea.form-control {
    min-height: 90px;
    height: auto;
    font-size: var(--br-control-font-size);
    border-radius: var(--br-control-radius);
    border-color: var(--br-border);
    padding: 0.5rem var(--br-control-padding-x);
}

/* Input group: joined controls share corners/height */
.input-group > .input-group-text {
    background: #f1f4f9;
    color: var(--br-muted);
    border-color: var(--br-border);
}

.form-control::placeholder { color: #94a3b8; }

.form-control:disabled, .form-control[readonly],
.form-select:disabled {
    background-color: #eef1f6;
    color: var(--br-muted);
    opacity: 1;
}

/* ---- Select2 (single) -- matches normal inputs exactly ---- */
/* Select2 copies the source <select>'s "form-select" class onto its
   container; neutralise the container so only the inner box is sized. */
.select2-container.form-select,
.select2-container.form-control {
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
}

.select2-container--bootstrap-5:not(.form-floating > .select2-container) .select2-selection--single {
    box-sizing: border-box !important;
    height: var(--br-control-height) !important;
    min-height: var(--br-control-height) !important;
    display: flex;
    align-items: center;
    padding: 0 2.25rem 0 var(--br-control-padding-x) !important;
    font-size: var(--br-control-font-size);
    border-radius: var(--br-control-radius);
    border-color: var(--br-border);
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    padding: 0 !important;
    line-height: calc(var(--br-control-height) - 2px);
    font-size: var(--br-control-font-size);
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: calc(var(--br-control-height) - 2px);
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear {
    margin-top: 0;
    align-self: center;
}

.select2-container--bootstrap-5 .select2-selection--multiple {
    min-height: var(--br-control-height);
    border-radius: var(--br-control-radius);
    border-color: var(--br-border);
    font-size: var(--br-control-font-size);
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
    height: var(--br-control-height);
    font-size: var(--br-control-font-size);
    border-radius: var(--br-control-radius);
}

.select2-container--bootstrap-5 .select2-dropdown .select2-results__option {
    font-size: var(--br-control-font-size);
    padding: 0.45rem var(--br-control-padding-x);
}

/* Dropdown menus above modals / sticky bars and never clipped by them */
.select2-container--open .select2-dropdown { z-index: 2000; }

/* ---- Select2 focus matches inputs ---- */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--br-primary);
    box-shadow: 0 0 0 0.2rem rgba(20, 43, 80, 0.15);
}

/* ---- Labels, helper text, validation ---- */
.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--br-text);
    margin-bottom: 0.3rem;
}

.form-text { font-size: 12px; color: var(--br-muted); }

.text-danger.field-validation-error,
span.field-validation-error,
.invalid-feedback {
    display: block;
    font-size: 12px;
    line-height: 1.2;
}

/* ---- Buttons ---- */
.btn:not(.btn-sm):not(.btn-lg):not(.btn-close):not(.dt-button):not(.topbar-icon-btn) {
    min-height: var(--br-control-height);
    font-size: var(--br-control-font-size);
    border-radius: var(--br-control-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding-left: 1rem;
    padding-right: 1rem;
}

.btn-sm { border-radius: var(--br-control-radius); }

.btn-icon, .btn-sm.btn-icon { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ---- Cards / tables / badges / alerts ---- */
.card { border-radius: var(--br-card-radius); border-color: var(--br-border); }
.card-header { background: var(--br-surface); }

.table > thead > tr > th {
    background-color: var(--br-primary);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border-color: var(--br-primary);
}

.table > tbody > tr > td { font-size: 13.5px; vertical-align: middle; }

.modal-content { border-radius: var(--br-card-radius); }
.alert { border-radius: var(--br-control-radius); }
.badge { font-weight: 600; }
.page-link { font-size: 13px; }

.page-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: var(--br-section-gap); }

/* Dashboard redesign: navy sidebar + light app background (light theme only) */
:root:not([data-bs-theme="dark"]) { --brent-sidebar-bg: #0D2147; }

.topbar-icon-btn .notif-count {
    position: absolute;
    top: 2px;
    right: 0;
    font-size: 0.62rem;
    min-width: 18px;
    padding: 2px 5px;
}

/* ======================================================================== */
/* BR ENTERPRISE -- shared page layer (Index / Create / Edit / Details)      */
/* One place for every module's list, form and modal look. Tokens: --br-*.   */
/* ======================================================================== */
:root:not([data-bs-theme="dark"]) {
    --br-navy: #142B50;
    --br-red: #D71920;
    --br-page-bg: #F4F6FA;
    --br-border: #D8DFE9;
    --br-text: #17243B;
    --br-text-muted: #64748B;
}
:root:not([data-bs-theme="dark"]) body { background-color: var(--br-page-bg); color: var(--br-text); }

/* ---- page header: title lives in the layout's breadcrumb bar; the view adds description + actions ---- */
.page-intro-text { color: var(--br-text-muted); font-size: .92rem; max-width: 780px; }
.app-breadcrumb-bar h1 { font-weight: 700; color: var(--br-navy); }
[data-bs-theme="dark"] .app-breadcrumb-bar h1 { color: inherit; }

/* ---- list-page card + DataTables toolbar ---- */
.card { border-color: var(--br-border); border-radius: 10px; }
.card > .card-body > table.dataTable, .card > .card-body > .table { margin-bottom: 0; }
div.dataTables_wrapper div.dataTables_length { display: inline-flex; align-items: center; margin: 0; }
div.dataTables_wrapper div.dataTables_length label { display: inline-flex; align-items: center; gap: .4rem; margin: 0; font-size: .85rem; color: var(--br-text-muted); }
div.dataTables_wrapper div.dataTables_length select { width: auto; min-width: 72px; height: 36px; padding: 0 1.8rem 0 .7rem; }
div.dataTables_wrapper div.dataTables_filter { margin: 0; width: 100%; max-width: 320px; }
div.dataTables_wrapper div.dataTables_filter label { width: 100%; margin: 0; }
div.dataTables_wrapper div.dataTables_filter input { width: 100% !important; margin: 0 !important; height: 40px; padding-left: 2.2rem; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748B' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E") no-repeat .75rem center; }
div.dataTables_wrapper div.dataTables_processing { background: rgba(255,255,255,.85); border: 1px solid var(--br-border); border-radius: 8px; box-shadow: 0 6px 18px rgba(20,43,80,.12); color: var(--br-navy); font-weight: 600; padding: .6rem 1rem; z-index: 5; }

/* ---- table body: consistent row height, hover, numeric alignment ---- */
table.dataTable > tbody > tr > td { padding: .6rem .8rem; vertical-align: middle; font-size: .9rem; }
table.dataTable.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-accent-bg: rgba(20,43,80,.025); }
table.dataTable.table-hover > tbody > tr:hover > * { --bs-table-accent-bg: rgba(215,25,32,.05); }
table.dataTable td.dt-right, table.dataTable th.dt-right, td.text-end { font-variant-numeric: tabular-nums; }
table.dataTable td .btn-group .btn { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; min-height: 32px; }
table.dataTable td .btn-group .btn-outline-primary:hover { background: var(--br-navy); border-color: var(--br-navy); }
table.dataTable td .btn-group .btn-outline-danger:hover { background: var(--br-red); border-color: var(--br-red); }
table.dataTable td .dataTables_empty { padding: 2.2rem 0; color: var(--br-text-muted); }

/* pagination */
.page-item.active .page-link { background: var(--br-navy); border-color: var(--br-navy); }
.page-link { color: var(--br-navy); }
div.dataTables_wrapper div.dataTables_info { color: var(--br-text-muted); font-size: .82rem; padding-top: 0; }

/* bulk-action bar */
.bulk-actions-bar { border-radius: 8px; border: 1px solid var(--br-border); background: #fff; padding: .5rem .9rem; margin-bottom: .75rem; display: flex; align-items: center; gap: .75rem; }

/* ---- status badges: one look everywhere (Bootstrap bg-* badges become soft pills) ---- */
.badge.bg-success { background-color: #dcfce7 !important; color: #166534; }
.badge.bg-danger { background-color: #fee2e2 !important; color: #b91c1c; }
.badge.bg-warning { background-color: #fef3c7 !important; color: #92400e !important; }
.badge.bg-secondary { background-color: #e8ecf3 !important; color: #475569; }
.badge.bg-info { background-color: #dbeafe !important; color: #1d4ed8; }
.badge.bg-primary { background-color: #e0e7f5 !important; color: var(--br-navy); }
.badge { border-radius: 999px; padding: .38em .75em; font-size: .75rem; }

/* ---- forms (modal and full page) ---- */
.form-label { font-weight: 600; font-size: .82rem; color: var(--br-text); margin-bottom: .3rem; }
.form-label.is-required::after { content: " *"; color: var(--br-red); font-weight: 700; }
.form-text, .field-hint { font-size: .78rem; color: var(--br-text-muted); }
.text-danger.small[data-valmsg-for], span.text-danger[data-valmsg-for] { font-size: .78rem; display: block; margin-top: .2rem; }
.form-control.input-validation-error, .form-select.input-validation-error { border-color: var(--br-red); }
.form-control:disabled, .form-control[readonly], .form-select:disabled { background-color: #eef1f6; color: var(--br-text-muted); }

/* ---- modals: navy header strip, sticky footer so Save/Cancel are always reachable ---- */
.modal-header { border-bottom: 1px solid var(--br-border); padding: 1rem 1.25rem; }
.modal-header .modal-title { font-weight: 700; color: var(--br-navy); font-size: 1.1rem; }
[data-bs-theme="dark"] .modal-header .modal-title { color: inherit; }
.modal-body { padding: 1.25rem; }
.modal-dialog-scrollable .modal-footer, .modal-footer { border-top: 1px solid var(--br-border); padding: .85rem 1.25rem; background: inherit; position: sticky; bottom: 0; z-index: 2; gap: .5rem; }
.modal-content { box-shadow: 0 20px 50px rgba(20,43,80,.25); border: 0; }
.modal-xl, .modal-lg { max-width: min(96vw, var(--bs-modal-width)); }

/* ---- details cards ---- */
.detail-view-header { border-bottom: 1px solid var(--br-border); padding-bottom: .9rem; margin-bottom: 1rem; }
.detail-view-icon { background: #e8edf7; color: var(--br-navy); }
.detail-item { border-radius: 8px; }
.detail-item-label { color: var(--br-text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.detail-item-value { font-weight: 600; color: var(--br-text); }

/* ---- breadcrumb + empty states ---- */
.breadcrumb { font-size: .82rem; }
.breadcrumb-item.active { color: var(--br-text-muted); }
.empty-state { text-align: center; color: var(--br-text-muted); padding: 2.5rem 1rem; }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .6; }

/* ---- responsive: no horizontal page overflow; tables scroll inside their card ---- */
/* Only list-page cards scroll sideways; form cards must not clip dropdowns, and sticky action bars need a non-scrolling ancestor. */
.card-body:has(> table.dataTable), .card-body:has(> .dataTables_wrapper) { overflow-x: auto; }
@media (max-width: 767.98px) {
    div.dataTables_wrapper div.dataTables_filter { max-width: 100%; }
    .modal-dialog { margin: .5rem; }
    .app-breadcrumb-bar { align-items: flex-start !important; }
}

/* ---- form sections (Products / Customers / Vendors modals; reusable for every form) ---- */
.form-section { border: 1px solid var(--br-border, #D8DFE9); border-radius: 10px; padding: 1rem 1.1rem 1.1rem; background: var(--brent-surface, #fff); }
.form-section + .form-section { margin-top: 1rem; }
.form-section-title { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: .92rem; color: var(--br-navy, #142B50); margin-bottom: .85rem; }
.form-section-title i { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: #e8edf7; color: var(--br-navy, #142B50); font-size: .95rem; }
[data-bs-theme="dark"] .form-section-title { color: inherit; }
.form-section-hint { font-size: .8rem; color: var(--br-text-muted, #64748B); margin: -.4rem 0 .8rem; }
.modal-body:has(.form-section) { background: var(--br-page-bg, #F4F6FA); }
[data-bs-theme="dark"] .modal-body:has(.form-section) { background: transparent; }

/* ---- details sections + card headers ---- */
.detail-section + .detail-section { margin-top: 1.1rem; }
.detail-section-title { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: .85rem; color: var(--br-navy, #142B50); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .6rem; }
.detail-section-title i { color: var(--br-red, #D71920); }
[data-bs-theme="dark"] .detail-section-title { color: inherit; }
.text-navy { color: var(--br-navy, #142B50); }
[data-bs-theme="dark"] .text-navy { color: inherit; }
.card-header { font-weight: 700; color: var(--br-navy, #142B50); background: transparent; border-bottom: 1px solid var(--br-border, #D8DFE9); }
[data-bs-theme="dark"] .card-header { color: inherit; }
.card-header > i, .card-header span > i { color: var(--br-red, #D71920); }

/* Action column: icon-only square buttons with even spacing (never text labels -- those get crushed). */
table.dataTable td .btn-group { display: inline-flex; flex-wrap: nowrap; gap: 4px; }
table.dataTable td .btn-group > .btn { flex: 0 0 32px; width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 6px !important; display: inline-flex; align-items: center; justify-content: center; margin: 0 !important; line-height: 1; }
table.dataTable td .btn-group > .btn i { font-size: .95rem; margin: 0; }
table.dataTable td:last-child { white-space: nowrap; }


/* Notifications dropdown */
.dropdown-menu.notif-menu { width: 340px; max-width: calc(100vw - 24px); padding: 0; border: 1px solid var(--br-border, #e5e7eb); border-radius: 12px; overflow: hidden; z-index: 1085; background: #fff; }
.notif-menu .notif-head { padding: .75rem 1rem; font-weight: 700; font-size: .9rem; color: #0D2147; border-bottom: 1px solid #eef0f4; }
.notif-menu .notif-item { display: flex; align-items: flex-start; gap: .75rem; padding: .75rem 1rem; white-space: normal; border-bottom: 1px solid #f3f4f6; }
.notif-menu .notif-item:hover { background: #f6f8fc; }
.notif-menu .notif-ico { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #fff4e0; color: #e08a00; font-size: 1rem; }
.notif-menu .notif-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.notif-menu .notif-text strong { font-size: .85rem; color: #1f2937; }
.notif-menu .notif-text small { font-size: .78rem; color: #6b7280; white-space: normal; word-break: break-word; }
.notif-menu .notif-foot { text-align: center; }
.notif-menu .notif-foot a { display: block; padding: .65rem 1rem; font-size: .82rem; font-weight: 600; color: #C8102E; text-decoration: none; }
.notif-menu .notif-foot a:hover { background: #f6f8fc; }

/* Action buttons that carry a text label keep their natural width */
table.dataTable td .btn-group > .btn.btn-labeled { flex: 0 0 auto; width: auto; min-width: 32px; padding: 0 .7rem; gap: .35rem; white-space: nowrap; font-size: .8rem; font-weight: 600; }
table.dataTable td .btn-group > .btn.btn-labeled i { font-size: .9rem; }
table.dataTable td .btn-group:has(> .btn-labeled) { flex-wrap: nowrap; }

/* ===== Reusable ActionButton component (row actions on every Index/List page) =====
   Icon-only, 36x36, flex row centred with a 6px gap, never wraps; colour by role. */
.br-actions { display: inline-flex; align-items: center; justify-content: center; flex-wrap: nowrap; gap: 6px; white-space: nowrap; }
td:has(> .br-actions) { text-align: center; }
.br-actions > .br-act {
    --act: #475569; flex: 0 0 36px; width: 36px; height: 36px; min-height: 36px; padding: 0; margin: 0 !important;
    display: inline-flex; align-items: center; justify-content: center; line-height: 1;
    background: #fff; color: var(--act); border: 1px solid var(--act); border-radius: 8px !important;
    transition: background-color .15s, color .15s, box-shadow .15s;
}
.br-actions > .br-act i { font-size: 1.05rem; margin: 0; line-height: 1; pointer-events: none; }
.br-act-view   { --act: #1d4ed8 !important; }
.br-act-bill   { --act: #1d4ed8 !important; }
.br-act-print  { --act: #15803d !important; }
.br-act-edit   { --act: #b45309 !important; }
.br-act-delete { --act: #dc2626 !important; }
.br-actions > .br-act:hover { background: var(--act); color: #fff; }
.br-actions > .br-act:focus-visible { outline: 0; box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--act) 30%, transparent); }
.br-actions > .br-act:active { transform: translateY(1px); }
.br-actions > .br-act:disabled, .br-actions > .br-act.disabled, .br-actions > .br-act[aria-disabled="true"] { opacity: .45; pointer-events: none; }
