/* =============================================================================
   OrganicSystem — UI-1.5 Global Popup / Modal / Dialog Standardization
   Presentation only: surfaces, overlay, chrome, stacking. No behavior changes.
   Load AFTER os-dropdown-theme.css (UI-1.4): dropdown chrome stays owned there;
   this file only elevates dropdown z-index while a modal/popup is open.
   ============================================================================= */

:root {
  --os-popup-radius: var(--os-erp-popup-radius, var(--os-erp-radius, 0.5rem));
  --os-popup-shadow: var(--os-shadow, var(--os-color-shadow-md));
  --os-popup-bg: var(--os-color-popup, var(--os-surface, var(--os-color-surface)));
  --os-popup-fg: var(--os-text, var(--os-color-text));
  --os-popup-border: var(--os-border, var(--os-color-border));
  --os-popup-header-bg: var(--os-popup-bg);
  --os-popup-header-fg: var(--os-popup-fg);
  --os-popup-footer-bg: var(--os-surface-alt, var(--os-color-surface-muted));
  --os-popup-overlay: var(--os-overlay, var(--os-color-overlay));
  /* UI-POPUP-HEIGHT-1 — global popup control geometry (touch-friendly, Light+Dark). */
  --os-popup-control-height: 40px;
  --os-popup-control-font-size: 0.875rem;
  --os-popup-control-line-height: 1.25;
  --os-popup-control-padding-y: 0.375rem;
  --os-popup-control-padding-x: 0.65rem;
  --os-popup-textarea-min-height: 80px;
  --os-popup-list-item-min-height: 30px;
  --os-popup-check-row-min-height: 32px;
  --os-erp-popup-field-h: var(--os-popup-control-height);
}

/* Hosts that are true dialogs/modals — NOT SelectBox/DateBox/TagBox overlays */
.modal-content,
.offcanvas,
.popover,
.os-confirm-dialog,
#os-plan-sync-overlay .os-plan-sync-dialog,
.os-report-popup__dialog,
.swal2-popup,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) > .dx-overlay-content.dx-popup-normal,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) > .dx-overlay-content.dx-popup-draggable,
.dx-dialog-wrapper .dx-overlay-content,
.dx-popover-wrapper .dx-overlay-content,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) > .dx-overlay-content {
  background-color: var(--os-popup-bg) !important;
  color: var(--os-popup-fg) !important;
  border-color: var(--os-popup-border) !important;
  box-shadow: var(--os-popup-shadow);
  border-radius: var(--os-popup-radius);
}

.modal-header,
.modal-footer,
.offcanvas-header,
.offcanvas-footer,
.os-report-popup__header,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-title,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-bottom.dx-toolbar,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-title,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-bottom.dx-toolbar,
.dx-dialog-wrapper .dx-popup-title {
  background-color: var(--os-popup-header-bg) !important;
  color: var(--os-popup-header-fg) !important;
  border-color: var(--os-popup-border) !important;
}

.modal-footer,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-bottom.dx-toolbar,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-bottom.dx-toolbar {
  background-color: var(--os-popup-footer-bg) !important;
}

.modal-title,
.offcanvas-title,
.os-report-popup__title,
.dx-dialog-message,
.os-confirm-dialog .os-confirm-message,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-title .dx-toolbar-label,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-title .dx-toolbar-label .dx-toolbar-item-content,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-title .dx-toolbar-label {
  color: var(--os-popup-fg) !important;
}

.modal-body,
.offcanvas-body,
.popover-body,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content,
.dx-dialog-wrapper .dx-popup-content {
  background-color: var(--os-popup-bg) !important;
  color: var(--os-popup-fg) !important;
}

/* Close / dismiss controls */
.modal-header .btn-close,
.offcanvas-header .btn-close,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-closebutton .dx-icon,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-title .dx-button .dx-icon,
.os-report-popup__btn {
  color: var(--os-popup-header-fg) !important;
  opacity: 0.85;
}

.modal-header .btn-close {
  filter: none;
}

