/* Status is expressed with both text and color. */
.cy-order-status.state-pending { color: #991b1b; background: #fee2e2; border: 1px solid #fca5a5; }
.cy-order-status.state-loading { color: #9a3412; background: #ffedd5; border: 1px solid #fdba74; }
.cy-order-status.state-completed { color: #166534; background: #dcfce7; border: 1px solid #86efac; }
.cy-dispatch-table .cy-dispatch-group-title > th { padding: 18px 0 10px; background: transparent; border: 0; text-align: left; white-space: normal; }
.cy-dispatch-group-count { display: inline-block; margin-left: 10px; color: #54677e; font-size: 14px; font-weight: 600; }
.cy-dispatch-vehicle-number { font-size: 17px; font-weight: 800; color: #172b45; }
.cy-dispatch-vehicle-number.is-unassigned { color: #69788d; }
.cy-dispatch-weight-number { font-size: 18px; color: #174ba3; font-variant-numeric: tabular-nums; }
.cy-dispatch-weight-unit { margin-left: 4px; color: #54677e; font-size: 13px; }
.cy-dispatch-pallet-method { display: block; color: #65768b; font-size: 12px; }
.cy-dispatch-meta { color: #65768b; }
.cy-dispatch-table td .cy-order-manual-label { color: #805000; }
.cy-order-actions-cell > .cy-dispatch-primary { color: #fff; background: #235ac5; border-color: #235ac5; font-weight: 700; }
.cy-dispatch-table details.cy-dispatch-more { display: block; width: 100%; min-width: 0; max-width: 100%; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; align-self: start; }
.cy-dispatch-table .cy-dispatch-more > summary { display: flex; align-items: center; justify-content: center; width: 100%; height: 44px; min-height: 44px; margin: 0; padding: 8px 12px; border: 1px solid #bdc9d8; border-radius: 7px; background: #f8fafc; color: #43566f; cursor: pointer; box-sizing: border-box; font-size: 14px; font-weight: 500; list-style: none; }
.cy-dispatch-more > summary::-webkit-details-marker, .cy-dispatch-mixed > summary::-webkit-details-marker { display: none; }
.cy-dispatch-more > summary::marker, .cy-dispatch-mixed > summary::marker { content: ''; }
.cy-dispatch-more > summary::after { content: '▾'; margin-left: 6px; }
.cy-dispatch-more[open] > summary::after { content: '▴'; }
.cy-dispatch-more-links { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; margin-top: 8px; }
.cy-dispatch-more-links > a { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 40px; margin: 0; padding: 8px; border: 1px solid #d5deea; border-radius: 6px; color: #43566f; background: #fff; text-align: center; text-decoration: none; white-space: normal; overflow-wrap: anywhere; box-sizing: border-box; font-size: 13px; }
.cy-dispatch-more summary:focus-visible, .cy-dispatch-more-links a:focus-visible { outline: 3px solid #80aef6; outline-offset: 2px; }
.cy-order-list-head:has(> .cy-dispatch-filter) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); align-items: end; gap: 16px; }
.cy-order-list-head .cy-dispatch-filter { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; width: 100%; max-width: 100%; min-width: 0; margin: 0; }
.cy-order-list-head .cy-dispatch-filter > label { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; }
.cy-order-list-head .cy-dispatch-filter input[type='date'] { width: 100% !important; max-width: 100%; min-width: 0; height: 44px; margin: 0; box-sizing: border-box; }
.cy-order-list-head .cy-dispatch-filter > button { height: 44px; min-height: 44px; min-width: 60px; margin: 0; padding: 8px 14px; align-self: end; box-sizing: border-box; }
.cy-dispatch-table details.cy-dispatch-mixed { width: 100%; min-width: 0; max-width: 100%; margin: 0; padding: 0; border: 0; background: transparent; }
.cy-dispatch-table .cy-dispatch-mixed > summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; min-width: 0; min-height: 44px; margin: 0; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; list-style: none; }
.cy-dispatch-table .cy-mixed-load-badge { display: inline-block; padding: 4px 8px; border: 1px solid #fecaca; border-radius: 6px; background: #fff1f2; color: #b91c1c; font-size: 13px; font-weight: 800; line-height: 1.6; white-space: nowrap; }
.cy-mixed-load-products { margin-top: 8px; padding: 10px; border: 1px solid #fecaca; border-radius: 8px; background: #fff7f7; color: #6f3030; font-size: 13px; font-weight: 400; line-height: 1.6; overflow-wrap: anywhere; }
.cy-mixed-load-products p { margin: 0 0 6px; }
.cy-mixed-load-products ul { margin: 0; padding-left: 18px; }
.cy-mixed-load-products li { margin: 6px 0; }
.cy-mixed-load-products li > strong, .cy-mixed-load-products li > span { display: block; }
.cy-mixed-load-products li a { display: inline-block; min-height: 24px; margin-right: 8px; color: #8d2525; text-decoration: underline; }
.cy-mixed-load-products .cy-mixed-load-note { margin: 8px 0 0; color: #7c5656; font-size: 12px; }
.cy-dispatch-mixed > summary:focus-visible { outline: 3px solid #80aef6; outline-offset: 2px; border-radius: 4px; }

/* The same cell classes are used on initial render and home auto-refresh. */
@media screen and (max-width: 1100px), screen and (hover: none) and (pointer: coarse) {
  :is(.cy-order-list, .cy-home-orders) .cy-order-table-scroll { overflow: visible; min-width: 0; max-width: 100%; }
  :is(.cy-order-list, .cy-home-orders) .cy-dispatch-table { display: block; width: 100%; min-width: 0; max-width: 100%; }
  .cy-dispatch-table > thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .cy-dispatch-table > tbody { display: block; min-width: 0; width: 100%; }
  .cy-dispatch-table .cy-dispatch-group-title { display: block; margin-top: 8px; }
  .cy-dispatch-table .cy-dispatch-group-title > th { display: flex; align-items: center; padding: 10px 0 4px; }
  .cy-dispatch-table .cy-dispatch-group-title .cy-order-status { font-size: 14px; padding: 6px 12px; }
  .cy-dispatch-table tr[data-order-id] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: 'vehicle vehicle' 'grade grade' 'weight pallet' 'meta meta' 'state state' 'actions actions';
    gap: 9px 14px;
    min-width: 0;
    width: 100%;
    margin: 10px 0 14px;
    padding: 14px;
    border: 1px solid #d9e1eb;
    border-inline-start: 5px solid #cbd5e1;
    border-radius: 12px;
    background: #fff;
    box-sizing: border-box;
  }
  .cy-dispatch-table tbody[data-dispatch-group='PENDING'] tr[data-order-id] { border-inline-start-color: #dc2626; }
  .cy-dispatch-table tbody[data-dispatch-group='LOADING'] tr[data-order-id] { border-inline-start-color: #f97316; }
  .cy-dispatch-table tbody[data-dispatch-group='COMPLETED'] tr[data-order-id] { border-inline-start-color: #16a34a; background: #fbfefc; }
  .cy-dispatch-table td { display: block; width: auto; min-width: 0; max-width: 100%; padding: 0; border: 0; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; box-sizing: border-box; }
  .cy-dispatch-table td[data-label]::before { display: block; content: attr(data-label); margin-bottom: 3px; color: #65768b; font-size: 12px; font-weight: 500; }
  .cy-dispatch-table .cy-dispatch-vehicle { grid-area: vehicle; }
  .cy-dispatch-table .cy-dispatch-grade { grid-area: grade; }
  .cy-dispatch-table .cy-dispatch-weight { grid-area: weight; padding: 10px; border-radius: 8px; background: #f1f6fd; }
  .cy-dispatch-table .cy-dispatch-pallet { grid-area: pallet; padding: 10px 6px; border-radius: 8px; background: #f8fafc; text-align: center; }
  .cy-dispatch-table .cy-dispatch-meta { grid-area: meta; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 12px; }
  .cy-dispatch-table .cy-dispatch-state { grid-area: state; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 10px; border-top: 1px solid #e3e9f0; }
  .cy-dispatch-table .cy-dispatch-actions { grid-area: actions; padding-top: 3px; }
  .cy-dispatch-table td.cy-dispatch-meta::before, .cy-dispatch-table td.cy-dispatch-state::before { content: none; }
  .cy-dispatch-table .cy-dispatch-meta a { min-height: 24px; padding: 0; color: #65768b; }
  .cy-dispatch-table .cy-dispatch-meta small { margin: 0; }
  .cy-dispatch-table .cy-dispatch-vehicle-number { display: block; font-size: 25px; line-height: 1.3; letter-spacing: -.3px; overflow-wrap: anywhere; }
  .cy-dispatch-table .cy-dispatch-grade a { max-width: 100%; min-height: 0; padding: 0; color: #314f7b; white-space: normal; overflow-wrap: anywhere; }
  .cy-dispatch-table .cy-dispatch-grade strong { font-size: 19px; }
  .cy-dispatch-table .cy-dispatch-weight-number { font-size: 25px; line-height: 1.4; }
  .cy-dispatch-table .cy-dispatch-weight-unit { margin-left: 3px; font-size: 13px; }
  .cy-dispatch-table .cy-order-pallet-count { display: block; margin-top: 4px; font-size: 20px; line-height: 1.4; font-weight: 700; text-align: center; white-space: normal; overflow-wrap: anywhere; }
  .cy-dispatch-table .cy-dispatch-state > small { flex-basis: 100%; margin: 0; }
  .cy-dispatch-table .cy-order-progress { display: flex; flex: 1 1 190px; flex-wrap: nowrap; align-items: end; gap: 8px; min-width: 0; max-width: 100%; margin: 0; }
  .cy-dispatch-table .cy-order-progress label { flex: 1; min-width: 0; margin: 0; }
  .cy-dispatch-table .cy-progress-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .cy-dispatch-table .cy-order-progress select { width: 100%; min-width: 0; max-width: 100%; min-height: 44px; padding: 8px; border: 1px solid #bfcbd9; border-radius: 7px; background: #fff; color: #22344a; box-sizing: border-box; font: inherit; }
  .cy-dispatch-table .cy-order-progress button { flex-shrink: 0; min-height: 44px; padding: 8px 12px; }
  .cy-dispatch-table .cy-order-actions-cell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 8px; min-width: 0; max-width: 100%; }
  .cy-dispatch-table .cy-order-actions-cell > .cy-dispatch-primary { grid-column: 1 / -1; }
  .cy-dispatch-table .cy-order-actions-cell > a, .cy-dispatch-table .cy-dispatch-more > summary { display: flex; align-items: center; justify-content: center; width: 100%; min-width: 0; height: 44px; min-height: 44px; margin: 0; padding: 8px; border: 1px solid #bdc9d8; border-radius: 7px; text-align: center; white-space: normal; overflow-wrap: anywhere; box-sizing: border-box; font-size: 14px; }
  .cy-dispatch-table .cy-dispatch-more > summary::after { content: '▾'; margin-left: 6px; }
  .cy-dispatch-table .cy-dispatch-more[open] > summary::after { content: '▴'; }
  .cy-dispatch-table .cy-dispatch-more-links > a { min-height: 44px; }
  .cy-order-list-head:has(> .cy-dispatch-filter) { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}
