/* Right-side profile drawer with compact Appearance controls. */
#offcanvasRight .profile-header-mark {
    height: 86px;
    background: color-mix(in srgb, var(--hb-primary) 25%, var(--hb-on-primary) 75%);
    mask: url('../images/hasitrans.png') center / contain no-repeat;
}

#offcanvasRight.profile-modal-offcanvas {
    top: 0; right: 0; bottom: 0; left: auto;
    width: min(100vw, 420px); height: 100vh; height: 100dvh;
    max-width: 100vw; border: 0; border-radius: 0;
    background: var(--hb-secondary); color: var(--hb-text);
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28); overflow: hidden;
    transform: translateX(100%);
    transition: transform .3s ease-in-out;
}
#offcanvasRight.profile-modal-offcanvas.showing,
#offcanvasRight.profile-modal-offcanvas.show:not(.hiding) { transform: none; }
#offcanvasRight.profile-modal-offcanvas > .profile-modal-content { display: flex; flex-direction: column; flex: 1 1 auto; height: 100%; min-height: 0; overflow: hidden; }
#offcanvasRight.profile-modal-offcanvas .offcanvas-header { flex-shrink: 0; min-height: 62px; padding: 16px; }
#offcanvasRight.profile-modal-offcanvas .offcanvas-body {
    flex: 1 1 auto; min-height: 0; padding: 0; gap: 0; overflow-y: auto;
    overscroll-behavior-y: contain; scrollbar-gutter: stable; background: var(--hb-secondary); color: var(--hb-text);
}
body:has(#offcanvasRight.show) .offcanvas-backdrop.show { opacity: .35; backdrop-filter: blur(3px); }
#offcanvasRight .user-profile-summary { flex-shrink: 0; padding: 24px 16px; border: 0; border-radius: 0; box-shadow: none; background: transparent; color: inherit; }
#offcanvasRight .user-profile-summary :is(.user-profile-name, .user-profile-role) { color: inherit; }
#offcanvasRight .userInfo-img { width: 120px; height: 120px; border-radius: 50%; }
#offcanvasRight .user-profile-version { margin: 0 16px 16px; }
#offcanvasRight .theme-settings {
    flex-shrink: 0; margin: 16px; padding: 18px; border: 1px solid var(--hb-border);
    border-radius: 16px; background: var(--hb-surface); color: var(--hb-text);
}
.theme-settings-heading, .theme-setting-row, .theme-color-section, .theme-color-inputs { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.theme-settings-heading h6 { margin: 0; font-size: 1rem; font-weight: 700; }
.theme-reset { padding: 6px 0; border: 0; background: transparent; color: var(--hb-link); font-size: .8rem; text-decoration: underline; }
.theme-settings-help { margin: 8px 0 14px; font-size: .8rem; line-height: 1.5; color: var(--hb-muted); }
.theme-setting-row { min-height: 44px; font-size: .9rem; }
#offcanvasRight .theme-settings #ThemeDensityId { width: 144px; flex-shrink: 0; }
.theme-color-section { flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--hb-border); }
.theme-color-section label { display: block; margin: 0; font-size: .9rem; font-weight: 700; }
.theme-color-section small { display: block; margin-top: 3px; color: var(--hb-muted); font-size: .75rem; }
.theme-color-inputs { justify-content: flex-start; gap: 8px; }
.theme-color-inputs input { height: 38px; border: 1px solid var(--hb-border); border-radius: 8px; background: var(--hb-input); color: var(--hb-text); }
.theme-color-inputs input[type="color"] { width: 44px; padding: 3px; cursor: pointer; }
.theme-color-inputs input[type="text"] { width: 92px; padding: 6px 8px; font: .85rem monospace; }
.theme-color-inputs input[aria-invalid="true"] { border-color: #d13438; }
#themeColorStatus { margin-bottom: 0; }
.theme-settings .dx-texteditor { background: var(--hb-input); color: var(--hb-text); border-color: var(--hb-border); }
.theme-settings .dx-texteditor-input { color: var(--hb-text); }
.theme-settings .dx-dropdowneditor-icon { color: var(--hb-muted); }
.theme-settings :focus-visible { outline: 2px solid var(--hb-focus); outline-offset: 2px; }
body.dark-mode #offcanvasRight { background: var(--hb-secondary) !important; color: var(--hb-text); }
@media (max-width: 767.98px) {
    #offcanvasRight.profile-modal-offcanvas {
        top: 50%; right: auto; bottom: auto; left: 50%;
        width: calc(100vw - 24px);
        height: min(85vh, 760px); height: min(85dvh, 760px);
        max-width: none; border-radius: 20px;
        opacity: 0;
        transform: translate(-50%, calc(-50% + 24px)) scale(.96);
        transition: transform .25s ease, opacity .25s ease;
    }
    #offcanvasRight.profile-modal-offcanvas.showing,
    #offcanvasRight.profile-modal-offcanvas.show:not(.hiding) {
        opacity: 1; transform: translate(-50%, -50%) scale(1);
    }
}
@media (prefers-reduced-motion: reduce) {
    #offcanvasRight.profile-modal-offcanvas { transition: none; }
}