html[data-theme="dark"] .modal-header .btn-close,
html[data-bs-theme="dark"] .modal-header .btn-close,
html[data-theme="dark"] .offcanvas-header .btn-close,
html[data-bs-theme="dark"] .offcanvas-header .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Overlay / shader / backdrop */
.modal-backdrop,
.offcanvas-backdrop,
.dx-overlay-shader,
.os-plan-sync-overlay,
.os-loading-overlay,
.os-report-popup__backdrop {
  background-color: var(--os-popup-overlay) !important;
}

/* Forms / grids inside dialog hosts */
.modal-body .form-control,
.modal-body .form-select,
.modal-body textarea,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content .form-control,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content .form-select,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content textarea,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-texteditor,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-texteditor-input,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-texteditor,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-texteditor-input,
.dx-dialog-wrapper .dx-texteditor,
.dx-dialog-wrapper .dx-texteditor-input {
  background-color: var(--os-input-bg, var(--os-color-form-control-bg)) !important;
  color: var(--os-input-text, var(--os-color-input-text)) !important;
  border-color: var(--os-input-border, var(--os-color-form-border)) !important;
}

.modal-body .dx-datagrid,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-datagrid,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-datagrid-headers,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-datagrid-rowsview,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-datagrid-pager,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-datagrid {
  background-color: var(--os-color-grid, var(--os-popup-bg)) !important;
  color: var(--os-popup-fg) !important;
  border-color: var(--os-popup-border) !important;
}

.modal-body,
.offcanvas-body,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content,
.os-report-popup__body {
  scrollbar-color: color-mix(in srgb, var(--os-popup-fg) 35%, transparent)
    color-mix(in srgb, var(--os-popup-bg) 88%, var(--os-popup-fg));
  scrollbar-width: thin;
}

/* ---------- Stacking (UI-1.14 documents layers in os-theme.css) ---------- */
.modal-backdrop {
  z-index: var(--os-z-modal-backdrop, 1050);
}

.modal {
  z-index: var(--os-z-modal, 1055);
}

.popover {
  z-index: var(--os-z-popover, 1080);
}

/*
  UI-1.14: restore DX dialog/popover stack after UI-1.6 deferred ownership here.
  Use --os-z-dx-* (1500), not Bootstrap --os-z-popover (1080) which sits under
  mobile overlay (1200). Exclude dropdowneditor/datebox — UI-1.4 owns those.
*/
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper),
.dx-dialog-wrapper {
  z-index: var(--os-z-dx-popup, 1500);
}

.dx-overlay-wrapper.dx-popover-wrapper {
  z-index: var(--os-z-dx-popover, 1500);
}

/*
  UI-1.4 sets dropdown overlays to ~3500 (above normal chrome).
  Elevated popups (e.g. harvest 16000) need dropdowns higher while open.
  Page-specific harvest rule (17050) remains compatible.
*/
body:has(.modal.show) .dx-overlay-wrapper.dx-dropdowneditor-overlay,
body:has(.modal.show) .dx-overlay-wrapper.dx-datebox-wrapper,
body:has(.modal.show) .dx-overlay-wrapper.dx-header-filter-menu,
body:has(.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-state-invisible):not(.dx-dropdowneditor-overlay)) .dx-overlay-wrapper.dx-dropdowneditor-overlay,
body:has(.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-state-invisible):not(.dx-dropdowneditor-overlay)) .dx-overlay-wrapper.dx-datebox-wrapper,
body:has(.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-state-invisible):not(.dx-dropdowneditor-overlay)) .dx-overlay-wrapper.dx-header-filter-menu,
body:has(.dx-overlay-wrapper[class*="-popup"]:not(.dx-state-invisible):not(.dx-dropdowneditor-overlay)) .dx-overlay-wrapper.dx-dropdowneditor-overlay,
body:has(.dx-overlay-wrapper[class*="-popup"]:not(.dx-state-invisible):not(.dx-dropdowneditor-overlay)) .dx-overlay-wrapper.dx-datebox-wrapper,
body:has(.dx-overlay-wrapper[class*="-popup"]:not(.dx-state-invisible):not(.dx-dropdowneditor-overlay)) .dx-overlay-wrapper.dx-header-filter-menu {
  z-index: var(--os-z-dropdown-in-popup, 17050) !important;
}

