/* Normal ERP screens opt in through erp-content. Report/print views never opt in.
   Screen-only rules also keep print/export dimensions independent of the phone UI. */
.erp-menu-toggle,
.erp-drawer-heading,
.erp-drawer-backdrop {
    display: none;
}

@media screen and (max-width: 1199px) {
    body.erp-page-active {
        overflow-y: auto;
        overflow-x: clip;
    }

    .erp-shell .hbPlus-mainContainer,
    .erp-shell .hbplus-body {
        min-width: 0;
        width: 100%;
        overflow: visible;
    }

    .erp-shell .hbPlus-rBodyCon {
        min-width: 0;
        width: 100%;
    }

    body.erp-page-active .erp-shell .hbPlus-rBodyCon {
        height: auto;
        min-height: 100dvh;
    }

    .erp-shell #erpNavigation {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(320px, 88vw) !important;
        height: 100dvh;
        margin: 0 !important;
        border-radius: 0 12px 12px 0;
        z-index: 1050;
        visibility: hidden;
        transform: translateX(-100%);
        transition: transform 180ms ease, visibility 180ms ease;
        background: var(--primary-Bg-color, #f8f9fc);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .erp-shell #erpNavigation.erp-drawer-open {
        transform: translateX(0);
        visibility: visible;
    }

    .erp-shell #erpNavigation .hbPlus-siderCon-body {
        height: auto;
        min-height: calc(100% - 56px);
    }

    .erp-shell #erpNavigation .hbplus-sidebar-menu {
        height: auto !important;
        padding: 8px 0 24px;
        overflow: visible !important;
    }

    .erp-shell #erpNavigation .hBplus-SideBarFooterCon {
        display: none;
    }

    .erp-shell .erp-drawer-heading {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 6px 12px;
        min-height: 56px;
        font-size: 18px;
        font-weight: 600;
        border-bottom: 1px solid #d6dbe1;
    }

    .erp-shell .erp-menu-toggle,
    .erp-shell .erp-menu-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        border: 0;
        border-radius: 6px;
        background: transparent;
        color: inherit;
        font-size: 24px;
    }

    .erp-shell .erp-menu-toggle { color: #fff; }

    .erp-drawer-backdrop:not([hidden]) {
        display: block;
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        border: 0;
        background: rgba(15, 23, 42, .48);
        z-index: 1049;
        touch-action: none;
    }

    /* Override the old icon-only sidebar media rules inside the mobile drawer. */
    .erp-shell #erpNavigation .hbPlus-ImgComConTitle,
    .erp-shell #erpNavigation .hbPlus-CompanyName,
    .erp-shell #erpNavigation .menuName,
    .erp-shell #erpNavigation .hBplus-subMenuFont,
    .erp-shell #erpNavigation .hbplus-mMenu-chevron {
        display: block !important;
    }

    .erp-shell #erpNavigation .hbPlus-Company {
        justify-content: flex-start;
        padding: 12px 18px;
        gap: 12px;
    }

    .erp-shell #erpNavigation .hbplus-mMenu-title {
        justify-content: flex-start;
        gap: 12px;
        min-width: 0;
        white-space: normal;
    }

    .erp-shell #erpNavigation .hbplus-mMenu-list,
    .erp-shell #erpNavigation .hbplus-mMenu-companylist,
    .erp-shell #erpNavigation .hbPlus-subMenuBtn,
    .erp-shell #erpNavigation .hbPlus-sMenuBtn,
    .erp-shell #erpNavigation .hbPlus-ThirdMenuBtn,
    .erp-shell #erpNavigation .hbplus-sThirdButtonMenuList {
        min-height: 44px;
        padding: 10px 16px;
        gap: 12px;
        justify-content: space-between;
        font-size: 14px;
        white-space: normal;
    }

    .erp-shell #erpNavigation .hbplus-sMenu-List,
    .erp-shell #erpNavigation .navigation-sMenu {
        margin-left: 16px !important;
        max-width: calc(100% - 16px);
    }

    .erp-shell .hbPlus-header { min-height: 52px; }

    .erp-shell .erp-header-row {
        gap: 8px;
        flex-wrap: wrap;
        min-width: 0;
        overflow: visible !important;
    }

    .erp-shell #hBplus-SearchPanelList {
        flex: 1 1 160px;
        min-width: 0;
        max-width: 100%;
        margin: 0;
        font-size: 16px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .erp-shell #hBplus-SearchPanelList .dx-texteditor { width: 100% !important; }

    .erp-shell .erp-header-actions {
        flex-shrink: 0;
        flex-wrap: wrap;
        padding-right: 8px !important;
    }

    .erp-shell .erp-header-actions button { min-height: 44px; }
    .erp-shell .hBplus-HeaderBtn button { min-width: 44px; }

    .erp-content:not(.erp-report, .erp-report *) {
        min-width: 0;
        max-width: 100%;
        font-size: 14px;
    }

    .erp-content .hbPlus-gridPanelCon:not(.erp-report, .erp-report *),
    .erp-content .dx-datagrid:not(.erp-report, .erp-report *),
    .erp-content .dx-treelist:not(.erp-report, .erp-report *) {
        min-width: 0;
        width: 100% !important;
        max-width: 100%;
    }

    .erp-content .hBplus-ListHeader:not(.erp-report, .erp-report *),
    .erp-content #hBplus-TitleForm:not(.erp-report, .erp-report *),
    .erp-content #hBplus-SubmitAndCanceAjaxlID:not(.erp-report, .erp-report *),
    .erp-content .hbPlus-itemWrapper:not(.erp-report, .erp-report *) {
        flex-wrap: wrap;
        gap: 8px;
        width: auto;
        max-width: 100%;
    }

    .erp-content .hBplus-ListHeader > .d-flex:not(.erp-report, .erp-report *) { flex-wrap: wrap; }

    .erp-content .dx-toolbar:not(.erp-report, .erp-report *),
    .erp-content .dx-toolbar-items-container:not(.erp-report, .erp-report *) {
        height: auto !important;
        min-height: 44px;
    }

    .erp-content .dx-toolbar-items-container:not(.erp-report, .erp-report *),
    .erp-content .dx-toolbar-before:not(.erp-report, .erp-report *),
    .erp-content .dx-toolbar-center:not(.erp-report, .erp-report *),
    .erp-content .dx-toolbar-after:not(.erp-report, .erp-report *) {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        min-width: 0;
        max-width: 100%;
    }

    .erp-content .dx-toolbar-before:not(.erp-report, .erp-report *),
    .erp-content .dx-toolbar-center:not(.erp-report, .erp-report *),
    .erp-content .dx-toolbar-after:not(.erp-report, .erp-report *) {
        position: static !important;
        float: none;
        margin: 0 !important;
        padding: 0;
    }

    .erp-content .dx-toolbar-after:not(.erp-report, .erp-report *) { margin-left: auto !important; }
    .erp-content .dx-toolbar-item:not(.erp-report, .erp-report *) { max-width: 100%; }
    .erp-content .dx-datagrid:not(.erp-report, .erp-report *) { font-size: 14px; }
    .erp-content .dx-datagrid .dx-row > td:not(.erp-report, .erp-report *) { padding: 10px 8px; }

    .erp-content .dx-pager:not(.erp-report, .erp-report *),
    .erp-content .dx-pages:not(.erp-report, .erp-report *),
    .erp-content .dx-page-indexes:not(.erp-report, .erp-report *) {
        flex-wrap: wrap;
        white-space: normal;
        height: auto;
    }

    .erp-content .dx-pager .dx-page:not(.erp-report, .erp-report *),
    .erp-content .dx-pager .dx-navigate-button:not(.erp-report, .erp-report *) {
        min-width: 40px;
        min-height: 40px;
    }

    .erp-content .dx-button:not(.erp-report, .erp-report *),
    .erp-content .btn:not(.erp-report, .erp-report *) {
        min-height: 44px;
        min-width: 44px;
        max-width: 100%;
        font-size: 14px;
    }

    .erp-content .dx-form:not(.erp-report, .erp-report *),
    .erp-content .dx-layout-manager:not(.erp-report, .erp-report *),
    .erp-content .dx-field-item-content:not(.erp-report, .erp-report *) { min-width: 0; max-width: 100%; }

    .erp-content .dx-field-item-label-text:not(.erp-report, .erp-report *) { white-space: normal; }

    .erp-content [id].dx-widget:has(> .dx-datagrid):not(.erp-report, .erp-report *),
    .erp-content [id].dx-widget:has(> .dx-treelist):not(.erp-report, .erp-report *) {
        width: 100% !important;
        max-width: 100%;
        min-width: 0;
    }

    .erp-content .modal-dialog:not(.erp-report, .erp-report *) {
        width: min(95vw, 800px);
        max-width: 95vw !important;
        margin: 16px auto !important;
    }

    .erp-content .modal-content:not(.erp-report, .erp-report *) { max-height: calc(100dvh - 32px); }
    .erp-content .modal-body:not(.erp-report, .erp-report *) { overflow-y: auto; min-height: 0; }
    .erp-content .modal-footer:not(.erp-report, .erp-report *) { flex-wrap: wrap; gap: 8px; }

    .erp-popup .dx-overlay-content {
        max-width: 95vw !important;
        max-height: 90dvh !important;
    }

    .erp-popup.dx-popup-wrapper .dx-overlay-content,
    .erp-popup.dx-dropdowneditor-overlay .dx-overlay-content {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
    }

    .erp-popup.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-overlay-content { width: 95vw !important; }
    .erp-popup .dx-popup-content { max-height: calc(90dvh - 100px); overflow-y: auto; }
    .erp-popup .dx-list-item-content { padding: 12px; font-size: 14px; white-space: normal; }
}

