.shipment-history-page {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.shipment-history-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.shipment-history-summary article {
  display: grid;
  gap: 5px;
  min-height: 92px;
  padding: 16px 18px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(12, 43, 82, 0.05);
}

.shipment-history-summary article.has-error {
  border-color: #edc6c8;
  background: #fffafa;
}

.shipment-history-summary span,
.shipment-history-summary small {
  color: #68778a;
}

.shipment-history-summary strong {
  color: #123a6b;
  font-size: 25px;
}

.shipment-history-summary .has-error strong {
  color: #b72d34;
}

.shipment-history-filter {
  display: grid;
  grid-template-columns: 210px 170px 170px minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  background: #fff;
}

.shipment-history-filter label {
  display: grid;
  gap: 5px;
  color: #53657a;
  font-size: 12px;
  font-weight: 700;
}

.shipment-history-filter input,
.shipment-history-filter select {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #cbd6e2;
  border-radius: 5px;
  background: #fff;
}

.history-group-assignment {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.history-group-assignment select {
  width: min(180px, 100%);
  min-height: 34px;
  border: 1px solid #cbd7e4;
  border-radius: 5px;
  background: #fff;
}

.history-group-assignment button { min-height: 34px; padding: 0 12px; white-space: nowrap; }

.shipment-history-list-card .card-head {
  align-items: flex-start;
}

.shipment-history-list-card .card-head p {
  margin: 5px 0 0;
  color: #6f7e8e;
  font-size: 12px;
}

.shipment-history-table-scroll {
  max-height: calc(100vh - 395px);
  overflow: auto;
}

.shipment-history-table {
  min-width: 1500px;
}


.shipment-history-dialog {
  width: min(1500px, 96vw);
  max-width: 96vw;
  max-height: 94vh;
}

.shipment-history-dialog > form {
  max-height: 92vh;
  overflow: auto;
}

.shipment-history-detail {
  display: grid;
  gap: 14px;
  padding: 4px 2px 18px;
}

.history-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 7px;
  background: #eef4fb;
}

.history-detail-head h3,
.history-detail-head p {
  margin: 0;
}

.history-detail-head p {
  margin-top: 5px;
  color: #65768a;
  font-size: 12px;
}

.history-info-grid {
  display: grid;
  grid-template-columns: 110px minmax(140px, 1fr) 110px minmax(140px, 1fr) 110px minmax(140px, 1fr);
  margin: 0;
  border: 1px solid #dce4ee;
  border-radius: 7px;
  overflow: hidden;
}

.history-info-grid dt,
.history-info-grid dd {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid #e5ebf2;
}

.history-info-grid dt {
  color: #43556c;
  font-weight: 700;
  background: #f5f8fc;
}

.history-info-grid dd {
  min-width: 0;
  color: #1d2f44;
  word-break: break-word;
}

.shipment-history-detail h4 {
  margin: 6px 0 -5px;
  color: #183c68;
}

.shipment-history-detail h4 small {
  color: #6a7a8d;
  font-size: 12px;
}

.history-subtable {
  max-height: 250px;
  overflow: auto;
  border: 1px solid #dce4ee;
  border-radius: 6px;
}

.history-subtable table {
  min-width: 900px;
}

.history-subtable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.history-items-table {
  max-height: 360px;
}

.history-items-table table,
.history-checks-table table {
  min-width: 1500px;
}

.history-checks-table {
  max-height: 430px;
}

@media (max-width: 1100px) {
  .shipment-history-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shipment-history-filter {
    grid-template-columns: 1fr 1fr;
  }

  .shipment-history-filter .history-query {
    grid-column: 1 / -1;
  }

  .shipment-history-filter .hfr-product-group-select {
    grid-column: 1 / -1;
  }

  .history-info-grid {
    grid-template-columns: 105px minmax(0, 1fr) 105px minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  .shipment-history-summary,
  .shipment-history-filter,
  .history-info-grid {
    grid-template-columns: 1fr;
  }

  .shipment-history-filter .history-query {
    grid-column: auto;
  }

  .shipment-history-filter .hfr-product-group-select {
    grid-column: auto;
  }

  .history-group-assignment { align-items: stretch; flex-direction: column; }
  .history-group-assignment select { width: 100%; }

  .history-info-grid dt,
  .history-info-grid dd {
    border-bottom: 1px solid #e5ebf2;
  }

  .shipment-history-table-scroll {
    max-height: none;
  }

  .shipment-history-dialog {
    width: 98vw;
    max-width: 98vw;
  }
}

.history-detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.history-detail-actions button {
  min-width: 112px;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .history-detail-head {
    flex-direction: column;
  }

  .history-detail-actions {
    width: 100%;
  }
}
/* Full-page shipment detail */
.hfr-shipment-detail-page .shipment-history-detail {
  min-width: 0;
  padding: 0;
}

.hfr-shipment-detail-page .history-subtable {
  max-width: 100%;
  max-height: min(58vh, 560px);
  scrollbar-gutter: stable;
}

.hfr-shipment-detail-page .history-detail-head {
  border: 1px solid #d8e3ef;
}

@media (max-width: 700px) {
  .hfr-shipment-detail-page .history-detail-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hfr-shipment-detail-page .history-detail-actions button {
    width: 100%;
    min-width: 0;
  }
}
