/* Mobile order entry, shared with the customer and order lists. */
.sales-portal-page [hidden] { display: none !important; }
.sales-portal-page .sp-content-shell,
.sales-portal-page .sp-section,
.sales-portal-page .sp-toolbar > *,
.sales-portal-page .sp-grid > * { min-width: 0; }
#order-editor .sp-customer-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 0; gap: .5rem; border: 0; background: transparent; }
#order-editor .sp-customer-name { display: block; color: var(--color-heading); font-size: .9rem; overflow-wrap: anywhere; }
#order-editor .sp-delivery-address { margin-top: .5rem; width: 100%; padding: 0; border: 0; background: transparent; }
#order-editor .sp-section--customer .sp-section-heading-row { margin-bottom: .5rem; gap: 0; }
#order-editor .sp-section--customer .sp-section-heading-row h3 { margin-bottom: 0; }
#order-editor .sp-delivery-address .sp-help { margin-bottom: 0; }
#order-editor .sp-section-kicker,
#order-editor .sp-cell-category,
#order-editor .sp-cell-type,
#order-editor .sp-line-category,
#order-editor .sp-lines thead th:nth-child(3),
#order-editor #line-type-header { display: none; }
#order-editor .sp-line-unit-price { display: block; min-height: 2.5rem; padding-block: .65rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
#order-editor .sp-cell-qty input { width: 4.5rem; min-width: 0; }
#order-editor .sp-money-input { gap: .25rem; min-width: 0; }
#order-editor .sp-money-input .sp-input { min-width: 0; width: 4.5rem; }
#order-editor .sp-cell-total input { width: 100%; min-width: 5rem; }
#order-editor .sp-cell-item::before { display: none; }
#order-editor .sp-delivery-note { padding: .5rem 0; }
/* Las casillas del formulario van en fila y alineadas a la izquierda: la regla
   general de .sp-grid label las apilaba y centraba. */
#order-editor .sp-grid label.sp-checkbox-row { flex-direction: row; align-items: center; justify-content: flex-start; }
#order-editor .sp-delivery-note-summary { margin: 0; font-size: .8rem; color: var(--color-text-secondary); }
#order-editor .sp-section--conditions .sp-grid { gap: .75rem; }
#order-editor .sp-section--conditions textarea { min-height: 3rem; }
@media (max-width: 1279px) {
  #order-editor .sp-lines tbody tr { grid-template-columns: 4rem minmax(0, 1fr) 4.5rem minmax(5rem, 1fr); grid-template-areas: "item item item item" "qty price disc total" "dep act act act"; gap: .45rem .6rem; padding: .65rem; align-items: center; }
  #order-editor .sp-lines tbody td.sp-cell-no { display: none; }
  #order-editor .sp-lines tbody td.sp-cell-item { font-size: .8rem; line-height: 1.35; overflow-wrap: anywhere; }
  #order-editor .sp-lines tbody td[data-label]::before { font-size: .6rem; letter-spacing: 0; text-transform: none; white-space: nowrap; }
  #order-editor .sp-lines tbody .sp-input { padding: .5rem .35rem; min-height: 2.5rem; font-size: .875rem; width: 100%; }
  #order-editor .sp-lines tbody .sp-cell-total input { min-width: 0; }
  #order-editor .sp-lines tbody td.sp-cell-actions { gap: .25rem; flex-wrap: nowrap; }
  #order-editor .sp-lines tbody td.sp-cell-actions .sp-btn { min-width: 2.5rem; min-height: 2.5rem; padding: .35rem; }
  #order-editor .sp-lines tbody tr.sp-line-text-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "text act"; gap: .5rem; padding-block: .4rem; }
  #order-editor .sp-line-text-row .sp-line-text-input { min-height: 2.5rem; }
}
@media (max-width: 720px) {
  .sales-portal-page .main-content { min-width: 0; padding-inline: .5rem; }
  .sales-portal-page .sp-content-shell { padding-top: .5rem; }
  .sales-portal-page .sp-section { padding: .75rem .6rem; margin-bottom: .65rem; }
  .sales-portal-page .sp-list-header { flex-wrap: wrap; gap: .5rem; }
  .sales-portal-page .sp-list-actions { flex-wrap: wrap; }
  .sales-portal-page .sp-operational-list, .sales-portal-page .sp-operational-list tbody { display: block; width: 100%; }
  .sales-portal-page .sp-operational-list thead { display: none; }
  .sales-portal-page .sp-operational-list tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem .75rem; padding: .65rem; border-bottom: 1px solid var(--color-border); }
  .sales-portal-page .sp-operational-list tbody td { display: block; min-width: 0; padding: 0; border: 0; overflow-wrap: anywhere; white-space: normal; }
  .sales-portal-page .sp-operational-list td[data-label]::before { content: attr(data-label); display: block; font-size: .65rem; color: var(--color-text-secondary); }
  .sales-portal-page .sp-operational-list td.sp-col-actions { width: auto; grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; }
  .sales-portal-page .sp-operational-list .sp-row-actions { display: flex; flex-wrap: wrap; gap: .4rem; width: 100%; }
  .sales-portal-page .sp-operational-list .sp-row-actions .sp-btn { flex: 0 0 auto; white-space: nowrap; overflow-wrap: normal; }
  .sales-portal-page .sp-operational-list .sp-badge { max-width: 100%; white-space: normal; }
  #order-editor .sp-actions--top { padding: .4rem; margin-bottom: .6rem; gap: .4rem; }
  #order-editor .sp-actions-group { gap: .35rem; flex: 0 0 auto; }
  #order-editor .sp-actions .sp-btn { padding: .5rem; font-size: .75rem; height: 2.5rem; min-height: 2.5rem; }
  #order-editor input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
  #order-editor input[type="number"]::-webkit-inner-spin-button,
  #order-editor input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  #order-editor .sp-editor-header { margin-bottom: .5rem; }
  #order-editor .sp-section h3 { margin-bottom: .5rem; }
  #order-editor .sp-customer-summary { grid-template-columns: minmax(0, 1fr); }
  #order-editor .sp-cs-body { width: 100%; }
  #order-editor .sp-lines tbody td.sp-cell-qty .sp-input { width: 100%; }
  #order-editor .sp-totals { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; padding: .75rem; margin: .75rem 0; }
  #order-editor .sp-totals .sp-total { grid-column: 1 / -1; text-align: end; }
  #order-editor .sp-info-tip::after { max-width: min(15rem, 75vw); white-space: normal; }
}
@media (max-width: 360px) {
  #order-editor .sp-lines tbody tr { grid-template-columns: 3rem minmax(0, 1fr) 3.5rem minmax(4rem, 1fr); gap: .35rem; padding: .5rem; }
  #order-editor .sp-line-unit-price { font-size: .75rem; }
}

