/* CPGCBL EMD R11.6.0 | Narrow read-only non-Daily-Work drawers
   Baseline: R11.5.9. This only changes layout and density; no information is
   copied, hidden from the data model, or submitted. Daily Work is untouched.
   A drawer receives both .r1159-active and data-r1156-kind ONLY when the
   existing non-work record renderer has identified a read-only details shell. */

/* At 1366px viewport this leaves about 666px of the page unobscured. */
body.r107-ui #drawer.r1159-active[data-r1156-kind] .drawerpanel {
  width: min(700px, calc(100vw - 12px)) !important;
  max-width: 700px !important;
  min-width: 0 !important;
}
body.r107-ui #drawer.r1159-active[data-r1156-kind] .drawerbody {
  padding: 7px 8px 12px !important;
  overflow-x: hidden !important;
}
/* Keep the sticky title and primary controls usable at a narrower width. */
body.r107-ui #drawer.r1159-active[data-r1156-kind] .drawerhead {
  gap: 6px !important;
  padding: 7px 9px !important;
  min-height: 49px !important;
}
#drawer.r1159-active[data-r1156-kind] #drawerTitle {
  font-size: 13px !important;
  line-height: 1.24 !important;
  overflow-wrap: anywhere !important;
  min-width: 0 !important;
}
#drawer.r1159-active[data-r1156-kind] #drawerSub {
  font-size: 10px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
#drawer.r1159-active[data-r1156-kind] .drawerhead .btn {
  padding: 6px 8px !important;
  min-height: 29px !important;
  font-size: 10px !important;
  flex-shrink: 0 !important;
}
#drawer.r1159-active[data-r1156-kind] .r1159-status-badge {
  max-width: 100px !important;
  font-size: 9px !important;
}
#drawer.r1159-active[data-r1156-kind] .r1155-top .r5-actions {
  gap: 4px !important;
}
#drawer.r1159-active[data-r1156-kind] .r1155-top .r5-actions :is(button,.btn) {
  min-height: 27px !important;
  padding: 5px 8px !important;
  font-size: 10.5px !important;
}

/* The photo is a single existing gallery, alongside the original specs. */
body.r107-ui #drawer.r1159-active[data-r1156-kind] .r1159-primary-pair,
body.r107-ui #drawer.r1159-active[data-r1156-kind] .r1156-group-overview > .r79-bearing-top {
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr) !important;
  gap: 6px !important;
  min-width: 0 !important;
  align-items: start !important;
}
#drawer.r1159-active[data-r1156-kind] .r1159-primary-pair > *,
#drawer.r1159-active[data-r1156-kind] .r79-bearing-top > * {
  min-width: 0 !important;
  max-width: 100% !important;
}
#drawer.r1159-active[data-r1156-kind] .r1159-primary-pair :is(.r5-drawer-section,.r79-media-card,.r79-spec-card),
#drawer.r1159-active[data-r1156-kind] .r79-bearing-top > * {
  padding: 6px !important;
  border-radius: 7px !important;
}
#drawer.r1159-active[data-r1156-kind] .r1157-photo-card .emd-r93-main-photo,
#drawer.r1159-active[data-r1156-kind] .r79-media-card .emd-r93-main-photo {
  height: 137px !important;
  min-height: 130px !important;
  max-height: 137px !important;
}
#drawer.r1159-active[data-r1156-kind] .r1157-photo-card .emd-r93-main-photo img,
#drawer.r1159-active[data-r1156-kind] .r79-media-card .emd-r93-main-photo img {
  object-fit: contain !important;
}
#drawer.r1159-active[data-r1156-kind] .r79-media-card .r79-catalog-image {
  height: 137px !important;
  min-height: 130px !important;
  max-height: 137px !important;
}
#drawer.r1159-active[data-r1156-kind] .r79-media-card .r79-catalog-image img {max-height: 135px !important;}
#drawer.r1159-active[data-r1156-kind] .r1157-photo-card .emd-r93-thumb,
#drawer.r1159-active[data-r1156-kind] .r79-media-card .emd-r93-thumb {
  width: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  flex-basis: 36px !important;
  height: 35px !important;
}
#drawer.r1159-active[data-r1156-kind] .r79-section-head :is(button,.btn),
#drawer.r1159-active[data-r1156-kind] .r1157-photo-card .r7-media-actions .btn {
  padding: 4px 6px !important;
  min-height: 25px !important;
  font-size: 10px !important;
}

