:root {
    --brand-burgundy: #87374f;
    --brand-burgundy-bright: #a54763;
    --brand-blue: #1f6899;
    --brand-blue-bright: #2d88c2;
    --brand-blue-soft: #74b0d5;
    --color-text-on-dark: #f5f7fb;
    --color-text-muted-on-dark: #afbfd4;
    --color-ink: #162236;
    --color-ink-soft: #5f708a;
    --color-surface-light: #f6f8fc;
    --color-surface-dark: #071019;
}

html, body {
    font-family: 'Manrope', sans-serif;
    color: var(--mud-palette-text-primary, #162236);
    background: var(--mud-palette-background, #f3f6fb);
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
}

a, .btn-link {
    color: var(--brand-blue-soft);
    transition: transform 120ms ease, opacity 120ms ease, color 120ms ease, background 120ms ease;
}

a:hover, .btn-link:hover {
    opacity: 0.96;
}

button,
input,
textarea,
select {
    font: inherit;
}

.form-control:focus {
    outline: none;
    border-color: rgba(116, 176, 213, 0.8);
    box-shadow: 0 0 0 0.18rem rgba(116, 176, 213, 0.18);
}

h1:focus {
    outline: none;
}

p {
    line-height: 1.6;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeGxpbmxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgb3ZlcmZsb3c9ImhpZGRlbiI+PGRlZnM+PGNsaXBQYXRoIGlkPSJjbGlwMCI+PHJlY3QgeD0iMjM1IiB5PSI1MSIgd2lkdGg9IjU2IiBoZWlnaHQ9IjQ5Ii8+PC9jbGlwUGF0aD48L2RlZnM+PGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwKSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTIzNSAtNTEpIj48cGF0aCBkPSJNMjYzLjUwNiA1MUMyNjQuNzE3IDUxIDI2NS44MTMgNTEuNDgzNyAyNjYuNjA2IDUyLjI2NThMMjY3LjA1MiA1Mi43OTg3IDI2Ny41MzkgNTMuNjI4MyAyOTAuMTg1IDkyLjE4MzEgMjkwLjU0NSA5Mi43OTUgMjkwLjY1NiA5Mi45OTZDMjkwLjg3NyA5My41MTMgMjkxIDk0LjA4MTUgMjkxIDk0LjY3ODIgMjkxIDk3LjA2NTEgMjg5LjAzOCA5OSAyODYuNjE3IDk5TDI0MC4zODMgOTlDMjM3Ljk2MyA5OSAyMzYgOTcuMDY1MSAyMzYgOTQuNjc4MiAyMzYgOTQuMzc5OSAyMzYuMDMxIDk0LjA4ODYgMjM2LjA4OSA5My44MDcyTDIzNi4zMzggOTMuMDE2MiAyMzYuODU4IDkyLjEzMTQgMjU5LjQ3MyA1My42Mjk0IDI1OS45NjEgNTIuNzk4NSAyNjAuNDA3IDUyLjI2NThDMjYxLjIgNTEuNDgzNyAyNjIuMjk2IDUxIDI2My41MDYgNTFaTTI2My41ODYgNjYuMDE4M0MyNjAuNzM3IDY2LjAxODMgMjU5LjMxMyA2Ny4xMjQ1IDI1OS4zMTMgNjkuMzM3IDI1OS4zMTMgNjkuNjEwMiAyNTkuMzMyIDY5Ljg2MDggMjU5LjM3MSA3MC4wODg3TDI2MS43OTUgODQuMDE2MSAyNjUuMzggODQuMDE2MSAyNjcuODIxIDY5Ljc0NzVDMjY3Ljg2IDY5LjczMDkgMjY3Ljg3OSA2OS41ODc3IDI2Ny44NzkgNjkuMzE3OSAyNjcuODc5IDY3LjExODIgMjY2LjQ0OCA2Ni4wMTgzIDI2My41ODYgNjYuMDE4M1pNMjYzLjU3NiA4Ni4wNTQ3QzI2MS4wNDkgODYuMDU0NyAyNTkuNzg2IDg3LjMwMDUgMjU5Ljc4NiA4OS43OTIxIDI1OS43ODYgOTIuMjgzNyAyNjEuMDQ5IDkzLjUyOTUgMjYzLjU3NiA5My41Mjk1IDI2Ni4xMTYgOTMuNTI5NSAyNjcuMzg3IDkyLjI4MzcgMjY3LjM4NyA4OS43OTIxIDI2Ny4zODcgODcuMzAwNSAyNjYuMTE2IDg2LjA1NDcgMjYzLjU3NiA4Ni4wNTQ3WiIgZmlsbD0iI0ZGRTUwMCIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9nPjwvc3ZnPg==) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

.backoffice-theme-host .sf-grid.e-grid {
    border: 1px solid var(--backoffice-syncfusion-border) !important;
    border-radius: 1rem !important;
    background: var(--backoffice-syncfusion-surface) !important;
    color: var(--backoffice-syncfusion-text) !important;
    border-color: var(--backoffice-syncfusion-border) !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden;
    box-shadow: 0 18px 34px rgba(7, 16, 27, 0.12);
}

.backoffice-theme-host .sf-grid.e-grid .e-gridheader,
.backoffice-theme-host .sf-grid.e-grid .e-columnheader,
.backoffice-theme-host .sf-grid.e-grid .e-headercontent,
.backoffice-theme-host .sf-grid.e-grid .e-gridcontent,
.backoffice-theme-host .sf-grid.e-grid .e-content,
.backoffice-theme-host .sf-grid.e-grid .e-table,
.backoffice-theme-host .sf-grid.e-grid .e-gridpager,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer,
.backoffice-theme-host .sf-grid.e-grid .e-parentmsgbar,
.backoffice-theme-host .sf-grid.e-grid .e-pagerexternalmsg {
    background: var(--backoffice-syncfusion-surface) !important;
    color: var(--backoffice-syncfusion-text) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-headercell,
.backoffice-theme-host .sf-grid.e-grid .e-detailheadercell,
.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell {
    background: var(--backoffice-syncfusion-header) !important;
    color: var(--backoffice-syncfusion-text) !important;
    border-color: var(--backoffice-syncfusion-border) !important;
    font-weight: 800;
}

.backoffice-theme-host .sf-grid.e-grid .e-headercell .e-headertext,
.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell,
.backoffice-theme-host .sf-grid.e-grid .e-rowcell,
.backoffice-theme-host .sf-grid.e-grid .e-summarycell,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer,
.backoffice-theme-host .sf-grid.e-grid .e-parentmsgbar,
.backoffice-theme-host .sf-grid.e-grid .e-pagerdropdown,
.backoffice-theme-host .sf-grid.e-grid .e-pagerexternalmsg,
.backoffice-theme-host .sf-grid.e-grid .e-icons {
    color: var(--backoffice-syncfusion-text) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-row,
.backoffice-theme-host .sf-grid.e-grid .e-altrow,
.backoffice-theme-host .sf-grid.e-grid .e-row .e-rowcell,
.backoffice-theme-host .sf-grid.e-grid .e-altrow .e-rowcell,
.backoffice-theme-host .sf-grid.e-grid .e-gridcontent tr,
.backoffice-theme-host .sf-grid.e-grid .e-gridcontent td {
    background: var(--backoffice-syncfusion-surface) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-rowcell,
.backoffice-theme-host .sf-grid.e-grid .e-gridpager,
.backoffice-theme-host .sf-grid.e-grid .e-summaryrow,
.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell,
.backoffice-theme-host .sf-grid.e-grid .e-headercell {
    border-color: var(--backoffice-syncfusion-border) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-row:hover .e-rowcell,
.backoffice-theme-host .sf-grid.e-grid .e-altrow:hover .e-rowcell {
    background: var(--backoffice-syncfusion-row-hover) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-emptyrow,
.backoffice-theme-host .sf-grid.e-grid .e-emptyrow td {
    background: var(--backoffice-syncfusion-surface) !important;
    color: var(--backoffice-syncfusion-text) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-gridpager {
    border-top: 1px solid var(--backoffice-syncfusion-border) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-gridpager,
.backoffice-theme-host .sf-grid.e-grid .sf-pager.e-pager,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer,
.backoffice-theme-host .sf-grid.e-grid .e-parentmsgbar,
.backoffice-theme-host .sf-grid.e-grid .e-numericcontainer {
    background: var(--backoffice-syncfusion-surface) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-parentmsgbar,
.backoffice-theme-host .sf-grid.e-grid .e-parentmsgbar span,
.backoffice-theme-host .sf-grid.e-grid .e-pagenomsg,
.backoffice-theme-host .sf-grid.e-grid .e-pagecountmsg {
    color: var(--backoffice-syncfusion-muted) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-link,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-first,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-prev,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-next,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-last,
.backoffice-theme-host .sf-grid.e-grid .e-mfirst,
.backoffice-theme-host .sf-grid.e-grid .e-mprev,
.backoffice-theme-host .sf-grid.e-grid .e-mnext,
.backoffice-theme-host .sf-grid.e-grid .e-mlast {
    color: var(--backoffice-syncfusion-muted) !important;
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    border-radius: 0.75rem;
}

.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-link:hover,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-first:hover,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-prev:hover,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-next:hover,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-last:hover,
.backoffice-theme-host .sf-grid.e-grid .e-mfirst:hover,
.backoffice-theme-host .sf-grid.e-grid .e-mprev:hover,
.backoffice-theme-host .sf-grid.e-grid .e-mnext:hover,
.backoffice-theme-host .sf-grid.e-grid .e-mlast:hover {
    background: var(--backoffice-syncfusion-accent-soft) !important;
    color: var(--backoffice-syncfusion-accent) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-link.e-disable,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-first.e-disable,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-prev.e-disable,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-next.e-disable,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-last.e-disable,
.backoffice-theme-host .sf-grid.e-grid .e-mfirst.e-disable,
.backoffice-theme-host .sf-grid.e-grid .e-mprev.e-disable,
.backoffice-theme-host .sf-grid.e-grid .e-mnext.e-disable,
.backoffice-theme-host .sf-grid.e-grid .e-mlast.e-disable {
    opacity: 0.5;
    background: transparent !important;
    color: var(--backoffice-syncfusion-muted) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-currentitem,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-currentitem.e-active,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-currentitem:hover,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-currentitem:focus,
.backoffice-theme-host .sf-grid.e-grid .e-pagercontainer .e-currentitem:focus-visible {
    background: color-mix(in srgb, var(--backoffice-syncfusion-accent) 22%, var(--backoffice-syncfusion-surface)) !important;
    color: var(--backoffice-syncfusion-text) !important;
    border: 1px solid color-mix(in srgb, var(--backoffice-syncfusion-accent) 72%, white 8%) !important;
    border-radius: 0.9rem !important;
    font-weight: 800;
    box-shadow: none !important;
    outline: none !important;
    text-decoration: none !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell {
    background: var(--backoffice-syncfusion-header) !important;
    color: var(--backoffice-syncfusion-text) !important;
    border-color: var(--backoffice-syncfusion-border) !important;
    padding: 0.35rem !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell .e-filterdiv,
.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell .e-fltrinputdiv {
    background: transparent !important;
    padding: 0 !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell .e-input-group,
.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell .e-input-group.e-control-wrapper {
    background: var(--backoffice-syncfusion-input-background) !important;
    border: 1px solid var(--backoffice-syncfusion-input-border) !important;
    border-color: var(--backoffice-syncfusion-input-border) !important;
    border-radius: 0.85rem !important;
    box-shadow: none !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell .e-input-group:focus-within,
.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell .e-input-group.e-control-wrapper:focus-within {
    border-color: var(--backoffice-syncfusion-accent) !important;
    box-shadow: 0 0 0 2px var(--backoffice-syncfusion-accent-soft) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell input,
.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell input::placeholder {
    color: var(--backoffice-syncfusion-muted) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell input {
    background: transparent !important;
    color: var(--backoffice-syncfusion-text) !important;
    padding: 0.55rem 0.85rem !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0;
}

.backoffice-theme-host .sf-grid.e-grid .e-filterbarcell .e-clear-icon {
    background: transparent !important;
    color: var(--backoffice-syncfusion-muted) !important;
    border-left: 1px solid var(--backoffice-syncfusion-input-border);
}

/* Syncfusion grid toolbar (Add / Edit / Delete / Update / Cancel) — inherit backoffice theme. */
.backoffice-theme-host .sf-grid.e-grid .e-toolbar,
.backoffice-theme-host .sf-grid.e-grid .e-toolbar .e-toolbar-items,
.backoffice-theme-host .sf-grid.e-grid .e-toolbar .e-toolbar-item,
.backoffice-theme-host .sf-grid.e-grid .e-toolbar .e-toolbar-pop {
    background: var(--backoffice-syncfusion-header) !important;
    color: var(--backoffice-syncfusion-text) !important;
    border-color: var(--backoffice-syncfusion-border) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-toolbar {
    border-bottom: 1px solid var(--backoffice-syncfusion-border) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-toolbar .e-tbar-btn,
.backoffice-theme-host .sf-grid.e-grid .e-toolbar .e-tbar-btn .e-tbar-btn-text,
.backoffice-theme-host .sf-grid.e-grid .e-toolbar .e-tbar-btn .e-icons {
    background: transparent !important;
    color: var(--backoffice-syncfusion-text) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-toolbar .e-tbar-btn:hover,
.backoffice-theme-host .sf-grid.e-grid .e-toolbar .e-tbar-btn:focus {
    background: var(--backoffice-syncfusion-row-hover) !important;
    color: var(--backoffice-syncfusion-text) !important;
}

.backoffice-theme-host .sf-grid.e-grid .e-toolbar .e-tbar-btn.e-overlay,
.backoffice-theme-host .sf-grid.e-grid .e-toolbar .e-tbar-btn[aria-disabled="true"] {
    color: var(--backoffice-syncfusion-muted) !important;
    opacity: 0.55;
}

/* Hoist the backoffice Syncfusion theme variables to body level so portaled popups
   (edit dialog, dropdowns, etc.) inherit the correct colors per active theme.
   The :has() selector keeps a single source of truth on the layout host. */
body:has(.backoffice-theme-host.backoffice-layout-dark) {
    --backoffice-syncfusion-surface: rgba(13, 20, 33, 0.96);
    --backoffice-syncfusion-surface-alt: rgba(17, 27, 43, 0.98);
    --backoffice-syncfusion-header: rgba(19, 29, 46, 0.98);
    --backoffice-syncfusion-border: rgba(130, 148, 172, 0.18);
    --backoffice-syncfusion-text: #e8eef8;
    --backoffice-syncfusion-muted: #9fb2c9;
    --backoffice-syncfusion-accent: #74b0d5;
    --backoffice-syncfusion-accent-soft: rgba(116, 176, 213, 0.2);
    --backoffice-syncfusion-row-hover: rgba(116, 176, 213, 0.1);
    --backoffice-syncfusion-input-background: rgba(8, 14, 24, 0.94);
    --backoffice-syncfusion-input-border: rgba(116, 176, 213, 0.16);
}

body:has(.backoffice-theme-host.backoffice-layout-light) {
    --backoffice-syncfusion-surface: rgba(255, 255, 255, 0.98);
    --backoffice-syncfusion-surface-alt: rgba(247, 250, 253, 0.98);
    --backoffice-syncfusion-header: rgba(242, 246, 251, 0.98);
    --backoffice-syncfusion-border: rgba(92, 114, 140, 0.16);
    --backoffice-syncfusion-text: #18304b;
    --backoffice-syncfusion-muted: #607390;
    --backoffice-syncfusion-accent: #1f6899;
    --backoffice-syncfusion-accent-soft: rgba(31, 104, 153, 0.12);
    --backoffice-syncfusion-row-hover: rgba(31, 104, 153, 0.06);
    --backoffice-syncfusion-input-background: rgba(255, 255, 255, 0.98);
    --backoffice-syncfusion-input-border: rgba(31, 104, 153, 0.16);
}

/* Edit dialog popups portal to body, so style globally using the hoisted variables.
   `.e-dlg-container` is the outer wrapper Syncfusion injects around the dialog —
   theme it too so semi-transparent surfaces don't show a white seam underneath. */
body .e-dlg-container:has(> .e-dialog),
body .e-dialog.e-popup,
body .e-dialog.e-popup > *,
body .e-dialog.e-popup .e-dlg-header-content,
body .e-dialog.e-popup .e-dlg-content,
body .e-dialog.e-popup .e-footer-content {
    background: var(--backoffice-syncfusion-surface) !important;
    color: var(--backoffice-syncfusion-text) !important;
    border-color: var(--backoffice-syncfusion-border) !important;
}

body .e-dlg-container {
    background: transparent !important;
}

body .e-dialog.e-popup .e-dlg-header,
body .e-dialog.e-popup .e-dlg-header *,
body .e-dialog.e-popup label,
body .e-dialog.e-popup .e-label,
body .e-dialog.e-popup .e-float-text,
body .e-dialog.e-popup .e-float-text.e-label-top,
body .e-dialog.e-popup .e-float-text.e-label-bottom {
    color: var(--backoffice-syncfusion-text) !important;
}

body .e-dialog.e-popup .e-input,
body .e-dialog.e-popup .e-input-group,
body .e-dialog.e-popup .e-input-group.e-control-wrapper {
    background: var(--backoffice-syncfusion-input-background) !important;
    color: var(--backoffice-syncfusion-text) !important;
    border-color: var(--backoffice-syncfusion-input-border) !important;
}

body .e-dialog.e-popup .e-input::placeholder {
    color: var(--backoffice-syncfusion-muted) !important;
}

/* Row add/edit dialog: wider than Syncfusion's narrow default. */
body .e-dialog.e-popup.e-edit-dialog,
body .e-dialog.e-popup.e-edit-dialog .e-dlg-content {
    min-width: 36rem !important;
    width: min(48rem, calc(100vw - 4rem)) !important;
}


/* FileManager context menu portals to body — theme it with the hoisted vars. */
body ul.e-contextmenu {
    background: var(--backoffice-syncfusion-surface) !important;
    border-color: var(--backoffice-syncfusion-border) !important;
    color: var(--backoffice-syncfusion-text) !important;
}

body ul.e-contextmenu .e-menu-item,
body ul.e-contextmenu .e-menu-item .e-caret,
body ul.e-contextmenu .e-menu-item .e-menu-icon {
    color: var(--backoffice-syncfusion-text) !important;
    background: transparent !important;
}

body ul.e-contextmenu .e-menu-item.e-focused,
body ul.e-contextmenu .e-menu-item:hover {
    background: var(--backoffice-syncfusion-row-hover) !important;
}

body ul.e-contextmenu .e-menu-item.e-disabled {
    color: var(--backoffice-syncfusion-muted) !important;
}

body ul.e-contextmenu .e-separator {
    border-color: var(--backoffice-syncfusion-border) !important;
}

.dashboard-state,
.dashboard-empty {
    min-height: 18rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-align: center;
}

.dashboard-actions-cell {
    width: 13rem;
    text-align: right;
    white-space: nowrap;
}

.dashboard-dialog-shell {
    display: grid;
    gap: 1rem;
    min-width: min(32rem, 80vw);
}

.dashboard-dialog-tab-panel {
    padding: 1rem 0 0;
}

.dashboard-view-shell {
    display: grid;
    gap: 1.25rem;
}

.dashboard-view-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.dashboard-view-kicker {
    display: block;
    color: var(--mud-palette-primary);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
}

.dashboard-view-header h1 {
    margin: 0.15rem 0 0.25rem;
    font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.dashboard-view-header p {
    margin: 0;
    color: color-mix(in srgb, currentColor 72%, transparent);
}

.dashboard-view-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.dashboard-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.dashboard-filter-dialog {
    height: min(70vh, 42rem);
    width: 100%;
    display: flex;
    overflow: hidden;
    background: var(--mud-palette-background-grey);
}

.dashboard-filter-dialog-nav {
    width: 14rem;
    flex: 0 0 14rem;
    border-right: 1px solid var(--mud-palette-divider);
    overflow-y: auto;
    background: var(--mud-palette-background);
    padding: 0.5rem 0;
}

.dashboard-filter-dialog-content {
    flex: 1 1 auto;
    min-width: 0;
    overflow-y: auto;
    background: var(--mud-palette-background);
    padding: 1rem;
}

.dashboard-visual-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

/* ════════════════════════════════════════════════════════════════════
   Dashboard view canvas
   View mode uses the SAME positioning math as the layout editor
   (DashboardGridGeometry) so a saved layout renders pixel-identical in
   both pages. No Syncfusion: every panel is an absolutely positioned div
   inside a position:relative canvas.
   ════════════════════════════════════════════════════════════════════ */
.dashboard-view-canvas-wrapper {
    width: 100%;
    min-width: 0;
}

.dashboard-view-canvas {
    position: relative;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.dashboard-view-panel {
    position: absolute;
    box-sizing: border-box;
    overflow: hidden;
}

.dashboard-view-empty {
    width: 100%;
    min-height: 20rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    opacity: 0.5;
}

/* ════════════════════════════════════════════════════════════════════
   Custom Dashboard Layout Editor
   Dedicated page – no Syncfusion, no class collisions with the view-mode
   styles. All selectors are scoped under .layout-editor-*.
   ════════════════════════════════════════════════════════════════════ */

.layout-editor-shell {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem 2rem 3rem;
    max-width: 100%;
    min-width: 0;
}

.layout-editor-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.layout-editor-header h1 {
    margin: 0.2rem 0 0.2rem;
    font-size: 1.55rem;
    font-weight: 700;
}

.layout-editor-header p {
    margin: 0;
    opacity: 0.7;
    font-size: 0.85rem;
}

.layout-editor-kicker {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    opacity: 0.6;
    font-weight: 600;
}

.layout-editor-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.layout-editor-canvas-wrapper {
    width: 100%;
    min-width: 0;
}

/* The canvas is a position:relative container; every panel inside is
   absolutely positioned with percentages for left/width (responsive)
   and pixels for top/height (predictable row sizing). */
.layout-editor-canvas {
    position: relative;
    width: 100%;
    min-width: 0;
    background: transparent;
    box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.22);
    border-radius: 8px;
    box-sizing: border-box;
    user-select: none;
}

/* Faint dashed column guides so the grid is legible */
.layout-editor-grid-col {
    position: absolute;
    border-left: 1px dashed rgba(128, 128, 128, 0.18);
    border-right: 1px dashed rgba(128, 128, 128, 0.18);
    pointer-events: none;
    z-index: 0;
}

/* Each chart panel: absolute positioning controlled inline by C#.
   No transforms, no transitions on layout properties — JS sets pixel
   values directly during drag/resize. */
/* No header strip — the whole panel body is the drag handle. */
.layout-editor-panel {
    position: absolute;
    background: transparent;
    border: 1px solid rgba(128, 128, 128, 0.35);
    border-radius: 6px;
    overflow: hidden;
    box-sizing: border-box;
    z-index: 1;
}

.layout-editor-panel:hover {
    border-color: rgba(128, 128, 128, 0.7);
}

.layout-editor-panel-dragging,
.layout-editor-panel-resizing {
    border-color: rgba(128, 128, 128, 0.95) !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    opacity: 0.95;
    pointer-events: none; /* let the global JS listeners own the mouse */
}

.layout-editor-panel-body {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

/* Transparent overlay above the chart that captures all pointer events.
   This serves two purposes: it stops the chart from receiving tooltips/clicks
   during layout editing, and it makes the entire panel face a drag handle. */
.layout-editor-panel-body-blocker {
    position: absolute;
    inset: 0;
    z-index: 10;
    cursor: grab;
    background: transparent;
}

.layout-editor-panel-body-blocker:active {
    cursor: grabbing;
}

/* Resize handle in bottom-right corner */
.layout-editor-panel-resize {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    background:
        linear-gradient(
            135deg,
            transparent 0%,
            transparent 50%,
            rgba(128, 128, 128, 0.55) 50%,
            rgba(128, 128, 128, 0.55) 60%,
            transparent 60%,
            transparent 70%,
            rgba(128, 128, 128, 0.55) 70%,
            rgba(128, 128, 128, 0.55) 80%,
            transparent 80%
        );
    z-index: 20;
}

.layout-editor-panel-resize:hover {
    background-color: rgba(128, 128, 128, 0.15);
}

/* Snap-target preview shown during drag/resize. Hidden by default;
   JS adds .layout-editor-ghost-visible to reveal it. */
.layout-editor-ghost {
    position: absolute;
    display: none;
    border: 2px dashed rgba(128, 128, 128, 0.7);
    background: rgba(128, 128, 128, 0.10);
    border-radius: 6px;
    pointer-events: none;
    z-index: 50;
    box-sizing: border-box;
}

.layout-editor-ghost-visible {
    display: block;
}

.layout-editor-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    opacity: 0.5;
    pointer-events: none;
}

/* Global cursors while interacting so the cursor doesn't flicker
   when the mouse leaves the panel */
body.layout-editor-grabbing,
body.layout-editor-grabbing * {
    cursor: grabbing !important;
}

body.layout-editor-resizing,
body.layout-editor-resizing * {
    cursor: nwse-resize !important;
}

.caducore-gauge-tooltip {
    background: rgba(33, 33, 33, 0.92);
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

.dashboard-visual {
    position: relative;
    height: 100%;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.dashboard-visual-body {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dashboard-visual-body > * {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

.dashboard-chart-host {
    min-width: 0;
    width: 100%;
    flex: 1 1 auto;
}

.dashboard-visual-card {
    grid-column: span 1;
}

.dashboard-visual-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.dashboard-visual-header span {
    color: var(--dashboard-accent);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.dashboard-visual-header h2 {
    margin: 0.15rem 0 0;
    font-size: 1.05rem;
}

.dashboard-visual-header strong {
    color: var(--dashboard-accent);
    font-size: 1.6rem;
}

.dashboard-visual-actions {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.15rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--mud-palette-surface) 85%, transparent);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.dashboard-visual:hover .dashboard-visual-actions,
.dashboard-visual:focus-within .dashboard-visual-actions {
    opacity: 1;
    pointer-events: auto;
}

.dashboard-visual-loading {
    min-height: 11rem;
    display: grid;
    place-items: center;
}

.dashboard-card-figure {
    height: 11rem;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 0.35rem;
}

.dashboard-card-figure span {
    color: var(--dashboard-accent);
    font-size: 3rem;
    font-weight: 800;
}

.dashboard-card-figure small,
.dashboard-bar-column small {
    color: color-mix(in srgb, currentColor 62%, transparent);
}

.dashboard-bar-chart {
    height: 12rem;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: end;
    gap: 0.75rem;
    padding-top: 1rem;
}

.dashboard-bar-column {
    height: 100%;
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 0.5rem;
    align-items: end;
    text-align: center;
}

.dashboard-bar-column span {
    display: block;
    min-height: 0.5rem;
    border-radius: 0.45rem 0.45rem 0 0;
    background: var(--dashboard-accent);
}

.dashboard-line-chart {
    width: 100%;
    height: 12rem;
    margin-top: 1rem;
}

.dashboard-line-chart polyline {
    fill: none;
    stroke: var(--dashboard-accent);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dashboard-pie-chart {
    width: min(12rem, 80%);
    aspect-ratio: 1;
    border-radius: 50%;
    margin: 1.25rem auto 0;
    box-shadow: inset 0 0 0 1rem color-mix(in srgb, var(--mud-palette-surface) 96%, transparent);
}

.dashboard-pie-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem 0.75rem;
    margin-top: 1rem;
    color: color-mix(in srgb, currentColor 65%, transparent);
    font-size: 0.8rem;
}

@media (max-width: 900px) {
    .dashboard-filter-bar,
    .dashboard-visual-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-view-header {
        flex-direction: column;
    }

    .dashboard-view-actions {
        justify-content: flex-start;
    }

    /* The filter editor's split-pane layout (nav + content) is too cramped
       on tablet — stack the nav above the content. */
    .dashboard-filter-dialog {
        flex-direction: column;
        height: auto;
        max-height: 80vh;
    }

    .dashboard-filter-dialog-nav {
        width: 100%;
        flex: 0 0 auto;
        max-height: 14rem;
        border-right: none;
        border-bottom: 1px solid var(--mud-palette-divider);
    }
}

/* ════════════════════════════════════════════════════════════════════
   Mobile (≤600px) — backoffice-wide
   Everything here is shared across pages: dialogs, dashboard view,
   layout editor, pagination chrome, and visualization-renderer
   action bars. Keep page-specific phone overrides in the page's
   scoped CSS, not here.
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 599.98px) {
    /* ── Dashboard header collapses tighter than the 900px breakpoint */
    .dashboard-view-header h1 {
        font-size: clamp(1.45rem, 6vw, 1.85rem);
    }

    .dashboard-view-header p {
        font-size: 0.88rem;
    }

    .dashboard-view-actions {
        width: 100%;
    }

    .dashboard-view-actions > * {
        flex: 1 1 auto;
    }

    /* ── Dashboard view canvas: panels stack vertically and become
       full-width so charts stay readable on a phone. The absolute
       positioning math from DashboardGridGeometry assumes ~12 columns
       of horizontal room, which doesn't make sense at this width. */
    .dashboard-view-canvas {
        height: auto !important;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .dashboard-view-panel {
        position: static !important;
        width: 100% !important;
        left: 0 !important;
        top: 0 !important;
        height: auto !important;
        min-height: 18rem;
    }

    /* ── Layout editor: drag/resize is a desktop-class interaction
       (no touch support today). Make the toolbar usable but the
       canvas still works — the user can at least preview. */
    .layout-editor-shell {
        padding: 0.75rem 0.85rem 2rem;
        gap: 0.85rem;
    }

    .layout-editor-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .layout-editor-header h1 {
        font-size: 1.3rem;
    }

    .layout-editor-actions {
        width: 100%;
    }

    .layout-editor-actions > * {
        flex: 1 1 auto;
    }

    .layout-editor-canvas-editable {
        min-height: 24rem;
        padding: 4px;
    }

    /* ── Per-chart action bar in dashboard panels (fullscreen/download/
       edit/delete buttons). Reduce horizontal spacing so they don't
       crowd the chart on narrow panels. */
    .dashboard-visual-actions {
        gap: 0.1rem;
        padding: 0.2rem;
    }

    /* ── Pagination bar wraps onto a second row instead of scrolling */
    .dashboard-pagination-bar {
        flex-wrap: wrap;
    }
}

/* ════════════════════════════════════════════════════════════════════
   Dialog full-width on phones
   MudBlazor dialogs default to a centered box; on a 320–600px viewport
   that wastes horizontal pixels and the content gets cramped. Take the
   full width with a tiny side margin.
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 599.98px) {
    .mud-dialog-container .mud-dialog {
        width: calc(100vw - 1rem) !important;
        max-width: calc(100vw - 1rem) !important;
        min-width: 0 !important;
        margin: 0.5rem !important;
    }

    .mud-dialog-container .mud-dialog .mud-dialog-content {
        padding: 1rem 0.85rem;
    }

    .mud-dialog-container .mud-dialog .mud-dialog-actions {
        padding: 0.75rem 0.85rem;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .mud-dialog-container .mud-dialog .mud-dialog-actions > * {
        flex: 1 1 auto;
    }

    /* Dialog content shells used across the app collapse their grid
       gaps so the form fields breathe in the smaller space. */
    .dynamic-dialog-shell {
        gap: 0.7rem;
    }

    .dynamic-dialog-actions-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .dynamic-dialog-actions-row > * {
        width: 100%;
    }

    /* ── Dashboard / chart dialogs: stack the fixed split-pane layouts ──
       These dialogs use inline pixel widths/heights for their nav+content
       split panes, so the overrides below need !important to win over the
       inline style. On a phone the nav drops above the content and both
       go full-width. */

    /* Chart type picker (categories sidebar + grid) */
    .chart-type-dialog-body {
        flex-direction: column !important;
        height: auto !important;
        max-height: 70vh;
        overflow-y: auto !important;
    }

    .chart-type-dialog-nav {
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--mud-palette-divider) !important;
        max-height: 13rem;
    }

    /* Runtime global-filters editor (settings nav + content) */
    .dashboard-filter-dialog {
        flex-direction: column !important;
        height: auto !important;
        max-height: 78vh;
    }

    .dashboard-filter-dialog-nav {
        width: 100% !important;
        flex: 0 0 auto !important;
        max-height: 12rem;
        border-right: none !important;
        border-bottom: 1px solid var(--mud-palette-divider) !important;
    }

    /* Series editor field/operator/value row stacks vertically */
    .series-editor-condition-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.6rem !important;
    }

    /* Fullscreen visualization preview shrinks its body height so the
       chart + header fit a phone screen without inner scroll. */
    .dashboard-visual-fullscreen-body {
        height: 62vh !important;
    }
}

.caducore-gauge {
    position: relative;
}

.caducore-gauge .e-circulargauge {
    width: 100% !important;
    height: 100% !important;
}

.caducore-gauge .e-circulargauge > svg {
    width: 100% !important;
    height: 100% !important;
}
