/* Sales workspace: hierarchy through type, whitespace and semantic accents. */
.native-order-page { max-width: 1560px; min-width: 0; margin-inline: auto; }
.order-page-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 8px 0 16px; border-bottom: 1px solid var(--border); }
.order-page-header > div { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; }
.order-page-header .btn-ghost-secondary { margin-left: -12px; color: var(--text-secondary); }
.order-page-title { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
.crm-app .order-page-title h2 { margin: 0; font-size: 24px; line-height: 1.3; font-weight: 650; }
.order-entry-status { color: var(--info-strong); background: var(--info-soft); padding: 4px 8px; border-radius: 4px; font-size: 12px; }
.order-page-header [data-order-save] { min-width: 148px; }
.order-destination { display: flex; align-items: end; flex-wrap: wrap; gap: 16px 24px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.order-destination fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-wrap: wrap; gap: 0; }
.order-destination legend { width: 100%; font-size: 12px; font-weight: 550; color: var(--text-secondary); margin: 0 0 8px; }
.crm-app .order-destination fieldset label { display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 9px 12px; margin: 0; border: 1px solid var(--border); color: var(--text-primary); background: var(--surface); min-height: 40px; }
.order-destination fieldset label:first-of-type { border-radius: 6px 0 0 6px; }
.order-destination fieldset label:last-of-type { border-radius: 0 6px 6px 0; margin-left: -1px; }
.order-destination fieldset label:has(input:checked) { color: var(--primary-dark); background: var(--primary-light); border-color: var(--primary); z-index: 1; }
.crm-app .order-destination input[type=radio] { width: 16px; height: 16px; min-height: 16px; min-width: 16px; flex: 0 0 16px; padding: 0; margin: 0; border-radius: 50%; }
.order-destination [data-order-existing-picker] { flex: 1 1 330px; max-width: 650px; }
.order-entry-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.order-entry-main { min-width: 0; }
.order-entry-section { padding: 18px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 100px; }
.order-entry-section > header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.crm-app .order-entry-section h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 650; margin: 0; }
.order-entry-section h3 svg { width: 17px; height: 17px; color: var(--secondary); }
.order-customer-search { display: flex; align-items: end; gap: 12px; margin-bottom: 12px; }
.order-customer-search > .order-lookup { flex: 1; min-width: 0; }
.order-customer-search > button { flex-shrink: 0; }
.order-customer-identity { display: flex; align-items: center; gap: 14px; padding: 16px; min-height: 84px; background: var(--info-soft); border-left: 3px solid var(--info); }
.order-customer-identity > div:nth-child(2) { flex: 1; min-width: 0; }
.crm-app .order-customer-identity h2 { font-size: 21px; font-weight: 650; line-height: 1.35; color: var(--text-primary); margin: 0; overflow-wrap: anywhere; }
.order-customer-avatar { color: var(--info-strong); display: grid; place-items: center; flex-shrink: 0; width: 32px; }
.order-customer-avatar svg { width: 25px; height: 25px; }
.order-customer-meta { font-size: 12px; color: var(--text-secondary); margin-top: 4px; overflow-wrap: anywhere; }
.order-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 16px; }
.order-fields--two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.order-fields--details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.order-more-details { margin-top: 12px; }
.order-more-details > summary { color: var(--text-secondary); font-size: 12px; cursor: pointer; }
.order-more-details > label { margin-top: 12px; }
.order-fields .order-field-wide { grid-column: span 2; }
.order-fields .full { grid-column: 1 / -1; }
.order-fields label, .order-fields > div { min-width: 0; }
.order-fields label { margin: 0; }
.order-linked-facts { padding: 12px 0; font-size: 13px; color: var(--text-secondary); line-height: 1.7; overflow-wrap: anywhere; }
.order-warning { display: flex; gap: 8px; align-items: start; padding: 12px; margin: 16px 0 0; background: var(--warning-soft); color: var(--warning-strong); font-size: 12px; border-left: 3px solid var(--warning); }
.order-warning svg { width: 17px; height: 17px; flex-shrink: 0; }
.order-lookup { position: relative; min-width: 0; }
.order-lookup > label { display: block; margin-bottom: 6px; }
.order-lookup-input { position: relative; }
.order-lookup-input > svg { position: absolute; left: 11px; top: 11px; width: 17px; height: 17px; color: var(--text-muted); pointer-events: none; }
.crm-app .native-order-page .order-lookup-input > input { width: 100%; padding-left: 36px; }
.order-lookup-results { position: absolute; inset: 100% 0 auto; z-index: 30; max-height: 310px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); margin-top: 4px; padding: 4px; }
.crm-app button.order-lookup-option { display: flex; flex-direction: column; align-items: start; justify-content: start; width: 100%; min-height: 50px; border: 0; padding: 9px 10px; text-align: left; color: var(--text-primary); background: var(--surface); gap: 3px; border-radius: 4px; white-space: normal; overflow-wrap: anywhere; }
.crm-app button.order-lookup-option:hover, .crm-app button.order-lookup-option[aria-selected=true] { color: var(--primary-dark); background: var(--primary-light); }
.order-lookup-option strong { font-size: 13px; font-weight: 550; }
.order-lookup-option small { font-size: 11px; color: var(--text-secondary); font-weight: 400; }
.order-lookup-results p { padding: 12px; margin: 0; color: var(--text-secondary); }
.order-items-scroll { min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; border-block: 1px solid var(--border); }
.crm-app .order-items-table { width: 100%; min-width: 670px; margin: 0; table-layout: fixed; }
.crm-app .order-items-table th { font-size: 11px; font-weight: 600; color: var(--text-secondary); background: var(--surface-soft); padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: normal; }
.crm-app .order-items-table td { padding: 12px 8px; height: 64px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; font-size: 13px; overflow-wrap: anywhere; }
.order-items-table th:first-child { width: auto; }
.order-items-table th:nth-child(2) { width: 62px; }
.order-items-table th:nth-child(3) { width: 94px; }
.order-items-table th:nth-child(4) { width: 118px; }
.order-items-table th:nth-child(5) { width: 110px; }
.order-items-table th:nth-child(6) { width: 48px; }
.crm-app .order-items-table input { width: 100%; min-width: 0; padding: 8px; }
.order-items-table input[type=number], .order-items-table .currency-input { text-align: right; font-variant-numeric: tabular-nums; }
.order-items-table td[data-order-line-total] { font-weight: 600; white-space: nowrap; }
.crm-app .order-items-table .btn-icon { width: 32px; height: 36px; padding: 6px; }
.crm-app .order-items-table .btn-icon:hover { color: var(--danger); background: var(--danger-soft); }
.order-products-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.order-products-footer > span { font-size: 12px; color: var(--text-secondary); }
.order-entry-section textarea { width: 100%; resize: vertical; }
.order-summary { position: sticky; top: 100px; min-width: 0; padding: 20px; margin-top: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.crm-app .order-summary > h3 { font-size: 15px; font-weight: 650; margin: 0 0 16px; }
.order-summary-context { display: flex; flex-direction: column; gap: 6px; padding-bottom: 16px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.order-summary-context strong { font-size: 14px; line-height: 1.5; }
.order-summary-context span { font-size: 12px; color: var(--text-secondary); }
.order-summary-context [data-order-summary-kind] { color: var(--info-strong); }
.order-summary dl { margin: 0; padding: 16px 0; }
.order-summary dl > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.order-summary dt { font-weight: 400; font-size: 13px; color: var(--text-secondary); }
.order-summary dd { font-size: 15px; font-weight: 600; margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.order-summary-adjustments { display: grid; gap: 12px; }
.crm-app .order-summary-adjustments label { display: grid; grid-template-columns: 1fr 116px; gap: 8px; align-items: center; margin: 0; font-size: 12px; }
.order-summary-adjustments input { width: 100%; text-align: right; font-variant-numeric: tabular-nums; }
.order-summary-total { display: flex; flex-direction: column; gap: 5px; margin: 20px -20px 16px; padding: 16px 20px; background: var(--primary-light); color: var(--primary-dark); border-block: 1px solid var(--border); }
.order-summary-total span { font-size: 12px; font-weight: 550; }
.order-summary-total strong { font-size: 27px; line-height: 1.35; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.order-summary > button { width: 100%; margin-top: 8px; }
.order-page-error:empty { display: none; }
.order-page-error:not(:empty), .order-reference-feedback { margin: 16px 0; padding: 12px 16px; border-left: 3px solid var(--danger); background: var(--danger-soft); }
.order-reference-feedback { border-color: var(--info); color: var(--info-strong); background: var(--info-soft); font-size: 13px; }
.order-page-loading { padding: 40px 0; color: var(--text-secondary); }
.order-saved > .order-customer-identity { margin: 24px 0; }
.order-saved-state { display: inline-flex; align-items: center; gap: 6px; color: var(--success-strong); background: var(--success-soft); padding: 4px 8px; font-size: 12px; border-radius: 4px; }
.order-saved-state svg { width: 16px; height: 16px; }
.order-saved-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.order-saved-totals { display: flex; flex-wrap: wrap; gap: 24px 48px; padding: 20px 0; border-top: 1px solid var(--border); }
.order-saved-totals > div { display: grid; gap: 6px; }
.order-saved-totals span { font-size: 12px; color: var(--text-secondary); }
.order-saved-totals strong { font-size: 24px; font-weight: 650; color: var(--primary-dark); }
@media (max-width: 1250px) {
  .order-entry-layout { grid-template-columns: minmax(0, 1fr) 270px; gap: 20px; }
  .order-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-fields .order-field-wide { grid-column: auto; }
}
@media (max-width: 1050px) {
  .order-entry-layout { grid-template-columns: minmax(0, 1fr); }
  .order-summary { position: static; margin-top: 0; }
}
@media (max-width: 600px) {
  .order-page-header { gap: 12px; align-items: end; }
  .order-page-header [data-order-save] { min-width: 0; max-width: 142px; }
  .order-customer-search { align-items: stretch; flex-direction: column; }
  .order-customer-search > button { align-self: start; }
  .order-customer-identity { padding: 14px 12px; gap: 8px; }
  .order-customer-avatar { display: none; }
  .order-fields, .order-fields--two { grid-template-columns: minmax(0, 1fr); }
  .order-destination fieldset { flex-direction: column; width: 100%; }
  .order-destination fieldset label:first-of-type { border-radius: 6px 6px 0 0; }
  .order-destination fieldset label:last-of-type { border-radius: 0 0 6px 6px; margin: -1px 0 0; }
  .order-destination [data-order-existing-picker] { flex-basis: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .order-entry-status, .order-summary-total { transition: background-color 160ms var(--motion-ease); }
}