body:has(.modal.show) .dropdown-menu.show {
  z-index: calc(var(--os-z-modal, 1055) + 20) !important;
}

.os-report-popup {
  z-index: var(--os-z-report-popup, 20050);
}

body > .dropdown-menu.os-toolbar-dropdown-menu-portaled,
body > .dropdown-menu.os-toolbar-dropdown-menu-portaled.show {
  z-index: var(--os-z-toolbar-menu, 20050) !important;
}

.os-action-toast-host,
#os-action-toast-host {
  z-index: var(--os-z-toast, 20100);
}

/* ---------- Dark: no white dialog chrome ---------- */
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .offcanvas,
html[data-theme="dark"] .popover,
html[data-theme="dark"] .os-confirm-dialog,
html[data-theme="dark"] #os-plan-sync-overlay .os-plan-sync-dialog,
html[data-theme="dark"] .os-report-popup__dialog,
html[data-theme="dark"] .swal2-popup,
html[data-theme="dark"] .dx-dialog-wrapper .dx-overlay-content,
html[data-theme="dark"] .dx-popover-wrapper .dx-overlay-content,
html[data-theme="dark"] .dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) > .dx-overlay-content,
html[data-theme="dark"] .dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) > .dx-overlay-content,
html[data-theme="dark"] .modal-body,
html[data-theme="dark"] .dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-content,
html[data-theme="dark"] .dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-title,
html[data-theme="dark"] .dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-bottom.dx-toolbar,
html[data-bs-theme="dark"] .modal-content,
html[data-bs-theme="dark"] .dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) > .dx-overlay-content,
html[data-bs-theme="dark"] .dx-dialog-wrapper .dx-overlay-content {
  background-color: var(--os-popup-bg) !important;
  color: var(--os-popup-fg) !important;
  border-color: var(--os-popup-border) !important;
}

html[data-theme="dark"] .os-report-popup__body {
  background: var(--os-color-page-bg, var(--os-popup-bg)) !important;
}

html[data-theme="dark"] .os-report-popup__loading,
html[data-theme="dark"] .os-report-popup__error {
  background: color-mix(in srgb, var(--os-popup-bg) 92%, transparent) !important;
  color: var(--os-popup-fg) !important;
}

/* =============================================================================
   UI-POPUP-HEIGHT-1 — FINAL popup control height (all dialog hosts)
   Presentation only. No JS. Does not target dropdown list overlays as dialogs.
   Scope: Bootstrap modal/offcanvas, DX popup/dialog (not SelectBox/DateBox host),
   confirm / report / SweetAlert hosts.
   ============================================================================= */

/* Single-line editors + native fields */
.modal-body .form-control:not(textarea):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.modal-body .form-control-sm:not(textarea):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.modal-body .form-select,
.modal-body .form-select-sm,
.offcanvas-body .form-control:not(textarea):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.offcanvas-body .form-select,
.os-confirm-dialog .form-control:not(textarea),
.os-confirm-dialog .form-select,
.os-report-popup__body .form-control:not(textarea),
.os-report-popup__body .form-select,
.swal2-popup .swal2-input,
.swal2-popup .swal2-select,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .form-control:not(textarea):not([type="checkbox"]):not([type="radio"]),
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .form-select,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .form-control:not(textarea),
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .form-select,
.dx-dialog-wrapper .form-control:not(textarea),
.dx-dialog-wrapper .form-select,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .dx-texteditor:not(.dx-textarea):not(.dx-tagbox),
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-texteditor:not(.dx-textarea):not(.dx-tagbox),
.dx-dialog-wrapper .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) {
  min-height: var(--os-popup-control-height);
  height: var(--os-popup-control-height);
  max-height: none;
  box-sizing: border-box;
  font-size: var(--os-popup-control-font-size);
  line-height: var(--os-popup-control-line-height);
  padding-block: var(--os-popup-control-padding-y);
  padding-inline: var(--os-popup-control-padding-x);
}

