/* Additional shipments inherit the existing form's colors and controls. */
#shipmentForm.has-shipment-blocks > :not(#shipmentBlocks):not(#activeRowActions):not(#shipmentLineId) { display: none !important; }
#shipmentForm.new-shipments-only > :not(#shipmentBlocks):not(#activeRowActions):not(#shipmentLineId) { display: none !important; }
#shipmentPane { container-type: inline-size; }
#shipmentBlocks { min-width: 0; width: 100%; }
#shipmentBlocks .attached-item { grid-template-columns: minmax(0, 1fr) 44px; }
#shipmentBlocks .attached-open-button { background: var(--accent, #80bf16); color: var(--ink, #202a33); border-radius: 6px; padding: 6px 8px; }
#shipmentBlocks .attached-open-button strong { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
#shipmentBlocks .attached-open-button small { font-weight: normal; }
#shipmentBlocks .shipment-block-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
#shipmentBlocks .shipment-block-list { display: grid; gap: 4px; }
#shipmentBlocks .shipment-block { border-top: 1px solid var(--border, #596168); padding-top: 4px; min-width: 0; }
#shipmentBlocks .shipment-block-content > * + * { margin-top: 12px; }
#legacyShipmentSection, #shipmentBlocks .shipment-block-section { min-width: 0; }
#legacyShipmentSection > summary, #shipmentBlocks .shipment-block-section > summary { cursor: pointer; min-height: 44px; font-size: 16px; font-weight: 700; padding: 0; box-sizing: border-box; overflow-wrap: anywhere; }
#legacyShipmentSection > summary { min-height: 32px; line-height: 24px; padding: 4px 0; }
#shipmentBlocks .shipment-block-section > summary { display: flex; align-items: center; gap: 8px; }
#shipmentBlocks .shipment-block-section > summary::before { content: '\25B6'; font-size: 12px; flex: 0 0 12px; }
#shipmentBlocks .shipment-block-section[open] > summary::before { content: '\25BC'; }
#shipmentBlocks .shipment-block-section > summary > span { flex: 1; min-width: 0; }
#legacyShipmentFields, #shipmentBlocks .shipment-block-content { padding-top: 10px; min-width: 0; }
#legacyShipmentFields { padding-top: 2px; }
#legacyShipmentFields .selection-actions:not(:has(button:not([hidden]))) { display: none; }
#legacyShipmentSection:not([open]) > #legacyShipmentFields, #shipmentBlocks details:not([open]) > .shipment-block-content { display: none !important; }
#shipmentBlocks header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#shipmentBlocks h3, #shipmentBlocks h4 { margin: 0; font-size: 16px; letter-spacing: 0; }
#shipmentBlocks label { display: grid; gap: 6px; min-width: 0; }
#shipmentBlocks input:not([type=checkbox]):not(.visually-hidden-date), #shipmentBlocks select, #shipmentBlocks textarea { box-sizing: border-box; min-width: 0; width: 100%; max-width: 100%; margin: 0; text-align: left; }
#shipmentBlocks .shipment-block-main { display: grid; gap: 12px; }
#shipmentBlocks [data-block-field=quantity] { max-width: 280px !important; }
#shipmentBlocks .shipment-block-dates, #shipmentBlocks .shipment-block-stock, #shipmentBlocks .shipment-block-tracking { display: grid; gap: 8px; min-width: 0; }
#shipmentBlocks .shipment-block-stock { padding-top: 12px; }
#shipmentBlocks .shipment-stock-card { min-width: 0; }
#shipmentBlocks .shipment-stock-card > div, #shipmentBlocks .shipment-tracking-link > button { min-width: 0; overflow-wrap: anywhere; }
#shipmentBlocks .shipment-stock-card > button { width: auto; }
#shipmentBlocks .block-document, #shipmentBlocks .block-tracking-link, #shipmentBlocks .block-tracking-picker { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: 8px; min-width: 0; }
#shipmentBlocks .block-document a, #shipmentBlocks .block-document span, #shipmentBlocks .block-tracking-link span { min-width: 0; overflow-wrap: anywhere; }
#shipmentBlocks .block-document a { display: block; padding: 10px; border-radius: 8px; background: var(--accent, #80bf16); color: var(--text, #202a33); font-weight: 700; text-decoration: none; }
#shipmentBlocks .shipment-block-upload { display: grid; gap: 8px; }
#shipmentBlocks .block-checkbox { display: flex; align-items: center; gap: 8px; }
#shipmentBlocks input[type=checkbox] { width: 18px; height: 18px; flex: 0 0 18px; margin: 0; }
#shipmentBlocks .stock-action-icon-button, #shipmentBlocks .block-plus { position: static !important; width: 44px; height: 44px; min-width: 44px; min-height: 44px; margin: 0; }
#shipmentBlocks .block-plus { position: relative !important; display: grid; place-items: center; padding: 0; font-size: 0; line-height: 1; max-width: 44px; max-height: 44px; }
#shipmentBlocks .shipment-block-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 8px; }
#shipmentBlocks .shipment-block-footer strong { flex: 1; min-width: 0; margin-right: auto; }
#shipmentBlocks .shipment-block-footer [data-block-action=save-blocks] { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; margin-left: auto; }
#shipmentBlocks .shipment-block-message { margin: 8px 0 0; overflow-wrap: anywhere; }
#shipmentBlocks .shipment-block-message:empty { display: none; }
#shipmentBlocks .shipment-block-message.is-error { color: var(--danger, #df5555); }
#shipmentBlocks .date-entry { position: relative; display: block; min-width: 0; }
#shipmentBlocks [data-block-date] { padding-right: 44px; }
#shipmentBlocks .date-picker-button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
#shipmentBlocks .visually-hidden-date { width: 1px !important; height: 1px !important; min-width: 0 !important; min-height: 0 !important; padding: 0 !important; border: 0; right: 0; clip-path: inset(50%); }
#shipmentBlocks [data-block-file] { height: auto !important; min-height: 48px !important; max-height: none !important; padding: 6px !important; font-size: 13px !important; line-height: 32px; }
#shipmentBlocks [data-block-file]::file-selector-button { height: 32px; padding: 0 10px; margin-right: 8px; border: 1px solid #71808b; border-radius: 4px; background: #47525d; color: #fff; font: inherit; }
#shipmentBlocks .block-tracking-picker > .custom-select { grid-column: 1; grid-row: 1; min-width: 0; }
#shipmentBlocks .block-tracking-picker > .block-plus { grid-column: 2; grid-row: 1; }
#shipmentBlocks .custom-select-button { text-align: left; }

