/* Application-owned theme. Package assets and printable documents stay independent. */
:root {
    --crm-page: #f8fafc;
    --crm-surface: #fff;
    --crm-raised: #fff;
    --crm-subtle: #f8f9fa;
    --crm-hover: #e9ecef;
    --crm-input: #fff;
    --crm-text: #212529;
    --crm-muted: #6c757d;
    --crm-border: #dee2e6;
    --crm-border-strong: #adb5bd;
    --crm-link: #2176bd;
    --crm-primary: #3490dc;
    --crm-primary-hover: #227dc7;
    --crm-primary-text: #fff;
    --crm-focus: #3490dc;
    --crm-info-bg: #eaf4fc;
    --crm-info-text: #2176bd;
    --crm-success-bg: #d7f3e3;
    --crm-success-text: #1d643b;
    --crm-warning-bg: #fff3cd;
    --crm-warning-text: #856404;
    --crm-danger-bg: #f8d7da;
    --crm-danger-text: #761b18;
    --crm-overlay: #0006;
    --crm-shadow: #00000030;
}
:root[data-crm-theme="dark"] {
    /* Codex's bundled gray-200/100/300/350/850/700 dark palette. */
    --crm-page: #212121;
    --crm-surface: #212121;
    --crm-raised: #303030;
    --crm-subtle: #181818;
    --crm-hover: #393939;
    --crm-input: #303030;
    --crm-text: #dcdcdc;
    --crm-muted: #afafaf;
    --crm-border: #ffffff1f;
    --crm-border-strong: #ffffff33;
    --crm-link: #dcdcdc;
    --crm-primary: #f3f3f3;
    --crm-primary-hover: #ededed;
    --crm-primary-text: #0d0d0d;
    --crm-focus: #fff;
    --crm-info-bg: #00284d;
    --crm-info-text: #99ceff;
    --crm-success-bg: #173e30;
    --crm-success-text: #9be3bc;
    --crm-warning-bg: #493b19;
    --crm-warning-text: #f6d77d;
    --crm-danger-bg: #4b252d;
    --crm-danger-text: #ffb9c1;
    --crm-overlay: #0009;
    --crm-shadow: #0008;
}
.crm-theme-control {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    margin: 0;
    padding: .4rem .65rem;
    font: inherit;
    font-size: .8rem;
    color: var(--crm-muted);
}
.crm-theme-control select {
    width: auto;
    min-width: 88px;
    min-height: 36px;
    padding: .3rem 1.8rem .3rem .55rem;
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    background-color: var(--crm-input);
    color: var(--crm-text);
    font: inherit;
}
.crm-theme-control select:focus-visible { outline: 2px solid var(--crm-focus); outline-offset: 2px; }
.crm-auth-theme { display: flex; justify-content: center; padding: .75rem; }
.crm-error { margin: 0; min-height: 100vh; display: grid; place-items: center; background: var(--crm-page); color: var(--crm-text); font-family: system-ui, sans-serif; }
.crm-error main { padding: 2rem; text-align: center; }
.crm-error h1 { font-size: 3rem; margin: 0; }
.crm-error a { color: var(--crm-link); }