/* TagBox / multi-select: match min height, grow when tags wrap */
.modal-body .dx-tagbox.dx-texteditor,
.offcanvas-body .dx-tagbox.dx-texteditor,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .dx-tagbox.dx-texteditor,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-tagbox.dx-texteditor,
.dx-dialog-wrapper .dx-tagbox.dx-texteditor {
  min-height: var(--os-popup-control-height);
  height: auto;
  max-height: none;
  box-sizing: border-box;
  font-size: var(--os-popup-control-font-size);
}

/* Textarea: never force single-line height */
.modal-body textarea.form-control,
.modal-body textarea.form-control-sm,
.offcanvas-body textarea.form-control,
.os-confirm-dialog textarea.form-control,
.os-report-popup__body textarea.form-control,
.swal2-popup textarea.swal2-textarea,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content textarea.form-control,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .dx-textarea.dx-texteditor,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content textarea.form-control,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-textarea.dx-texteditor,
.dx-dialog-wrapper textarea.form-control,
.dx-dialog-wrapper .dx-textarea.dx-texteditor {
  min-height: var(--os-popup-textarea-min-height);
  height: auto;
  max-height: none;
  box-sizing: border-box;
  font-size: var(--os-popup-control-font-size);
  line-height: 1.4;
  padding-block: var(--os-popup-control-padding-y);
  padding-inline: var(--os-popup-control-padding-x);
}

/* Sync DX editor chrome (input + buttons) inside dialogs */
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-container,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-input-container,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-container,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-input-container,
.dx-dialog-wrapper .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-container,
.dx-dialog-wrapper .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-input-container,
.modal-body .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-container,
.modal-body .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-input-container {
  min-height: calc(var(--os-popup-control-height) - 2px);
  height: 100%;
  box-sizing: border-box;
}

.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-input,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-input,
.dx-dialog-wrapper .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-input,
.modal-body .dx-texteditor:not(.dx-textarea):not(.dx-tagbox) .dx-texteditor-input {
  min-height: calc(var(--os-popup-control-height) - 2px);
  height: calc(var(--os-popup-control-height) - 2px);
  box-sizing: border-box;
  font-size: var(--os-popup-control-font-size);
  line-height: var(--os-popup-control-line-height);
  padding-block: var(--os-popup-control-padding-y);
}

.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .dx-texteditor:not(.dx-textarea) .dx-dropdowneditor-button,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .dx-texteditor:not(.dx-textarea) .dx-clear-button-area,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-texteditor:not(.dx-textarea) .dx-dropdowneditor-button,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-texteditor:not(.dx-textarea) .dx-clear-button-area,
.dx-dialog-wrapper .dx-texteditor:not(.dx-textarea) .dx-dropdowneditor-button,
.dx-dialog-wrapper .dx-texteditor:not(.dx-textarea) .dx-clear-button-area,
.modal-body .dx-texteditor:not(.dx-textarea) .dx-dropdowneditor-button,
.modal-body .dx-texteditor:not(.dx-textarea) .dx-clear-button-area {
  min-height: calc(var(--os-popup-control-height) - 2px);
  height: calc(var(--os-popup-control-height) - 2px);
  box-sizing: border-box;
}

/* Buttons — body + footer + DX toolbar */
.modal-body .btn:not(.btn-link):not(.btn-close):not(.dropdown-item),
.modal-footer .btn:not(.btn-link):not(.btn-close):not(.dropdown-item),
.modal-header .btn:not(.btn-link):not(.btn-close):not(.dropdown-item),
.offcanvas-body .btn:not(.btn-link):not(.btn-close):not(.dropdown-item),
.offcanvas-header .btn:not(.btn-link):not(.btn-close):not(.dropdown-item),
.os-confirm-dialog .btn:not(.btn-link):not(.btn-close),
.os-report-popup__header .os-report-popup__btn,
.os-report-popup__footer .btn,
.swal2-popup .swal2-actions .swal2-styled,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-bottom .dx-button,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-title .dx-button:not(.dx-closebutton),
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .dx-button:not(.dx-button-has-icon.dx-button-normal.dx-widget.dx-button-mode-text),
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-bottom .dx-button,
.dx-dialog-wrapper .dx-dialog-button {
  min-height: var(--os-popup-control-height);
  height: var(--os-popup-control-height);
  max-height: none;
  box-sizing: border-box;
  font-size: var(--os-popup-control-font-size);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-block: 0;
}