@media screen and (max-width: 767px) {
    .erp-shell .hbPlus-rBodyCon { padding: 6px !important; }
    .erp-content .hBplus-ListHeader:not(.erp-report, .erp-report *),
    .erp-content #hBplus-TitleForm:not(.erp-report, .erp-report *) { padding: 12px !important; align-items: flex-start; }
    .erp-content .hBplus-ListHeader > h5:not(.erp-report, .erp-report *) { flex-basis: 100%; font-size: 20px; }
    .erp-content #hBplus-TitleForm h5:not(.erp-report, .erp-report *) { font-size: 20px; overflow-wrap: anywhere; }

    .erp-content #hbPlus-formConID:not(.erp-report, .erp-report *),
    .erp-content #hBplus-dataView:not(.erp-report, .erp-report *) {
        padding: 12px !important;
        margin: 0;
        height: auto !important;
        max-height: none;
        overflow: visible;
        min-width: 0;
    }

    .erp-content #hBplus-SubmitAndCanceAjaxlID:not(.erp-report, .erp-report *) { padding: 12px; bottom: 0; }
    .erp-content .hbPlus-itemWrapper:not(.erp-report, .erp-report *) { display: flex; align-items: center; }
    .erp-content #hBplus-SubmitAndCanceAjaxlID > br:not(.erp-report, .erp-report *) { display: none; }
    .erp-content #hBplus-BtnSaveClose:not(.erp-report, .erp-report *) { flex: 1 1 100%; }
    .erp-content .hBplus-BtnEvnt:not(.erp-report, .erp-report *) { flex: 1 1 auto; }
    .erp-content #hBplus-BtnSaveClose .dx-button:not(.erp-report, .erp-report *) { width: 100%; }
    .erp-content #hBplus-FormDetailCon:not(.erp-report, .erp-report *) { margin-top: 20px; }
    .erp-content .nav-tabs:not(.erp-report, .erp-report *) { flex-wrap: wrap; justify-content: flex-start !important; }
    .erp-content .nav-tabs .nav-link:not(.erp-report, .erp-report *) { min-height: 44px; white-space: normal; }

    /* Reflow generated Form/GroupItem rows without recreating editors or templates. */
    .erp-content .dx-form .dx-layout-manager .dx-box-flex:not(.erp-report, .erp-report *) {
        flex-direction: column !important;
        height: auto !important;
        min-width: 0 !important;
        max-width: 100%;
    }

    .erp-content .dx-form .dx-layout-manager .dx-box-item:not(.erp-report, .erp-report *) {
        flex: 0 0 auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .erp-content .dx-form .dx-field-item:not(.erp-report, .erp-report *) { padding: 8px 0 !important; }
    .erp-content .dx-form .dx-field-item-label:not(.erp-report, .erp-report *) {
        float: none;
        display: block;
        width: 100% !important;
        padding: 0 0 6px !important;
        text-align: left;
    }

    .erp-content .dx-form .dx-field-item-label-content:not(.erp-report, .erp-report *) { width: auto !important; }
    .erp-content .dx-form .dx-field-item-content:not(.erp-report, .erp-report *) { width: 100% !important; }

    .erp-content .dx-texteditor:not(.erp-report, .erp-report *),
    .erp-content .dx-lookup:not(.erp-report, .erp-report *),
    .erp-content .form-control:not(.erp-report, .erp-report *),
    .erp-content .form-select:not(.erp-report, .erp-report *) {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100%;
        min-height: 44px;
        font-size: 16px;
    }

    .erp-content .dx-texteditor-input:not(.erp-report, .erp-report *) { font-size: 16px; min-height: 42px; }
    .erp-content .dx-dropdowneditor-button:not(.erp-report, .erp-report *) { min-width: 40px; }
    .erp-content .dx-checkbox:not(.erp-report, .erp-report *) { min-height: 44px; padding: 8px 0; }
    .erp-content .dx-radiogroup .dx-collection:not(.erp-report, .erp-report *) { display: flex; flex-wrap: wrap; gap: 8px; }
    .erp-content .dx-radiobutton:not(.erp-report, .erp-report *) { min-height: 44px; }
    .erp-content .dx-tagbox .dx-tag-content:not(.erp-report, .erp-report *) { white-space: normal; overflow-wrap: anywhere; }
    .erp-content .dx-field:not(.erp-report, .erp-report *) { display: flex; flex-direction: column; gap: 6px; }
    .erp-content .dx-field-label:not(.erp-report, .erp-report *),
    .erp-content .dx-field-value:not(.erp-report, .erp-report *) { width: 100% !important; float: none; white-space: normal; }
    .erp-content table:not(.dx-datagrid-table):not(.dx-treelist-table):not(.dx-calendar-body):not(.erp-report, .erp-report *) {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }
    .erp-content .dx-datagrid .dx-link:not(.erp-report, .erp-report *) { display: inline-block; padding: 10px 6px; min-width: 40px; }
    .erp-content .dx-datagrid-search-panel:not(.erp-report, .erp-report *) { margin: 0 !important; width: 100% !important; }
    .erp-content .dx-toolbar-item:has(.dx-texteditor):not(.erp-report, .erp-report *) { flex: 1 1 100%; width: 100%; }
    .erp-content .dx-toolbar-after:not(.erp-report, .erp-report *) { margin-left: 0 !important; }
    .erp-content .dx-datagrid-adaptive-more:not(.erp-report, .erp-report *) { min-width: 44px; min-height: 44px; }
    .erp-content .dx-datagrid-adaptive-more:not(.erp-report, .erp-report *)::before { font-size: 22px; }
    .erp-content .dx-adaptive-detail-row .dx-field-item-content:not(.erp-report, .erp-report *) { overflow-wrap: anywhere; }
    .erp-content .hbplus-form-card:not(.erp-report, .erp-report *) { padding: 12px; }
    .erp-content .row:not(.erp-report, .erp-report *) { --bs-gutter-x: 16px; }
    .erp-content .row > [class*="col-"]:not(.erp-report, .erp-report *) { flex: 0 0 100%; width: 100%; max-width: 100%; min-width: 0; }
    .erp-content .container-fluid:not(.erp-report, .erp-report *) { padding-left: 0; padding-right: 0; }
    .erp-content .erp-filters:not(.erp-report, .erp-report *),
    .erp-content #crudPartialViewID:not(.erp-report, .erp-report *),
    .erp-content .d-flex:has(> .dx-texteditor):not(.erp-report, .erp-report *),
    .erp-content .d-flex:has(> .dx-lookup):not(.erp-report, .erp-report *) {
        flex-direction: column;
        align-items: stretch !important;
        width: 100%;
        min-width: 0;
        gap: 12px;
    }
    .erp-content .erp-filters > .wrapper:not(.erp-report, .erp-report *) { width: 100%; min-width: 0; }
    .erp-content .erp-filters button:not(.erp-report, .erp-report *) { width: 100%; white-space: normal; }
    .erp-content #hBplus-crudPartialViewID .hbPlus-itemWrapper:not(.erp-report, .erp-report *) { width: auto; flex-wrap: wrap; }
    .erp-content .dx-form .pe-4:not(.erp-report, .erp-report *),
    .erp-content .dx-form .pe-5:not(.erp-report, .erp-report *) { padding-right: 0 !important; }
    .erp-content .modal-dialog:not(.erp-report, .erp-report *) { width: 95vw; }
    .erp-content .modal-body:not(.erp-report, .erp-report *) { padding: 12px; }
    .erp-content #modalRemarks .modal-Wrapper:not(.erp-report, .erp-report *),
    #modalRemarks.erp-content .modal-Wrapper:not(.erp-report, .erp-report *) { width: 95vw !important; max-width: 95vw; max-height: 90dvh; overflow-y: auto; }
    .erp-content .hBplus-forContentUI:not(.erp-report, .erp-report *) {
        width: 95vw;
        max-width: 95vw;
        height: auto;
        max-height: 90dvh;
        overflow-y: auto;
    }
    .erp-content .hBplus-forBodyUI:not(.erp-report, .erp-report *) { height: auto; overflow: visible; padding: 12px; }
    .erp-content .hBplus-forHeaderUI:not(.erp-report, .erp-report *) { flex-wrap: wrap; padding: 12px; }
}