/* Specifications remain two readable columns without pushing the drawer wide. */
#drawer.r1159-active[data-r1156-kind] .r1157-media-details .r5-detail-grid {
  gap: 0 4px !important;
}
#drawer.r1159-active[data-r1156-kind] .r1157-media-details .r5-detail-grid > .r5-detail {
  min-width: 0 !important;
  grid-template-columns: minmax(60px,.46fr) minmax(0,1fr) !important;
  padding: 4px 2px !important;
  gap: 3px !important;
}
#drawer.r1159-active[data-r1156-kind] .r1157-media-details .r5-detail-grid > .r5-detail :is(b,strong,small),
#drawer.r1159-active[data-r1156-kind] .r79-catalog-copy,
#drawer.r1159-active[data-r1156-kind] .r79-ref-actions {overflow-wrap: anywhere !important;min-width: 0 !important;}
#drawer.r1159-active[data-r1156-kind] .r79-dim-grid {grid-template-columns: repeat(3,minmax(0,1fr)) !important;gap: 3px !important;}
#drawer.r1159-active[data-r1156-kind] .r79-dim-grid > div {min-width: 0 !important;min-height: 40px !important;padding: 5px 4px !important;}
#drawer.r1159-active[data-r1156-kind] .r79-dim-grid > div :is(b,strong) {font-size: 12px !important;}

/* Inventory: still show all installed, available, target and to-buy counts. */
#drawer.r1159-active[data-r1156-kind] .r1156-metrics,
#drawer.r1159-active[data-r1156-kind] .r1157-stock-kpis,
#drawer.r1159-active[data-r1156-kind] .r1157-grease-kpis {
  gap: 4px !important;
  min-width: 0 !important;
}
#drawer.r1159-active[data-r1156-kind="spare"] .r1156-metrics,
#drawer.r1159-active[data-r1156-kind="generic"] .r1156-metrics {
  grid-template-columns: repeat(auto-fit,minmax(105px,1fr)) !important;
}
#drawer.r1159-active[data-r1156-kind] .r1156-metrics > * {
  padding: 5px 6px !important;
  min-height: 44px !important;
  min-width: 0 !important;
}
#drawer.r1159-active[data-r1156-kind] .r1156-metrics > * :is(small,span) {
  overflow-wrap: anywhere !important;
}
#drawer.r1159-active[data-r1156-kind] .r1156-group > :is(.r5-drawer-section,.r1155-card) {padding: 7px 8px !important;}
#drawer.r1159-active[data-r1156-kind] .r1156-group :is(.tablewrap,.r5-tablewrap) {
  width: 100% !important;
  max-width: 100% !important;
  max-height: 165px !important;
  overflow: auto !important;
  scrollbar-width: thin !important;
}
#drawer.r1159-active[data-r1156-kind] .r1156-group :is(.table,.r5-table) {
  min-width: 540px !important;
  width: 100% !important;
  border-collapse: collapse !important;
}
#drawer.r1159-active[data-r1156-kind] .r1156-group :is(.table,.r5-table) :is(th,td) {
  padding: 4px 5px !important;
  line-height: 1.24 !important;
  white-space: normal !important;
}
/* Empty tables stay a single readable line, never an oversized blank card. */
#drawer.r1159-active[data-r1156-kind] .r1159-empty-table {max-height: 42px !important;}
#drawer.r1159-active[data-r1156-kind] .r1159-empty-table :is(.table,.r5-table) {min-width: 0 !important;}
/* Preserve keyboard focus and original edit/delete/photo viewer click actions. */
#drawer.r1159-active[data-r1156-kind] :is(button,.btn,a,[role="button"]):focus-visible {
  outline: 2px solid var(--r1155-accent) !important;
  outline-offset: 2px !important;
}

/* Small screens use full-width and readable, stacked detail cards. */
@media (max-width: 720px) {
  body.r107-ui #drawer.r1159-active[data-r1156-kind] .drawerpanel {
    width: 100vw !important;max-width: 100vw !important;
  }
  body.r107-ui #drawer.r1159-active[data-r1156-kind] .r1159-primary-pair,
  body.r107-ui #drawer.r1159-active[data-r1156-kind] .r1156-group-overview > .r79-bearing-top {
    grid-template-columns: minmax(0,1fr) !important;
  }
  #drawer.r1159-active[data-r1156-kind] .r1156-metrics {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
  }
  #drawer.r1159-active[data-r1156-kind] .r1157-media-details .r5-detail-grid {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
  }
  #drawer.r1159-active[data-r1156-kind] .drawerhead .btn {
    max-width: 125px !important;
    white-space: normal !important;
  }
}
@media (max-width: 370px) {
  #drawer.r1159-active[data-r1156-kind] .r1157-media-details .r5-detail-grid {
    grid-template-columns: minmax(0,1fr) !important;
  }
  #drawer.r1159-active[data-r1156-kind] .r79-dim-grid {
    grid-template-columns: repeat(3,minmax(0,1fr)) !important;
  }
}