/* Order identity stays readable in desktop tables and mobile rows. */
.sales-portal-page .sp-cell-authorship { max-width: 16rem; overflow-wrap: anywhere; white-space: normal; }
.sales-portal-page .sp-order-owner { display: block; }
.sales-portal-page .sp-order-creator { display: block; margin-top: .2rem; font-size: .75rem; color: var(--color-text-secondary); }

.sales-portal-page .sp-order-ownership-summary { margin-block: .5rem .75rem; font-size: .875rem; overflow-wrap: anywhere; }

#order-editor a.sp-customer-name { color: var(--color-text-brand); text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; cursor: pointer; }
#order-editor a.sp-customer-name:hover { text-decoration-thickness: 2px; }
#order-editor a.sp-customer-name:focus-visible { outline: 2px solid var(--color-border-focus); outline-offset: 3px; border-radius: .15rem; }
.sp-customer-card-dialog { width: min(52rem, calc(100vw - 1rem)); max-height: calc(100dvh - 2rem); padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-lg); color: var(--color-text-primary); background: var(--color-bg-surface); overflow: auto; }
.sp-customer-card-dialog::backdrop { background: rgb(15 23 32 / .45); }
.sp-customer-card-dialog .ds-modal-header { position: sticky; top: 0; background: var(--color-bg-surface); z-index: 1; }
.sp-customer-card-dialog .ds-modal-title { overflow-wrap: anywhere; }
.sp-customer-card-dialog .ds-field-value { overflow-wrap: anywhere; min-width: 0; }

#order-editor .sp-cell-deposit[hidden], #order-editor #line-deposit-header[hidden] { display: none !important; }
@media (min-width: 721px) and (max-width: 900px) {
  .sales-portal-page .sp-operational-list { table-layout: fixed; width: 100%; }
  .sales-portal-page .sp-operational-list th, .sales-portal-page .sp-operational-list td { padding: .4rem; overflow-wrap: anywhere; white-space: normal; }
  .sales-portal-page .sp-operational-list th:has(#orders-select-all) { width: 2rem; }
}

.sp-customer-card-dialog .ds-modal-close { flex: 0 0 2.5rem; width: 2.5rem; height: 2.5rem; }
@media (max-width: 480px) {
  .sp-customer-card-dialog .ds-modal-header, .sp-customer-card-dialog .ds-modal-body { padding: .85rem; }
  .sp-customer-card-dialog .ds-modal-title { font-size: 1rem; }
}

.sales-portal-page .sp-shipping-estimate { min-width: 0; }
.sales-portal-page .sp-shipping-estimate small { display: block; margin-top: .2rem; color: var(--color-text-secondary); font-size: .7rem; }
.sales-portal-page .sp-shipping-estimate small[hidden] { display: none; }
.sales-portal-page .sp-shipping-estimate-note { grid-column: 1 / -1; flex-basis: 100%; margin: .25rem 0 0; font-size: .7rem; line-height: 1.35; color: var(--color-text-secondary); }

.sales-portal-page .sp-shipping-estimate-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: .25rem; }
.sales-portal-page .sp-shipping-estimate-controls .sp-money-input { width: 7rem; max-width: 100%; }
.sales-portal-page .sp-shipping-estimate-controls input { min-width: 0; width: 100%; }
.sales-portal-page .sp-shipping-estimate-controls button { font-size: .7rem; padding: .35rem .5rem; white-space: normal; }
.sales-portal-page .sp-shipping-estimate-controls button[hidden] { display: none; }
.sales-portal-page .sp-totals > .sp-shipping-estimate { display: block; }
.sales-portal-page .sp-shipping-estimate-controls input[type="number"] { appearance: textfield; }
.sales-portal-page .sp-shipping-estimate-controls input::-webkit-inner-spin-button,
.sales-portal-page .sp-shipping-estimate-controls input::-webkit-outer-spin-button { appearance: none; margin: 0; }
@media (max-width: 720px) {
  #order-editor .sp-totals > div:not(.sp-shipping-estimate) { flex-wrap: wrap; justify-content: flex-start; gap: .15rem .35rem; }
}
