/* ERP Online modal guard.
   CSS only. Loaded after the theme so old inline/page modal rules cannot hide scroll areas. */
html.gc-erp-online-theme :where(.modal-overlay, .pos-modal-overlay, [class*="modal-overlay"]) {
    box-sizing: border-box !important;
    overflow: hidden !important;
    overscroll-behavior: contain !important;
}

html.gc-erp-online-theme :where(.modal-overlay, .pos-modal-overlay, [class*="modal-overlay"]) > :where(
    .modal,
    .modal-content,
    .modal-cliente,
    .modal-produto,
    .modal-categoria,
    .modal-conta,
    .modal-usuario,
    .modal-cupom,
    .modal-orcamento,
    .modal-venda,
    .modal-status-os,
    .modal-caixa,
    .modal-impressao,
    .modal-conta-recebimento,
    .pos-modal
) {
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    max-height: calc(100vh - 32px) !important;
    max-height: calc(100dvh - 32px) !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

html.gc-erp-online-theme :where(.modal-overlay, .pos-modal-overlay, [class*="modal-overlay"]) > :where(
    .modal,
    .modal-content,
    .modal-cliente,
    .modal-produto,
    .modal-categoria,
    .modal-conta,
    .modal-usuario,
    .modal-cupom,
    .modal-orcamento,
    .modal-venda,
    .modal-status-os,
    .modal-caixa,
    .modal-impressao,
    .modal-conta-recebimento,
    .pos-modal
) > form {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow: hidden !important;
}

html.gc-erp-online-theme :where(.modal-overlay, .pos-modal-overlay, [class*="modal-overlay"]) :where(
    .modal-header,
    .modal-footer,
    .form-actions,
    .pos-modal-header,
    .pos-modal-footer,
    .gc-edit-tool-modal__header,
    .gc-edit-tool-modal__footer
) {
    flex: 0 0 auto !important;
}

html.gc-erp-online-theme :where(.modal-overlay, .pos-modal-overlay, [class*="modal-overlay"]) :where(
    .modal-body,
    .pos-modal-body,
    .gc-edit-tool-modal__body
) {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-gutter: stable !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
}

html.gc-erp-online-theme :where(.modal-overlay, .pos-modal-overlay, [class*="modal-overlay"]) > .modal > form > .modal-content,
html.gc-erp-online-theme :where(.modal-overlay, .pos-modal-overlay, [class*="modal-overlay"]) > .modal-content > form > .modal-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-gutter: stable !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
}

html.gc-erp-online-theme :where(.gc-edit-tool-overlay) {
    z-index: 260000 !important;
}

html.gc-erp-online-theme :where(.gc-edit-tool-modal) {
    display: flex !important;
    flex-direction: column !important;
    z-index: 260001 !important;
}

html.gc-erp-online-theme :where(.gc-variant-list) {
    min-height: 0 !important;
    padding-bottom: 0.25rem !important;
}

/* Variants inside edit sale/budget: fixed modal chrome, scrollable option list. */
html.gc-erp-online-theme :where(#modalVariantesItem, #modalVariantesItemOrc).gc-variant-overlay {
    align-items: center !important;
    justify-content: center !important;
    padding: 18px !important;
    overflow: hidden !important;
    z-index: 260000 !important;
}

html.gc-erp-online-theme :where(#modalVariantesItem, #modalVariantesItemOrc) .gc-variant-modal {
    display: flex !important;
    flex-direction: column !important;
    width: min(560px, calc(100vw - 36px)) !important;
    max-width: 560px !important;
    height: min(720px, calc(100vh - 36px)) !important;
    height: min(720px, calc(100dvh - 36px)) !important;
    max-height: calc(100vh - 36px) !important;
    max-height: calc(100dvh - 36px) !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

html.gc-erp-online-theme :where(#modalVariantesItem, #modalVariantesItemOrc) .gc-edit-tool-modal__header,
html.gc-erp-online-theme :where(#modalVariantesItem, #modalVariantesItemOrc) .gc-edit-tool-modal__footer {
    flex: 0 0 auto !important;
}

html.gc-erp-online-theme :where(#modalVariantesItem, #modalVariantesItemOrc) .gc-edit-tool-modal__body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: scroll !important;
    scrollbar-gutter: stable both-edges !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
}

html.gc-erp-online-theme :where(.modal-body, .pos-modal-body, .gc-edit-tool-modal__body) {
    scrollbar-width: thin;
    scrollbar-color: rgba(14, 165, 198, 0.75) rgba(226, 232, 240, 0.85);
}

html.gc-erp-online-theme :where(.modal-body, .pos-modal-body, .gc-edit-tool-modal__body)::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

html.gc-erp-online-theme :where(.modal-body, .pos-modal-body, .gc-edit-tool-modal__body)::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, 0.85);
    border-radius: 999px;
}