@media screen and (min-width: 768px) and (max-width: 1199px) {
    .erp-content .dx-form .dx-layout-manager .dx-box-flex[style*="row"]:has(> .dx-box-item:nth-child(3)):not(.erp-report, .erp-report *) {
        flex-wrap: wrap !important;
        height: auto !important;
    }
    .erp-content .dx-form .dx-layout-manager .dx-box-flex[style*="row"]:has(> .dx-box-item:nth-child(3)) > .dx-box-item:not(.erp-report, .erp-report *) {
        flex: 0 0 50% !important;
        min-width: 0 !important;
        max-width: 50%;
    }
}

@media screen and (max-width: 480px) {
    .erp-shell .erp-header-row { gap: 4px; }
    .erp-shell #hBplus-SearchPanelList { flex-basis: 100%; order: 3; padding: 4px 8px; }
    .erp-shell .erp-header-actions { margin-left: auto; }
    .erp-content .hBplus-ListHeader > .d-flex:not(.erp-report, .erp-report *) { justify-content: flex-start !important; width: 100%; }
    .erp-content .dx-pager .dx-info:not(.erp-report, .erp-report *) { width: 100%; margin: 8px 0; }
}

@media (prefers-reduced-motion: reduce) {
    .erp-shell #erpNavigation { transition: none; }
}