/* Bootstrap screens, including components inherited from the package. */
@media screen {
    :root[data-crm-theme="dark"] {
        --crm-page-custom: var(--crm-page);
        --crm-surface-custom: var(--crm-surface);
        --crm-subtle-custom: var(--crm-subtle);
        --crm-hover-custom: var(--crm-hover);
        --crm-border-custom: var(--crm-border);
        --crm-border-strong-custom: var(--crm-border-strong);
        --crm-text-custom: var(--crm-text);
        --crm-muted-custom: var(--crm-muted);
        --crm-info-bg-custom: var(--crm-info-bg);
        --crm-info-text-custom: var(--crm-info-text);
        --crm-link-custom: var(--crm-link);
        --crm-success-bg-custom: var(--crm-success-bg);
        --crm-success-text-custom: var(--crm-success-text);
        --crm-warning-text-custom: var(--crm-warning-text);
        --crm-danger-text-custom: var(--crm-danger-text);
    }
    [data-crm-theme="dark"] body.crm-app { background: var(--crm-page); color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .footer { background-color: var(--crm-subtle); }
    [data-crm-theme="dark"] .crm-app a:not(.btn):not(.badge):not(.nav-link):not(.dropdown-item):not(.page-link):not(.ticket-card-title):not(.crm-job-summary) { color: var(--crm-link); }
    [data-crm-theme="dark"] .crm-app .card,
    [data-crm-theme="dark"] .crm-app .list-group-item,
    [data-crm-theme="dark"] .crm-app .modal-content { background-color: var(--crm-surface); color: var(--crm-text); border-color: var(--crm-border); }
    [data-crm-theme="dark"] .crm-app .card-header,
    [data-crm-theme="dark"] .crm-app .card-footer { background-color: var(--crm-subtle); border-color: var(--crm-border); }
    [data-crm-theme="dark"] .crm-app .bg-white { background-color: var(--crm-surface) !important; }
    [data-crm-theme="dark"] .crm-app .bg-light { background-color: var(--crm-subtle) !important; }
    [data-crm-theme="dark"] .crm-app .bg-dark { background-color: #131313 !important; }
    [data-crm-theme="dark"] .crm-app .bg-secondary { background-color: #414141 !important; }
    [data-crm-theme="dark"] .crm-app .text-dark,
    [data-crm-theme="dark"] .crm-app .text-body { color: var(--crm-text) !important; }
    [data-crm-theme="dark"] .crm-app .text-muted,
    [data-crm-theme="dark"] .crm-app .text-secondary { color: var(--crm-muted) !important; }
    [data-crm-theme="dark"] .crm-app .text-primary { color: var(--crm-text) !important; }
    [data-crm-theme="dark"] .crm-app .text-info { color: var(--crm-info-text) !important; }
    [data-crm-theme="dark"] .crm-app .text-success { color: var(--crm-success-text) !important; }
    [data-crm-theme="dark"] .crm-app .text-danger,
    [data-crm-theme="dark"] .crm-app .invalid-feedback,
    [data-crm-theme="dark"] .crm-app .invalid-feedback-custom { color: var(--crm-danger-text) !important; }
    [data-crm-theme="dark"] .crm-app .text-warning { color: var(--crm-warning-text) !important; }
    [data-crm-theme="dark"] .crm-app .border,
    [data-crm-theme="dark"] .crm-app .border-top,
    [data-crm-theme="dark"] .crm-app .border-bottom,
    [data-crm-theme="dark"] .crm-app .border-left,
    [data-crm-theme="dark"] .crm-app .border-right { border-color: var(--crm-border) !important; }
    [data-crm-theme="dark"] .crm-app hr,
    [data-crm-theme="dark"] .crm-app .modal-header,
    [data-crm-theme="dark"] .crm-app .modal-footer { border-color: var(--crm-border); }
    [data-crm-theme="dark"] .crm-app .navbar-light .navbar-brand,
    [data-crm-theme="dark"] .crm-app .navbar-light .navbar-nav .nav-link,
    [data-crm-theme="dark"] .crm-app .navbar-light .navbar-toggler { color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .navbar-light .navbar-toggler { border-color: var(--crm-border); }
    [data-crm-theme="dark"] .crm-app .navbar-toggler-icon { filter: invert(1); }
    [data-crm-theme="dark"] .crm-app .nav-link { color: var(--crm-link); }
    [data-crm-theme="dark"] .crm-app .nav-pills .nav-link.active { background: var(--crm-raised); color: #fff; }
    [data-crm-theme="dark"] .crm-app .nav-tabs { border-color: var(--crm-border); }
    [data-crm-theme="dark"] .crm-app .nav-tabs .nav-link:hover { background: var(--crm-hover); border-color: var(--crm-border); }
    [data-crm-theme="dark"] .crm-app .nav-tabs .nav-link.active,
    [data-crm-theme="dark"] .crm-app .nav-tabs .nav-item.show .nav-link { background: var(--crm-surface) !important; color: var(--crm-text); border-color: var(--crm-border); border-bottom-color: var(--crm-surface) !important; }
    [data-crm-theme="dark"] .crm-app .table { color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .table th,
    [data-crm-theme="dark"] .crm-app .table td,
    [data-crm-theme="dark"] .crm-app .table thead th { border-color: var(--crm-border); }
    [data-crm-theme="dark"] .crm-app .table .thead-light th { background: var(--crm-raised); color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .table-striped tbody tr:nth-of-type(odd) { background: #ffffff04; }
    [data-crm-theme="dark"] .crm-app .table-hover tbody tr:hover { background: var(--crm-hover); color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .table-active,
    [data-crm-theme="dark"] .crm-app .table-active > td { background: var(--crm-hover); }
    [data-crm-theme="dark"] .crm-app .table-success,
    [data-crm-theme="dark"] .crm-app .table-success > td,
    [data-crm-theme="dark"] .crm-app .alert-success { background: var(--crm-success-bg); color: var(--crm-success-text); border-color: var(--crm-success-text); }
    [data-crm-theme="dark"] .crm-app .table-danger,
    [data-crm-theme="dark"] .crm-app .table-danger > td,
    [data-crm-theme="dark"] .crm-app .alert-danger { background: var(--crm-danger-bg); color: var(--crm-danger-text); border-color: var(--crm-danger-text); }
    [data-crm-theme="dark"] .crm-app .table-warning,
    [data-crm-theme="dark"] .crm-app .table-warning > td,
    [data-crm-theme="dark"] .crm-app .alert-warning { background: var(--crm-warning-bg); color: var(--crm-warning-text); border-color: var(--crm-warning-text); }
    [data-crm-theme="dark"] .crm-app .table-info,
    [data-crm-theme="dark"] .crm-app .table-info > td,
    [data-crm-theme="dark"] .crm-app .table-primary,
    [data-crm-theme="dark"] .crm-app .table-primary > td,
    [data-crm-theme="dark"] .crm-app .alert-info,
    [data-crm-theme="dark"] .crm-app .alert-primary { background: var(--crm-info-bg); color: var(--crm-info-text); border-color: var(--crm-info-text); }
    [data-crm-theme="dark"] .crm-app .alert-secondary,
    [data-crm-theme="dark"] .crm-app .alert-light { background: var(--crm-raised); color: var(--crm-text); border-color: var(--crm-border); }
    [data-crm-theme="dark"] .crm-app .alert-link { color: inherit !important; text-decoration: underline; }
    [data-crm-theme="dark"] .crm-app .form-control,
    [data-crm-theme="dark"] .crm-app .custom-select,
    [data-crm-theme="dark"] .crm-app .custom-file-label,
    [data-crm-theme="dark"] .crm-app .input-group-text,
    [data-crm-theme="dark"] .crm-app trix-editor { background-color: var(--crm-input); color: var(--crm-text); border-color: var(--crm-border-strong); }
    [data-crm-theme="dark"] .crm-app .form-control:disabled,
    [data-crm-theme="dark"] .crm-app .form-control[readonly] { background-color: var(--crm-raised); color: var(--crm-muted); }
    [data-crm-theme="dark"] .crm-app .form-control-plaintext { color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app select option { background: var(--crm-input); color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app input::placeholder,
    [data-crm-theme="dark"] .crm-app textarea::placeholder { color: var(--crm-muted); opacity: 1; }
    [data-crm-theme="dark"] .crm-app .form-control:focus,
    [data-crm-theme="dark"] .crm-app .custom-select:focus { border-color: var(--crm-focus); box-shadow: 0 0 0 .2rem #ffffff1f; }
    [data-crm-theme="dark"] .crm-app .custom-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3E%3Cpath fill='%23dcdcdc' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E"); }
    [data-crm-theme="dark"] .crm-app .form-control.is-invalid { border-color: var(--crm-danger-text); }
    [data-crm-theme="dark"] .crm-app .filter-active .custom-select { color: var(--crm-success-text) !important; border-color: var(--crm-success-text) !important; }
    [data-crm-theme="dark"] .crm-app .bootstrap-duallistbox-container select,
    [data-crm-theme="dark"] .crm-app .bootstrap-duallistbox-container .btn-outline-secondary { color: var(--crm-text) !important; border-color: var(--crm-border-strong) !important; background-color: var(--crm-input); }
    [data-crm-theme="dark"] .crm-app .custom-control-label::before { background: var(--crm-input); border-color: var(--crm-border-strong); }
    [data-crm-theme="dark"] .crm-app .custom-control-input:checked ~ .custom-control-label::before { background: var(--crm-primary); }
    [data-crm-theme="dark"] .crm-app .custom-control-input:checked ~ .custom-control-label::after { filter: invert(1); }
    [data-crm-theme="dark"] .crm-app .custom-file-label::after { background: var(--crm-raised); color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .btn-primary { background: var(--crm-primary); border-color: var(--crm-primary); color: var(--crm-primary-text); }
    [data-crm-theme="dark"] .crm-app .btn-primary:hover { background: var(--crm-primary-hover); }
    [data-crm-theme="dark"] .crm-app .btn-primary:not(:disabled):not(.disabled):active,
    [data-crm-theme="dark"] .crm-app .btn-primary:not(:disabled):not(.disabled).active,
    [data-crm-theme="dark"] .crm-app .show > .btn-primary.dropdown-toggle { background: var(--crm-primary-hover); border-color: var(--crm-primary-hover); color: var(--crm-primary-text); }
    [data-crm-theme="dark"] .crm-app .btn:focus-visible { outline: 2px solid var(--crm-focus); outline-offset: 2px; box-shadow: 0 0 0 .2rem #ffffff1f; }
    [data-crm-theme="dark"] .crm-app .btn-secondary { background: #414141; border-color: var(--crm-border-strong); color: #fff; }
    [data-crm-theme="dark"] .crm-app .btn-light,
    [data-crm-theme="dark"] .crm-app .btn-outline-secondary { background: var(--crm-surface); border-color: var(--crm-border-strong); color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .btn-light:hover,
    [data-crm-theme="dark"] .crm-app .btn-outline-secondary:hover { background: var(--crm-hover); }
    [data-crm-theme="dark"] .crm-app .btn-link { color: var(--crm-link); }
    [data-crm-theme="dark"] .crm-app .btn-outline-primary { color: var(--crm-text); border-color: var(--crm-border-strong); }
    [data-crm-theme="dark"] .crm-app .btn-outline-info { color: var(--crm-info-text); border-color: var(--crm-info-text); }
    [data-crm-theme="dark"] .crm-app .btn-outline-success { color: var(--crm-success-text); border-color: var(--crm-success-text); }
    [data-crm-theme="dark"] .crm-app .btn-outline-danger { color: var(--crm-danger-text); border-color: var(--crm-danger-text); }
    [data-crm-theme="dark"] .crm-app .btn-outline-warning { color: var(--crm-warning-text); border-color: var(--crm-warning-text); }
    [data-crm-theme="dark"] .crm-app .btn-outline-primary:hover { background: var(--crm-hover); }
    [data-crm-theme="dark"] .crm-app .btn-outline-primary:not(:disabled):not(.disabled):active,
    [data-crm-theme="dark"] .crm-app .btn-outline-primary:not(:disabled):not(.disabled).active,
    [data-crm-theme="dark"] .crm-app .show > .btn-outline-primary.dropdown-toggle { background: var(--crm-primary); color: var(--crm-primary-text); border-color: var(--crm-primary); }
    [data-crm-theme="dark"] .crm-app .btn-outline-info:hover { background: var(--crm-info-bg); }
    [data-crm-theme="dark"] .crm-app .btn-outline-success:hover { background: var(--crm-success-bg); }
    [data-crm-theme="dark"] .crm-app .btn-outline-danger:hover { background: var(--crm-danger-bg); }
    [data-crm-theme="dark"] .crm-app .btn-outline-warning:hover { background: var(--crm-warning-bg); }
    [data-crm-theme="dark"] .crm-app .btn-success { background: var(--crm-success-bg); color: var(--crm-success-text); border-color: var(--crm-success-text); }
    [data-crm-theme="dark"] .crm-app .btn-danger { background: var(--crm-danger-bg); color: var(--crm-danger-text); border-color: var(--crm-danger-text); }
    [data-crm-theme="dark"] .crm-app .btn-info { background: var(--crm-info-bg); color: var(--crm-info-text); border-color: var(--crm-info-text); }
    [data-crm-theme="dark"] .crm-app .badge-light { background: var(--crm-raised); color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .badge-primary { background: var(--crm-raised); color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .badge-info { background: var(--crm-info-bg); color: var(--crm-info-text); }
    [data-crm-theme="dark"] .crm-app .badge-success { background: var(--crm-success-bg); color: var(--crm-success-text); }
    [data-crm-theme="dark"] .crm-app .badge-danger { background: var(--crm-danger-bg); color: var(--crm-danger-text); }
    [data-crm-theme="dark"] .crm-app .badge-warning { background: var(--crm-warning-bg); color: var(--crm-warning-text); }
    [data-crm-theme="dark"] .crm-app .dropdown-menu,
    [data-crm-theme="dark"] .crm-app .page-link { background: var(--crm-raised); color: var(--crm-text); border-color: var(--crm-border); }
    [data-crm-theme="dark"] .crm-app .dropdown-item { color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .dropdown-item:hover,
    [data-crm-theme="dark"] .crm-app .dropdown-item:focus { background: var(--crm-hover); }
    [data-crm-theme="dark"] .crm-app .dropdown-item.active,
    [data-crm-theme="dark"] .crm-app .page-item.active .page-link { background: var(--crm-primary); color: var(--crm-primary-text); }
    [data-crm-theme="dark"] .crm-app .dropdown-item.disabled,
    [data-crm-theme="dark"] .crm-app .page-item.disabled .page-link { background: var(--crm-subtle); color: var(--crm-muted); }
    [data-crm-theme="dark"] .crm-app .dropdown-divider { border-color: var(--crm-border); }
    [data-crm-theme="dark"] .crm-app .close { color: var(--crm-text); text-shadow: none; opacity: .85; }
    [data-crm-theme="dark"] .crm-app .progress { background: var(--crm-hover); }
    [data-crm-theme="dark"] .crm-app tr.cursor-grab > td:hover { background-color: var(--crm-hover); }
    [data-crm-theme="dark"] .crm-app label span.required-label { color: var(--crm-danger-text); }
    [data-crm-theme="dark"] .crm-app .toast { background: var(--crm-raised); }
    [data-crm-theme="dark"] .crm-app .ticket-board { --primary: var(--crm-link); }
    [data-crm-theme="dark"] .crm-app .ticket-button-primary,
    [data-crm-theme="dark"] .crm-app .ticket-complete:hover { background: var(--crm-primary); color: var(--crm-primary-text); }
    [data-crm-theme="dark"] .crm-app .ticket-sticky:not(.is-completed) { border-top-color: var(--crm-border-strong); }
    [data-crm-theme="dark"] .crm-app .ticket-title-dot { background: var(--crm-text); }
    [data-crm-theme="dark"] .crm-app .ticket-button-primary:hover { background: var(--crm-primary-hover); }
    [data-crm-theme="dark"] .crm-app .ticket-text-button { color: var(--crm-link); }
    [data-crm-theme="dark"] .crm-app .ticket-dashboard .ticket-card-title:hover { color: var(--crm-link); }
    [data-crm-theme="dark"] .crm-app .ticket-panel-backdrop,
    [data-crm-theme="dark"] .crm-app .ticket-editor-backdrop,
    [data-crm-theme="dark"] .crm-app .crm-menu-backdrop { background: var(--crm-overlay); }
    [data-crm-theme="dark"] .crm-app .active-start-wheel button.is-selected,
    [data-crm-theme="dark"] .crm-app .time-entry-period-button.is-selected { background: var(--crm-primary); color: var(--crm-primary-text); }
    [data-crm-theme="dark"] .crm-app pre,
    [data-crm-theme="dark"] .crm-app code { color: var(--crm-info-text); }
    [data-crm-theme="dark"] .crm-app :focus-visible { outline-color: var(--crm-focus); }

    /* Third-party popups may be mounted directly under body. */
    [data-crm-theme="dark"] .select2-container--default .select2-selection--single,
    [data-crm-theme="dark"] .select2-container--default .select2-selection--multiple,
    [data-crm-theme="dark"] .select2-dropdown,
    [data-crm-theme="dark"] .select2-search__field,
    [data-crm-theme="dark"] .xdsoft_datetimepicker,
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_time_box,
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_label,
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_select,
    [data-crm-theme="dark"] .swal2-popup,
    [data-crm-theme="dark"] .popover { background-color: var(--crm-raised); color: var(--crm-text); border-color: var(--crm-border-strong); }
    [data-crm-theme="dark"] .select2-container--default .select2-selection__rendered,
    [data-crm-theme="dark"] .select2-container--default .select2-selection__placeholder,
    [data-crm-theme="dark"] .select2-container--default .select2-selection__clear { color: var(--crm-text); }
    [data-crm-theme="dark"] .select2-selection.select2-selection--multiple,
    [data-crm-theme="dark"] .select2-selection.select2-selection--single { color: var(--crm-text) !important; border-color: var(--crm-border-strong) !important; }
    [data-crm-theme="dark"] .select2-container--default.select2-container--disabled .select2-selection--single,
    [data-crm-theme="dark"] .select2-container--default.select2-container--disabled .select2-selection--multiple { background: var(--crm-subtle); }
    [data-crm-theme="dark"] .select2-selection__choice__remove { color: var(--crm-muted) !important; }
    [data-crm-theme="dark"] .select2-container--default .select2-selection__choice,
    [data-crm-theme="dark"] .select2-container--default .select2-results__option[aria-selected=true] { background: var(--crm-hover); color: var(--crm-text); border-color: var(--crm-border); }
    [data-crm-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--crm-primary); color: var(--crm-primary-text); }
    [data-crm-theme="dark"] .select2-container--default .select2-results__option[aria-disabled=true] { color: var(--crm-muted); }
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_calendar td,
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_calendar th,
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_time_box > div > div { background: var(--crm-input); color: var(--crm-text); border-color: var(--crm-border); }
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_current,
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_time_box > div > div.xdsoft_current,
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_select > div > .xdsoft_option.xdsoft_current { background: var(--crm-primary); color: var(--crm-primary-text); box-shadow: none; }
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_prev,
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_next,
    [data-crm-theme="dark"] .xdsoft_datetimepicker .xdsoft_today_button { filter: invert(1); }
    [data-crm-theme="dark"] .swal2-title,
    [data-crm-theme="dark"] .swal2-content,
    [data-crm-theme="dark"] .swal2-html-container,
    [data-crm-theme="dark"] .popover-body { color: var(--crm-text); }
    [data-crm-theme="dark"] .popover-header { background: var(--crm-subtle); color: var(--crm-text); border-color: var(--crm-border); }
    [data-crm-theme="dark"] .bs-popover-bottom > .arrow::after { border-bottom-color: var(--crm-raised); }
    [data-crm-theme="dark"] .bs-popover-top > .arrow::after { border-top-color: var(--crm-raised); }
    [data-crm-theme="dark"] .bs-popover-left > .arrow::after { border-left-color: var(--crm-raised); }
    [data-crm-theme="dark"] .bs-popover-right > .arrow::after { border-right-color: var(--crm-raised); }
    [data-crm-theme="dark"] .tooltip-inner { background: #f3f3f3; color: #0d0d0d; }
    [data-crm-theme="dark"] .bs-tooltip-top .arrow::before { border-top-color: #f3f3f3; }
    [data-crm-theme="dark"] .bs-tooltip-bottom .arrow::before { border-bottom-color: #f3f3f3; }
    [data-crm-theme="dark"] .bs-tooltip-left .arrow::before { border-left-color: #f3f3f3; }
    [data-crm-theme="dark"] .bs-tooltip-right .arrow::before { border-right-color: #f3f3f3; }
    [data-crm-theme="dark"] trix-toolbar .trix-button-group { border-color: var(--crm-border-strong); }
    [data-crm-theme="dark"] trix-toolbar .trix-button { border-color: var(--crm-border); color: var(--crm-text); }
    [data-crm-theme="dark"] trix-toolbar .trix-button--icon::before { filter: invert(1); }
    [data-crm-theme="dark"] trix-toolbar .trix-button.trix-active { background: var(--crm-hover); }
    [data-crm-theme="dark"] trix-toolbar .trix-dialog { background: var(--crm-raised); color: var(--crm-text); border-color: var(--crm-border); }
    [data-crm-theme="dark"] trix-toolbar .trix-input { background: var(--crm-input); color: var(--crm-text); }
    [data-crm-theme="dark"] .colorpicker { background: var(--crm-raised); color: var(--crm-text); border-color: var(--crm-border); }

    /* Stored HTML may specify colors. Keep it on a deliberate paper surface. */
    [data-crm-theme="dark"] .crm-rich-content { background: #fff; color: #212529; padding: 1rem; border-radius: 6px; color-scheme: light; }
    [data-crm-theme="dark"] .crm-app .crm-rich-content a { color: #1768aa !important; }
    [data-crm-theme="dark"] .crm-app .crm-rich-content pre,
    [data-crm-theme="dark"] .crm-app .crm-rich-content code { color: #212529; }

    /* Separate Tailwind auth/profile stack. These classes inherit the same preference. */
    [data-crm-theme="dark"] .crm-tailwind { background: var(--crm-page); color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-tailwind .bg-gray-100,
    [data-crm-theme="dark"] .crm-tailwind .bg-gray-50 { background-color: var(--crm-page); }
    [data-crm-theme="dark"] .crm-tailwind .bg-white { background-color: var(--crm-surface); }
    [data-crm-theme="dark"] .crm-tailwind .text-gray-900,
    [data-crm-theme="dark"] .crm-tailwind .text-gray-800,
    [data-crm-theme="dark"] .crm-tailwind .text-gray-700 { color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-tailwind .text-gray-600,
    [data-crm-theme="dark"] .crm-tailwind .text-gray-500,
    [data-crm-theme="dark"] .crm-tailwind .text-gray-400 { color: var(--crm-muted); }
    [data-crm-theme="dark"] .crm-tailwind .text-red-600 { color: var(--crm-danger-text); }
    [data-crm-theme="dark"] .crm-tailwind .text-green-600 { color: var(--crm-success-text); }
    [data-crm-theme="dark"] .crm-tailwind .border-gray-100,
    [data-crm-theme="dark"] .crm-tailwind .border-gray-200,
    [data-crm-theme="dark"] .crm-tailwind .border-gray-300 { border-color: var(--crm-border-strong); }
    [data-crm-theme="dark"] .crm-tailwind input:not([type=checkbox]):not([type=radio]),
    [data-crm-theme="dark"] .crm-tailwind textarea,
    [data-crm-theme="dark"] .crm-tailwind select { background-color: var(--crm-input); color: var(--crm-text); border-color: var(--crm-border-strong); }
    [data-crm-theme="dark"] .crm-tailwind .hover\:bg-gray-50:hover,
    [data-crm-theme="dark"] .crm-tailwind .hover\:bg-gray-100:hover,
    [data-crm-theme="dark"] .crm-tailwind .focus\:bg-gray-100:focus { background-color: var(--crm-hover); }
    [data-crm-theme="dark"] .crm-tailwind .focus\:bg-gray-50:focus,
    [data-crm-theme="dark"] .crm-tailwind .active\:bg-gray-100:active { background-color: var(--crm-hover); }
    [data-crm-theme="dark"] .crm-tailwind .hover\:text-gray-900:hover,
    [data-crm-theme="dark"] .crm-tailwind .hover\:text-gray-700:hover { color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-tailwind .bg-indigo-50 { background-color: var(--crm-info-bg); }
    [data-crm-theme="dark"] .crm-tailwind .text-indigo-700 { color: var(--crm-info-text); }
    [data-crm-theme="dark"] .crm-tailwind .bg-gray-800.text-white { background-color: var(--crm-primary); color: var(--crm-primary-text); }
    [data-crm-theme="dark"] .crm-tailwind .bg-gray-800.text-white:hover { background-color: var(--crm-primary-hover); }
    [data-crm-theme="dark"] .crm-tailwind .focus\:ring-indigo-500:focus { --tw-ring-color: var(--crm-focus); }
    [data-crm-theme="dark"] .crm-tailwind .hover\:bg-indigo-50:hover,
    [data-crm-theme="dark"] .crm-tailwind .focus\:bg-indigo-100:focus { background-color: var(--crm-info-bg); }
    [data-crm-theme="dark"] .crm-tailwind .focus\:text-indigo-800:focus { color: var(--crm-info-text); }
    [data-crm-theme="dark"] .crm-portal { background: var(--crm-page); color: var(--crm-text); }
    [data-crm-theme="dark"] .crm-portal .navbar.bg-white { background: var(--crm-surface) !important; }
    [data-crm-theme="dark"] .crm-portal .navbar-brand,
    [data-crm-theme="dark"] .crm-portal footer a { color: var(--crm-link); }
    [data-crm-theme="dark"] .crm-portal footer .text-muted { color: var(--crm-muted) !important; }
    [data-crm-theme="dark"] .crm-portal main { background: #fff; color: #212529; color-scheme: light; }
}
@media print {
    :root[data-crm-theme="dark"] {
        color-scheme: light !important;
        --crm-page: #f8fafc;
        --crm-surface: #fff;
        --crm-raised: #fff;
        --crm-subtle: #f8f9fa;
        --crm-hover: #e9ecef;
        --crm-input: #fff;
        --crm-text: #212529;
        --crm-muted: #6c757d;
        --crm-border: #dee2e6;
        --crm-border-strong: #adb5bd;
        --crm-link: #2176bd;
        --crm-primary: #3490dc;
        --crm-primary-hover: #227dc7;
        --crm-primary-text: #fff;
        --crm-focus: #3490dc;
        --crm-info-bg: #eaf4fc;
        --crm-info-text: #2176bd;
        --crm-success-bg: #d7f3e3;
        --crm-success-text: #1d643b;
        --crm-warning-bg: #fff3cd;
        --crm-warning-text: #856404;
        --crm-danger-bg: #f8d7da;
        --crm-danger-text: #761b18;
    }
    .crm-theme-control, .crm-auth-theme { display: none !important; }
    .crm-app .badge[style], .crm-app select[name="pipeline_stage_id"] { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
