/* Single-position requests keep their natural form height; every field stays in page flow. */
@media (min-width: 761px) {
  #cleanCrmApp [data-page-id='requests'] .request-expanded-layout > .dispatch:not(.is-position-paged),
  #cleanCrmApp [data-page-id='requests'] .request-expanded-layout > .dispatch:not(.is-position-paged) .dp-body,
  #cleanCrmApp [data-page-id='requests'] .request-expanded-layout > .dispatch:not(.is-position-paged) .dp-fields-wrap {
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }

  /* Multiple positions retain the established viewport and switch independently from page scroll. */
  #cleanCrmApp [data-page-id='requests'] .request-expanded-layout > .dispatch.is-position-paged .dp-fields-wrap {
    flex: 0 0 auto;
    height: clamp(300px, 55dvh, 600px) !important;
    min-height: 0;
    max-height: clamp(300px, 55dvh, 600px) !important;
    overflow: auto;
    scrollbar-gutter: stable;
    overscroll-behavior-y: contain;
    overflow-anchor: none;
  }

  #cleanCrmApp [data-page-id='requests'] .request-detail-accordion__item:not(.is-open) > .request-detail-accordion__panel {
    contain: size;
  }

  /* Only the form sets the natural row height; the chat history uses that available height. */
  #cleanCrmApp [data-page-id='requests'] .request-detail-accordion__item[data-accordion-id='chat'] > .request-detail-accordion__panel > .request-detail-accordion__panel-inner {
    contain: size;
  }
}

/* Optional request action has its own row; the chat occupies the remainder. */
#cleanCrmApp [data-page-id='requests'] .request-bichmi-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#cleanCrmApp [data-page-id='requests'] .request-bichmi-panel > .request-service-date-action {
  flex: 0 0 auto;
}

#cleanCrmApp [data-page-id='requests'] .request-bichmi-panel > .request-bichmi-panel__host {
  flex: 1 1 0;
  height: auto;
  min-height: 0;
}

#cleanCrmApp [data-page-id='requests'] .request-bichmi-panel__host > .bichmi-initial-frame > .bichmi-v2--compact {
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

#cleanCrmApp [data-page-id='requests'] .request-bichmi-panel .bichmi-v2__chat.is-compact {
  height: 100%;
  min-height: 0;
}

#cleanCrmApp [data-page-id='requests'] .request-service-schedule__days {
  box-sizing: border-box;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}
