/* Shared mobile dialog rules, including desktop sections embedded in mobile. */
html.m-app {
  --m-overlay-safe-top: env(safe-area-inset-top, 0px);
  --m-overlay-safe-right: env(safe-area-inset-right, 0px);
  --m-overlay-safe-bottom: env(safe-area-inset-bottom, 0px);
  --m-overlay-safe-left: env(safe-area-inset-left, 0px);
}
.m-overlay-safe-close {
  position: fixed !important;
  top: calc(var(--m-overlay-vtop, 0px) + max(8px, var(--m-overlay-safe-top, 0px))) !important;
  left: calc(var(--m-overlay-vleft, 0px) + var(--m-overlay-vwidth, 100vw) - max(8px, var(--m-overlay-safe-right, 0px)) - 112px) !important;
  right: auto !important;
  bottom: auto !important;
  z-index: 2147483646 !important;
  width: 112px !important;
  min-width: 112px !important;
  height: 48px !important;
  min-height: 48px !important;
  margin: 0 !important;
  padding: 0 12px !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 12px !important;
  background: #fff !important;
  color: #0f172a !important;
  box-shadow: 0 2px 14px #0004;
  font: 600 16px/1 system-ui, sans-serif !important;
  cursor: pointer;
  touch-action: manipulation;
}
.m-overlay-safe-close[hidden] { display: none !important; }
.m-overlay-safe-close:disabled { opacity: .55; }
html.m-app :is(.m-contract-edit-sheet__panel, .m-contract-driver-sheet__panel,
  .m-contract-comment-modal__panel, .m-est-sheet__panel, .m-more-sheet__panel,
  .rc-sheet__panel, .m-action-sheet__panel) {
  box-sizing: border-box;
  max-height: calc(var(--m-overlay-vheight, 100dvh) - max(12px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
  overflow-y: auto;
  overscroll-behavior: contain;
}
html.m-app :is(.m-contract-edit-sheet__head, .m-contract-driver-sheet__head, .m-est-sheet__head) {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--m-surface, #fff);
}
html.m-app :is(.m-contract-edit-sheet__close, .m-contract-driver-sheet__close,
  .m-contract-photo-overlay__close, .m-delivery-calc-modal__close,
  .m-est-sheet__head button, .catalogs-lightbox__close) {
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
  touch-action: manipulation;
}
html.m-app :is(.m-contract-photo-overlay, .m-delivery-calc-modal) {
  box-sizing: border-box;
}
html.m-app .m-contract-photo-overlay__close { z-index: 2; }
html.m-app .crm-disk-name-dialog {
  box-sizing: border-box;
  max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
  max-height: calc(var(--m-overlay-vheight, 100dvh) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
}
html.m-app .crm-disk-name-actions {
  position: sticky;
  bottom: 0;
  background: var(--m-surface, #fff);
  padding-top: 8px;
  z-index: 2;
}
html.m-app .m-chat-image-viewer[open] {
  position: fixed;
  inset: auto;
  top: var(--m-overlay-vtop, 0px);
  left: var(--m-overlay-vleft, 0px);
  width: var(--m-overlay-vwidth, 100vw);
  height: var(--m-overlay-vheight, 100dvh);
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  border: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: #20242a;
  color: white;
  overflow: hidden;
}
.m-chat-image-viewer header {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
  padding: calc(6px + var(--m-overlay-safe-top, 0px)) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
}
.m-chat-image-viewer strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-chat-image-viewer header button {
  flex: 0 0 auto;
  min-width: 106px;
  min-height: 48px;
  border: 1px solid #64748b;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font: 600 16px system-ui, sans-serif;
  touch-action: manipulation;
}
.m-chat-image-viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.m-chat-image-viewer p { padding: 16px; }