/* Custom palettes affect shared UI; Default leaves existing application styles intact. */
html[data-custom-theme] body { background: var(--hb-secondary) !important; color: var(--hb-text); }
html[data-custom-theme] :is(.hbPlus-header, .hbPlus-Company, .hbPlus-sidebarBrandBar, .hbplus-sidebar-menu,
    .hBplus-ListHeader, .hBplus-HeaderEvnt, .hBplus-ActionEvnt, .TitleFormArea, .hBplus-DateHeader) {
    background: var(--hb-surface) !important; color: var(--hb-text); border-color: var(--hb-border);
}
html[data-custom-theme] :is(.hbPlus-siderCon, .hbPlus-siderCon-body, #offcanvasRight, #hBplus-UserInfoView) {
    background: var(--hb-secondary); color: var(--hb-secondary-text);
}
html[data-custom-theme] :is(.hBplus-ListHeader h5, .hbPlus-CompanyName, .hbPlus-BrandEyebrow, .TitleFormArea) { color: var(--hb-link); }
html[data-custom-theme] .hBplus-ListHeader::before { background: var(--hb-decoration); }
html[data-custom-theme] .offcanvas-header { background: var(--hb-primary) !important; color: var(--hb-on-primary); }
html[data-custom-theme] #offcanvasRight .btn-close { filter: none !important; background-image: none; color: inherit; opacity: 1; }
html[data-custom-theme] #offcanvasRight .btn-close::before { content: '\00d7'; font-size: 1.5rem; line-height: 1; }
html[data-custom-theme] :is(.hbplus-dashboardHero, .hbplus-dashboardShell, .hbplus-dashboardPage) { background: var(--hb-secondary); color: var(--hb-secondary-text); }
html[data-custom-theme] :is(.salesPbItem, .hBplus-totalCon, .hBplus-ChooserClas, .dx-overlay-content, .dx-popup-content,
    .dx-popup-title, .dx-toolbar, .dx-datagrid, .dx-treelist, .dx-list, .dx-form, .dx-tabpanel-container) {
    background-color: var(--hb-surface) !important; color: var(--hb-text); border-color: var(--hb-border);
}
html[data-custom-theme] :is(.dx-field-item-label-text, .dx-form-group-caption, .dx-datagrid-headers, .dx-datagrid-total-footer,
    .dx-treelist-headers, .dx-placeholder, .dx-toolbar-label) { color: var(--hb-text); }
html[data-custom-theme] :is(.dx-datagrid-headers, .dx-datagrid-total-footer, .dx-treelist-headers) { background: var(--hb-surface); border-color: var(--hb-border); }
html[data-custom-theme] .dx-texteditor:not(.dx-invalid) { background: var(--hb-input); border-color: var(--hb-border); }
html[data-custom-theme] .dx-texteditor-input { color: var(--hb-text); }
html[data-custom-theme] .dx-texteditor.dx-state-focused:not(.dx-invalid) { border-color: var(--hb-focus); }
html[data-custom-theme] .dx-link { color: var(--hb-link); }
html[data-custom-theme] .dx-button.dx-button-default.dx-button-mode-contained,
html[data-custom-theme] .btn-primary { background: var(--hb-primary); border-color: var(--hb-primary); color: var(--hb-on-primary); }
html[data-custom-theme] .dx-button.dx-button-default:is(.dx-button-mode-outlined, .dx-button-mode-text) { color: var(--hb-link); border-color: var(--hb-link); }
html[data-custom-theme] .dx-button.dx-button-normal { background: var(--hb-surface); color: var(--hb-text); border-color: var(--hb-border); }
html[data-custom-theme] .dx-button:is(.dx-button-default, .dx-button-normal) .dx-icon { color: inherit; }
html[data-custom-theme] .dx-button:is(.dx-button-default, .dx-button-normal):is(:hover, .dx-state-hover):not(.dx-state-disabled),
html[data-custom-theme] .btn-primary:hover { background: var(--hb-hover); border-color: var(--hb-hover); color: var(--hb-on-hover); }
html[data-custom-theme] .hbplus-sidebar-menu :is(.hbplus-mMenu-list, .hbplus-mMenu-companylist, .navigationclass,
    .hbplus-mMenu-listReport, .hbPlus-sMenuBtn, .hbPlus-subMenuBtn, .hbPlus-ThirdMenuBtn, .sMenuSub-class) { color: var(--hb-text); }
