/* CMMS overlays: retain Bootstrap focus, dismissal and submission behavior. */
body :is(.modal-backdrop,.offcanvas-backdrop) { background: #172b35; }
body :is(.modal-backdrop,.offcanvas-backdrop).show { opacity: .45; }
body #profileModal { background-color: rgba(23,43,53,.45) !important; }
body .modal .modal-dialog { margin: 24px auto; }
body .modal .modal-dialog-centered { min-height: calc(100% - 48px); }
body .modal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 48px);
    border: 0 !important;
    border-radius: 8px !important;
    background: #fff;
    color: #20343c;
    box-shadow: 0 16px 44px rgba(23,43,53,.2) !important;
    overflow: hidden;
}
body #profileModal .modal-content { border: 0 !important; }
body .modal-content > form { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
body :is(.modal-header,.offcanvas-header) {
    display: flex;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
    padding: 16px 24px !important;
    border-bottom: 1px solid #d5dfe0 !important;
    background: #fff !important;
}
body :is(.modal-title,.offcanvas-title) { min-width: 0; margin: 0 !important; color: #172b35 !important; font-size: 1.125rem !important; font-weight: 650 !important; line-height: 1.4; letter-spacing: -.01em; }
body :is(.modal-title,.offcanvas-title) > .bi { color: #195e57 !important; font-size: 1.125rem !important; }
body :is(.modal-header,.offcanvas-header) > .btn-close { position: static !important; flex-shrink: 0; margin: 0 0 0 auto !important; opacity: .85; }
body .modal .modal-body { min-height: 0; padding: 24px !important; overflow-y: auto; overscroll-behavior: contain; font-size: .875rem; line-height: 1.6; }
body #profileModal .modal-body { max-height: none; padding: 24px !important; }
body .modal .modal-footer {
    flex-shrink: 0;
    align-items: stretch;
    gap: 8px;
    padding: 16px 24px !important;
    border-top: 1px solid #d5dfe0 !important;
    border-radius: 0 !important;
    background: #f5f8f7 !important;
}
body .modal-footer > :is(.btn,.cmms-button,.pf-button) { margin: 0; }
body .offcanvas.offcanvas-end {
    max-width: min(90vw,760px) !important;
    height: 100dvh;
    border: 0 !important;
    border-inline-start: 1px solid #d5dfe0 !important;
    border-radius: 0 !important;
    background: #fff;
    color: #20343c;
    box-shadow: none !important;
}
body .offcanvas-body { min-height: 0; padding: 24px !important; overflow-y: auto; overscroll-behavior: contain; font-size: .875rem; line-height: 1.6; }
body :is(.modal,.offcanvas) :is(.form-control,.form-select),
body .offcanvas .pf-form :is(input:not([type=hidden]):not([type=checkbox]):not([type=radio]),select,textarea) {
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #82949c;
    border-radius: 4px !important;
    background-color: #fff;
    color: #20343c;
    font-size: .875rem;
    line-height: 1.5;
    box-shadow: none;
}
body :is(.modal,.offcanvas) :is(.form-control,.form-select):focus-visible { border-color: var(--brand, #0f5b47); outline: var(--mtd-focus-width, 2px) solid var(--focus, #1f8f6f); outline-offset: 2px; box-shadow: none; }
body :is(.modal,.offcanvas) .select2-container { max-width: 100%; }
body :is(.modal,.offcanvas) .select2-container--bootstrap-5 .select2-selection { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line, #e2e9e5); border-radius: var(--r-input, 12px); font-size: .875rem; }
body :is(.modal,.offcanvas) .select2-container--bootstrap-5.select2-container--focus .select2-selection { border-color: var(--brand, #0f5b47); outline: var(--mtd-focus-width, 2px) solid var(--focus, #1f8f6f); outline-offset: 2px; box-shadow: none; }
body :is(.modal,.offcanvas) .was-validated :is(.form-control,.form-select):invalid,
body :is(.modal,.offcanvas) .input-validation-error { border-color: var(--red, #b42318); }
body :is(.modal,.offcanvas) :is(.field-validation-error,.invalid-feedback) { color: var(--red, #b42318); font-size: .8125rem; line-height: 1.5; }
body .offcanvas :is(.pf-actions,.nr-actions,.od-actions) {
    position: sticky;
    bottom: -24px;
    z-index: 2;
    margin-inline: -24px;
    padding: 16px 24px;
    border-top: 1px solid #d5dfe0;
    background: #f5f8f7;
}
.od-context { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid #d5dfe0; }
.od-record { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.od-record > strong { color: #195e57; font-size: .9375rem; }
.od-context > p { color: #20343c; line-height: 1.6; margin: 0 0 16px; overflow-wrap: anywhere; }
.od-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 0; }
.od-facts div { min-width: 0; }
.od-facts dt { color: #52616a; font-size: .8125rem; font-weight: 500; margin-bottom: 4px; }
.od-facts dd { color: #20343c; font-size: .875rem; margin: 0; overflow-wrap: anywhere; }
.od-field { margin-bottom: 20px; }
.od-field > label { display: block; margin-bottom: 6px; color: #20343c; font-size: .875rem; font-weight: 600; }
.od-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 24px; }
body .wod-lightbox .modal-body { padding: 12px !important; }
body .modal-body > img { max-width: 100%; max-height: 65dvh; object-fit: contain; }
body #mobileQuickActionsSheet { max-height: calc(100dvh - 24px); border-radius: 8px 8px 0 0 !important; }
body #mobileQuickActionsSheet .mobile-sheet-handle { background: #82949c; }
body .quick-action-sheet-item { border-radius: 4px; }
body .quick-action-sheet-icon { border-radius: 4px; background: #edf5f1 !important; color: #195e57 !important; }
body .swal2-popup { max-height: calc(100dvh - 32px); padding: 24px !important; overflow-y: auto; border-radius: 8px !important; color: #20343c; font-family: inherit; font-size: .875rem; box-shadow: 0 16px 44px rgba(23,43,53,.2) !important; }
body .swal2-title { color: #172b35; font-size: 1.25rem; font-weight: 650; line-height: 1.4; }
body .swal2-html-container { color: #52616a; font-size: .875rem; line-height: 1.6; }
body .swal2-actions { gap: 8px; }
@media (max-width: 767.98px) {
    body #globalOffcanvas, body .offcanvas.offcanvas-end { width: 100% !important; max-width: 100% !important; border-inline-start: 0 !important; border-radius: 0 !important; }
    body :is(.modal-header,.offcanvas-header) { padding: 12px 16px !important; }
    body :is(.modal-header,.offcanvas-header) > .btn-close { align-self: center !important; }
    body .offcanvas-body { padding: 20px 16px !important; padding-bottom: max(20px,env(safe-area-inset-bottom)) !important; }
    body .offcanvas :is(.pf-actions,.nr-actions,.od-actions) { bottom: -20px; margin-inline: -16px; padding: 16px; padding-bottom: max(16px,env(safe-area-inset-bottom)); }
    body .modal .modal-dialog { position: relative !important; bottom: auto !important; width: calc(100% - 24px) !important; max-width: none !important; margin: 12px auto !important; }
    body .modal .modal-dialog-centered { min-height: calc(100% - 24px); }
    body .modal .modal-content { max-height: calc(100dvh - 24px); border-radius: 8px !important; }
    body .modal .modal-body,body #profileModal .modal-body { padding: 20px 16px !important; }
    body .modal .modal-footer { padding: 12px 16px !important; }
    body .modal-footer > :is(.btn,.cmms-button,.pf-button) { flex: 1 1 120px; }
    body :is(.modal,.offcanvas) :is(.form-control,.form-select) { font-size: 1rem; }
    body .swal2-popup { padding: 20px 16px !important; }
}
@media (prefers-reduced-motion: reduce) { body :is(.modal,.offcanvas,.modal-dialog,.modal-backdrop,.offcanvas-backdrop) { transition: none !important; } }

/* Side drawers and dialogs do not use the legacy bottom-sheet grab handle. */
body .offcanvas-end .offcanvas-header::before, body .modal-content::before { display: none !important; content: none !important; }
body .offcanvas-title { text-align: start !important; justify-content: flex-start !important; }

