/* v170: Equipment dialogs share one bounded scroll region. The outside page
   remains locked while a modal is open; it must not be the only scroll owner.
   Keep these rules scoped to Equipment & Compliance (this sheet loads there
   only). No form values, completion flags, permissions or dates are changed. */
@media screen {
  .record-dialog[open] {
    position: fixed;
    inset: 8px;
    margin: auto;
    padding: 0;
    max-width: calc(100% - 16px);
    height: auto;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
  }
  .record-dialog[open] > :is(form, .task-list-dialog-shell,
      .activity-detail-shell, .asset-compliance-dialog-shell, .quick-look-shell) {
    display: flex;
    flex-direction: column;
    flex: 0 1 auto;
    width: 100%;
    height: auto;
    max-height: inherit;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
  }
  .record-dialog[open] :is(.form-grid, .barge-status-body,
      .document-date-body, .task-list-dialog-body, .activity-detail-body,
      .asset-compliance-detail-list, .asset-quick-look-grid) {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scroll-padding-block: 16px;
    box-sizing: border-box;
  }
  .record-dialog[open] :is(.dialog-head, .dialog-actions, .barge-status-footer) {
    position: relative;
    top: auto;
    bottom: auto;
    flex: 0 0 auto;
    min-width: 0;
    box-sizing: border-box;
  }
  .record-dialog[open] .dialog-head > div { min-width: 0; }
  .record-dialog[open] .dialog-head h3,
  .record-dialog[open] .dialog-head p { overflow-wrap: anywhere; }
  .record-dialog[open] .dialog-head .icon-btn { flex-shrink: 0; }
  .record-dialog[open] .dialog-actions {
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .record-dialog[open] .dialog-actions button { white-space: normal; }
  .record-dialog[open] .dialog-record-error:not(:empty) {
    flex: 0 1 auto;
    max-height: 80px;
    overflow-y: auto;
    overflow-wrap: anywhere;
  }
  .record-dialog[open] .barge-status-body {
    align-content: start;
    overflow-wrap: anywhere;
  }
  /* The general equipment table has a 1050px minimum. It must not enlarge
     the COI / return-to-service dialog past a phone's visible width. */
  .record-dialog[open] .barge-status-body table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
  }
  .record-dialog[open] .barge-status-body th {
    position: static;
    white-space: normal;
  }
  .record-dialog[open] .barge-status-body :is(td, th) {
    overflow-wrap: anywhere;
  }
  .record-dialog[open] .barge-status-footer {
    border-top: 1px solid var(--line, #cbd5e1);
    background: var(--sbm-surface, #fff);
    color: var(--sbm-text, var(--ink, #162f43));
  }
  .record-dialog[open] .barge-status-footer .dialog-actions {
    border-top: 0;
    box-shadow: none;
    background: transparent;
  }
  .record-dialog[open] .barge-status-footer .barge-status-confirm {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 12px 20px 0;
    font-weight: 700;
    line-height: 1.45;
    cursor: pointer;
  }
  .record-dialog[open] .barge-status-footer .barge-status-error:not(:empty) {
    margin: 8px 20px 0;
    max-height: 72px;
    overflow-y: auto;
  }
  .record-dialog[open] :is(input, select, textarea, summary):focus-visible {
    outline: 3px solid var(--sbm-link, #216d9a);
    outline-offset: 2px;
  }
}
/* Landscape, a reduced workspace, or a large browser zoom can leave too little
   height for a header + fixed confirmation + footer. In that case scroll the
   WHOLE dialog instead of trapping a zero-height body between fixed controls. */
@media screen and (max-height: 460px) {
  .record-dialog[open] {
    display: block;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scroll-padding-block: 12px;
  }
  .record-dialog[open] > :is(form, .task-list-dialog-shell,
      .activity-detail-shell, .asset-compliance-dialog-shell, .quick-look-shell) {
    display: block;
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .record-dialog[open] :is(.form-grid, .barge-status-body,
      .document-date-body, .task-list-dialog-body, .activity-detail-body,
      .asset-compliance-detail-list, .asset-quick-look-grid) {
    max-height: none;
    overflow: visible;
    scrollbar-gutter: auto;
  }
}