/* Close / dismiss — keep square hit area without stretching icon chrome oddly */
.modal-header .btn-close,
.offcanvas-header .btn-close {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0.5rem;
  box-sizing: content-box;
}

.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-closebutton,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-closebutton {
  min-width: var(--os-popup-control-height);
  min-height: var(--os-popup-control-height);
}

/* Checkbox / radio / switch — enlarge clickable row, not the glyph alone */
.modal-body .form-check,
.offcanvas-body .form-check,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .form-check,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .form-check,
.dx-dialog-wrapper .form-check {
  min-height: var(--os-popup-check-row-min-height);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.modal-body .form-check-label,
.offcanvas-body .form-check-label,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .form-check-label {
  line-height: 1.3;
  padding-block: 0.35rem;
}

.modal-body .form-switch,
.offcanvas-body .form-switch,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .form-switch {
  min-height: var(--os-popup-check-row-min-height);
  padding-block: 0.25rem;
}

/* Grid filter editors inside dialogs — not smaller than standard */
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay):not(.dx-datebox-wrapper) .dx-popup-content .dx-datagrid-filter-row .dx-editor-cell .dx-texteditor,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-content .dx-datagrid-filter-row .dx-editor-cell .dx-texteditor,
.modal-body .dx-datagrid-filter-row .dx-editor-cell .dx-texteditor {
  min-height: var(--os-popup-control-height);
  height: var(--os-popup-control-height);
  box-sizing: border-box;
}

/* Header / footer vertical centering */
.modal-header,
.offcanvas-header,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-title,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-title {
  min-height: var(--os-erp-popup-header-h, 2.75rem);
  display: flex;
  align-items: center;
}

.modal-footer,
.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-dropdowneditor-overlay) .dx-popup-bottom.dx-toolbar,
.dx-overlay-wrapper[class*="-popup"]:not(.dx-dropdowneditor-overlay) .dx-popup-bottom.dx-toolbar {
  min-height: calc(var(--os-popup-control-height) + 0.9rem);
  align-items: center;
}

/*
  Opened dropdown list items while a dialog is open — comfortable click height.
  Does not enlarge the closed editor beyond --os-popup-control-height.
*/
body:has(.modal.show) .dx-overlay-wrapper.dx-dropdowneditor-overlay .dx-list-item,
body:has(.modal.show) .dx-overlay-wrapper.dx-datebox-wrapper .dx-list-item,
body:has(.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-state-invisible):not(.dx-dropdowneditor-overlay)) .dx-overlay-wrapper.dx-dropdowneditor-overlay .dx-list-item,
body:has(.dx-overlay-wrapper[class*="-popup"]:not(.dx-state-invisible):not(.dx-dropdowneditor-overlay)) .dx-overlay-wrapper.dx-dropdowneditor-overlay .dx-list-item {
  min-height: var(--os-popup-list-item-min-height);
  box-sizing: border-box;
}

body:has(.modal.show) .dx-overlay-wrapper.dx-dropdowneditor-overlay .dx-list-search .dx-texteditor,
body:has(.dx-overlay-wrapper.dx-popup-wrapper:not(.dx-state-invisible):not(.dx-dropdowneditor-overlay)) .dx-overlay-wrapper.dx-dropdowneditor-overlay .dx-list-search .dx-texteditor {
  min-height: var(--os-popup-control-height);
  height: var(--os-popup-control-height);
  box-sizing: border-box;
}

/* Touch: slight bump on coarse pointers without forcing 44px everywhere */
@media (pointer: coarse) {
  :root {
    --os-popup-control-height: 42px;
    --os-popup-list-item-min-height: 32px;
    --os-popup-check-row-min-height: 34px;
  }
}