html[data-custom-theme] .hbplus-sidebar-menu :is(.menuName, .hBplus-subMenuFont, .hbplus-mMenu-chevron) { color: inherit; filter: none; }
html[data-custom-theme] .hbplus-sidebar-menu :is(.hbplus-active, .hbplus-submenu-active, [aria-current="page"]) {
    background: var(--hb-primary) !important; color: var(--hb-on-primary);
}
html[data-custom-theme] .hbplus-sidebar-menu .hbplus-active::before { background: var(--hb-on-primary); }
html[data-custom-theme] .hbplus-sidebar-menu .hbplus-active .hbPlus-ModuleIcon { filter: none; }
html[data-custom-theme] .hbplus-sidebar-menu :is(.hbplus-mMenu-list, .hbplus-mMenu-companylist, .navigationclass,
    .hbplus-mMenu-listReport, .hbPlus-sMenuBtn, .hbPlus-subMenuBtn, .hbPlus-ThirdMenuBtn, .sMenuSub-class):is(:hover, :focus-visible) {
    background: var(--hb-hover) !important; color: var(--hb-on-hover);
}
html[data-custom-theme] .hbplus-sidebar-menu :is(.hbplus-mMenu-list, .hbplus-mMenu-companylist):hover .hbPlus-ModuleIcon { filter: none; }
html[data-custom-theme] .dx-list-item:is(.dx-state-hover, .dx-state-focused),
html[data-custom-theme] .dx-datagrid-rowsview .dx-data-row.dx-state-hover:not(.dx-edit-row, .dx-row-inserted, .dx-row-removed) > td:not(.dx-focused) {
    background: var(--hb-hover) !important; color: var(--hb-on-hover) !important;
}
html[data-custom-theme] .dx-datagrid-rowsview .dx-selection > td,
html[data-custom-theme] .dx-list-item-selected,
html[data-custom-theme] .dx-tab.dx-tab-selected { background: var(--hb-selected) !important; color: var(--hb-text) !important; }
html[data-custom-theme] .dx-datagrid-rowsview .dx-row-focused.dx-data-row > td:not(.dx-focused) {
    background: var(--hb-primary) !important; color: var(--hb-on-primary) !important;
}
html[data-custom-theme] .salesPbItem::before { background: var(--hb-decoration); }
/* Existing form styles use !important for labels, editor containers and focus. */
html[data-custom-theme] .dx-field-item-label-text { color: var(--hb-text) !important; }
html[data-custom-theme] .dx-texteditor-input-container { background-color: var(--hb-input) !important; }
html[data-custom-theme] .dx-texteditor:not(.dx-invalid) { border-color: var(--hb-border) !important; }
html[data-custom-theme] .dx-texteditor.dx-state-focused:not(.dx-invalid) { border-color: var(--hb-focus) !important; box-shadow: 0 0 0 2px var(--hb-selected) !important; }
html[data-custom-theme] .dx-texteditor.dx-state-disabled .dx-texteditor-input { background: var(--hb-input) !important; color: var(--hb-muted) !important; }
html[data-custom-theme] body .hbplus-sidebar-menu :is(.menuName, .hBplus-subMenuFont, .hbplus-mMenu-chevron) { color: inherit !important; }
html[data-custom-theme] body :is(.hbPlus-siderCon, .hbPlus-siderCon-body) { background: var(--hb-surface) !important; }
html[data-custom-theme] body .dx-datagrid .dx-data-row > td { color: inherit !important; }