/* A collapsed note still shows two complete lines at every pane width. */
#shipmentPane textarea.compact-note:not(.expanded) {
  box-sizing: border-box;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  line-height: 1.25;
  overflow: hidden;
}

/* The side pane can be visually narrowed by app zoom, so stock cards always
   use the robust vertical layout instead of relying on viewport thresholds. */
  #shipmentPane .shipment-stock-card,
  #shipmentPane .shipment-stock-card.is-linked {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto !important;
    align-items: stretch;
    gap: 10px;
  }

  #shipmentPane .shipment-stock-card > div,
  #shipmentPane .shipment-stock-card > label,
  #shipmentPane .shipment-stock-card > button,
  #shipmentPane .shipment-stock-card .shipment-stock-heading,
  #shipmentPane .shipment-stock-card .shipment-stock-details,
  #shipmentPane .shipment-stock-card .shipment-stock-actions {
    grid-column: 1 !important;
    grid-row: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  #shipmentPane .shipment-stock-card > button {
    min-height: 44px;
    height: auto;
    padding: 8px 12px;
    white-space: normal;
  }

  #shipmentPane .shipment-stock-card > label,
  #shipmentPane .shipment-stock-card .block-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-wrap: normal;
  }

  #shipmentPane .shipment-stock-card.is-linked .shipment-stock-actions {
    flex-direction: row;
    justify-content: flex-start;
  }

@container (max-width: 420px) {
  #shipmentForm #activeRowActions {
    display: grid !important;
    grid-template-columns: 44px 44px 44px minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  #shipmentForm #activeRowActions > button {
    min-width: 0 !important;
    margin: 0 !important;
  }

  #shipmentForm #selectSpecRowsButton {
    grid-column: 1 / -1 !important;
    grid-row: 2;
    width: 100% !important;
    max-width: 100% !important;
    white-space: normal !important;
    line-height: 1.15;
  }

  #shipmentBlocks .shipment-block-section > summary {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) 44px;
    align-items: center;
    min-width: 0;
  }

  #shipmentBlocks .shipment-block-section > summary::before {
    grid-column: 1;
  }

  #shipmentBlocks .shipment-block-section > summary > span {
    grid-column: 2;
    overflow-wrap: anywhere;
  }

  #shipmentBlocks .shipment-block-section > summary > button {
    grid-column: 3;
    justify-self: end;
  }

  #shipmentBlocks .shipment-block-footer {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    width: 100%;
  }

  #shipmentBlocks .shipment-block-footer strong {
    grid-column: 2;
    margin: 0;
    overflow-wrap: anywhere;
  }

  #shipmentBlocks .shipment-block-footer [data-block-action=save-blocks] {
    grid-column: 3;
    width: 44px;
    justify-self: end;
  }
}

@container (max-width: 300px) {
  #shipmentBlocks .shipment-block-section > summary {
    font-size: 14px;
  }

  #shipmentBlocks .shipment-block-footer {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }
}
/* Constrain native choice dialogs when the application itself is zoomed. */
#stockIssueDialog.shipment-block-choice,
#trackingDialog.shipment-block-choice {
  box-sizing: border-box;
  width: min(1280px, calc(100vw / var(--shipment-choice-scale, 1) - 16px)) !important;
  max-width: calc(100vw / var(--shipment-choice-scale, 1) - 16px) !important;
  max-height: calc(100dvh / var(--shipment-choice-scale, 1) - 16px) !important;
  overflow: auto !important;
  margin: auto !important;
  padding: 0 !important;
}
#stockIssueDialog.shipment-block-choice .stock-issue-dialog,
#trackingDialog.shipment-block-choice .tracking-dialog {
  box-sizing: border-box;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}
