/* Shared Select2 4.x controls. Keep report printing unchanged. */
@media screen {
    body.system-ui .select2-container {
        --sms-enhanced-height: var(--sms-control-height, 36px);
        --sms-enhanced-radius: var(--sms-control-radius, 9px);
        max-width: 100%;
        vertical-align: middle;
        font-size: 13px;
        font-weight: 400;
    }
    body.system-ui select.input-sm + .select2-container,
    body.system-ui select.form-control-sm + .select2-container {
        --sms-enhanced-height: 34px;
        --sms-enhanced-radius: 8px;
    }
    body.system-ui select.input-lg + .select2-container {
        --sms-enhanced-height: 44px;
        --sms-enhanced-radius: 11px;
    }
    body.system-ui select.form-control + .select2-container {
        width: 100% !important;
    }

    /* Select2 fields: keep single values aligned and let multiple values grow. */
    body.system-ui .select2-container .select2-selection {
        min-height: var(--sms-enhanced-height);
        margin: 0 !important;
        border: 1px solid var(--sms-control-border, #d5dbea) !important;
        border-radius: var(--sms-enhanced-radius) !important;
        background: #fff !important;
        color: var(--sms-control-text, #344054);
        font-size: 13px;
        font-weight: 400;
        box-shadow: 0 1px 2px rgba(16,24,40,.04);
        transition: border-color 160ms ease, box-shadow 160ms ease;
    }
    body.system-ui .select2-container .select2-selection--single {
        height: var(--sms-enhanced-height) !important;
        padding: 0 !important;
    }
    body.system-ui .select2-container .select2-selection--single .select2-selection__rendered {
        display: block;
        height: 100%;
        padding: 0 34px 0 10px !important;
        color: var(--sms-control-text, #344054) !important;
        font-weight: 400;
        line-height: calc(var(--sms-enhanced-height) - 2px) !important;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    body.system-ui .select2-container .select2-selection__placeholder {
        color: #7c8798 !important;
        font-weight: 400;
    }
    body.system-ui .select2-container .select2-selection--single .select2-selection__arrow {
        display: flex;
        align-items: center;
        justify-content: center;
        top: 0;
        right: 12px;
        width: 10px;
        height: 100% !important;
        border: 0 !important;
        border-radius: 0;
        background: none !important;
    }
    body.system-ui .select2-container .select2-selection--single .select2-selection__arrow b {
        position: static;
        width: 7px;
        height: 7px;
        margin: -3px 0 0;
        border: solid var(--sms-control-primary, #2b3087) !important;
        border-width: 0 1.5px 1.5px 0 !important;
        transform: rotate(45deg);
    }
    body.system-ui .select2-container--open .select2-selection--single .select2-selection__arrow b {
        margin-top: 3px;
        transform: rotate(225deg);
    }
    body.system-ui .select2-container .select2-selection__clear {
        position: absolute;
        top: 50%;
        right: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 20px;
        height: 20px;
        margin: 0 !important;
        border: 0;
        border-radius: 5px;
        background: transparent;
        color: #667085;
        font-size: 18px;
        line-height: 1;
        transform: translateY(-50%);
    }
    body.system-ui .select2-selection--single:has(.select2-selection__clear) .select2-selection__rendered {
        padding-right: 56px !important;
    }
    body.system-ui .select2-container .select2-selection--multiple {
        height: auto !important;
        padding: 3px 6px !important;
    }
    body.system-ui .select2-container .select2-selection--multiple .select2-selection__rendered {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px;
        min-height: calc(var(--sms-enhanced-height) - 8px);
        margin: 0 !important;
        padding: 0 !important;
        list-style: none;
    }
    body.system-ui .select2-container .select2-selection--multiple .select2-selection__choice {
        display: inline-flex;
        align-items: center;
        float: none;
        gap: 5px;
        max-width: 100%;
        min-height: 24px;
        margin: 0 !important;
        padding: 2px 7px;
        border: 1px solid #dadef2;
        border-radius: 6px;
        background: #eef0fa;
        color: var(--sms-control-primary, #2b3087);
        font-size: 12px;
        line-height: 18px;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    body.system-ui .select2-container .select2-selection__choice__remove {
        flex: 0 0 auto;
        margin: 0;
        border: 0;
        border-radius: 3px;
        background: transparent;
        color: var(--sms-control-primary, #2b3087);
        font-size: 16px;
        font-weight: 400;
        line-height: 18px;
        cursor: pointer;
    }
    body.system-ui .select2-container .select2-search--inline {
        flex: 1 1 auto;
        min-width: 1em;
        max-width: 100%;
        margin: 0;
    }
    body.system-ui .select2-container .select2-search--inline .select2-search__field {
        max-width: 100%;
        height: 24px !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 3px !important;
        border: 0 !important;
        background: transparent !important;
        color: var(--sms-control-text, #344054);
        font: inherit;
        line-height: 24px;
        outline: 0;
        box-shadow: none !important;
    }
    body.system-ui .select2-selection--multiple .select2-selection__clear {
        order: 2;
        flex: 0 0 20px;
        position: static;
        float: right;
        margin-left: auto !important;
        transform: none;
    }
    body.system-ui .select2-container .select2-selection__clear:hover {
        background: #eef0fa;
        color: var(--sms-control-primary, #2b3087);
    }

    /* Shared hover and focus: preserve keyboard visibility without the blue fill. */
    body.system-ui .select2-container:not(.select2-container--disabled) .select2-selection:hover {
        border-color: #b8c2d6 !important;
    }
    body.system-ui .select2-container--focus:not(.select2-container--disabled) .select2-selection,
    body.system-ui .select2-container--open:not(.select2-container--disabled) .select2-selection {
        border-color: var(--sms-control-primary, #2b3087) !important;
        outline: 0 !important;
        box-shadow: 0 0 0 3px rgba(43,48,135,.13) !important;
    }
    body.system-ui .select2-container--disabled .select2-selection {
        border-color: #e4e8f0 !important;
        background: #f3f5f9 !important;
        color: #98a2b3 !important;
        cursor: not-allowed;
        opacity: 1;
        box-shadow: none !important;
    }
    body.system-ui .select2-container--disabled .select2-selection__rendered,
    body.system-ui .select2-container--disabled .select2-selection__choice { color: #98a2b3 !important; }
    body.system-ui .select2-container--disabled .select2-selection__arrow b { border-color: #98a2b3 !important; }
    body.system-ui .has-error .select2-selection,
    body.system-ui select.error ~ .select2-container .select2-selection,
    body.system-ui select.parsley-error + .select2-container .select2-selection,
    body.system-ui select[aria-invalid="true"] + .select2-container .select2-selection {
        margin-bottom: 0 !important;
        border-color: #d34b4b !important;
    }

    /* Select2 dropdowns, including body-mounted portals. */
    body.system-ui .select2-container--open { z-index: 2000; }
    body.system-ui .select2-dropdown {
        box-sizing: border-box;
        margin-top: 6px;
        overflow: hidden;
        border: 1px solid var(--sms-control-border, #d5dbea) !important;
        border-radius: 12px !important;
        background: #fff !important;
        color: var(--sms-control-text, #344054);
        font-size: 13px;
        font-weight: 400;
        box-shadow: 0 12px 28px rgba(16,24,40,.14) !important;
    }
    body.system-ui .select2-dropdown--above { margin-top: -6px; }
    body.system-ui .select2-dropdown { max-width: calc(100vw - 24px); }
    body.system-ui .select2-results > .select2-results__options {
        max-height: min(320px, calc(100dvh - 180px));
        padding: 4px 0;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: #c9d2e1 transparent;
    }
    body.system-ui .select2-search--dropdown {
        margin: 0 0 5px;
        padding: 8px;
        border-bottom: 1px solid #e7eaf0;
        background: #fff;
    }
    body.system-ui .select2-search--dropdown .select2-search__field {
        width: 100% !important;
        height: 34px !important;
        min-height: 34px !important;
        margin: 0;
        padding: 7px 10px !important;
        border: 1px solid var(--sms-control-border, #d5dbea) !important;
        border-radius: 8px !important;
        background: #fff !important;
        color: var(--sms-control-text, #344054);
        font: inherit;
        outline: 0;
        box-shadow: none;
    }
    body.system-ui .select2-search--dropdown .select2-search__field:focus {
        border-color: var(--sms-control-primary, #2b3087) !important;
        box-shadow: 0 0 0 2px rgba(43,48,135,.12) !important;
    }

    /* Selected options use the primary tint; hover and keyboard focus stay distinct. */
    body.system-ui .select2-results__option {
        min-height: 36px;
        margin: 1px 6px;
        padding: 8px 10px;
        border-radius: 8px;
        background: transparent;
        color: var(--sms-control-text, #344054);
        font-size: 13px;
        font-weight: 400;
        line-height: 20px;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    body.system-ui .select2-results__option[aria-selected="true"] {
        background: #eef0fa !important;
        color: var(--sms-control-primary, #2b3087) !important;
    }
    body.system-ui .select2-results__option--highlighted[aria-selected] {
        background: #f3f5f9 !important;
        color: var(--sms-control-primary, #2b3087) !important;
    }
    body.system-ui .select2-results__option--highlighted[aria-selected="true"] {
        background: #e4e7f7 !important;
    }
    body.system-ui .select2-results__option[aria-disabled="true"] {
        background: transparent !important;
        color: #98a2b3 !important;
        cursor: not-allowed;
        outline: 0 !important;
    }
    body.system-ui .select2-results__option[role="group"] { padding: 0; background: transparent !important; }
    body.system-ui .select2-results__group {
        margin: 0;
        padding: 8px 10px 5px;
        color: #667085;
        font-size: 11px;
        font-weight: 600;
    }
    body.system-ui .select2-results__message {
        padding: 12px;
        background: transparent;
        color: #667085;
        white-space: normal;
    }

    /* Input groups keep joined edges rather than showing overlapping rounded borders. */
    body.system-ui .input-group > .select2-container:not(:first-child) .select2-selection {
        border-top-left-radius: 0 !important;
        border-bottom-left-radius: 0 !important;
    }
    body.system-ui .input-group > .select2-container:not(:last-child) .select2-selection {
        border-top-right-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }
    body.system-ui .input-group > select:first-child + .select2-container .select2-selection {
        border-top-left-radius: var(--sms-enhanced-radius) !important;
        border-bottom-left-radius: var(--sms-enhanced-radius) !important;
    }
    @media (max-width: 767px) {
    body.system-ui .select2-container .select2-selection,
    body.system-ui .select2-search--dropdown .select2-search__field { font-size: 16px; }
    }
}


/* Bootstrap Select theme ported from zispp-sms/assets/css/erp-form-controls.css.
   Source values are preserved; scope and priority fit legacy MHNWS views. */
@media screen {
/* Bootstrap Select */
body.system-ui .bootstrap-select:not(.bs-container) {
    width: 100% !important;
}

body.system-ui .bootstrap-select.form-control {
    border: 0 !important;
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
}

body.system-ui .dropdown.bootstrap-select > .dropdown-toggle.btn,
body.system-ui .bootstrap-select > .dropdown-toggle.btn-default {
    width: 100%;
    height: var(--sms-control-height) !important;
    min-height: var(--sms-control-height) !important;
    border: 1px solid var(--sms-control-border) !important;
    border-radius: var(--sms-control-radius) !important;
    background: #fff !important;
    color: var(--sms-control-text) !important;
    font-size: 13px !important;
    line-height: 1.4;
    padding: 8px 34px 8px 10px !important;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04) !important;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

body.system-ui .dropdown.bootstrap-select > .dropdown-toggle.btn:hover {
    border-color: #b8c2d6 !important;
}

body.system-ui .bootstrap-select.open > .dropdown-toggle.btn-default,
body.system-ui .bootstrap-select.open > .dropdown-toggle.btn-default:hover,
body.system-ui .bootstrap-select > .dropdown-toggle.btn-default:focus {
    border-color: var(--sms-control-primary) !important;
    background: #fff !important;
    color: var(--sms-control-text) !important;
    outline: 0 !important;
    box-shadow: 0 0 0 3px rgba(43, 48, 135, 0.16), 0 6px 18px rgba(16, 24, 40, 0.08) !important;
}

body.system-ui .bootstrap-select.disabled > .dropdown-toggle.btn {
    border-color: #e4e8f0 !important;
    background: #f3f5f9 !important;
    color: var(--sms-control-muted) !important;
    opacity: 1;
}

body.system-ui .bootstrap-select > .dropdown-toggle .filter-option {
    overflow: hidden !important;
    text-overflow: ellipsis;
    white-space: nowrap !important;
}

body.system-ui .bootstrap-select > .dropdown-menu {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    max-height: var(--sms-select-panel-max-height) !important;
    margin-top: 6px !important;
    overflow: hidden !important;
    border: 1px solid var(--sms-control-border);
    border-radius: 16px !important;
    background: #fff !important;
    padding: 6px !important;
    box-shadow: 0 12px 28px rgba(16, 24, 40, 0.14) !important;
}

body.system-ui .bootstrap-select .bs-searchbox {
    margin: -6px -6px 5px !important;
    padding: 8px !important;
    border-bottom: 1px solid #e7eaf0;
    background: #fff !important;
}

body.system-ui .bootstrap-select .bs-searchbox .form-control {
    width: 100% !important;
    height: 34px !important;
    min-height: 34px !important;
    border: 1px solid var(--sms-control-border) !important;
    background: #fff !important;
    color: var(--sms-control-text) !important;
    border-radius: 8px !important;
    padding: 7px 9px !important;
}

body.system-ui .bootstrap-select > .dropdown-menu > .inner {
    max-height: calc(var(--sms-select-panel-max-height) - 102px) !important;
    overflow-y: auto !important;
}

body.system-ui .bootstrap-select .dropdown-menu.inner {
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
}

body.system-ui .bootstrap-select .dropdown-menu.inner > li > a {
    min-height: 36px !important;
    margin: 1px 0 !important;
    border-radius: 9px !important;
    color: #243454 !important;
    font-size: 13px !important;
    line-height: 20px;
    padding: 8px 10px !important;
    white-space: normal !important;
}

body.system-ui .bootstrap-select .dropdown-menu.inner > li > a:hover {
    background: #f3f5f9 !important;
    color: var(--sms-control-primary) !important;
    outline: 0;
}

/* Focus alone must not look like a selected option. Keep a keyboard indicator. */
body.system-ui .bootstrap-select .dropdown-menu.inner > li:not(.selected):not(.active) > a:focus:not(:hover) {
    background: transparent !important;
}

body.system-ui .bootstrap-select .dropdown-menu.inner > li > a:focus-visible {
    outline: 1px solid var(--sms-control-primary);
    outline-offset: -2px;
}

body.system-ui .bootstrap-select .dropdown-menu.inner > li.selected > a,
body.system-ui .bootstrap-select .dropdown-menu.inner > li.active > a {
    background: #eef2ff !important;
    color: var(--sms-control-primary) !important;
}

body.system-ui .bootstrap-select.show-tick .dropdown-menu .selected .check-mark {
    top: 50% !important;
    right: 10px;
    margin: 0 !important;
    transform: translateY(-50%);
}

body.system-ui .bootstrap-select .bs-actionsbox .actions-btn {
    height: 36px !important;
    min-height: 36px !important;
    border: 0 !important;
    border-radius: 9px !important;
    background: transparent !important;
    color: #243454 !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    line-height: 20px;
    text-align: left;
    padding: 8px 10px !important;
    box-shadow: none !important;
}

body.system-ui .bootstrap-select .bs-actionsbox .btn-group {
    display: flex;
    width: auto;
}

body.system-ui .bootstrap-select .actions-btn.bs-select-all,
body.system-ui .bootstrap-select .actions-btn.bs-deselect-all {
    flex: 1 1 auto;
    width: auto;
    max-width: 100%;
}

body.system-ui .bootstrap-select .actions-btn.bs-deselect-all {
    display: none;
}

body.system-ui .bootstrap-select.all-options-selected .actions-btn.bs-select-all {
    display: none;
}

body.system-ui .bootstrap-select.all-options-selected .actions-btn.bs-deselect-all {
    display: block;
}

body.system-ui .bootstrap-select .bs-actionsbox .actions-btn:hover,
body.system-ui .bootstrap-select .bs-actionsbox .actions-btn:focus {
    border-color: transparent !important;
    background: #f3f5f9 !important;
    color: var(--sms-control-primary) !important;
    outline: 0;
}

}

/* Integration guards: retain the source theme across legacy views and portals. */
@media screen {
    body.system-ui .bootstrap-select:not(.bs-container) {
        display: inline-block !important;
        flex-direction: initial !important;
        max-width: 100%;
        vertical-align: middle;
    }
    body.system-ui .bootstrap-select.form-control:not(.bs-container) {
        height: auto !important; min-height: 0 !important; margin: 0; padding: 0 !important;
    }
    body.system-ui .dropdown.bootstrap-select > .dropdown-toggle.btn { margin: 0 !important; }
    body.system-ui .bootstrap-select.bs-container { position: absolute !important; z-index: 2000; }
    body.system-ui .bootstrap-select.dropup > .dropdown-menu { margin-top: 0 !important; margin-bottom: 6px; }
    body.system-ui .bootstrap-select .dropdown-menu > .inner { min-width: 0 !important; overflow-x: hidden !important; }
    body.system-ui .bootstrap-select .bs-searchbox .form-control {
        margin: 0 !important;
        border-radius: var(--sms-control-radius) !important;
        box-shadow: 0 1px 2px rgba(16,24,40,.04) !important;
    }
    body.system-ui .bootstrap-select .bs-searchbox .form-control:focus {
        border-color: var(--sms-control-primary) !important; outline: 0;
        box-shadow: 0 0 0 3px rgba(43,48,135,.16), 0 6px 18px rgba(16,24,40,.08) !important;
    }
    body.system-ui .bootstrap-select .dropdown-menu.inner > li.disabled > a,
    body.system-ui .bootstrap-select .dropdown-menu.inner > li.disabled > a:hover { color: var(--sms-control-muted) !important; background: transparent !important; cursor: not-allowed; }
    body.system-ui .bootstrap-select .dropdown-menu.inner > li > a > .text { white-space: normal !important; overflow-wrap: anywhere; }
    body.system-ui .bootstrap-select .bs-actionsbox .btn-group { flex-direction: row; }
    body.system-ui .has-error .bootstrap-select > .dropdown-toggle.btn,
    body.system-ui .bootstrap-select:has(> select.error) > .dropdown-toggle.btn,
    body.system-ui .bootstrap-select:has(> select.parsley-error) > .dropdown-toggle.btn,
    body.system-ui .bootstrap-select:has(> select[aria-invalid="true"]) > .dropdown-toggle.btn { border-color: #d34b4b !important; }
    body.system-ui fieldset[disabled] .bootstrap-select > .dropdown-toggle.btn { border-color: #e4e8f0 !important; background: #f3f5f9 !important; color: var(--sms-control-muted) !important; box-shadow: none !important; }
    body.system-ui .input-group > .bootstrap-select { display: table-cell !important; }
    body.system-ui .input-group > .bootstrap-select:not(:first-child) > .dropdown-toggle.btn { border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; }
    body.system-ui .input-group > .bootstrap-select:not(:last-child) > .dropdown-toggle.btn { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
    /* Old checkbox-select pages use the same ZISPP rows and selected checkmarks. */
    body.system-ui .bootstrap-select.checkbox-select .dropdown-menu li > a::before,
    body.system-ui .bootstrap-select.checkbox-select .dropdown-menu li > a::after { content: none !important; }
    body.system-ui .bootstrap-select.checkbox-select.show-tick .dropdown-menu .selected .check-mark { display: inline-block !important; color: var(--sms-control-primary); }
    @media (max-width: 767px) {
        body.system-ui .dropdown.bootstrap-select > .dropdown-toggle.btn,
        body.system-ui .bootstrap-select .bs-searchbox .form-control { font-size: 16px !important; }
    }
}
