/* Version 3.98618: Dispatch mobile task-first flow.
   Status chips, filters, and information-first load details. */

@media (max-width: 720px) {
  /* Status metrics → horizontal chips */
  html body #boardView > .metric-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    margin: 0 -12px 10px !important;
    padding: 0 12px 4px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }

  html body #boardView > .metric-grid::-webkit-scrollbar {
    display: none !important;
  }

  html body #boardView > .metric-grid .metric {
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    min-height: 36px !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 6px 12px !important;
    border-radius: 999px !important;
    white-space: nowrap !important;
  }

  html body #boardView > .metric-grid .metric span {
    font-size: 12px !important;
    line-height: 1 !important;
  }

  html body #boardView > .metric-grid .metric strong {
    font-size: 13px !important;
    line-height: 1 !important;
  }

  html body #boardView #dispatchOwnerQuickTiles {
    display: none !important;
  }

  /* Sticky search + Filters */
  html body #boardView .board-tools {
    position: sticky !important;
    top: calc(52px + env(safe-area-inset-top, 0px)) !important;
    z-index: 9 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 8px !important;
    align-items: center !important;
    margin: 0 -12px 10px !important;
    padding: 8px 12px !important;
    border-bottom: 1px solid #d7e0ea !important;
    background: #f5f7fb !important;
    box-shadow: none !important;
  }

  html body #boardView .board-tools > .search-wrap {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  html body #boardView .board-tools > .search-wrap input,
  html body #boardView .board-tools #searchInput {
    width: 100% !important;
    min-height: 42px !important;
  }

  html body #boardView .board-tools > #dispatchMobileFiltersToggle {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 84px !important;
    min-height: 42px !important;
    border-radius: 8px !important;
    font-weight: 800 !important;
  }

  html body #boardView .board-tools > #dispatchMobileFiltersDone,
  html body #boardView .board-tools > :not(.search-wrap):not(#dispatchMobileFiltersToggle):not(#dispatchMobileFiltersDone) {
    display: none !important;
  }

  html body #boardView .board-tools > #clearFilters:not([hidden]) {
    display: none !important;
  }

  /* Filters as full-screen sheet */
  html body.dispatch-mobile-filters-open {
    overflow: hidden !important;
  }

  html body.dispatch-mobile-filters-open #boardView .board-tools {
    position: fixed !important;
    inset: 0 !important;
    z-index: 60 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-auto-rows: min-content !important;
    align-content: start !important;
    gap: 10px !important;
    margin: 0 !important;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(20px + env(safe-area-inset-bottom, 0px)) !important;
    overflow: auto !important;
    background: #fff !important;
    border: 0 !important;
    -webkit-overflow-scrolling: touch !important;
  }

  html body.dispatch-mobile-filters-open #boardView .board-tools > .search-wrap {
    grid-column: 1 / -1 !important;
  }

  html body.dispatch-mobile-filters-open #boardView .board-tools > #dispatchMobileFiltersToggle {
    display: none !important;
  }

  html body.dispatch-mobile-filters-open #boardView .board-tools > #dispatchMobileFiltersDone {
    grid-column: 1 / -1 !important;
    display: inline-flex !important;
    justify-content: center !important;
    order: 99 !important;
    min-height: 44px !important;
    margin-top: 8px !important;
    border-radius: 8px !important;
    font-weight: 800 !important;
  }

  html body.dispatch-mobile-filters-open #boardView .board-tools > :not(#dispatchMobileFiltersToggle) {
    display: block !important;
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 42px !important;
  }

  html body.dispatch-mobile-filters-open #boardView .board-tools > .search-wrap {
    display: block !important;
  }

  html body.dispatch-mobile-filters-open #boardView .board-tools > #clearFilters[hidden] {
    display: none !important;
  }

  html body #boardView #loadsSection > .table-header {
    display: none !important;
  }

  html body #boardView #loadRows > tr.load-detail-row,
  html body #boardView #loadRows > tr.selected-load-detail-row {
    display: none !important;
  }

  /* Full-screen load sheet */
  #dispatchMobileLoadSheet.mobile-load-sheet {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    background: #eef3f8 !important;
    overflow: hidden !important;
    color: #142438 !important;
  }

  #dispatchMobileLoadSheet.mobile-load-sheet::backdrop {
    background: rgb(8 18 29 / .55) !important;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-frame {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
    min-height: 0;
    background: #eef3f8;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: start;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 18px 18px;
    border: 0;
    background: linear-gradient(145deg, #102131 0%, #173a57 100%);
    box-shadow: 0 8px 24px rgb(15 33 49 / .18);
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-identity {
    min-width: 0;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-kicker {
    display: block;
    margin-bottom: 5px;
    color: #8fc8ef;
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .08em;
    line-height: 1.2;
    text-transform: uppercase;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-head h2 {
    margin: 0;
    overflow: hidden;
    color: #fff;
    font-size: clamp(26px, 7vw, 32px);
    font-weight: 900;
    letter-spacing: -.025em;
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-customer {
    margin: 7px 0 0;
    overflow: hidden;
    color: #fff;
    font-size: 15px;
    font-weight: 750;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-lane {
    display: inline-flex;
    max-width: 100%;
    margin: 8px 0 0;
    padding: 6px 9px;
    overflow: hidden;
    border: 1px solid rgb(255 255 255 / .14);
    border-radius: 8px;
    background: rgb(255 255 255 / .08);
    color: #c9d8e5;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-close {
    display: grid;
    place-items: center;
    width: 46px;
    min-width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid rgb(255 255 255 / .22);
    border-radius: 14px;
    background: rgb(255 255 255 / .1);
    color: #fff;
    font-size: 27px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-close:active {
    background: rgb(255 255 255 / .2);
    transform: scale(.96);
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow: auto;
    padding: 12px 12px 22px;
    overscroll-behavior: contain;
    scroll-padding-bottom: 24px;
    -webkit-overflow-scrolling: touch;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-section {
    margin: 0;
    padding: 14px;
    border: 1px solid #d5dfe9;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 2px 8px rgb(31 53 75 / .05);
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 11px;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-section-heading h3 {
    margin: 0;
    color: #42546a;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .065em;
    text-transform: uppercase;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-section-heading > span {
    color: #7b8b9d;
    font-size: 12px;
    font-weight: 700;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-status-section {
    display: grid;
    grid-template-columns: minmax(72px, auto) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 11px 12px;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-status-section .mobile-load-sheet-section-heading {
    display: block;
    margin: 0;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-status-section .mobile-load-sheet-section-heading > span {
    display: block;
    margin-top: 3px;
    font-size: 11px;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-status-control {
    position: relative;
    min-width: 0;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-status-control::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 16px;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    pointer-events: none;
    transform: translateY(-70%) rotate(45deg);
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-status {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    min-height: 46px;
    padding: 0 40px 0 16px !important;
    border-width: 1px !important;
    border-radius: 999px;
    background-image: none !important;
    font-size: 12px !important;
    font-weight: 900 !important;
    letter-spacing: .045em;
    text-align: center;
    text-align-last: center;
    text-transform: uppercase;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-route {
    position: relative;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-route::before {
    content: "";
    position: absolute;
    top: 30px;
    bottom: 30px;
    left: 17px;
    width: 2px;
    border-radius: 999px;
    background: linear-gradient(#2d78b6, #38a06c);
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop {
    position: relative;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop + .mobile-load-sheet-stop {
    margin-top: 17px;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop-marker {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 4px solid #e8f2fa;
    border-radius: 50%;
    background: #2d78b6;
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    box-sizing: border-box;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop-delivery .mobile-load-sheet-stop-marker {
    border-color: #e5f4ec;
    background: #279565;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop-copy {
    min-width: 0;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop-copy > span {
    display: block;
    margin: 1px 0 2px;
    color: #748397;
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop-copy strong {
    display: block;
    color: #142438;
    font-size: 15px;
    font-weight: 850;
    line-height: 1.28;
    overflow-wrap: anywhere;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop-copy strong small {
    display: block;
    margin-top: 2px;
    color: #6d7d90;
    font-size: 12px;
    font-weight: 650;
    line-height: 1.3;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop-copy time {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 26px;
    margin-top: 6px;
    padding: 3px 9px;
    border-radius: 8px;
    background: #edf4fa;
    color: #215b87;
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop-delivery time {
    background: #eaf6ef;
    color: #176d49;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-stop-copy time b {
    opacity: .45;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-route-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 13px;
    padding-top: 11px;
    border-top: 1px solid #e7edf3;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-route-meta:has(> div:only-child) {
    grid-template-columns: 1fr;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-route-meta div,
  #dispatchMobileLoadSheet .mobile-load-sheet-fact {
    min-width: 0;
    padding: 10px 11px;
    border: 1px solid #e2e9f0;
    border-radius: 11px;
    background: #f6f9fb;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-route-meta span,
  #dispatchMobileLoadSheet .mobile-load-sheet-fact > span {
    display: block;
    margin-bottom: 3px;
    color: #738296;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-route-meta strong,
  #dispatchMobileLoadSheet .mobile-load-sheet-fact > strong {
    display: block;
    overflow: hidden;
    color: #182a3e;
    font-size: 14px;
    font-weight: 850;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-fact-wide,
  #dispatchMobileLoadSheet .mobile-load-sheet-fact-carrier {
    grid-column: 1 / -1;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-fact-carrier {
    border-color: #d4e4f1;
    background: #eef6fc;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-fact strong small {
    display: block;
    margin-top: 2px;
    color: #728196;
    font-size: 11px;
    font-weight: 700;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-notes-list {
    display: grid;
    gap: 10px;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-notes-list > div + div {
    padding-top: 10px;
    border-top: 1px solid #e7edf3;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-notes-list span {
    display: block;
    color: #738296;
    font-size: 11px;
    font-weight: 800;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-notes-list p,
  #dispatchMobileLoadSheet .mobile-load-sheet-empty-copy {
    margin: 4px 0 0;
    color: #24374d;
    font-size: 14px;
    font-weight: 650;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-notes-empty {
    padding-block: 12px;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-notes-empty .mobile-load-sheet-section-heading {
    margin-bottom: 2px;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-empty-copy {
    color: #7a899b;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 11px 12px calc(11px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #d5dfe9;
    background: rgb(255 255 255 / .97);
    box-shadow: 0 -8px 24px rgb(31 53 75 / .1);
    backdrop-filter: blur(12px);
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-actions .primary-button,
  #dispatchMobileLoadSheet .mobile-load-sheet-actions .ghost-button {
    min-height: 52px;
    margin: 0;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 850;
  }

  #dispatchMobileLoadSheet .mobile-load-sheet-actions .primary-button {
    box-shadow: 0 5px 12px rgb(38 102 155 / .2);
  }

  body.dispatch-mobile-sheet-open {
    overflow: hidden !important;
  }

  @media (max-height: 620px) {
    #dispatchMobileLoadSheet .mobile-load-sheet-head {
      padding-top: calc(12px + env(safe-area-inset-top, 0px));
      padding-bottom: 13px;
    }

    #dispatchMobileLoadSheet .mobile-load-sheet-lane {
      margin-top: 5px;
      padding-block: 4px;
    }
  }

  /* Desktop-only chrome stays off the phone Board */
  html body #boardView .board-column-customizer-bar,
  html body[data-current-view="board"] .board-column-customizer-bar,
  html body:has(#boardView.active-view) .board-column-customizer-bar {
    display: none !important;
  }

  html body[data-current-view="board"] .ec-top-actions,
  html body:has(#boardView.active-view) .ec-top-actions,
  html body[data-current-view="board"] #openCustomerServiceLoadImport,
  html body[data-current-view="board"] #openCustomerServiceTmsBulk,
  html body:has(#boardView.active-view) #openCustomerServiceLoadImport,
  html body:has(#boardView.active-view) #openCustomerServiceTmsBulk {
    display: none !important;
  }

  /* Compact Board header: date/title + refresh + overflow menu only */
  html body[data-current-view="board"] .topbar,
  html body:has(#boardView.active-view) .topbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 8px !important;
    align-items: center !important;
    margin: -6px -12px 8px !important;
    padding: 6px 12px 8px !important;
  }

  html body[data-current-view="board"] .topbar > div:first-child,
  html body:has(#boardView.active-view) .topbar > div:first-child {
    display: grid !important;
    gap: 2px !important;
    min-width: 0 !important;
  }

  html body[data-current-view="board"] #mainTitle,
  html body:has(#boardView.active-view) #mainTitle {
    font-size: 24px !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
  }

  html body[data-current-view="board"] #mainTitle::before,
  html body[data-current-view="board"] #mainTitle::after,
  html body:has(#boardView.active-view) #mainTitle::before,
  html body:has(#boardView.active-view) #mainTitle::after {
    content: none !important;
    display: none !important;
  }

  html body[data-current-view="board"] .top-actions,
  html body:has(#boardView.active-view) .top-actions {
    display: inline-flex !important;
    grid-template-columns: none !important;
    gap: 6px !important;
    align-items: center !important;
    justify-content: flex-end !important;
    width: auto !important;
  }

  html body[data-current-view="board"] .top-actions > *,
  html body:has(#boardView.active-view) .top-actions > * {
    width: auto !important;
    min-width: 0 !important;
    min-height: 40px !important;
  }

  html body[data-current-view="board"] .top-actions #newLoad,
  html body:has(#boardView.active-view) .top-actions #newLoad {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 42px !important;
    min-width: 42px !important;
    padding: 0 !important;
    font-size: 22px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
  }

  html body[data-current-view="board"] .top-actions #refreshBoard,
  html body[data-current-view="board"] .top-actions #dispatchActionsMenu,
  html body:has(#boardView.active-view) .top-actions #refreshBoard,
  html body:has(#boardView.active-view) .top-actions #dispatchActionsMenu {
    display: inline-flex !important;
    width: 42px !important;
    min-width: 42px !important;
    justify-content: center !important;
  }

  /* Prefer full route text on cards */
  html body #boardView #loadRows .mobile-customer-route {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }

  /* Keep jump-top clear of the bottom tab bar */
  html body .dispatch-jump-top-button {
    right: 14px !important;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (min-width: 721px) {
  #dispatchMobileFiltersToggle,
  #dispatchMobileFiltersDone,
  #dispatchMobileLoadSheet {
    display: none !important;
  }
}
