/* Opt-in Material appearance. Every rule is scoped; Current keeps the original cascade.
   Screen-only loading also leaves printed reports unchanged. */
html[data-system-theme="material"] {
    --mt-primary: #4f46a5;
    --mt-primary-hover: #3e358b;
    --mt-on-primary: #fff;
    --mt-tint: #eeebff;
    --mt-surface: #fff;
    --mt-canvas: #f5f5fa;
    --mt-text: #252334;
    --mt-muted: #646174;
    --mt-line: #d7d4e2;
    --mt-shadow: 0 2px 8px rgba(35, 27, 68, .08), 0 1px 2px rgba(35, 27, 68, .05);
    --bg-gradient: linear-gradient(120deg, #4f46a5, #7463bf);
    accent-color: var(--mt-primary);
    color-scheme: light;
}
html[data-system-theme="material"] body {
    background: var(--mt-canvas) !important;
    color: var(--mt-text);
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.5;
}
html[data-system-theme="material"] :is(.app-container, .app-main, .app-main__outer, .app-main__inner, .page-wraper, .page-content) {
    background: var(--mt-canvas) !important;
}
html[data-system-theme="material"] :is(h1, h2, h3, h4, h5, h6, .heading, .headingText, .card-header, .modal-title) {
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    letter-spacing: -.02em;
}
html[data-system-theme="material"] :is(.card, .main-card, .modal-content, .swal-modal, .swal2-popup, .list-group) {
    background: var(--mt-surface) !important;
    color: var(--mt-text);
    border: 1px solid #e6e3ee !important;
    border-radius: 16px !important;
    box-shadow: var(--mt-shadow) !important;
}
html[data-system-theme="material"] :is(.card-header, .modal-header, .swal-title, .swal2-title) {
    background: var(--mt-surface) !important;
    color: var(--mt-text) !important;
    border-bottom: 1px solid #ebe8f1 !important;
    border-radius: 16px 16px 0 0 !important;
    font-weight: 600;
    text-transform: none;
}
html[data-system-theme="material"] :is(.card-header, .modal-header) { padding: 16px 20px; }
html[data-system-theme="material"] :is(.card-footer, .modal-footer) {
    background: #faf9fd !important;
    border-top: 1px solid #ebe8f1 !important;
    border-radius: 0 0 16px 16px !important;
    padding: 12px 20px;
}
html[data-system-theme="material"] .card-body { padding: 20px; }
html[data-system-theme="material"] :is(.box-shadow-32, .form-group[class*="box-shadow"]) { box-shadow: none !important; }
html[data-system-theme="material"] :is(label, .form-label, .control-label) { color: var(--mt-muted); font-weight: 600; font-size: .875rem; }

/* Native inputs, Selectize, Select2, multi-select and Kendo field wrappers. */
html[data-system-theme="material"] :is(input:not([type]), input[type="text"], input[type="password"], input[type="email"], input[type="tel"], input[type="url"], input[type="search"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"], input[type="week"], textarea, select, .form-control:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]), .form-select, .selectize-input, .select2-selection, .multi-select-button, .k-picker, .k-input, .k-picker-wrap, .k-numeric-wrap, .k-dropdown-wrap) {
    background-color: var(--mt-surface) !important;
    color: var(--mt-text);
    border: 1px solid #aaa5b9 !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    font-family: inherit;
    font-size: .9rem;
    min-height: 40px;
    height: auto;
    padding: 8px 12px;
    transition: border-color .15s, box-shadow .15s;
}
html[data-system-theme="material"] textarea { min-height: 88px; resize: vertical; }
html[data-system-theme="material"] :is(input, textarea)::placeholder { color: #777184; opacity: 1; }
html[data-system-theme="material"] :is(input, textarea, select, .form-control, .form-select):focus,
html[data-system-theme="material"] :is(.selectize-input.focus, .select2-container--focus .select2-selection, .k-picker:focus-within, .k-input:focus-within, .k-picker-wrap:focus-within) {
    border-color: var(--mt-primary) !important;
    box-shadow: 0 0 0 2px rgba(79, 70, 165, .2) !important;
    outline: none;
}
html[data-system-theme="material"] :is(input, textarea, select):disabled,
html[data-system-theme="material"] :is(.selectize-control.disabled .selectize-input, .k-disabled, .k-state-disabled) {
    background-color: #efedf3 !important;
    color: #757080;
    cursor: not-allowed;
    opacity: .75;
}
html[data-system-theme="material"] :is(input, textarea)[readonly] { background-color: #f6f4f9 !important; }
html[data-system-theme="material"] :is(.input-validation-error, .is-invalid, [aria-invalid="true"]) { border-color: #b3261e !important; }
html[data-system-theme="material"] :is(.field-validation-error, .invalid-feedback, .validation-summary-errors) { color: #b3261e; }
html[data-system-theme="material"] :is(.selectize-input, .select2-selection) { display: block; }
html[data-system-theme="material"] :is(.selectize-input > input, .select2-search__field, .k-input-inner, .k-input > input, .k-picker > input, .k-picker-wrap > input, .k-numeric-wrap > input) {
    border: 0 !important;
    border-radius: 0 !important;
    min-height: 0;
    padding: 0;
    box-shadow: none !important;
    background: transparent !important;
}
html[data-system-theme="material"] :is(.k-picker, .k-input, .k-picker-wrap, .k-numeric-wrap, .k-dropdown-wrap) { padding: 0; }
html[data-system-theme="material"] :is(.k-input-inner, .k-picker-wrap > input, .k-numeric-wrap > input) { padding: 8px 12px; }
html[data-system-theme="material"] .multi-select-button { height: auto !important; }
html[data-system-theme="material"] :is(.selectize-dropdown, .select2-dropdown, .multi-select-menu, .dropdown-menu, .k-popup, .k-list-container, .ui-datepicker, .datepicker-dropdown, .bootstrap-datetimepicker-widget, .flatpickr-calendar, .daterangepicker) {
    background: var(--mt-surface) !important;
    color: var(--mt-text);
    border: 1px solid #e4dfed !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 28px rgba(35, 27, 68, .18) !important;
}
html[data-system-theme="material"] :is(.selectize-dropdown .option, .dropdown-item, .k-list-item, .select2-results__option) { padding: 10px 14px; }
html[data-system-theme="material"] :is(.selectize-dropdown .active, .dropdown-item:hover, .dropdown-item:focus, .k-list-item.k-hover, .k-state-hover, .select2-results__option--highlighted) {
    background: var(--mt-tint) !important;
    color: var(--mt-primary) !important;
}
html[data-system-theme="material"] :is(.selectize-control.multi .selectize-input > div, .select2-selection__choice) {
    border: 0 !important;
    border-radius: 6px !important;
    padding: 3px 8px;
    background: var(--mt-tint) !important;
    color: var(--mt-primary) !important;
}
html[data-system-theme="material"] .input-group-text { background: #f0edf7; border-color: #aaa5b9; border-radius: 8px; color: var(--mt-muted); }
html[data-system-theme="material"] :is(input[type="checkbox"], input[type="radio"]) {
    appearance: auto !important;
    -webkit-appearance: auto !important;
    accent-color: var(--mt-primary);
    width: 20px !important;
    height: 20px !important;
    min-height: 20px;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    vertical-align: middle;
    cursor: pointer;
}
html[data-system-theme="material"] .form-switch .form-check-input {
    appearance: none !important;
    -webkit-appearance: none !important;
    width: 40px !important;
    height: 24px !important;
    border: 2px solid #8c859d !important;
    border-radius: 20px;
    background-color: #e7e1ef;
    background-image: radial-gradient(circle, #797187 0 6px, transparent 7px) !important;
    background-size: 20px 20px;
    background-position: left center;
    background-repeat: no-repeat;
}
html[data-system-theme="material"] .form-switch .form-check-input:checked {
    border-color: var(--mt-primary) !important;
    background-color: var(--mt-primary);
    background-image: radial-gradient(circle, white 0 7px, transparent 8px) !important;
    background-position: right center;
}
html[data-system-theme="material"] input[type="range"] { accent-color: var(--mt-primary); }
html[data-system-theme="material"] input[type="color"] { height: 40px; border: 1px solid var(--mt-line); border-radius: 8px; padding: 4px; }
html[data-system-theme="material"] input[type="file"]::file-selector-button { border: 0; border-radius: 6px; padding: 6px 12px; background: var(--mt-tint); color: var(--mt-primary); }

/* Raised and tonal actions retain success/danger meanings. */
html[data-system-theme="material"] :is(.btn, .k-button, .swal-button, .swal2-styled) {
    border-radius: 20px !important;
    font-family: inherit;
    font-weight: 600;
    letter-spacing: .01em;
    box-shadow: none;
    transition: background-color .15s, box-shadow .15s;
}
html[data-system-theme="material"] :is(.btn, .k-button) { min-height: 36px; padding: 7px 16px; }
html[data-system-theme="material"] :is(.btn-primary, .k-button-solid-primary, .k-primary, .swal-button--confirm, .swal2-confirm) { background: var(--mt-primary) !important; color: white !important; border-color: var(--mt-primary) !important; box-shadow: var(--mt-shadow); }
html[data-system-theme="material"] :is(.btn-primary:hover, .k-button-solid-primary:hover, .swal2-confirm:hover) { background: var(--mt-primary-hover) !important; }
html[data-system-theme="material"] :is(.btn-outline-primary, .btn-light, .btn-secondary, .btn-info) { background: var(--mt-tint); color: var(--mt-primary); border-color: transparent; }
html[data-system-theme="material"] .btn-success { background: #176b4a; border-color: #176b4a; color: white; }
html[data-system-theme="material"] .btn-danger { background: #b3261e; border-color: #b3261e; color: white; }
html[data-system-theme="material"] .btn-warning { background: #f8df9e; border-color: #f8df9e; color: #563f05; }
html[data-system-theme="material"] :is(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid #9b8ee0; outline-offset: 3px; }
html[data-system-theme="material"] :is(.btn, button):disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
html[data-system-theme="material"] .btn-group > .btn { border-radius: 6px !important; }
html[data-system-theme="material"] :is(.nav-tabs, .nav-pills) { border-bottom: 1px solid var(--mt-line); gap: 4px; padding: 4px; }
html[data-system-theme="material"] :is(.nav-tabs, .nav-pills) .nav-link { color: var(--mt-muted); border: 0 !important; background: transparent; border-radius: 20px !important; padding: 10px 18px; font-weight: 600; }
html[data-system-theme="material"] :is(.nav-tabs, .nav-pills) .nav-link.active { color: var(--mt-primary) !important; background: var(--mt-tint) !important; box-shadow: none !important; }

/* Tables include DataTables and Kendo grids, without recoloring financial values. */
html[data-system-theme="material"] :is(table, .table, .k-grid) { background-color: var(--mt-surface); border-color: var(--mt-line) !important; font-family: inherit; }
html[data-system-theme="material"] :is(.table, table.dataTable, .k-grid-table) > thead > tr > :is(th, td),
html[data-system-theme="material"] :is(.k-grid-header, .k-grid-header th) { background: #eeebf6 !important; color: #51486b !important; border-color: #ded8ea !important; font-weight: 600; padding: 12px 14px; }
html[data-system-theme="material"] :is(.table, table.dataTable, .k-grid-table) > tbody > tr > :is(td, th) { padding: 10px 14px; border-color: #e8e4ee !important; vertical-align: middle; }
html[data-system-theme="material"] :is(.table, table.dataTable) > tbody > tr:nth-child(even):not(.selected):not([class*="table-"]) { background-color: #f9f8fc; }
html[data-system-theme="material"] :is(.table, table.dataTable) > tbody > tr.odd { background-color: var(--mt-surface); }
html[data-system-theme="material"] :is(.table-hover, table.dataTable) > tbody > tr:hover { background-color: #f0ecfa !important; }
html[data-system-theme="material"] :is(table.dataTable tbody tr.selected, .k-grid .k-selected, .k-grid .k-state-selected) { background-color: #e6dff9 !important; color: #35265d; }
html[data-system-theme="material"] :is(.table, table.dataTable) > tfoot > tr > :is(th, td) { background-color: #f2eff8; border-top: 2px solid #d5cde5; font-weight: 600; padding: 12px 14px; }
html[data-system-theme="material"] :is(.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter, .dataTables_wrapper .dataTables_paginate) { color: var(--mt-muted); padding-top: 12px; padding-bottom: 12px; }
html[data-system-theme="material"] :is(.page-link, .dataTables_paginate .paginate_button, .k-pager-numbers .k-link) { border: 0 !important; border-radius: 50% !important; color: var(--mt-primary); background: transparent; margin: 2px; }
html[data-system-theme="material"] :is(.page-item.active .page-link, .dataTables_paginate .paginate_button.current, .k-pager-numbers .k-selected) { background: var(--mt-primary) !important; color: white !important; }
html[data-system-theme="material"] :is(.dataTables_scroll, .table-responsive, .k-grid) { border-radius: 12px; }

/* Calendars, time pickers and their body-level popups. */
html[data-system-theme="material"] :is(.k-calendar, .k-timepicker, .k-time-container, .k-datetime-container, .k-dateinput, .k-list) { background-color: var(--mt-surface); color: var(--mt-text); border-color: var(--mt-line); font-family: inherit; }
html[data-system-theme="material"] :is(.k-calendar-header, .k-calendar .k-header, .ui-datepicker-header, .datepicker .datepicker-switch) { background: var(--mt-tint); color: var(--mt-primary); border: 0; padding: 10px; }
html[data-system-theme="material"] :is(.k-calendar .k-link, .flatpickr-day, .datepicker td.day, .ui-datepicker td a) { border-radius: 50%; }
html[data-system-theme="material"] :is(.k-calendar .k-selected .k-link, .k-calendar .k-state-selected .k-link, .k-calendar td.k-selected, .k-list .k-selected, .k-list .k-state-selected, .flatpickr-day.selected, .datepicker td.active, .ui-datepicker .ui-state-active, .bootstrap-datetimepicker-widget td.active, .daterangepicker td.active) { background: var(--mt-primary) !important; color: white !important; border-color: var(--mt-primary) !important; }
html[data-system-theme="material"] :is(.k-calendar .k-today .k-link, .flatpickr-day.today) { box-shadow: inset 0 0 0 1px var(--mt-primary); }
html[data-system-theme="material"] :is(.k-input-button, .k-select) { background: #f0ecf8; color: var(--mt-primary); border-color: var(--mt-line); }

/* Application chrome, off-canvas menus, login and user navigation. */
html[data-system-theme="material"] :is(#header_Menu .inner-wrapper, .app-header, .body-header, .header) { background: var(--bg-gradient) !important; color: white; box-shadow: 0 3px 12px rgba(44, 31, 94, .16); }
html[data-system-theme="material"] :is(.body-footer, .menubar-area, .app-footer, .app-footer__inner) { background: #f1edf8 !important; color: var(--mt-primary); border-top: 1px solid #dcd4ea; box-shadow: 0 -2px 12px rgba(35, 27, 68, .06); }
html[data-system-theme="material"] :is(.body-footer, .menubar-area) :is(a, .nav-link) { color: #5d5276 !important; border-radius: 16px; }
html[data-system-theme="material"] :is(.body-footer, .menubar-area) :is(a.active, .nav-link.active) { background: #e1d9f3 !important; color: #38266b !important; }
html[data-system-theme="material"] :is(.app-sidebar, .hc-offcanvas-nav .nav-container, .hc-offcanvas-nav .nav-content, .hc-offcanvas-nav .nav-wrapper, .hc-offcanvas-nav ul) { background: #f8f6fc !important; color: var(--mt-text); }
html[data-system-theme="material"] .hc-offcanvas-nav :is(h2, .nav-title) { background: #eee8f8 !important; color: var(--mt-primary) !important; border: 0; }
html[data-system-theme="material"] .hc-offcanvas-nav :is(.nav-item-link, a, .nav-close-button) { background: transparent; color: #494255 !important; border-color: #e8e2ef !important; }
html[data-system-theme="material"] .hc-offcanvas-nav .nav-item-link { margin: 3px 8px; border-radius: 22px; }
html[data-system-theme="material"] .hc-offcanvas-nav :is(.nav-item-link:hover, .nav-item-link.active) { background: #e7dff5 !important; color: #392766 !important; }
html[data-system-theme="material"] .hc-offcanvas-nav :is(.nav-next span::before, .nav-back span::before, .nav-close span::before, .nav-close span::after) { border-color: var(--mt-primary) !important; }
html[data-system-theme="material"] .version-info { background: #e7e0f2 !important; color: #514669; }
html[data-system-theme="material"] :is(.list-group-item, .accordion-item, .accordion-button) { background: var(--mt-surface); border-color: var(--mt-line); color: var(--mt-text); }
html[data-system-theme="material"] :is(.list-group-item.active, .accordion-button:not(.collapsed)) { background: var(--mt-tint); color: var(--mt-primary); }
html[data-system-theme="material"] :is(.badge, .alert, .breadcrumb, .toast, .jq-toast-single) { border-radius: 10px; }
html[data-system-theme="material"] :is(.progress, .progress-bar) { border-radius: 20px; }
html[data-system-theme="material"] .progress-bar { background-color: var(--mt-primary); }
html[data-system-theme="material"] .modal-backdrop { background: #201832; }
html[data-system-theme="material"] .tooltip-inner { background: #373043; border-radius: 8px; padding: 8px 12px; }
@media (max-width: 576px) {
    html[data-system-theme="material"] .card-body { padding: 12px; }
    html[data-system-theme="material"] :is(.card-header, .card-footer, .modal-header, .modal-footer) { padding: 12px; }
    html[data-system-theme="material"] :is(.nav-tabs, .nav-pills) .nav-link { padding: 8px 12px; }
    html[data-system-theme="material"] :is(.table, table.dataTable) > tbody > tr > :is(td, th) { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    html[data-system-theme="material"] *, html[data-system-theme="material"] *::before, html[data-system-theme="material"] *::after { transition: none !important; animation: none !important; }
}
