/* Version 3.97323: keep Delivered tiles and filters compact, including Custom purge input. */
@media (min-width: 721px) {
  html body #customerServiceDeliveredView #customerServiceDeliveredMetrics.delivered-metric-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    width: min(1120px, 100%) !important;
    max-width: 1120px !important;
    margin: 0 auto 14px !important;
  }

  html body #customerServiceDeliveredView #customerServiceDeliveredMetrics .metric {
    min-width: 0 !important;
    max-width: none !important;
  }

  html body #customerServiceDeliveredView .shipment-tools {
    display: grid !important;
    grid-template-columns: minmax(260px, 1.5fr) repeat(4, minmax(0, 1fr)) !important;
    width: min(1040px, 100%) !important;
    max-width: 1040px !important;
    gap: 8px !important;
  }

  html body #customerServiceDeliveredView #customerServiceDeliveredSort,
  html body #customerServiceDeliveredView #customerServiceDeliveredStatusFilter,
  html body #customerServiceDeliveredView #customerServiceDeliveredUserFilter {
    display: none !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-control {
    display: grid !important;
    grid-template-columns: auto 94px !important;
    grid-template-rows: 46px auto !important;
    justify-content: start !important;
    gap: 6px !important;
    width: 100% !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-control select {
    width: 94px !important;
  }
}

/* Center every visible Customer Service Delivered tile across the full metric row. */
@media (min-width: 721px) {
  html body #customerServiceDeliveredView #customerServiceDeliveredMetrics.delivered-metric-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
    align-items: stretch !important;
    gap: 12px !important;
    width: min(1120px, 100%) !important;
    max-width: 1120px !important;
    margin: 0 auto 14px !important;
  }

  html body #customerServiceDeliveredView #customerServiceDeliveredMetrics.delivered-metric-grid .metric {
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
  }
}

html body #customerServiceDeliveredView .delivered-purge-control {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  min-width: 0 !important;
  color: #40536a !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  white-space: nowrap !important;
}

html body #customerServiceDeliveredView .delivered-purge-control select {
  display: revert !important;
  width: 94px !important;
  min-width: 0 !important;
  min-height: 46px !important;
  border: 1px solid #d5dde7 !important;
  border-radius: 6px !important;
  background: #fff !important;
  color: #0f172a !important;
  font: inherit !important;
  font-weight: 700 !important;
  padding: 0 10px !important;
}

html body #customerServiceDeliveredView .delivered-purge-control.is-custom {
  align-content: start !important;
}

html body #customerServiceDeliveredView .delivered-purge-custom {
  grid-column: 1 / -1 !important;
  display: none !important;
  align-items: center !important;
  gap: 5px !important;
  color: #40536a !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
}

html body #customerServiceDeliveredView .delivered-purge-custom:not([hidden]) {
  display: flex !important;
}

html body #customerServiceDeliveredView .delivered-purge-custom input {
  width: 82px !important;
  min-width: 0 !important;
  min-height: 34px !important;
  border: 1px solid #d5dde7 !important;
  border-radius: 6px !important;
  background: #fff !important;
  color: #0f172a !important;
  font: inherit !important;
  padding: 0 8px !important;
}

@media (min-width: 721px) {
  html body #customerServiceDeliveredView .delivered-purge-control {
    display: grid !important;
    grid-template-columns: auto 94px !important;
    grid-template-rows: 46px auto !important;
    justify-content: start !important;
    gap: 6px !important;
    width: 100% !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-control select {
    width: 94px !important;
  }
}

@media (max-width: 720px) {
  html body #customerServiceDeliveredView .delivered-purge-control {
    justify-content: space-between !important;
    width: 100% !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-control select {
    width: min(220px, 100%) !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-control.is-custom {
    grid-template-rows: 46px auto !important;
  }
}

/* Keep the Custom purge controls readable: search and purge each get their own space. */
@media (min-width: 721px) {
  html body #customerServiceDeliveredView .shipment-tools {
    grid-template-columns: minmax(260px, 1fr) minmax(360px, 390px) !important;
    width: min(1040px, 100%) !important;
    max-width: 1040px !important;
    gap: 8px !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-control {
    grid-template-columns: auto minmax(94px, 1fr) !important;
    grid-template-rows: 46px auto !important;
    min-width: 360px !important;
    width: 100% !important;
    overflow: visible !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-control > span:first-child {
    overflow: visible !important;
    white-space: nowrap !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-custom {
    grid-column: 1 / -1 !important;
    display: none !important;
    min-width: 0 !important;
    overflow: visible !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-custom:not([hidden]) {
    display: flex !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-custom input {
    width: 92px !important;
  }

  html body #customerServiceDeliveredView .delivered-purge-custom select {
    width: 112px !important;
    min-height: 34px !important;
    padding: 0 8px !important;
  }
}
