#modalForm:has(.mesh-order-grid) { width: min(1120px, 96vw); }

.mesh-order-editor { grid-column: 1 / -1; min-width: 0; }
.mesh-order-editor > .table-actions { margin-block: 8px; }
.mesh-order-grid { min-width: 850px; }
.mesh-order-grid th { white-space: nowrap; }
.mesh-order-grid input { width: 100%; }
.mesh-order-grid .mesh-spec-trigger {
  width: 100%;
  min-width: 185px;
  min-height: 38px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}
.mesh-spec-trigger::after {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  margin: -3px 2px 0 0;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.mesh-spec-dialog {
  width: min(500px, calc(100vw - 32px));
  max-height: min(530px, calc(100vh - 32px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mesh-spec-dialog[open] { display: flex; flex-direction: column; gap: 10px; }
.mesh-spec-dialog::backdrop { background: rgba(5, 19, 16, .24); }
.mesh-spec-header { display: flex; align-items: center; justify-content: space-between; }
.mesh-spec-header h3, .mesh-spec-dialog p { margin: 0; }
.mesh-spec-dialog input { width: 100%; }
.mesh-spec-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.mesh-spec-dialog .crm-order-option { overflow-wrap: anywhere; }
.mesh-spec-dialog .crm-order-option:focus-visible { outline-offset: -2px; }
.mesh-spec-dialog [data-mesh-spec-more]:not([hidden]) { display: block; width: 100%; margin-top: 6px; }
.mesh-order-grid input[type="number"] { min-width: 74px; }
.mesh-order-grid [data-mesh-field="reference"] { min-width: 104px; }
.mesh-order-grid [data-mesh-color-choice] { width: 100%; min-width: 106px; }
.mesh-order-grid [data-mesh-field="color"] { margin-top: 5px; }
.mesh-spec-colors { align-items: start; }
.mesh-spec-color-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.mesh-spec-color-row input { flex: 1; min-width: 0; }
.mesh-spec-color-row button { flex-shrink: 0; }
.mesh-order-grid details { min-width: 64px; }
.mesh-order-grid details[open] { min-width: 145px; }
.mesh-order-grid details label { display: block; margin-top: 6px; }
.mesh-order-grid [data-mesh-default],
.mesh-order-grid [data-mesh-amount] { text-align: right; font-variant-numeric: tabular-nums; }
.mesh-order-grid td:last-child { white-space: nowrap; }
.mesh-editor-totals { gap: 10px 18px; }
#meshOrderQuantity { margin-inline-start: auto; }

#modalForm:has(.mesh-order-detail) {
  width: min(1260px, 100%);
  overflow-x: hidden;
}

.mesh-order-detail { min-width: 0; }
.mesh-detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}
.mesh-detail-summary dt { color: var(--muted); }
.mesh-detail-summary dd {
  margin: 5px 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.mesh-detail-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}
.mesh-detail-table th,
.mesh-detail-table td { white-space: normal; overflow-wrap: anywhere; }
.mesh-detail-table th:nth-child(2) { width: 25%; }

@media (max-width: 760px) {
  .mesh-detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mesh-detail-table,
  .mesh-detail-table tbody,
  .mesh-detail-table tr { display: block; }
  .mesh-detail-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
  }
  .mesh-detail-table tbody tr {
    padding-block: 6px;
    border-top: 1px solid var(--line);
  }
  .mesh-detail-table td {
    display: grid;
    grid-template-columns: minmax(65px, 30%) minmax(0, 1fr);
    gap: 8px;
    padding: 6px 0;
    border: 0;
  }
  .mesh-detail-table td::before {
    content: attr(data-label);
    color: var(--muted);
  }
}
