/* Light theme (default) */
:root {
    /* ===== Accent =====
       Derived from the active DevExpress Fluent accent stylesheet
       (--DS-primary-*), so the whole app follows the accent chosen on
       Company Defaults (install default) or in the Appearance panel
       (per-browser override). The hex fallbacks are the historical indigo,
       used only if the DevExpress accent file fails to load. */
    --app-accent: var(--DS-primary-100, #4F46E5);          /* filled buttons, bars, gradients (light stop) */
    --app-accent-hover: var(--DS-primary-110, #4338ca);    /* hover state of filled elements */
    --app-accent-strong: var(--DS-primary-120, #393991);   /* gradient dark stop, pressed state */
    --app-accent-text: var(--DS-primary-100, #4F46E5);     /* accent used as foreground text/icon */
    --app-accent-soft: color-mix(in srgb, var(--app-accent) 10%, transparent);         /* tinted backgrounds */
    --app-accent-soft-strong: color-mix(in srgb, var(--app-accent) 18%, transparent);  /* stronger tint */
    --app-accent-text-on: #ffffff;                         /* text on top of --app-accent */

    /* Page-background gradient (login / password pages, e-mail respond,
       error pages): a two-hue sweep derived from the accent — overridden
       below with relative-color stops; these flat values are the fallback
       for browsers without relative color syntax. */
    --app-gradient-start: var(--app-accent);
    --app-gradient-end: var(--app-accent-strong);

    --header-bg: #f8f9fb;
    --content-bg: #ffffff;
    --sidebar-bg: #f8f9fb;
    --sidebar-text: #374151;
    --sidebar-text-secondary: #6b7280;
    --sidebar-hover: #f3f4f6;
    --sidebar-active-bg: var(--app-accent-soft);
    --sidebar-active-text: var(--app-accent-text);
    --sidebar-border: #e5e7eb;
    --sidebar-brand: #1f2937;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --hover-bg: #f3f4f6;
    --card-bg: #ffffff;
    --search-group-header-bg: #f3f4f6;
    --search-group-header-text: #4b5563;
}

/* Dark theme */
html.dark {
    /* In dark mode the accent used as foreground needs a lighter shade to
       stay readable; tints need more strength against dark surfaces. */
    --app-accent-text: var(--DS-primary-50, #a5b4fc);
    --app-accent-soft: color-mix(in srgb, var(--app-accent) 20%, transparent);
    --app-accent-soft-strong: color-mix(in srgb, var(--app-accent) 30%, transparent);

    --header-bg: #1e1e2e;
    --content-bg: #141420;
    --sidebar-bg: #1e1e2e;
    --sidebar-text: #b0b0c8;
    --sidebar-text-secondary: #8888a8;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active-bg: var(--app-accent-soft);
    --sidebar-active-text: var(--app-accent-text);
    --sidebar-border: #2d2d3f;
    --sidebar-brand: #ffffff;
    --text-primary: #e0e0e8;
    --text-secondary: #9ca3af;
    --border-color: #2d2d3f;
    --hover-bg: #2a2a3c;
    --card-bg: #1e1e2e;
    --search-group-header-bg: #252538;
    --search-group-header-text: #a0a0b8;
}

/* Two-hue page gradient: lighter at the accent's own hue, then the same
   lightness swung ~35° around the wheel — tuned so the Purple accent
   reproduces the classic #667eea → #764ba2 backdrop. Needs CSS relative
   color syntax (all evergreen browsers since 2023/24); others keep the
   flat fallback defined on :root above. */
@supports (color: oklch(from red calc(l + 0.1) c h)) {
    :root {
        --app-gradient-start: oklch(from var(--app-accent) calc(l + 0.11) calc(c * 0.9) h);
        --app-gradient-end: oklch(from var(--app-accent) l calc(c * 0.85) calc(h + 35));
    }
}

/* Font size scaling — applied to <html> so all rem values scale proportionally */
html.font-small { font-size: 13px; }
html              { font-size: 15px; } /* medium (default) */
html.font-large { font-size: 17px; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--content-bg);
    color: var(--text-primary);
}

h1:focus {
    outline: none;
}

/* ===== Input focus highlight =====
   Gives every editable field a visible border in the current theme accent
   color when it has focus. Driven by DevExpress's `--DS-primary-100`, which
   automatically updates whenever the accent swatch changes in ThemePanel,
   so this rule follows the theme with no extra wiring.

   Tweak --field-focus-color to change the color globally.
   Tweak --field-focus-ring-width / --field-focus-ring-color to adjust the
   size or softness of the glow. */
:root {
    --field-focus-color: var(--DS-primary-120, #393991);
    --field-focus-ring-width: 2px;
    /* Soft glow around the focused field — derived from the accent so it
       follows the theme. color-mix is supported in all modern browsers. */
    --field-focus-ring-color: var(--field-focus-color);
}

/* DevExpress editor wrappers get the `dxbl-focused` state class when the
   inner input has focus. Covers DxTextBox, DxComboBox, DxTagBox, DxDateEdit,
   DxSpinEdit, DxMaskedInput, etc.

   Also suppresses DevExpress Fluent's bottom-underline focus indicator
   so the editor matches the clean single-border look used elsewhere
   (e.g. the global search box). */
.dxbl-text-edit.dxbl-focused,
.dxbl-text-edit:focus-within,
.dxbl-memo-edit.dxbl-focused,
.dxbl-memo-edit:focus-within {
    --dxbl-text-edit-underline-color: transparent;
    /* The dropdown caret inherits this one, spin/other buttons inherit
       --dxbl-btn-border-color — override both so every child button's
       border follows the focused accent color. */
    --dxbl-text-edit-border-color: var(--field-focus-color);
    --dxbl-btn-border-color: var(--field-focus-color);
    border-color: var(--field-focus-color) !important;
    box-shadow: 0 0 0 var(--field-focus-ring-width) var(--field-focus-ring-color);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Native inputs (Identity/login pages, any plain <input>/<textarea>/<select>).
   Excludes DevExpress-wrapped inputs — their inner `<input>` sits inside a
   `.dxbl-text-edit` wrapper which gets its own focus styling above. Painting
   a ring on the inner input there would only cover the text area, leaving
   the dropdown/spin buttons outside the ring. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([class*="dxbl-"]):focus-visible,
textarea:not([class*="dxbl-"]):focus-visible,
select:not([class*="dxbl-"]):focus-visible {
    outline: none;
    border-color: var(--field-focus-color);
    box-shadow: 0 0 0 var(--field-focus-ring-width) var(--field-focus-ring-color);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* ===== Read-only field styling =====
   Visually distinguish read-only inputs so users can tell they're not
   editable. DevExpress adds `.dxbl-readonly` on the editor wrapper; native
   inputs use the `readonly` attribute. Tweak --field-readonly-bg to
   change the shade. */
:root {
    --field-readonly-bg: var(--hover-bg, #f3f4f6);
    --field-readonly-text: var(--text-secondary, #6b7280);
}

/* Exclude dropdown editors (DxComboBox, DxTagBox, DxDateEdit, etc.) —
   they render as `.dxbl-text-edit.dxbl-readonly` even when interactive
   because the user can only pick from the list, not type freely.
   The dropdown caret (`.dxbl-edit-btn-dropdown`) is our signal that it's
   a picker, not a true read-only field. */
.dxbl-text-edit.dxbl-readonly:not(:has(.dxbl-edit-btn-dropdown)),
.dxbl-memo-edit.dxbl-readonly {
    background-color: var(--field-readonly-bg) !important;
}

.dxbl-text-edit.dxbl-readonly:not(:has(.dxbl-edit-btn-dropdown)) .dxbl-text-edit-input,
.dxbl-memo-edit.dxbl-readonly .dxbl-text-edit-input {
    color: var(--field-readonly-text);
    cursor: default;
}

/* Native read-only inputs, excluding DevExpress-wrapped editors (their
   inner input is styled via `.dxbl-text-edit.dxbl-readonly` above). */
input[readonly]:not([type="checkbox"]):not([type="radio"]):not([class*="dxbl-"]),
textarea[readonly]:not([class*="dxbl-"]) {
    background-color: var(--field-readonly-bg);
    color: var(--field-readonly-text);
    cursor: default;
}

/* ===== DxTreeView nav chevron & separator styling ===== */

/* Suppress focus/active ring flash on expand/collapse arrows */
.dxbl-treeview .dxbl-btn-tool {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
}

/* Move the expand/collapse button to the right side of the row */
.nav-treeview .dxbl-treeview-item-content {
    display: flex !important;
    flex-direction: row !important;
}

.nav-treeview .dxbl-btn-tool {
    order: 99 !important;
    margin-left: auto !important;
    margin-right: 0 !important;
}

/* Hide the DevExpress SVG chevron and replace with a text chevron */
.nav-treeview .dxbl-btn-tool svg {
    display: none !important;
}

.nav-treeview .dxbl-btn-tool::after {
    content: "\203A";
    font-size: 1.35rem;
    line-height: 1;
    color: var(--sidebar-text-secondary);
    transition: transform 0.2s ease;
    display: inline-block;
}

/* Rotate chevron when expanded */
.nav-treeview .dxbl-btn-tool[data-expanded]::after {
    transform: rotate(90deg);
}

/* Vertical indentation guide lines for expanded parent nodes */
.nav-treeview dxbl-expandable-container[expanded-state="True"] > ul {
    position: relative;
}

.nav-treeview dxbl-expandable-container[expanded-state="True"] > ul::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: color-mix(in srgb, var(--sidebar-text-secondary) 55%, transparent);
    pointer-events: none;
    z-index: 1;
    left: 0.933rem;
}

/* Deeper nesting: offset the guide line further right */
.nav-treeview dxbl-expandable-container[expanded-state="True"] > ul >
    li > dxbl-expandable-container[expanded-state="True"] > ul::before {
    left: 2rem;
}

/* Prevent horizontal scrollbar from tree guide lines */
.nav-treeview .dxbl-scroll-viewer-content {
    overflow-x: hidden !important;
}

.nav-treeview .dxbl-scroll-viewer-hor-scroll-bar {
    display: none !important;
}

/* Horizontal branch lines from vertical guide to each child item.
   Positioned on the li element, which is relative to the ul (also relative). */
.nav-treeview dxbl-expandable-container[expanded-state="True"] > ul > li {
    position: relative;
}

.nav-treeview dxbl-expandable-container[expanded-state="True"] > ul > li::after {
    content: "";
    position: absolute;
    top: 1.133rem;
    height: 1px;
    background: color-mix(in srgb, var(--sidebar-text-secondary) 55%, transparent);
    pointer-events: none;
}

/* Level-1 children: branch from vertical guide toward the icon.
   Width is intentionally short so a visible gap remains before the icon. */
.nav-treeview .dxbl-scroll-viewer > div > ul > li > dxbl-expandable-container[expanded-state="True"] > ul > li::after {
    left: 0.933rem;
    width: 0.2rem;
}

/* Level-2 children: branch from vertical guide toward the icon */
.nav-treeview dxbl-expandable-container[expanded-state="True"] > ul > li > dxbl-expandable-container[expanded-state="True"] > ul > li::after {
    left: 2rem;
    width: 0.2rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}



/* First-load overlay — absolutely positioned inside .main-content so it
   covers ONLY the page content area (the sidebar nav and app header stay
   visible). Used only on the very first page load in a Blazor circuit,
   gated by AppLoadState.IsFirstLoad. */
.page-loading-container {
    position: absolute;
    inset: 0;
    z-index: 200;
    background: var(--content-bg, #f8f9fb);
    display: flex;
    flex-direction: column;
}

/* Animated loading bar across the top of the overlay */
.page-loading-bar {
    position: relative;
    height: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.page-loading-bar::after {
    content: '';
    display: block;
    width: 40%;
    height: 100%;
    background: var(--app-accent);
    animation: loading-slide 1s ease-in-out infinite;
}

@keyframes loading-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* Page loading — delayed appearance via CSS animation.
   Stays invisible for 150ms, then fades in. If the page loads
   before 150ms, Blazor removes the element and it never shows. */
.loading-delayed {
    opacity: 0;
    animation: loading-fade-in 0.2s ease 150ms forwards;
}

@keyframes loading-fade-in {
    to { opacity: 1; }
}

/* Centered loading spinner inside the overlay */
.page-loading-panel {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Change log detail grid */
.changelog-detail-grid {
    margin: 0.5rem 1rem;
}

.changelog-detail-empty {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-style: italic;
}

/* TreeView nav - prevent parent nodes from showing selected state.
   Target only the direct node item, not the child nodes inside it. */
.parent-node > :first-child,
.parent-node > :first-child > * {
    background-color: transparent !important;
    background: transparent !important;
    color: inherit !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Toolbar button styles */
.btn-new-record,
.toolbar-btn-new {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}

/* Standard popup footer layout — used by every standalone DxPopup edit form.
   align-items: center keeps Save/Close and any custom buttons vertically
   centered on the same row. Scoped .razor.css overrides may exist in
   individual pages; this is the baseline. */
.popup-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 0.75rem 1rem;
    width: 100%;
}

/* ===== Popup sizing standard (see docs/grid-standards.md § Popup Sizing) =====
   Every DxPopup listed here auto-sizes to its content and is centered
   (DxPopup centers itself by default), capped at 95% of the viewport height.
   When content exceeds that cap, an internal scrollable region (.tab-body
   for edit popups, component-specific for shared popups) handles overflow
   so the popup chrome (header, footer) always stays visible.

   To add a new popup: set CssClass="foo-popup" on the DxPopup, omit Height,
   add "foo-popup" to both selector lists below, and ensure the body wraps
   its scrollable content in a <div class="tab-body"> (or equivalent). */
.user-popup,
.access-group-popup,
.menu-item-popup,
.help-article-popup,
.grid-view-popup,
.report-popup,
.global-search-popup,
.changelog-popup,
.icon-picker-popup,
.confirm-popup,
.country-code-popup,
.lookup-definition-popup,
.import-popup {
    max-height: 95vh !important;
    /* DxPopup adds margin: 28px on the popup element. With max-height: 95vh
       that makes the popup + margins exceed the viewport (848 + 56 > 893 on
       a typical viewport), which breaks symmetric centering. Override the
       margin so the popup is purely centered by the parent's CSS grid
       (DXBL-MODAL-ROOT has align-items: center). */
    margin: 0 !important;
}

.user-popup .dxbl-popup-content,
.access-group-popup .dxbl-popup-content,
.menu-item-popup .dxbl-popup-content,
.help-article-popup .dxbl-popup-content,
.grid-view-popup .dxbl-popup-content,
.report-popup .dxbl-popup-content,
.global-search-popup .dxbl-popup-content,
.changelog-popup .dxbl-popup-content,
.icon-picker-popup .dxbl-popup-content,
.confirm-popup .dxbl-popup-content,
.country-code-popup .dxbl-popup-content,
.lookup-definition-popup .dxbl-popup-content,
.import-popup .dxbl-popup-content {
    max-height: 95vh !important;
}

.confirm-popup .confirm-popup-body {
    padding: 1rem 1.25rem;
}

.confirm-popup .confirm-popup-body p {
    margin: 0;
    color: var(--text-primary);
}

/* Approve / Decline dialogs (PO Requests screen and Approvals page): the primary
   button keeps the theme's blue background with white text; while the action runs
   (disabled, "Working…") it turns gray with the approve-green / decline-red text. */
.confirm-popup .popup-footer .po-btn-respond-approve:not(:disabled),
.confirm-popup .popup-footer .po-btn-respond-decline:not(:disabled) {
    color: #fff !important;
}

.confirm-popup .popup-footer .po-btn-respond-approve:disabled,
.confirm-popup .popup-footer .po-btn-respond-decline:disabled {
    background-color: #e5e7eb !important;
    border-color: #e5e7eb !important;
    opacity: 1 !important;
}

.confirm-popup .popup-footer .po-btn-respond-approve:disabled {
    color: #059669 !important;
}

.confirm-popup .popup-footer .po-btn-respond-decline:disabled {
    color: #dc2626 !important;
}


/* Validation results in the PO Request / Approvals message popups: one problem per line. */
.po-message-list {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
    line-height: 1.5;
}

.po-message-list li {
    margin-bottom: 0.2rem;
}
/* Multi-tab popups: fix .tab-body at the 95vh cap so switching tabs doesn't
   resize the popup. Each DxTabPage's .tab-body gets the same height, and
   content that doesn't fit scrolls inside the tab. Add a new tabbed popup's
   class here when introducing it. Non-tabbed popups are NOT in this list —
   they keep the default auto-size behavior.

   Cap = 95vh minus popup header (~52px) + DxTabs bar (~50px) + footer
   (~64px) + body padding (~44px) = 210px. Non-tabbed popups (which don't
   have the tabs bar) use calc(95vh - 160px) in their own scoped CSS. */
.access-group-popup .tab-body,
.grid-view-popup .tab-body,
.global-search-popup .tab-body {
    height: calc(95vh - 210px);
}

/* Responsive popup sizing — every DxPopup with one of our edit-popup
   CssClass values goes full-screen on mobile so the fixed Width parameter
   set on edit popups (e.g. Width="800px") never triggers horizontal
   page scrolling. Selectors target both the inner popup element and the
   outer wrapper that DxPopup uses for positioning. */
@media (max-width: 768px) {
    .user-popup,
    .access-group-popup,
    .menu-item-popup,
    .changelog-popup,
    .icon-picker-popup,
    .help-article-popup,
    .grid-view-popup,
    .report-popup,
    .global-search-popup,
    .country-code-popup,
    .lookup-definition-popup,
    .import-popup {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        min-width: 0 !important;
        left: 0 !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        margin: 0 !important;
        transform: none !important;
        border-radius: 0 !important;
    }

    /* DevExpress popups wrap their visible chrome in .dxbl-popup-content;
       force it to fill the wrapper. */
    .user-popup .dxbl-popup-content,
    .access-group-popup .dxbl-popup-content,
    .menu-item-popup .dxbl-popup-content,
    .changelog-popup .dxbl-popup-content,
    .icon-picker-popup .dxbl-popup-content,
    .help-article-popup .dxbl-popup-content,
    .grid-view-popup .dxbl-popup-content,
    .report-popup .dxbl-popup-content,
    .country-code-popup .dxbl-popup-content,
    .lookup-definition-popup .dxbl-popup-content,
    .import-popup .dxbl-popup-content,
    .global-search-popup .dxbl-popup-content {
        width: 100% !important;
        height: 100% !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
    }
}

/* Pushes a button to the LEFT inside a flex .popup-footer that uses
   justify-content: flex-end. Wrap the History (or other left-aligned)
   button in <div class="popup-footer-left">. */
.popup-footer-left {
    margin-right: auto;
    display: inline-flex;
    align-items: center;
}

/* Toolbar row above an EditFormTemplate (used when there's no custom popup
   footer to host left-aligned buttons like History). */
.edit-form-toolbar {
    display: flex;
    justify-content: flex-start;
    padding: 0.5rem 1rem 0;
}

/* Change log popup */
.changelog-popup {
    max-width: 95vw !important;
}

.changelog-popup .changelog-body {
    display: flex;
    flex-direction: column;
    /* Popup auto-sizes up to 95vh (see Popup sizing standard above).
       Body fills that height; the grid inside scrolls when rows overflow. */
    max-height: calc(95vh - 52px);
    overflow: hidden;
}

.changelog-popup .changelog-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: #f8f9fb;
}

.changelog-popup .filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 180px;
}

.changelog-popup .filter-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.changelog-popup .filter-input {
    min-width: 180px;
}

/* Grid height caps at popup height (95vh) minus filter row, header, and
   padding. This prevents the grid from pushing the popup chrome off-screen
   when there are many records — the grid scrolls internally instead. */
.changelog-grid {
    height: calc(95vh - 11rem) !important;
    max-height: calc(95vh - 11rem) !important;
}

.changelog-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    min-height: 120px;
}

/* Loading / empty-state placeholders rendered inside DxGrid's
   EmptyDataAreaTemplate. Used by all maintenance pages. */
.grid-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    min-height: 200px;
}

.grid-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    min-height: 200px;
    color: var(--text-secondary, #6b7280);
    font-style: italic;
}

/* View manager popup */
.view-popup-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.view-popup-title {
    font-weight: 600;
    font-size: 1rem;
}

.view-reset-btn {
    margin-left: auto;
}

.view-manager {
    padding: 1rem;
}

.view-save-section {
    margin-bottom: 1.5rem;
}

.view-save-section h3,
.view-list-section h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
}

.view-save-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.view-name-input {
    flex: 1;
    min-width: 200px;
}

.view-empty {
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 1rem 0;
}

.view-action-btn {
    padding: 0.125rem 0.375rem !important;
    font-size: 0.75rem !important;
}

@media (max-width: 768px) {
    .view-manager-popup {
        width: 95vw !important;
    }

    .view-save-form {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Mobile overflow button */
.toolbar-overflow-btn {
    display: none;
}

@media (max-width: 768px) {
    .toolbar-overflow-btn {
        display: inline-flex;
    }
}

/* Standard grid styling — applies to ALL DxGrid instances */

/* Header row */
.dxbl-grid .dxbl-grid-header-row,
.dxbl-grid .dxbl-grid-header-row th {
    background-color: #e8eaed !important;
}

html.dark .dxbl-grid .dxbl-grid-header-row,
html.dark .dxbl-grid .dxbl-grid-header-row th {
    background-color: #2a2a3c !important;
}

/* Filter row — matches header background with bordered inputs */
.dxbl-grid .dxbl-grid-filter-row,
.dxbl-grid .dxbl-grid-filter-row td {
    background-color: #e8eaed !important;
}

.dxbl-grid .dxbl-grid-filter-row input,
.dxbl-grid .dxbl-grid-filter-row .dxbl-text-edit {
    border: 1px solid #c8ccd0 !important;
    border-radius: 4px !important;
    background-color: #ffffff !important;
}

html.dark .dxbl-grid .dxbl-grid-filter-row,
html.dark .dxbl-grid .dxbl-grid-filter-row td {
    background-color: #2a2a3c !important;
}

html.dark .dxbl-grid .dxbl-grid-filter-row input,
html.dark .dxbl-grid .dxbl-grid-filter-row .dxbl-text-edit {
    border: 1px solid #3d3d52 !important;
    background-color: #1e1e2e !important;
}

/* Error pages (404, 500) — standalone pages with EmptyLayout */
.error-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--app-gradient-start) 0%, var(--app-gradient-end) 100%);
    padding: 12vh 1rem 1rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.error-panel {
    background: #ffffff;
    border-radius: 16px;
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.error-icon {
    margin-bottom: 1.5rem;
}

.error-code {
    font-size: 4rem;
    font-weight: 800;
    color: #e5e7eb;
    margin: 0;
    line-height: 1;
    letter-spacing: -0.05em;
}

.error-icon-danger + .error-code {
    color: #fecaca;
}

.error-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0.5rem 0 0;
}

.error-message {
    color: #6b7280;
    font-size: 0.9375rem;
    margin: 0.75rem 0 1.5rem;
    line-height: 1.5;
}

.error-correlation {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.correlation-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.correlation-id {
    font-size: 0.8125rem;
    color: #374151;
    background: none;
    word-break: break-all;
}

.error-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.error-actions .btn-primary {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--app-accent-text-on);
    background: var(--app-accent);
    border: none;
    border-radius: 10px;
    text-decoration: none;
    transition: background 0.2s, box-shadow 0.2s;
}

.error-actions .btn-primary:hover {
    background: var(--app-accent-hover);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--app-accent) 35%, transparent);
}

.error-actions .btn-secondary {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.error-actions .btn-secondary:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

@media (max-width: 480px) {
    .error-panel {
        padding: 2rem 1.5rem;
        border-radius: 12px;
    }

    .error-actions {
        flex-direction: column;
    }
}

/* Toast notification — bottom-right, fades after a few seconds */
.toast-notification {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #059669;
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    animation: toast-slide-in 0.3s ease;
}

.toast-fade-out {
    animation: toast-fade-out 0.5s ease forwards;
}

@keyframes toast-slide-in {
    from { transform: translateY(1rem); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toast-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Page-level grid sizing — apply .page-grid to any full-page DxGrid */
.page-grid {
    height: calc(100vh - 10rem);
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
}

/* Edit popup sizing — global because DevExpress renders popups at document root */
.edit-popup {
    width: 800px !important;
    max-width: 90vw !important;
}

.access-group-popup {
    width: 900px !important;
    max-width: 90vw !important;
}

@media (max-width: 768px) {
    .edit-popup {
        width: 95vw !important;
    }
}

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: 3.5rem;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
}

/* Sidebar collapse — desktop: collapse via negative margin to allow smooth transition */
[data-sidebar="collapsed"] .nav-menu {
    margin-left: -260px;
}

/* Mobile overrides */
@media (max-width: 768px) {
    .nav-menu {
        position: fixed !important;
        top: 3.5rem !important;
        left: 0;
        z-index: 100;
        margin-left: 0 !important;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    /* Only show sidebar on mobile when explicitly opened via hamburger */
    [data-sidebar="mobile-open"] .nav-menu {
        transform: translateX(0);
    }

    [data-sidebar="mobile-open"] .sidebar-overlay {
        display: block;
    }
}

/* ===== Icon Picker Popup (rendered at document root, must be global) ===== */
.icon-picker-popup .icon-picker-body {
    display: flex;
    flex-direction: column;
    /* Popup auto-sizes up to 95vh (see Popup sizing standard above).
       Body caps here; the icon grid inside scrolls when it overflows. */
    max-height: calc(95vh - 52px);
    overflow: hidden;
    padding: 0.75rem 1rem 0;
}

.icon-picker-popup .icon-picker-search {
    margin-bottom: 0.75rem;
}

.icon-picker-popup .icon-picker-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.5rem;
    padding-right: 0.5rem;
}

.icon-picker-popup .icon-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem 0.25rem;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    min-height: 70px;
}

.icon-picker-popup .icon-tile:hover {
    background: #f3f4f6;
    border-color: color-mix(in srgb, var(--app-accent) 35%, transparent);
}

.icon-picker-popup .icon-tile.selected {
    background: var(--app-accent-soft);
    border-color: var(--app-accent);
}

.icon-picker-popup .icon-tile i {
    font-size: 1.5rem;
    color: var(--app-accent-text);
}

.icon-picker-popup .icon-tile span {
    font-size: 0.6875rem;
    color: #6b7280;
    text-align: center;
    word-break: break-all;
    line-height: 1.1;
}

.icon-picker-popup .icon-picker-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #6b7280;
    font-style: italic;
    padding: 2rem 0;
}

.icon-picker-popup .icon-picker-more {
    text-align: center;
    padding: 0.25rem 0 0;
}

/* Menu Items / Help Articles trees — category row shading for top two levels */
.menu-row-category,
.menu-row-category td,
.help-row-category,
.help-row-category td {
    background-color: #e5e7eb !important;
    font-weight: 600;
}

.menu-row-subcategory,
.menu-row-subcategory td,
.help-row-subcategory,
.help-row-subcategory td {
    background-color: #f3f4f6 !important;
    font-weight: 500;
}

html.dark .menu-row-category,
html.dark .menu-row-category td,
html.dark .help-row-category,
html.dark .help-row-category td {
    background-color: #2a2a3c !important;
}

html.dark .menu-row-subcategory,
html.dark .menu-row-subcategory td,
html.dark .help-row-subcategory,
html.dark .help-row-subcategory td {
    background-color: #222233 !important;
}

/* Active/Inactive status badges */
.status-active,
.status-inactive {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    min-width: 56px;
}

.status-active {
    background-color: #059669;
    color: #ffffff;
}

.status-inactive {
    background-color: #dc2626;
    color: #ffffff;
}

/* Record Locking */
.lock-banner {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    padding: 10px 14px;
    margin-bottom: 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #664d03;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lock-banner i {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.inactivity-modal-body {
    text-align: center;
    padding: 16px 8px;
}

.inactivity-icon {
    font-size: 2.5rem;
    color: #f59e0b;
    display: block;
    margin-bottom: 12px;
}

.inactivity-modal-body p {
    margin-bottom: 12px;
    color: #374151;
}

.inactivity-modal-body .lock-banner {
    text-align: left;
}

/* ── Nav Context Menu (right-click favorites) ── */
.nav-context-menu {
    position: fixed;
    z-index: 200;
    min-width: 180px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 4px 0;
    font-size: 0.8125rem;
}

.nav-context-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s;
}

.nav-context-menu-item:hover {
    background: var(--hover-bg);
}

.nav-context-menu-item i {
    font-size: 0.875rem;
    width: 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.nav-context-menu-separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* ===== Theme panel (global — renders as fixed overlay) ===== */

.theme-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.theme-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 90vw;
    background: var(--card-bg, #ffffff);
    border-left: 1px solid var(--border-color, #e5e7eb);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.theme-panel.open {
    transform: translateX(0);
}

.theme-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}

.theme-panel-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.theme-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.25rem;
    padding: 0.25rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.theme-panel-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.theme-panel-body {
    padding: 1.25rem;
    flex: 1;
}

.theme-section {
    margin-bottom: 1.75rem;
}

.theme-section h4 {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin: 0 0 0.75rem;
}

/* Mode & font size toggle buttons */
.theme-mode-toggle {
    display: flex;
    gap: 0.5rem;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8125rem;
    transition: all 0.15s;
}

.mode-btn:hover {
    background: var(--hover-bg);
}

.mode-btn.active {
    border-color: var(--app-accent-text);
    background: var(--app-accent-soft);
    color: var(--app-accent-text);
    font-weight: 600;
}

html.dark .mode-btn.active {
    color: var(--app-accent-text);
    border-color: var(--app-accent-text);
    background: var(--app-accent-soft);
}

/* Accent color grid */
.accent-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.625rem;
    justify-items: center;
}

.accent-swatch {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: var(--swatch-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.875rem;
    transition: transform 0.15s, box-shadow 0.15s;
    padding: 0;
}

.accent-swatch:hover {
    transform: scale(1.12);
}

.accent-swatch.active {
    box-shadow: 0 0 0 2px var(--card-bg, #ffffff), 0 0 0 4px var(--swatch-color);
}

/* The "use install default" swatch — shows the install's accent color with a
   dashed outline so it reads as "automatic" rather than a fixed color. */
.accent-swatch-default {
    border: 2px dashed rgba(255, 255, 255, 0.85);
}

.accent-default-hint {
    margin: 0.625rem 0 0;
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
}

/* Accent picker items on Company Defaults (combo dropdown renders at the
   document root, so this must live in global CSS). */
.theme-accent-option {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-accent-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex: none;
}

/* ===== Help panel (global - renders as fixed overlay) ===== */

.help-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.help-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 460px;
    max-width: 95vw;
    background: var(--card-bg, #ffffff);
    border-left: 1px solid var(--border-color, #e5e7eb);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.help-panel.open {
    transform: translateX(0);
}

.help-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
}

.help-panel-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.help-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.25rem;
    padding: 0.25rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.help-panel-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.help-panel-body {
    padding: 1.25rem 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.help-article-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem;
    color: var(--text-primary);
}

.help-article-body {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.help-article-body h1,
.help-article-body h2,
.help-article-body h3 {
    margin-top: 1.25rem;
}

.help-article-body p {
    margin: 0 0 0.75rem;
}

.help-article-body ul,
.help-article-body ol {
    padding-left: 1.25rem;
}

.help-panel-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.help-panel-link {
    color: var(--app-accent-text);
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.help-panel-link:hover {
    text-decoration: underline;
}

.help-panel-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

.help-panel-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.help-panel-loading {
    padding: 2rem;
    display: flex;
    justify-content: center;
}

@media (max-width: 576px) {
    .help-panel {
        width: 100vw;
    }
}

/* ===== Help Center page ===== */

.help-center-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1rem;
    /* Reclaim the vertical space the removed page-toolbar used to occupy.
       120px = app header + page padding. */
    height: calc(100vh - 120px);
    min-height: 500px;
}

.help-center-sidebar {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: var(--card-bg, #ffffff);
    padding: 1rem;
    overflow-y: auto;
}

.help-center-search {
    margin-bottom: 1rem;
}

.help-center-content {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: var(--card-bg, #ffffff);
    padding: 1.25rem 2rem;
    overflow-y: auto;
}

.help-center-content .help-article-title {
    /* Remove browser default top margin so the title hugs the top of the card. */
    margin: 0 0 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.help-center-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .help-center-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .help-center-sidebar {
        max-height: 300px;
    }
}


/* Dirty rows on the Application Settings screen — highlighted amber so the
   user can spot pending changes even without the Value column in view.
   Data rows are plain <tr> elements in DevExpress DxGrid (no dedicated class),
   so we target the `dirty-row` class we apply via CustomizeElement directly. */
.dxbl-grid tr.dirty-row,
.dxbl-grid tr.dirty-row td {
    background-color: rgba(245, 158, 11, 0.15) !important;
}

.dxbl-grid tr.dirty-row td:first-child {
    box-shadow: inset 4px 0 0 #f59e0b !important;
}

html.dark .dxbl-grid tr.dirty-row,
html.dark .dxbl-grid tr.dirty-row td {
    background-color: rgba(245, 158, 11, 0.22) !important;
}


/* Editable Value column on /admin/settings — subtle accent tint distinguishes
   the one editable column from the read-only surrounding columns. The header
   also carries a pencil icon (rendered by the page's HeaderTemplate). */
.dxbl-grid td.value-column-cell {
    background-color: color-mix(in srgb, var(--app-accent) 6%, transparent) !important;
    cursor: pointer;
}

.dxbl-grid td.value-column-cell:hover {
    background-color: color-mix(in srgb, var(--app-accent) 14%, transparent) !important;
}

.dxbl-grid th.value-column-header {
    background-color: color-mix(in srgb, var(--app-accent) 10%, transparent) !important;
}

/* Pencil icon before the "Value" caption — signals column is editable.
   Uses a Bootstrap Icons unicode glyph so no HeaderCaptionTemplate is needed. */
.dxbl-grid th.value-column-header .dxbl-grid-header-content::before {
    content: "\F4CB"; /* bi-pencil-square */
    font-family: "bootstrap-icons";
    font-weight: normal;
    color: var(--app-accent-text);
    margin-right: 0.4rem;
    font-size: 1rem;
    vertical-align: -1px;
}

html.dark .dxbl-grid td.value-column-cell {
    background-color: color-mix(in srgb, var(--app-accent-text) 10%, transparent) !important;
}

html.dark .dxbl-grid td.value-column-cell:hover {
    background-color: color-mix(in srgb, var(--app-accent-text) 20%, transparent) !important;
}

html.dark .dxbl-grid th.value-column-header {
    background-color: color-mix(in srgb, var(--app-accent-text) 14%, transparent) !important;
}

/* Dirty-row amber highlight already applies to all td in the row via
   `tr.dirty-row td`, but the value-column-cell rule above uses !important too.
   Bump the dirty-row rule to win via a more specific selector so an unsaved
   Value cell reads as amber (unsaved) rather than purple (editable). */
.dxbl-grid tr.dirty-row td.value-column-cell {
    background-color: rgba(245, 158, 11, 0.20) !important;
}

html.dark .dxbl-grid tr.dirty-row td.value-column-cell {
    background-color: rgba(245, 158, 11, 0.30) !important;
}

/* A system setting the user may not change (only Administrators can): no
   editable tint, default cursor; the Setting cell shows a lock icon. */
.dxbl-grid td.value-column-cell-locked {
    cursor: not-allowed;
}

.dxbl-grid td .system-setting-lock {
    margin-left: 0.4rem;
    color: var(--app-accent-text);
    opacity: 0.75;
    font-size: 0.85rem;
}

/* LookupComboBox GridMode: the DxDropDown's Width parameter sizes the
   window; the grid fills it and needs a fixed height for virtual
   scrolling. Global CSS because DevExpress renders dropdowns at the
   document root. Capped to the viewport so it never overflows. */
.lookup-grid-dropdown {
    height: min(560px, 70vh);
    width: 100%;
}

/* Multi-column dropdowns (LookupComboBox, CodePicker): even in
   ContentOrEditorWidth mode DevExpress opens a multi-column list at the
   editor's width, which hides the description behind a narrow code box.
   The control adds lookup-cols-N for its column count; give the list room
   accordingly, capped to the viewport. Global: dropdowns render at the
   document root. */
.lookup-combo-dropdown.lookup-cols-2 {
    min-width: min(22rem, 94vw);
}

.lookup-combo-dropdown.lookup-cols-3 {
    min-width: min(30rem, 94vw);
}

.lookup-combo-dropdown.lookup-cols-4 {
    min-width: min(38rem, 94vw);
}

.lookup-combo-dropdown.lookup-cols-5,
.lookup-combo-dropdown.lookup-cols-6,
.lookup-combo-dropdown.lookup-cols-7,
.lookup-combo-dropdown.lookup-cols-8 {
    min-width: min(46rem, 94vw);
}

/* ===== PO request status pill (RequestStatusBadge) =====
   Global because the badge is also rendered inside DevExpress grid cells. */
.req-status {
    display: inline-block;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25rem;
    white-space: nowrap;
}

.req-status-new {
    background-color: color-mix(in srgb, var(--app-accent) 12%, transparent);
    color: var(--app-accent-text);
}

.req-status-pending {
    background-color: rgba(217, 119, 6, 0.15);
    color: #b45309;
}

.req-status-approved {
    background-color: rgba(5, 150, 105, 0.15);
    color: #047857;
}

.req-status-declined,
.req-status-exportfailed {
    background-color: rgba(220, 38, 38, 0.15);
    color: #b91c1c;
}

.req-status-cancelled {
    background-color: rgba(107, 114, 128, 0.18);
    color: #4b5563;
}

.req-status-exported {
    background-color: rgba(37, 99, 235, 0.15);
    color: #1d4ed8;
}

html.dark .req-status-new { color: var(--app-accent-text); }
html.dark .req-status-pending { color: #fbbf24; }
html.dark .req-status-approved { color: #34d399; }
html.dark .req-status-declined,
html.dark .req-status-exportfailed { color: #f87171; }
html.dark .req-status-cancelled { color: #d1d5db; }
html.dark .req-status-exported { color: #93c5fd; }

/* The PO request line grid lives inside a card; the standard .page-grid
   height (viewport-based) does not apply, so it gets its own height. */
.po-request-lines-grid {
    flex: 1 1 auto;
    min-height: 16rem;
    width: 100% !important;
    max-width: 100% !important;
}

/* Header-tab radio group — DevExpress renders the items as siblings; keep
   them on one row with the hint text. */
.po-import-into .dxbl-radio-group {
    display: inline-flex;
    gap: 0.5rem;
}

/* PO Requests: e-mail popup field stack (popups render at the document root, so global CSS). */
.po-email-form {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.po-email-form > label {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.po-email-form > label:first-child {
    margin-top: 0;
}

/* Change log popup: time-zone note at the end of the filter bar. */
.changelog-popup .changelog-tz {
    align-self: flex-end;
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-secondary, #666);
    white-space: nowrap;
}

/* Muted helper text inside popups (the e-mail dialog); popups render at the document root. */
.po-hint {
    color: var(--text-secondary, #6b7280);
    font-size: 0.875rem;
}

/* A document whose file the document cleanup removed: the name stays, without a link (grids, banners, lines panel).
   Global because grid cells render through DevExpress templates. */
.po-doc-removed,
.po-grid-doc.po-grid-doc-removed {
    color: var(--text-secondary, #6b7280);
    cursor: help;
    text-decoration: none;
}
