/* Keep Dispatch quick-add dialogs inside the viewport at every supported width. */
html body .assign-carrier-dialog {
  box-sizing: border-box;
  max-width: calc(100vw - 32px);
  overflow-x: hidden;
  overflow-y: auto;
}

html body .assign-carrier-dialog > .assign-carrier-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
}

html body .assign-carrier-dialog :is(.dialog-head, .assign-carrier-field, .dialog-actions) {
  min-width: 0;
}

html body .assign-carrier-dialog :is(input, select, textarea) {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

/* The location quick adds previously forced a 520px card into a 480px dialog. */
html body .quick-customer-service-field-dialog {
  width: min(520px, calc(100vw - 32px));
}

html body .quick-customer-service-field-dialog .assign-carrier-card,
html body .quick-customer-service-location-grid,
html body .quick-customer-service-location-grid > .assign-carrier-field {
  min-width: 0;
  max-width: 100%;
}

/* Dispatch quick adds use a compact, self-contained card instead of the generic form shell. */
html body .dispatch-quick-add-dialog {
  box-sizing: border-box;
  width: min(500px, calc(100vw - 28px));
  max-width: 500px;
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: hidden;
  border: 1px solid #cbd7e4;
  border-radius: 16px;
  background: transparent;
  box-shadow: 0 28px 80px rgba(6, 20, 36, .38);
}

html body .dispatch-quick-add-dialog::backdrop {
  background: rgba(10, 21, 34, .58);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

html body .dispatch-quick-add-dialog > .assign-carrier-card {
  display: flex;
  width: 100%;
  max-height: calc(100dvh - 28px);
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: 0;
  border-radius: 15px;
  background: #fff;
}

html body .dispatch-quick-add-dialog .dialog-head {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0;
  padding: 22px 24px 19px;
  border: 0;
  background: linear-gradient(135deg, #12365f 0%, #245b91 100%);
  color: #fff;
}

html body .dispatch-quick-add-dialog .dialog-head > div {
  min-width: 0;
}

html body .dispatch-quick-add-dialog .dialog-head .eyebrow {
  margin: 0 0 5px;
  color: #b9d8f3;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

html body .dispatch-quick-add-dialog .dialog-head h2 {
  margin: 0;
  color: #fff;
  font-size: 25px;
  line-height: 1.15;
}

html body .dispatch-quick-add-dialog .assign-carrier-close {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 11px;
  background: rgba(255,255,255,.12);
  color: #fff;
  box-shadow: none;
  font-size: 24px;
  line-height: 1;
}

html body .dispatch-quick-add-dialog .assign-carrier-close:hover,
html body .dispatch-quick-add-dialog .assign-carrier-close:focus-visible {
  border-color: rgba(255,255,255,.7);
  background: rgba(255,255,255,.22);
  color: #fff;
  outline: 3px solid rgba(255,255,255,.18);
  outline-offset: 2px;
}

html body .dispatch-quick-add-dialog > .assign-carrier-card > .assign-carrier-field {
  margin: 0 24px;
  padding: 0;
}

html body .dispatch-quick-add-dialog > .assign-carrier-card > .dialog-head + .assign-carrier-field {
  margin-top: 22px;
}

html body .dispatch-quick-add-dialog > .assign-carrier-card > .assign-carrier-field + .assign-carrier-field {
  margin-top: 15px;
}

html body .dispatch-quick-add-dialog .assign-carrier-field {
  gap: 7px;
  color: #2f4359;
  font-size: 12px;
  font-weight: 900;
}

html body .dispatch-quick-add-dialog .assign-carrier-field[hidden] {
  display: none !important;
}

html body .dispatch-quick-add-dialog :is(input, select, textarea) {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid #c7d4e2;
  border-radius: 10px;
  background: #fff;
  padding: 0 13px;
  color: #14263a;
  font-size: 15px;
  font-weight: 700;
}

html body .dispatch-quick-add-dialog :is(input, select, textarea):focus {
  border-color: #367db6;
  box-shadow: 0 0 0 4px rgba(54,125,182,.15);
  outline: none;
}

html body .dispatch-quick-add-dialog .assign-carrier-rate-wrap {
  min-height: 48px;
  border-radius: 10px;
}

html body .dispatch-quick-add-dialog .quick-customer-service-location-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 24px 0;
}

html body .dispatch-quick-add-dialog .quick-customer-service-location-grid > .assign-carrier-field:first-child {
  grid-column: 1 / -1;
}

html body .dispatch-quick-add-dialog .dialog-note {
  margin: 14px 24px 0;
  color: #607286;
  font-size: 12px;
  line-height: 1.45;
}

html body .dispatch-quick-add-dialog .dialog-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0 0;
  padding: 16px 24px 20px;
  border-top: 1px solid #dde6ef;
  background: #f6f8fb;
}

html body .dispatch-quick-add-dialog .assign-carrier-card .dialog-actions {
  padding: 16px 24px 20px !important;
}

html body .dispatch-quick-add-dialog .dialog-actions button {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 900;
}

html body .dispatch-quick-add-dialog .dialog-actions .remove-carrier-button:not([hidden]) {
  grid-column: 1 / -1;
  order: 3;
}

html body .dispatch-quick-add-dialog :is(input, select, textarea)[aria-invalid="true"] {
  border-color: #b92f38;
  background: #fff8f8;
  box-shadow: 0 0 0 4px rgba(185,47,56,.12);
}

@media (max-width: 720px) {
  html body .assign-carrier-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
  }

  html body .assign-carrier-dialog > .assign-carrier-card {
    padding: 18px 16px;
  }

  html body .dispatch-quick-add-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  html body .dispatch-quick-add-dialog > .assign-carrier-card {
    max-height: calc(100dvh - 16px);
    padding: 0;
  }

  html body .dispatch-quick-add-dialog .dialog-head {
    padding: 19px 18px 17px;
  }

  html body .dispatch-quick-add-dialog > .assign-carrier-card > .assign-carrier-field {
    margin-right: 18px;
    margin-left: 18px;
  }

  html body .dispatch-quick-add-dialog .quick-customer-service-location-grid {
    margin-right: 18px;
    margin-left: 18px;
  }

  html body .dispatch-quick-add-dialog .dialog-note {
    margin-right: 18px;
    margin-left: 18px;
  }

  html body .dispatch-quick-add-dialog .dialog-actions {
    padding: 14px 18px 18px;
  }

  html body .dispatch-quick-add-dialog .assign-carrier-card .dialog-actions {
    padding: 14px 18px 18px !important;
  }
}

@media (max-width: 420px) {
  html body .dispatch-quick-add-dialog .quick-customer-service-location-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  html body .dispatch-quick-add-dialog .quick-customer-service-location-grid > .assign-carrier-field:first-child {
    grid-column: auto;
  }
}