/* Dashboard fragments include their own light/dark colors. Keep custom palettes
   authoritative, including after a tab or SPA fragment loads. */
html[data-custom-theme] body .hbplus-themed-canvas { color: var(--hb-secondary-text); }
html[data-custom-theme] body .hbplus-dashboardPage {
    --workspace-ink: var(--hb-secondary-text);
    --workspace-muted: var(--hb-secondary-text);
    --workspace-surface: var(--hb-surface);
    --workspace-line: var(--hb-border);
    color: var(--hb-secondary-text);
}
html[data-custom-theme] body .hbplus-dashboardSectionHeading :is(h2, span) { color: var(--hb-secondary-text); }
html[data-custom-theme] body .hbplus-dashboardPage .hbplus-welcomeBanner {
    background: linear-gradient(110deg, var(--hb-surface), var(--hb-selected)) !important;
    color: var(--hb-text); border-color: var(--hb-border) !important;
}
html[data-custom-theme] body .hbplus-dashboardPage :is(.hbplus-welcomeCopy h1, .hbplus-heroCompact h2) { color: var(--hb-text); }
html[data-custom-theme] body .hbplus-dashboardPage :is(.hbplus-welcomeCopy h1 > span, .hbplus-heroCompact h2 > span,
    .hbplus-welcomeEyebrow) { color: var(--hb-link); }
html[data-custom-theme] body .hbplus-dashboardPage :is(.hbplus-welcomeFeatures, .hbplus-welcomeUser, .hbplus-welcomeCopy p) { color: var(--hb-text); }
html[data-custom-theme] body .hbplus-dashboardPage :is(.hbplus-welcomeFeatures i, .hbplus-heroCompactIcon, .hbplus-artTile--box) {
    background: var(--hb-primary); color: var(--hb-on-primary); border-color: var(--hb-border);
}
html[data-custom-theme] body .hbplus-dashboardPage .hbplus-artTile { box-shadow: 0 18px 30px color-mix(in srgb, var(--hb-primary) 15%, transparent); }
html[data-custom-theme] body .hbplus-dashboardPage :is(.hbplus-artTile--chart, .hbplus-artTile--truck,
    .hbplus-artCaption, .hbplus-heroCompactBadges > span, .hbplus-heroToggle) {
    background: var(--hb-surface); color: var(--hb-link); border-color: var(--hb-border);
}
html[data-custom-theme] body .hbplus-dashboardPage .hbplus-artOrbit,
html[data-custom-theme] body .hbplus-dashboardPage .hbplus-artOrbit::before { border-color: var(--hb-link); }
html[data-custom-theme] body .hbplus-dashboardPage .hbplus-artDot { background: var(--hb-link); }
html[data-custom-theme] body .hbplus-dashboardPage .hb-dashboardTabList { background: var(--hb-surface); border-color: var(--hb-border); }
html[data-custom-theme] body .hbplus-dashboardPage .hb-dashboardTab {
    --tab-accent: var(--hb-primary);
    --tab-active: var(--hb-primary);
    --tab-soft: var(--hb-selected);
    background: var(--hb-surface); color: var(--hb-text); border-color: var(--hb-border);
}
html[data-custom-theme] body .hbplus-dashboardPage .hb-dashboardTab > i { background: var(--hb-primary); color: var(--hb-on-primary); }
html[data-custom-theme] body .hbplus-dashboardPage .hb-dashboardTab :is(strong, small) { color: inherit; opacity: 1; }
html[data-custom-theme] body .hbplus-dashboardPage .hb-dashboardTab.is-active { background: var(--hb-primary); color: var(--hb-on-primary); border-color: var(--hb-primary); }
html[data-custom-theme] body .hbplus-dashboardPage .hb-dashboardTab:hover,
html[data-custom-theme] body .hbplus-dashboardPage .hbplus-heroToggle:hover {
    background: var(--hb-hover); color: var(--hb-on-hover); border-color: var(--hb-focus);
}
html[data-custom-theme] body .hbplus-dashboardPage .hb-dashboardTab:focus-visible { outline-color: var(--hb-focus); }
html[data-custom-theme] body .hbplus-dashboardPage :is(.hBplus-DateHeader, .overallPanel, .salesPbItem,
    .saleSummaryItem, .hbplus-salesChartCard, .hbplus-dashboardBackBtn, .hb-managerHeader, .hb-managerCard, .hb-managerKpi,
    .hb-analyticsHero, .hb-analyticsCard, .hb-analyticsKpis article) {
    background: var(--hb-surface) !important; color: var(--hb-text); border-color: var(--hb-border);
}
html[data-custom-theme] body .hbplus-dashboardPage :is(.hBplus-disOverSales label, .hbplus-chartUnit, .hb-managerPill) {
    background: var(--hb-selected) !important; color: var(--hb-text); border-color: var(--hb-border);
}
html[data-custom-theme] body .hbplus-dashboardPage :is(.hb-managerStatus.is-loading, .hb-analyticsStatus:not(.is-error)) {
    background: var(--hb-selected); color: var(--hb-text);
}
html[data-custom-theme] body .hbplus-dashboardPage :is(.dateTitle-con, .overallItem, .overallItem > span:nth-child(2),
    .salesPbItem-head, .salesPbItem-value, .saleSummaryValue, .saleSummaryLabel, .hbplus-salesChartHeader h3,
    .hBplus-DetailHeaderText, .hBplus-DetailBranchName, .hb-managerHeader h2, .hb-managerCardHead h3,
    .hb-managerKpi > strong, .hb-managerKpiTop span, .hb-managerKpiFoot b, .hb-managerInsightValue, .hb-agingLabel, .hb-agingAmount,
    .hb-analyticsHero h2, .hb-analyticsTitle h3, .hb-analyticsKpis strong, .hb-analyticsKpis span,
    .hb-analyticsEyebrow, .hb-analyticsTitle span, .hb-analyticsInsight strong,
    .hb-managerTable :is(th, td, strong)) { color: var(--hb-text); border-color: var(--hb-border); }
