/* Consistent viewport bounds and scrolling for Staff overlays. Loaded after legacy styles. */
html {
  scrollbar-gutter: stable;
}

html.staff-overlay-open,
html.staff-overlay-open body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

body :is(dialog[open], [role="dialog"][aria-modal="true"]) {
  box-sizing: border-box;
  overscroll-behavior: contain;
}

body :is(.staff-modal, .tz-dialog, .request-detail-dialog)[open] {
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

body :is(.step35-admin-panel, .nik50-modal-card, .step48-modal-card, .step34-news-modal,
  .nikmed-step31-modal-card, .nik67-delete-card, .nikmed-step28-file-box)[aria-modal="true"] {
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

body .chat-people-dialog[open] {
  display: flex;
  flex-direction: column;
  width: min(680px, calc(100vw - 24px));
  height: min(760px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  padding: clamp(14px, 2vw, 24px);
}

body .chat-people-dialog[open] > header,
body .chat-people-dialog[open] > .tz-error {
  flex: 0 0 auto;
}

body .chat-people-dialog[open] > div:first-of-type {
  flex: 0 1 auto;
  max-height: min(210px, 28dvh);
  overflow: auto !important;
  overscroll-behavior: contain;
}

body .chat-people-dialog[open] > .staff-people-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

body .chat-people-dialog[open] .staff-people-list {
  max-height: min(420px, 45dvh) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  padding-right: 4px !important;
}

body .nikmed-discuss-modal {
  height: min(720px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  min-height: 0;
  overflow: hidden;
}

body .nikmed-discuss-grid {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

body .nikmed-discuss-grid section {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

body #nik87-company-standards-root .nik87-shell {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden !important;
}

body #nik87-company-standards-root .nik87-content {
  min-height: 0 !important;
  overflow: hidden !important;
}

body #nik87-company-standards-root .nik87-side,
body #nik87-company-standards-root .nik87-viewer {
  min-height: 0 !important;
  overscroll-behavior: contain;
}

body #nik87-company-standards-root .nik87-side {
  overflow-y: auto !important;
}

body .nik76-notifications-panel {
  max-height: min(520px, calc(100dvh - 100px));
  overscroll-behavior: contain;
}

body .nik76-notifications-list {
  min-height: 0;
  overscroll-behavior: contain;
}

body .staff-account-portal {
  position: fixed !important;
  right: auto !important;
  z-index: 10000;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: none !important;
}

@media (max-width: 760px) {
  body #nik87-company-standards-root .nik87-content {
    display: flex !important;
    flex-direction: column !important;
  }

  body #nik87-company-standards-root .nik87-side {
    flex: 0 1 33%;
    max-height: 33%;
  }

  body #nik87-company-standards-root .nik87-viewer {
    flex: 1 1 auto;
  }

  body .nikmed-discuss-grid {
    display: flex;
    flex-direction: column;
  }

  body .nikmed-discuss-grid section {
    flex: 1 1 0;
    min-height: 0;
  }

  body .chat-people-dialog[open] {
    height: calc(100dvh - 24px);
  }
}
