/* BizTrx MFG modern interface layer. Kept separate so legacy page CSS remains compatible. */
:root {
    --sidebar-width: 278px;
    --sidebar-collapsed-width: 82px;
    --navbar-height: 76px;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --secondary-color: #64748b;
    --bg-primary: #f4f6fb;
    --bg-secondary: #ffffff;
    --text-primary: #172033;
    --text-secondary: #64748b;
    --border-color: #e4e8f0;
    --surface-muted: #f8fafc;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 7px 22px rgba(15, 23, 42, .055);
    --shadow-lg: 0 18px 45px rgba(15, 23, 42, .12);
    --transition: 180ms cubic-bezier(.2, .8, .2, 1);
}

html { scroll-behavior: smooth; }

body {
    min-height: 100vh;
    color: var(--text-primary);
    background:
        radial-gradient(circle at 100% 0, rgba(79, 70, 229, .055), transparent 26rem),
        var(--bg-primary);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: .925rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

::selection { color: #fff; background: var(--brand-primary, var(--primary-color)); }
::-moz-selection { color: #fff; background: var(--brand-primary, var(--primary-color)); }
a { color: var(--primary-color); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }

/* Navigation */
.sidebar {
    width: var(--sidebar-width);
    padding: 14px 12px;
    color: #cbd5e1;
    border: 0;
    background:
        radial-gradient(circle at 0 0, rgba(99, 102, 241, .25), transparent 18rem),
        linear-gradient(180deg, #10182b 0%, #111827 100%);
    box-shadow: 8px 0 32px rgba(15, 23, 42, .12);
    transition: width var(--transition), transform var(--transition);
}

.sidebar-header {
    height: 62px;
    margin-bottom: 8px;
    padding: 12px 13px;
    gap: 13px;
    border: 0;
}

.sidebar-header > i {
    display: grid;
    place-items: center;
    flex: 0 0 39px;
    width: 39px;
    height: 39px;
    color: #fff;
    border-radius: 12px;
    background: linear-gradient(135deg, #818cf8, #4f46e5);
    box-shadow: 0 8px 20px rgba(79, 70, 229, .35);
    font-size: 17px;
}

.sidebar-brand-logo {
    display: block;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 3px;
    border: 1px solid #e5e9f0;
    border-radius: 11px;
    background: #fff;
    object-fit: contain;
}

.sidebar-title { color: #fff; font-size: 17px; font-weight: 750; letter-spacing: -.02em; }
.sidebar-nav { padding: 7px 0 16px; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(148, 163, 184, .25); }

.nav-item,
.nav-dropdown-toggle {
    min-height: 44px;
    margin: 3px 0;
    padding: 10px 13px;
    gap: 12px;
    color: #aebbd0;
    border: 1px solid transparent;
    border-radius: 11px;
    font-size: 13.5px;
    font-weight: 570;
    transition: color var(--transition), background var(--transition), border-color var(--transition), transform var(--transition);
}

.nav-item:hover,
.nav-dropdown-toggle:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, .06);
    background: rgba(255, 255, 255, .07);
}

.nav-item.active,
.nav-dropdown-toggle.active {
    color: #fff;
    border: 1px solid rgba(129, 140, 248, .25);
    background: linear-gradient(90deg, rgba(79, 70, 229, .4), rgba(79, 70, 229, .16));
    box-shadow: inset 3px 0 #818cf8;
}

.nav-item i,
.nav-dropdown-toggle i.fas { width: 22px; color: #8290a7; font-size: 15px; }
.nav-item:hover i,
.nav-item.active i,
.nav-dropdown-toggle:hover i,
.nav-dropdown-toggle.active i { color: #c7d2fe; }

.nav-dropdown-menu {
    margin: 0 5px;
    border-radius: 11px;
    background: rgba(2, 6, 23, .2);
}
.nav-dropdown-menu .nav-item { min-height: 38px; margin: 1px 0; padding: 8px 12px 8px 43px; font-size: 12.75px; }

.nav-menu-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 14px 6px 43px;
    color: #94a3b8;
    border: 0;
    background: transparent;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    line-height: 1.2;
    text-align: left;
    text-transform: uppercase;
    transition: color var(--transition), background var(--transition);
}

.nav-menu-group:first-child .nav-menu-group-toggle { padding-top: 8px; }
.nav-menu-group-toggle:hover,
.nav-menu-group-toggle:focus-visible { color: var(--brand-primary); background: color-mix(in srgb, var(--brand-primary) 4%, transparent); }
.nav-menu-group-toggle:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand-primary) 30%, transparent); outline-offset: -2px; }
.nav-menu-group-toggle i {
    width: auto;
    margin-left: 8px;
    font-size: 9px;
    transition: transform var(--transition), color var(--transition);
}
.nav-menu-group.open .nav-menu-group-toggle i { transform: rotate(180deg); }
.nav-menu-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
}
.nav-menu-group.open .nav-menu-group-items { max-height: 520px; }
.nav-dropdown-toggle .fa-chevron-down { opacity: .65; }
.sidebar-footer { padding: 10px 0 0; border-color: rgba(255, 255, 255, .08); }
.sidebar-footer .logout-btn { color: #fca5a5; border-radius: 11px; }
.sidebar-footer .logout-btn:hover { color: #fff; background: rgba(239, 68, 68, .14); }

.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .sidebar-header { padding-inline: 8px; }
.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-dropdown-toggle { justify-content: center; padding-inline: 8px; }
.sidebar.collapsed .nav-dropdown-toggle .left-content { justify-content: center; }

@media (min-width: 992px) {
    .sidebar.collapsed { overflow: hidden; }
    .sidebar.collapsed .sidebar-title,
    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .nav-dropdown-toggle .left-content span,
    .sidebar.collapsed .nav-dropdown-toggle > .fa-chevron-down,
    .sidebar.collapsed .nav-dropdown-menu {
        display: none !important;
    }
    .sidebar.collapsed .sidebar-brand-logo { flex-basis: 42px; margin: 0 auto; }
    .sidebar.collapsed .sidebar-nav { overflow-x: hidden; }
    .sidebar.collapsed .nav-dropdown-toggle .left-content {
        flex: 0 0 auto;
        justify-content: center;
    }
    .sidebar.collapsed .nav-item i,
    .sidebar.collapsed .nav-dropdown-toggle i.fas {
        flex: 0 0 22px;
        margin: 0;
    }
}

.main-content { margin-left: var(--sidebar-width); transition: margin-left var(--transition); }
.sidebar.collapsed ~ .sidebar-backdrop + .main-content { margin-left: var(--sidebar-collapsed-width); }
.sidebar-backdrop { display: none; }

/* Top bar */
.top-navbar {
    height: var(--navbar-height);
    padding: 0 clamp(18px, 3vw, 38px);
    border-color: rgba(226, 232, 240, .85);
    background: rgba(255, 255, 255, .86);
    box-shadow: 0 1px 0 rgba(15, 23, 42, .03);
    backdrop-filter: blur(14px);
}
.navbar-left { gap: 15px; min-width: 0; }
.btn-toggle {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: #475569;
    border: 1px solid var(--border-color);
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 2px 7px rgba(15, 23, 42, .04);
}
.btn-toggle:hover { color: var(--primary-color); border-color: #c7d2fe; background: var(--primary-soft); }
.page-title { overflow: hidden; color: #182033; font-size: clamp(17px, 2vw, 21px); font-weight: 720; letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }
.navbar-right { gap: 13px; }
.workspace-context { align-items: center; gap: 8px; padding: 7px 11px; color: #64748b; border: 1px solid var(--border-color); border-radius: 999px; background: #fff; font-size: 12px; font-weight: 600; }
.workspace-dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 3px #d1fae5; }
.user-menu { padding: 5px 7px 5px 5px; border: 1px solid transparent; border-radius: 13px; }
.user-menu:hover { border-color: var(--border-color); background: #fff; box-shadow: var(--shadow); }
.user-menu .user-avatar { width: 38px; height: 38px; color: #fff; background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.user-copy { display: grid; min-width: 0; line-height: 1.2; }
.user-copy strong { max-width: 150px; overflow: hidden; color: #334155; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.user-copy small { color: #94a3b8; font-size: 10.5px; }

/* Universal workspace search */
.global-search {
    position: relative;
    display: flex;
    flex: 1 1 420px;
    align-items: center;
    max-width: 520px;
    margin: 0 clamp(10px, 2vw, 28px);
}
form.global-search > input#globalSearchInput {
    width: 100%;
    height: 40px;
    min-height: 40px;
    padding: 0 43px 0 42px;
    color: #243047;
    border: 1px solid color-mix(in srgb, var(--brand-primary) 22%, #dfe5ed);
    border-radius: 11px;
    outline: 0;
    background: color-mix(in srgb, var(--brand-primary) 3%, #fff);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--brand-primary) 7%, transparent);
    font-size: 12.5px;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
form.global-search > input#globalSearchInput::placeholder { color: #8c98aa; }
form.global-search > input#globalSearchInput:hover { border-color: color-mix(in srgb, var(--brand-primary) 38%, #dfe5ed); background: #fff; }
form.global-search > input#globalSearchInput:focus { border-color: var(--brand-primary); background: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-primary) 11%, transparent), 0 3px 10px rgba(15, 23, 42, .05); }
.global-search-icon { position: absolute; left: 15px; z-index: 1; color: var(--brand-primary); font-size: 13px; opacity: .78; pointer-events: none; }
.global-search-shortcut {
    position: absolute;
    right: 11px;
    display: grid;
    place-items: center;
    width: 21px;
    height: 21px;
    color: #8190a5;
    border: 1px solid #dce2ea;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
    font-family: inherit;
    font-size: 10px;
}
.global-search-results {
    position: absolute;
    top: calc(100% + 9px);
    left: 0;
    z-index: 1100;
    width: 100%;
    min-width: 430px;
    max-height: min(68vh, 560px);
    overflow-y: auto;
    padding: 7px;
    border: 1px solid #e1e6ed;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .16);
}
.global-search-results[hidden] { display: none; }
.global-search-group { padding: 9px 10px 5px; color: #8a96a8; font-size: 9.5px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.global-search-result,
.search-page-result {
    display: flex;
    align-items: center;
    gap: 11px;
    color: #344158;
    text-decoration: none;
}
.global-search-result { min-height: 57px; padding: 7px 9px; border-radius: 10px; }
.global-search-result:hover,
.global-search-result.active { color: #202b40; background: color-mix(in srgb, var(--brand-primary) 6%, white); }
.search-result-icon,
.search-group-heading-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 36px;
    height: 36px;
    color: #475569;
    border-radius: 10px;
    background: #f1f5f9;
    font-size: 13px;
}
.search-result-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; }
.search-result-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
.search-result-title-row strong { overflow: hidden; color: #27344a; font-size: 12.5px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.search-result-title-row small { flex: 0 0 auto; color: #98a3b3; font-size: 9.5px; }
.search-result-subtitle { overflow: hidden; color: #778398; font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.search-result-arrow { color: #b4bdca; font-size: 10px; opacity: 0; transform: translateX(-3px); transition: opacity var(--transition), transform var(--transition); }
.global-search-result:hover .search-result-arrow,
.global-search-result.active .search-result-arrow { opacity: 1; transform: translateX(0); }
.global-search-state { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 76px; padding: 15px; color: #778398; font-size: 12px; }
.global-search-footer { width: 100%; padding: 10px; color: var(--brand-primary); border: 0; border-top: 1px solid #edf0f4; background: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.global-search-footer:hover { background: #f8fafc; }

.search-module-inventory { color: #2563eb; background: #eff6ff; }
.search-module-partners { color: #0891b2; background: #ecfeff; }
.search-module-sales { color: #7c3aed; background: #f5f3ff; }
.search-module-procurement { color: #d97706; background: #fffbeb; }
.search-module-production { color: #c2410c; background: #fff7ed; }
.search-module-quality { color: #059669; background: #ecfdf5; }
.search-module-dispatch { color: #0369a1; background: #f0f9ff; }
.search-module-administration { color: #475569; background: #f1f5f9; }
.search-module-master { color: #475569; background: #f1f5f9; }
.search-module-core { color: #4f46e5; background: #eef2ff; }

.search-page { max-width: 1120px; margin: 0 auto; }
.search-page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.search-page-header h1 { margin: 4px 0 5px; font-size: clamp(24px, 3vw, 34px); font-weight: 760; letter-spacing: -.035em; }
.search-page-header p { margin: 0; color: #718096; font-size: 13px; }
.search-page-form { display: grid; grid-template-columns: minmax(260px, 1fr) 190px auto; gap: 10px; padding: 13px; border: 1px solid #e1e6ed; border-radius: 15px; background: #fff; box-shadow: 0 5px 18px rgba(15, 23, 42, .05); }
.search-page-input { position: relative; display: flex; align-items: center; }
.search-page-input i { position: absolute; left: 15px; color: #8b97a8; }
.search-page-input input,
.search-page-form select { width: 100%; height: 44px; color: #334155; border: 1px solid #dce2ea; border-radius: 10px; background: #f9fafb; font-size: 12.5px; }
.search-page-input > input#workspaceSearchInput { padding: 0 14px 0 41px; }
.search-page-form select { padding: 0 34px 0 12px; }
.search-page-form .btn { min-width: 104px; }
.search-summary { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 12px; color: #64748b; font-size: 12px; }
.search-summary strong { color: #263248; }
.search-summary a { font-weight: 650; text-decoration: none; }
.search-groups { display: grid; gap: 14px; }
.search-group-card { overflow: hidden; border: 1px solid #e2e7ee; border-radius: 15px; background: #fff; box-shadow: 0 3px 12px rgba(15, 23, 42, .035); }
.search-group-card > header { display: flex; align-items: center; gap: 11px; padding: 14px 16px; border-bottom: 1px solid #edf0f4; background: #fbfcfd; }
.search-group-card > header h2 { margin: 0; font-size: 14px; font-weight: 730; }
.search-group-card > header small { color: #8b96a7; font-size: 10px; }
.search-group-heading-icon { width: 34px; height: 34px; }
.search-page-result { min-height: 66px; padding: 10px 16px; border-bottom: 1px solid #f0f2f5; }
.search-page-result:last-child { border-bottom: 0; }
.search-page-result:hover { color: #27344a; background: color-mix(in srgb, var(--brand-primary) 4%, white); }
.search-page-result .search-result-title-row { justify-content: flex-start; }
.search-page-result .search-result-title-row strong { font-size: 13px; }
.search-status { flex: 0 0 auto; padding: 4px 8px; color: #526075; border-radius: 999px; background: #f1f5f9; font-size: 9px; font-weight: 750; letter-spacing: .035em; text-transform: uppercase; }
.search-page-result-arrow { margin-left: 5px; color: #b1bbc8; font-size: 10px; }
.search-empty-state { display: grid; justify-items: center; max-width: 560px; margin: 72px auto 30px; color: #738096; text-align: center; }
.search-empty-icon { display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: 15px; color: var(--brand-primary); border-radius: 20px; background: color-mix(in srgb, var(--brand-primary) 9%, white); font-size: 23px; }
.search-empty-state h2 { margin-bottom: 7px; font-size: 18px; font-weight: 730; }
.search-empty-state p { max-width: 480px; font-size: 12.5px; line-height: 1.65; }

/* Role permission editor */
.role-form-page { max-width: 1060px; margin: 0 auto; }
.role-form-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.role-form-heading h1 { margin: 4px 0 5px; font-size: clamp(24px, 3vw, 32px); font-weight: 760; letter-spacing: -.035em; }
.role-form-heading p { margin: 0; color: #718096; font-size: 13px; }
.role-name-card,
.role-permissions-card { border: 1px solid #e1e6ed; border-radius: 15px; background: #fff; box-shadow: 0 4px 16px rgba(15, 23, 42, .04); }
.role-name-card { margin-bottom: 14px; padding: 18px; }
.role-name-card > label { display: block; margin: 0 0 2px; color: #263248; font-size: 13px; font-weight: 720; }
.role-name-card > label span { color: #dc2626; }
.role-name-card > p { margin: 0 0 11px; color: #8490a2; font-size: 10.5px; }
.role-name-card > input { width: min(100%, 520px); }
.role-access-mode-selector { margin: 18px 0 0; padding: 16px 0 0; border: 0; border-top: 1px solid #edf0f4; }
.role-access-mode-selector legend { width: auto; margin: 0 0 10px; padding: 0; color: #334155; font-size: 12px; font-weight: 720; }
.role-access-mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-access-mode-option { position: relative; display: flex; align-items: flex-start; gap: 11px; min-height: 86px; margin: 0; padding: 14px 40px 14px 14px; border: 1px solid #dfe5ed; border-radius: 12px; background: #fff; cursor: pointer; transition: border-color var(--transition), background var(--transition), box-shadow var(--transition); }
.role-access-mode-option:hover { border-color: color-mix(in srgb, var(--brand-primary) 30%, #dfe5ed); background: color-mix(in srgb, var(--brand-primary) 3%, white); }
.role-access-mode-option.selected { border-color: var(--brand-primary); background: color-mix(in srgb, var(--brand-primary) 6%, white); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 10%, transparent); }
.role-access-mode-option > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.role-access-mode-option > span:nth-of-type(2) { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.role-access-mode-option strong { color: #27344a; font-size: 12.5px; }
.role-access-mode-option small { color: #778499; font-size: 10px; font-weight: 500; line-height: 1.45; }
.role-access-mode-icon { display: grid; flex: 0 0 36px; place-items: center; width: 36px; height: 36px; color: var(--brand-primary); border-radius: 10px; background: color-mix(in srgb, var(--brand-primary) 9%, white); }
.role-access-mode-check { position: absolute; top: 14px; right: 14px; color: #cbd5e1; font-size: 16px; }
.role-access-mode-option.selected .role-access-mode-check { color: var(--brand-primary); }
.role-access-mode-option > input:focus-visible ~ .role-access-mode-check { outline: 3px solid color-mix(in srgb, var(--brand-primary) 18%, transparent); outline-offset: 3px; border-radius: 50%; }
.field-error { margin-top: 6px; color: #b42318; font-size: 11px; }
.role-permissions-card { overflow: hidden; }
.role-access-panel[hidden] { display: none; }
.role-permissions-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 18px; border-bottom: 1px solid #edf0f4; }
.role-permissions-header h2 { margin: 0 0 2px; font-size: 15px; font-weight: 740; }
.role-permissions-header p { margin: 0; color: #8490a2; font-size: 10.5px; }
.role-selected-summary { display: flex; align-items: baseline; gap: 5px; padding: 7px 10px; color: #718096; border-radius: 9px; background: color-mix(in srgb, var(--brand-primary) 6%, white); font-size: 10px; }
.role-selected-summary strong { color: var(--brand-primary); font-size: 15px; }
.role-permission-toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid #edf0f4; background: #fbfcfd; }
.role-permission-search { position: relative; display: flex; flex: 1; align-items: center; }
.role-permission-search > i { position: absolute; left: 13px; z-index: 1; color: #8c98aa; font-size: 12px; line-height: 1; pointer-events: none; }
form#roleForm .role-permission-search > input[type="search"] { width: 100%; height: 38px; min-height: 38px; padding: 0 36px 0 38px; border-color: #dce2ea; background: #fff; font-size: 11.5px; }
form#roleForm .role-permission-search > input[type="search"]:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 14%, transparent); outline: 0; }
form#roleForm .role-permission-search:focus-within > i { color: var(--brand-primary); }
.role-permission-search > button { position: absolute; right: 7px; display: grid; place-items: center; width: 27px; height: 27px; padding: 0; color: #8490a2; border: 0; border-radius: 7px; background: transparent; }
.role-permission-search > button:hover { color: #334155; background: #f1f5f9; }
.role-permission-groups { display: grid; gap: 9px; padding: 13px; background: #f8fafc; }
.role-permission-group { overflow: hidden; border: 1px solid #e2e7ee; border-radius: 12px; background: #fff; }
.role-permission-group[hidden],
.role-permission-option[hidden] { display: none; }
.role-permission-group-header { display: flex; align-items: center; min-height: 62px; }
.role-permission-group-toggle { display: flex; flex: 1; align-items: center; gap: 11px; min-width: 0; padding: 10px 13px; color: #334155; border: 0; background: transparent; text-align: left; }
.role-permission-group-toggle:hover { background: color-mix(in srgb, var(--brand-primary) 4%, white); }
.role-permission-module-icon { display: grid; flex: 0 0 36px; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-size: 13px; }
.role-permission-group-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.role-permission-group-copy strong { color: #27344a; font-size: 12.5px; font-weight: 720; }
.role-permission-group-copy small { color: #8a96a7; font-size: 9.5px; }
.role-permission-chevron { color: #a0aaba; font-size: 10px; transition: transform var(--transition); }
.role-permission-group.open .role-permission-chevron { transform: rotate(180deg); }
.role-group-select { display: flex; align-items: center; gap: 6px; margin: 0 13px 0 5px; color: #64748b; font-size: 10px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.role-group-select input { width: 15px; height: 15px; margin: 0; accent-color: var(--brand-primary); }
.role-permission-options { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; padding: 0 12px 12px; }
.role-permission-group.open .role-permission-options { display: grid; }
.role-permission-option { display: flex; align-items: flex-start; gap: 10px; min-height: 57px; margin: 0; padding: 10px; border: 1px solid #e7ebf0; border-radius: 10px; background: #fff; cursor: pointer; transition: border-color var(--transition), background var(--transition), box-shadow var(--transition); }
.role-permission-option:hover { border-color: color-mix(in srgb, var(--brand-primary) 28%, #e7ebf0); background: color-mix(in srgb, var(--brand-primary) 3%, white); }
.role-permission-option.selected { border-color: color-mix(in srgb, var(--brand-primary) 30%, #dfe5ed); background: color-mix(in srgb, var(--brand-primary) 6%, white); box-shadow: inset 3px 0 var(--brand-primary); }
.role-permission-option > input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.permission-check { display: grid; flex: 0 0 18px; place-items: center; width: 18px; height: 18px; margin-top: 1px; color: transparent; border: 1.5px solid #c5ceda; border-radius: 5px; background: #fff; font-size: 9px; }
.role-permission-option.selected .permission-check { color: #fff; border-color: var(--brand-primary); background: var(--brand-primary); }
.role-permission-option > input:focus-visible + .permission-check { outline: 3px solid color-mix(in srgb, var(--brand-primary) 18%, transparent); outline-offset: 2px; }
.permission-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.permission-copy strong { color: #344158; font-size: 11.5px; font-weight: 650; line-height: 1.35; }
.permission-copy small { overflow: hidden; color: #96a1b1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8.5px; text-overflow: ellipsis; white-space: nowrap; }
.role-permission-empty { display: grid; justify-items: center; gap: 5px; padding: 42px 20px; color: #8490a2; text-align: center; }
.role-permission-empty i { margin-bottom: 5px; color: #a3adba; font-size: 20px; }
.role-permission-empty strong { color: #475569; font-size: 13px; }
.role-permission-empty span { font-size: 10.5px; }
.role-form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 16px; }
.role-data-access-card { margin-top: 14px; }
.scope-security-note { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; color: #92400e; border-radius: 9px; background: #fff7ed; font-size: 10px; font-weight: 700; }
.scope-toolbar { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid #edf0f4; background: #fbfcfd; }
.scope-toolbar .role-permission-search { max-width: 520px; }
.scope-toolbar > span { color: #8490a2; font-size: 10px; }
.scope-module-list { display: grid; gap: 9px; padding: 13px; background: #f8fafc; }
.scope-module-card { overflow: hidden; border: 1px solid #e2e7ee; border-radius: 12px; background: #fff; }
.scope-module-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 13px; }
.scope-module-heading > div { display: flex; align-items: center; gap: 11px; }
.scope-module-summary { display: flex !important; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px !important; margin-left: auto; }
.scope-module-summary > span { padding: 4px 8px; border: 1px solid var(--app-border, #dbe3ef); border-radius: 999px; background: #fff; color: #53637b; font-size: 10px; font-weight: 700; }
.scope-module-summary .scope-none-warning { color: #9a6700; background: #fff8db; border-color: #f5d565; }
.scope-module-heading > div > div { display: flex; flex-direction: column; }
.scope-module-heading strong { color: #27344a; font-size: 12.5px; }
.scope-module-heading small { color: #8a96a7; font-size: 9.5px; }
.scope-module-toggle { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; color: var(--brand-primary); border: 1px solid color-mix(in srgb, var(--brand-primary) 22%, #e2e7ee); border-radius: 8px; background: #fff; font-size: 10px; font-weight: 700; }
.scope-module-toggle i { transition: transform var(--transition); }
.scope-module-toggle[aria-expanded="true"] i { transform: rotate(180deg); }
.scope-module-body { padding: 14px; border-top: 1px solid #edf0f4; background: #fcfdff; }
.scope-module-body[hidden], .scope-choice-panel[hidden] { display: none; }
.scope-domain-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.scope-domain { padding: 13px; border: 1px solid #e5eaf0; border-radius: 11px; background: #fff; }
.scope-domain-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.scope-domain-title > div { display: flex; flex-direction: column; }
.scope-domain-title strong { color: #334155; font-size: 11.5px; }
.scope-domain-title small { color: #8a96a7; font-size: 9px; }
.scope-domain-title select { width: 160px; min-height: 36px; padding: 6px 9px; font-size: 10.5px; }
.scope-choice-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.scope-choice-column { min-width: 0; padding: 9px; border-radius: 9px; background: #f8fafc; }
.scope-choice-column-wide { grid-column: 1 / -1; }
.scope-choice-column > span { display: block; margin-bottom: 7px; color: #64748b; font-size: 9px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.scope-choice-column ul { max-height: 190px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.scope-choice-column li { margin: 0 0 4px; }
.scope-choice-column label { display: flex; align-items: center; gap: 7px; margin: 0; padding: 5px 6px; border-radius: 7px; font-size: 10.5px; font-weight: 550; }
.scope-choice-column label:hover { background: color-mix(in srgb, var(--brand-primary) 6%, white); }
.scope-choice-column input { width: 15px; height: 15px; margin: 0; accent-color: var(--brand-primary); }
.scope-copy-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; padding-top: 11px; border-top: 1px solid #edf0f4; }
.scope-copy-row > span { margin-right: auto; color: #8490a2; font-size: 9.5px; }
.scope-copy-row select { width: 170px; min-height: 32px; padding: 4px 8px; font-size: 10.5px; }
@media (max-width: 780px) { .role-access-mode-options, .scope-domain-grid { grid-template-columns: 1fr; } .scope-toolbar { align-items: stretch; flex-direction: column; } }

/* Page rhythm */
.content-area { width: 100%; max-width: 1680px; margin: 0 auto; padding: clamp(18px, 3vw, 36px); }
.content-area > h1,
.content-area > h2 { margin-bottom: 1.25rem; font-weight: 750; letter-spacing: -.03em; }
h1, h2, h3, h4, h5, h6 { color: #182033; letter-spacing: -.015em; }
.text-muted { color: #738096 !important; }
hr { border-color: var(--border-color); opacity: 1; }

/* Cards and panels */
.card {
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, .92);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, .97);
    box-shadow: var(--shadow);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.import-export-focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, .08); }
.card.shadow-sm { box-shadow: var(--shadow) !important; }
.card-header {
    min-height: 62px;
    padding: 17px 21px;
    border-color: var(--border-color);
    background: linear-gradient(180deg, #fff, #fcfdff);
}
.card-header h4,
.card-header h5,
.card-header h6 { font-weight: 720; }
.card-body { padding: clamp(18px, 2.2vw, 25px); }
.card-footer { padding: 15px 21px; border-color: var(--border-color); background: var(--surface-muted); }

/* Buttons */
.btn {
    --bs-btn-padding-x: .9rem;
    --bs-btn-padding-y: .5rem;
    min-height: 38px;
    border-radius: 9px;
    font-size: .82rem;
    font-weight: 650;
    letter-spacing: -.005em;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-sm { min-height: 32px; padding: .35rem .65rem; border-radius: 8px; font-size: .75rem; }
.btn-lg { min-height: 46px; border-radius: 11px; }
.btn-primary {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #5b55e7, #4338ca);
    box-shadow: 0 5px 13px rgba(79, 70, 229, .2);
}
.btn-primary:hover,
.btn-primary:focus { border-color: #4338ca; background: linear-gradient(135deg, #4f46e5, #3730a3); box-shadow: 0 8px 18px rgba(79, 70, 229, .26); }
.btn-outline-primary { color: #4f46e5; border-color: #c7d2fe; background: #fff; }
.btn-outline-primary:hover { color: #3730a3; border-color: #a5b4fc; background: #eef2ff; }
.btn-outline-secondary { color: #526076; border-color: #d7dde7; background: #fff; }
.btn-outline-secondary:hover { color: #1e293b; border-color: #c2cad7; background: #f8fafc; }
.btn-light { color: #475569; border-color: var(--border-color); background: #fff; }
.btn-danger { border-color: #dc2626; background: linear-gradient(135deg, #ef4444, #dc2626); }
.btn-group > .btn { box-shadow: none; }

/* Forms, including legacy widgets without Bootstrap classes */
label,
.form-label { margin-bottom: .4rem; color: #334155; font-size: .79rem; font-weight: 650; }
.form-control,
.form-select,
form input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
form select,
form textarea {
    min-height: 42px;
    padding: .56rem .72rem;
    color: #1e293b;
    border: 1px solid #d9e0ea;
    border-radius: 10px;
    background-color: #fff;
    font-size: .86rem;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
form textarea { min-height: 96px; }
.form-control:focus,
.form-select:focus,
form input:not([type="checkbox"]):not([type="radio"]):focus,
form select:focus,
form textarea:focus {
    border-color: #818cf8;
    outline: 0;
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .11);
}
.form-control::placeholder,
form input::placeholder,
form textarea::placeholder { color: #a6b0bf; }
.form-control:disabled,
.form-select:disabled,
form input:disabled,
form select:disabled,
form textarea:disabled,
form input[readonly] { color: #64748b; background: #f1f5f9; }
.form-check { min-height: 1.5rem; }
.form-check-input { width: 1.05rem; height: 1.05rem; margin-top: .22rem; border-color: #bdc7d5; }
.form-check-input:checked { border-color: var(--primary-color); background-color: var(--primary-color); }
.form-check-input:focus { border-color: #818cf8; box-shadow: 0 0 0 4px rgba(99, 102, 241, .11); }
.form-text { margin-top: .35rem; color: #8491a3; font-size: .73rem; }
.input-group-text { color: #526076; border-color: #d9e0ea; background: #f8fafc; }
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple { min-height: 42px; border-color: #d9e0ea; border-radius: 10px; }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 40px; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 40px; }

/* Tables */
.table-responsive { border-radius: 0 0 var(--radius-lg) var(--radius-lg); scrollbar-color: #cbd5e1 transparent; }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: #f8faff; color: #334155; }
.table > :not(caption) > * > * { border-bottom-color: #e9edf3; }
.table thead th {
    padding: .78rem .9rem;
    color: #718096;
    border-bottom-width: 1px;
    background: #f8fafc;
    font-size: .68rem;
    font-weight: 750;
    letter-spacing: .065em;
    text-transform: uppercase;
    white-space: nowrap;
}
.table tbody td { padding: .82rem .9rem; color: #3f4b5f; font-size: .81rem; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.table-active > * { color: inherit; background: #eef2ff; box-shadow: inset 3px 0 #6366f1; }
.table a { font-weight: 620; text-decoration: none; }
.table-secondary { --bs-table-bg: #f1f5f9; --bs-table-color: #334155; }
.table-light { --bs-table-bg: #f8fafc; }

/* Status, feedback, and secondary components */
.badge { padding: .36rem .58rem; border-radius: 999px; font-size: .67rem; font-weight: 700; letter-spacing: .015em; }
.bg-success { background-color: #059669 !important; }
.bg-warning { background-color: #d97706 !important; }
.bg-danger { background-color: #dc2626 !important; }
.bg-info { background-color: #0284c7 !important; }
.bg-secondary { background-color: #64748b !important; }
.alert { padding: .85rem 1rem; border: 1px solid; border-left-width: 4px; border-radius: 12px; box-shadow: none; font-size: .84rem; }
.alert-success { color: #065f46; border-color: #a7f3d0; background: #ecfdf5; }
.alert-danger,
.alert-error { color: #991b1b; border-color: #fecaca; background: #fef2f2; }
.alert-warning { color: #92400e; border-color: #fde68a; background: #fffbeb; }
.alert-info { color: #075985; border-color: #bae6fd; background: #f0f9ff; }
.messages-container { position: relative; z-index: 20; margin: 18px clamp(18px, 3vw, 38px) -10px !important; }
.modal-content { overflow: hidden; border: 0; border-radius: 18px; box-shadow: 0 25px 70px rgba(15, 23, 42, .22); }
.modal-header,
.modal-footer { border-color: var(--border-color); }
.dropdown-menu { padding: .45rem; border-color: var(--border-color); border-radius: 12px; box-shadow: var(--shadow-lg); }
.dropdown-item { padding: .5rem .65rem; border-radius: 8px; font-size: .82rem; }
.dropdown-item:hover { color: #3730a3; background: #eef2ff; }
.nav-tabs { gap: 4px; border-color: var(--border-color); }
.nav-tabs .nav-link { color: #64748b; border: 0; border-bottom: 2px solid transparent; font-size: .82rem; font-weight: 650; }
.nav-tabs .nav-link:hover { color: #4f46e5; border-color: transparent; }
.nav-tabs .nav-link.active { color: #4338ca; border-color: #4f46e5; background: transparent; }
.pagination { gap: 4px; }
.page-link { min-width: 36px; color: #475569; border-color: var(--border-color); border-radius: 8px !important; text-align: center; }
.page-item.active .page-link { border-color: #4f46e5; background: #4f46e5; }
.list-group-item { padding: .8rem 1rem; border-color: var(--border-color); }
.progress { overflow: hidden; border-radius: 999px; background: #e8edf4; }

/* Empty states and common action layouts */
.card-body > p:only-child { color: var(--text-secondary); }
pre, code { border-radius: 7px; color: #4338ca; background: #f5f3ff; font-size: .78rem; }
pre { padding: .85rem; }
.sticky-top { z-index: 20; }

/* Login */
.login-card { border: 1px solid rgba(255, 255, 255, .55); box-shadow: 0 25px 65px rgba(15, 23, 42, .15) !important; }
.login-card::before { display: block; height: 5px; content: ""; background: linear-gradient(90deg, #4f46e5, #7c3aed, #0ea5e9); }

/* Responsive layout */
@media (max-width: 991.98px) {
    .sidebar { width: min(86vw, 300px); transform: translateX(-105%); }
    .sidebar.active { transform: translateX(0); }
    .sidebar.collapsed { width: min(86vw, 300px); transform: translateX(-105%); }
    .sidebar.collapsed.active { transform: translateX(0); }
    .sidebar.collapsed .sidebar-title,
    .sidebar.collapsed .nav-item span { display: inline; }
    .sidebar.collapsed .nav-item,
    .sidebar.collapsed .nav-dropdown-toggle { justify-content: flex-start; padding-inline: 13px; }
    .sidebar.collapsed .nav-dropdown-toggle .left-content { justify-content: flex-start; }
    .sidebar.collapsed .nav-dropdown-toggle .fa-chevron-down { display: inline-block; }
    .sidebar.collapsed .nav-dropdown-menu { display: block; }
    .main-content,
    .sidebar.collapsed ~ .sidebar-backdrop + .main-content { margin-left: 0; }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 990;
        display: block;
        visibility: hidden;
        padding: 0;
        border: 0;
        opacity: 0;
        background: rgba(15, 23, 42, .52);
        backdrop-filter: blur(2px);
        transition: opacity var(--transition), visibility var(--transition);
    }
    .sidebar.active + .sidebar-backdrop { visibility: visible; opacity: 1; }
    .top-navbar { padding-inline: 17px; }
    .top-navbar { gap: 10px; }
    .navbar-left .page-title { display: none; }
    .global-search { flex-basis: auto; max-width: none; margin: 0; }
    .global-search-results { min-width: min(500px, 72vw); }
    .content-area { padding: 18px; }
    .card-header { padding-inline: 17px; }
    .card-body { padding: 17px; }
}

@media (max-width: 575.98px) {
    :root { --navbar-height: 68px; }
    body { font-size: .88rem; }
    .user-copy { display: none; }
    .user-menu { padding: 3px; }
    .page-title { max-width: 52vw; }
    .navbar-right { display: none; }
    .global-search-shortcut { display: none; }
    form.global-search > input#globalSearchInput { padding-right: 12px; }
    .global-search-results { position: fixed; top: 61px; right: 10px; left: 10px; width: auto; min-width: 0; max-height: calc(100vh - 74px); }
    .search-page-form { grid-template-columns: 1fr; }
    .search-page-form .btn { width: 100%; }
    .search-page-header h1 { font-size: 24px; }
    .search-page-result { padding-inline: 12px; }
    .search-page-result .search-status { display: none; }
    .search-result-title-row small { display: none; }
    .role-form-heading { align-items: flex-start; flex-direction: column; }
    .role-permission-toolbar { align-items: stretch; flex-wrap: wrap; }
    .role-permission-search { flex-basis: 100%; }
    .role-permission-options { grid-template-columns: 1fr; }
    .role-permission-group-header { align-items: stretch; }
    .role-group-select { margin-right: 10px; }
    .role-group-select span { display: none; }
    .role-permissions-header { align-items: flex-start; }
    .content-area { padding: 14px 12px 24px; }
    .card { border-radius: 14px; }
    .card-header { min-height: 56px; padding: 14px; }
    .card-body { padding: 14px; }
    .card-header.d-flex { align-items: flex-start !important; flex-direction: column; gap: .75rem; }
    .card-header.d-flex > div,
    .card-header.d-flex > form { width: 100%; }
    .card-header .btn { flex: 1 1 auto; }
    .btn-group { max-width: 100%; flex-wrap: wrap; }
    .table thead th,
    .table tbody td { padding: .7rem .75rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Calm, high-clarity theme corrections */
body {
    color: #263244;
    background: #f6f7fa;
}

.sidebar {
    color: #526076;
    border-right: 1px solid #e3e7ee;
    background: #ffffff;
    box-shadow: none;
}

.sidebar-header { border-bottom: 1px solid #edf0f4; }
.sidebar-header > i {
    color: #4f46e5;
    background: #eef2ff;
    box-shadow: none;
}
.sidebar-title { color: #1e293b; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #d5dbe5; }

.nav-item,
.nav-dropdown-toggle { color: #657187; }
.nav-item i,
.nav-dropdown-toggle i.fas { color: #8792a5; }
.nav-item:hover,
.nav-dropdown-toggle:hover {
    color: #3530a3;
    border-color: transparent;
    background: #f6f7fb;
}
.nav-item:hover i,
.nav-dropdown-toggle:hover i { color: #6366f1; }
.nav-item.active,
.nav-dropdown-toggle.active {
    color: #3730a3;
    border-color: #dfe3ff;
    background: #eef2ff;
    box-shadow: inset 3px 0 #6366f1;
}
.nav-item.active i,
.nav-dropdown-toggle.active i { color: #4f46e5; }
.nav-dropdown-menu {
    border: 0;
    background: #fafbfc;
}
.nav-dropdown-menu .nav-item.active { background: #eef2ff; }
.sidebar-footer { border-color: #edf0f4; }
.sidebar-footer .logout-btn { color: #b42318; }
.sidebar-footer .logout-btn:hover { color: #991b1b; background: #fff1f2; }

.top-navbar {
    border-color: #e5e9f0;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .035);
    backdrop-filter: none;
}
.workspace-context { background: #f8fafc; }
.user-menu .user-avatar { background: #4f46e5; }
.content-area { padding-top: 28px; }

.card {
    border-color: #e3e7ee;
    background: #fff;
    box-shadow: 0 3px 14px rgba(15, 23, 42, .045);
}
.card-header { background: #fff; }
.card-header.d-flex { gap: 16px; }
.card-header.d-flex > :last-child { align-items: center; }

.btn-primary,
.btn-primary:hover,
.btn-primary:focus {
    border-color: #4f46e5;
    background: #4f46e5;
}
.btn-primary { box-shadow: 0 3px 8px rgba(79, 70, 229, .16); }
.btn-primary:hover,
.btn-primary:focus { background: #4338ca; box-shadow: 0 5px 12px rgba(79, 70, 229, .2); }
.btn-danger { border-color: #dc2626; background: #dc2626; }

.form-select-sm,
.input-group-sm > .form-select,
.input-group-sm > .form-control {
    min-height: 34px;
    padding-top: .3rem;
    padding-bottom: .3rem;
}

.table-responsive { border: 1px solid #e7ebf1; border-radius: 12px; }
.card-body > .table-responsive { margin: 0; }
.table thead th {
    height: 46px;
    padding: .7rem .85rem;
    color: #66748b;
    background: #f7f8fa;
    vertical-align: middle;
}
.table tbody td {
    height: 52px;
    padding: .7rem .85rem;
    vertical-align: middle;
}
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f8f9fc; }
.table .category-toggle > td { color: #334155; background: #f5f7fa; }
.table .product-toggle > td { color: #334155; background: #fafaff; box-shadow: inset 3px 0 #818cf8; }
.table .category-toggle i,
.table .product-toggle i { width: 16px; color: #64748b; text-align: center; }

/* Keep dense table actions aligned and visually quiet. */
.table td:last-child { white-space: nowrap; }
.table .btn-group {
    display: inline-flex;
    gap: 4px;
    vertical-align: middle;
}
.table .btn-group > .btn,
.table .btn-group > :not(.btn-check) + .btn {
    display: inline-grid;
    place-items: center;
    min-width: 32px;
    min-height: 32px;
    padding: .35rem .5rem;
    color: #59667a;
    border: 1px solid #dce2eb;
    border-radius: 8px !important;
    background: #fff;
    box-shadow: none;
}
.table .btn-group > .btn:hover { color: #4338ca; border-color: #b9c0f7; background: #f5f5ff; }
.table .btn-group > .btn-outline-primary {
    color: #4f46e5;
    border-color: #c7d2fe;
    background: #f5f5ff;
}
.table .btn-group > .btn-outline-info {
    color: #0284c7;
    border-color: #bae6fd;
    background: #f0f9ff;
}
.table .btn-group > .btn-outline-warning {
    color: #b45309;
    border-color: #fde68a;
    background: #fffbeb;
}
.table .btn-group > .btn-outline-success {
    color: #047857;
    border-color: #a7f3d0;
    background: #ecfdf5;
}
.table .btn-group > .btn-outline-danger {
    color: #b42318;
    border-color: #fecaca;
    background: #fff1f2;
}
.table .btn-group > .btn-outline-secondary {
    color: #526076;
    border-color: #d8dee8;
    background: #f8fafc;
}
.table .btn-group > .btn-outline-primary:hover { color: #fff; border-color: #4f46e5; background: #4f46e5; }
.table .btn-group > .btn-outline-info:hover { color: #fff; border-color: #0284c7; background: #0284c7; }
.table .btn-group > .btn-outline-warning:hover { color: #fff; border-color: #d97706; background: #d97706; }
.table .btn-group > .btn-outline-success:hover { color: #fff; border-color: #059669; background: #059669; }
.table .btn-group > .btn-outline-danger:hover { color: #fff; border-color: #dc2626; background: #dc2626; }
.table .btn-group > .btn-outline-secondary:hover { color: #fff; border-color: #64748b; background: #64748b; }

/* Legacy templates sometimes use neutral button classes for semantic actions.
   Key off the icon as well so action colors remain consistent everywhere. */
.table .btn-group .btn:has(.fa-eye),
.table .btn-group .btn:has(.fa-address-book),
.table .btn-group .btn:has(.fa-list),
.table .btn-group .btn:has(.fa-info-circle) {
    color: #0284c7;
    border-color: #bae6fd;
    background: #f0f9ff;
}
.table .btn-group .btn:has(.fa-edit),
.table .btn-group .btn:has(.fa-pen),
.table .btn-group .btn:has(.fa-pencil-alt) {
    color: #4f46e5;
    border-color: #c7d2fe;
    background: #f5f5ff;
}
.table .btn-group .btn:has(.fa-star),
.table .btn-group .btn:has(.fa-exclamation-triangle) {
    color: #b45309;
    border-color: #fde68a;
    background: #fffbeb;
}
.table .btn-group .btn:has(.fa-check),
.table .btn-group .btn:has(.fa-check-circle),
.table .btn-group .btn:has(.fa-play),
.table .btn-group .btn:has(.fa-toggle-on) {
    color: #047857;
    border-color: #a7f3d0;
    background: #ecfdf5;
}
.table .btn-group .btn:has(.fa-trash),
.table .btn-group .btn:has(.fa-trash-alt),
.table .btn-group .btn:has(.fa-ban),
.table .btn-group .btn:has(.fa-times) {
    color: #b42318;
    border-color: #fecaca;
    background: #fff1f2;
}
.table .btn-group .btn:has(.fa-file-pdf),
.table .btn-group .btn:has(.fa-print),
.table .btn-group .btn:has(.fa-download) {
    color: #7c3aed;
    border-color: #ddd6fe;
    background: #f5f3ff;
}
.table .btn-group .btn:has(.fa-eye):hover,
.table .btn-group .btn:has(.fa-address-book):hover,
.table .btn-group .btn:has(.fa-list):hover,
.table .btn-group .btn:has(.fa-info-circle):hover { color: #fff; border-color: #0284c7; background: #0284c7; }
.table .btn-group .btn:has(.fa-edit):hover,
.table .btn-group .btn:has(.fa-pen):hover,
.table .btn-group .btn:has(.fa-pencil-alt):hover { color: #fff; border-color: #4f46e5; background: #4f46e5; }
.table .btn-group .btn:has(.fa-star):hover,
.table .btn-group .btn:has(.fa-exclamation-triangle):hover { color: #fff; border-color: #d97706; background: #d97706; }
.table .btn-group .btn:has(.fa-check):hover,
.table .btn-group .btn:has(.fa-check-circle):hover,
.table .btn-group .btn:has(.fa-play):hover,
.table .btn-group .btn:has(.fa-toggle-on):hover { color: #fff; border-color: #059669; background: #059669; }
.table .btn-group .btn:has(.fa-trash):hover,
.table .btn-group .btn:has(.fa-trash-alt):hover,
.table .btn-group .btn:has(.fa-ban):hover,
.table .btn-group .btn:has(.fa-times):hover { color: #fff; border-color: #dc2626; background: #dc2626; }
.table .btn-group .btn:has(.fa-file-pdf):hover,
.table .btn-group .btn:has(.fa-print):hover,
.table .btn-group .btn:has(.fa-download):hover { color: #fff; border-color: #7c3aed; background: #7c3aed; }

/* Icon-color fallback for browsers that do not yet apply :has(). */
.table .btn-group .fa-eye,
.table .btn-group .fa-address-book,
.table .btn-group .fa-list,
.table .btn-group .fa-info-circle { color: #0284c7; }
.table .btn-group .fa-edit,
.table .btn-group .fa-pen,
.table .btn-group .fa-pencil-alt { color: #4f46e5; }
.table .btn-group .fa-star,
.table .btn-group .fa-exclamation-triangle { color: #d97706; }
.table .btn-group .fa-check,
.table .btn-group .fa-check-circle,
.table .btn-group .fa-play,
.table .btn-group .fa-toggle-on { color: #059669; }
.table .btn-group .fa-trash,
.table .btn-group .fa-trash-alt,
.table .btn-group .fa-ban,
.table .btn-group .fa-times { color: #dc2626; }
.table .btn-group .fa-file-pdf,
.table .btn-group .fa-print,
.table .btn-group .fa-download { color: #7c3aed; }
.table .btn-group .btn:hover i { color: inherit; }

.badge.bg-success { color: #047857 !important; background: #d1fae5 !important; }
.badge.bg-warning { color: #92400e !important; background: #fef3c7 !important; }
.badge.bg-danger { color: #b42318 !important; background: #fee2e2 !important; }
.badge.bg-info { color: #0369a1 !important; background: #e0f2fe !important; }
.badge.bg-secondary { color: #475569 !important; background: #e9edf3 !important; }
.card.bg-warning { color: #57430c !important; border-color: #f3dfaa; background: #fffbeb !important; }

.stat-icon,
.stat-icon.blue,
.stat-icon.green,
.stat-icon.orange,
.stat-icon.red { box-shadow: none; }
.stat-icon.blue { color: #2563eb; background: #dbeafe; }
.stat-icon.green { color: #059669; background: #d1fae5; }
.stat-icon.orange { color: #d97706; background: #fef3c7; }
.stat-icon.red { color: #dc2626; background: #fee2e2; }

/* Dashboard: compact, neutral, and readable. */
.dashboard-heading {
    align-items: center;
    padding: 1.25rem 1.4rem;
    color: #1e293b;
    border: 1px solid #e1e6ee;
    background: #ffffff;
    box-shadow: 0 3px 14px rgba(15, 23, 42, .045);
}
.dashboard-heading h1 { color: #172033; font-size: clamp(1.55rem, 2.2vw, 2rem); }
.dashboard-eyebrow { color: #4f46e5; }
.dashboard-subtitle { color: #64748b; }
.period-filter {
    border-color: #e3e7ee;
    background: #f8fafc;
    backdrop-filter: none;
}
.period-filter label span { color: #64748b; }
.period-filter input {
    color: #334155;
    border-color: #d9e0ea;
    background: #fff;
    color-scheme: light;
}
.kpi-card,
.dashboard-panel { box-shadow: 0 3px 14px rgba(15, 23, 42, .04); }
.kpi-card::after { display: none; }

.main-content.login-layout,
.login-card { background-image: none; }
.login-card::before { background: #4f46e5; }

@media (max-width: 991.98px) {
    .sidebar { box-shadow: none; }
    .dashboard-heading { align-items: stretch; }
}

@media (max-width: 575.98px) {
    .content-area { padding-top: 14px; }
    .card-header.d-flex > :last-child { justify-content: flex-start !important; }
    .card-header.d-flex > :last-child .btn,
    .card-header.d-flex > :last-child .btn-group { flex: 0 1 auto; }
    .table-responsive { border-radius: 10px; }
}