html.gc-erp-online-theme :where(.modal-body, .pos-modal-body, .gc-edit-tool-modal__body)::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 198, 0.78);
    border: 2px solid rgba(226, 232, 240, 0.85);
    border-radius: 999px;
}

html.gc-erp-online-theme :where(.gc-modal-shell) {
    box-sizing: border-box !important;
    position: fixed !important;
    inset: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    padding: clamp(12px, 2.5vh, 24px) !important;
    overflow: hidden !important;
    overscroll-behavior: contain !important;
    z-index: 240000 !important;
}

html.gc-erp-online-theme :where(.gc-modal-shell.gc-modal-tier-top) {
    z-index: 270000 !important;
}

html.gc-erp-online-theme :where(.gc-modal-dialog) {
    box-sizing: border-box !important;
    position: relative !important;
    z-index: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    max-height: calc(100vh - 32px) !important;
    max-height: calc(100dvh - 32px) !important;
    min-height: 0 !important;
    overflow: hidden !important;
    transform: none !important;
}

html.gc-erp-online-theme :where(.gc-modal-dialog-scroll) {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-gutter: stable !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
}

html.gc-erp-online-theme :where(.gc-modal-form) {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    min-height: 0 !important;
    max-height: 100% !important;
    overflow: hidden !important;
}

html.gc-erp-online-theme :where(.gc-modal-scroll-body) {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-gutter: stable !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
}

html.gc-erp-online-theme :where(.gc-modal-footer-lock) {
    flex: 0 0 auto !important;
}

html.gc-erp-online-theme :where(.gc-edit-tool-modal.gc-modal-dialog) {
    display: flex !important;
    flex-direction: column !important;
    max-height: calc(100vh - 36px) !important;
    max-height: calc(100dvh - 36px) !important;
    overflow: hidden !important;
}

html.gc-erp-online-theme :where(.gc-edit-tool-modal__body.gc-modal-scroll-body) {
    max-height: none !important;
}

html.gc-erp-online-theme :where(.gc-variant-list) {
    min-height: 0 !important;
    padding-bottom: 0.25rem !important;
}

html.gc-erp-online-theme :where(.gc-modal-scroll-body, .gc-modal-dialog-scroll) {
    scrollbar-width: thin;
    scrollbar-color: rgba(14, 165, 198, 0.75) rgba(226, 232, 240, 0.85);
}

html.gc-erp-online-theme :where(.gc-modal-scroll-body, .gc-modal-dialog-scroll)::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

html.gc-erp-online-theme :where(.gc-modal-scroll-body, .gc-modal-dialog-scroll)::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, 0.85);
    border-radius: 999px;
}

html.gc-erp-online-theme :where(.gc-modal-scroll-body, .gc-modal-dialog-scroll)::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 198, 0.78);
    border: 2px solid rgba(226, 232, 240, 0.85);
    border-radius: 999px;
}

@media (max-width: 768px) {
    html.gc-erp-online-theme :where(.gc-modal-shell) {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    html.gc-erp-online-theme :where(.gc-modal-dialog) {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 94vh !important;
        max-height: 94dvh !important;
        border-radius: 18px 18px 0 0 !important;
    }

    html.gc-erp-online-theme :where(.gc-edit-tool-modal.gc-modal-dialog) {
        max-height: 92vh !important;
        max-height: 92dvh !important;
    }
}