html[data-custom-theme] body .hbplus-dashboardPage :is(.saleSummaryHint, .hbplus-salesChartHeader p,
    .salesPbItem-subvalue, .salesPbItem-metric, .hb-managerHeader p, .hb-managerActions label,
    .hb-managerSectionLabel, .hb-managerEyebrow, .hb-managerLegend, .hb-managerTable td small,
    .hb-managerInsight p, .hb-managerMeterLabels, .hb-managerKpiFoot,
    .hb-analyticsHero p, .hb-analyticsFilters label, .hb-analyticsKpis small,
    .hb-analyticsTitle small, .hb-analyticsInsight p) { color: var(--hb-muted); }
html[data-custom-theme] body .hbplus-dashboardPage :is(.hb-managerMeter, .hb-agingTrack) { background: var(--hb-selected); }
html[data-custom-theme] body .hbplus-dashboardPage :is(.hb-managerDateRow, .hb-analyticsFilters) :is(input, button) {
    background: var(--hb-input); color: var(--hb-text); border-color: var(--hb-border);
}
html[data-custom-theme] body .hbplus-dashboardPage :is(.hb-managerDateRow, .hb-analyticsFilters) button:hover { background: var(--hb-hover); color: var(--hb-on-hover); }
html[data-custom-theme] body .hbplus-dashboardPage :is(.dxc-arg-elements, .dxc-val-elements, .dxc-legend) text { fill: var(--hb-text); }
html[data-custom-theme] body .hbplus-dashboardPage :is(.dxc-arg-grid, .dxc-val-grid) line { stroke: var(--hb-border); }
html[data-custom-theme] body .hbplus-sidebar-home { background: var(--hb-primary) !important; color: var(--hb-on-primary) !important; }
html[data-custom-theme] body .hbplus-sidebar-home > i { background: transparent; color: inherit !important; }
html[data-custom-theme] body .hbPlus-siderCon .hbplus-sidebar-home:hover { background: var(--hb-hover) !important; color: var(--hb-on-hover) !important; }
html[data-custom-theme] body :is(.hbplus-quick-dashboard, .hbplus-quick-navigation) {
    background: var(--hb-surface) !important; color: var(--hb-text) !important; border-color: var(--hb-border);
}
html[data-custom-theme] body :is(.hbplus-quick-dashboard, .hbplus-quick-navigation):hover {
    background: var(--hb-hover) !important; color: var(--hb-on-hover) !important;
}
html[data-custom-theme] body :is(.hbplus-dashboard-label, .hbplus-navigation-label, .hbplus-navigation-chevron) { color: inherit; }
