/* Phone-only customer work mode.  It keeps the existing customer API and
 * permissions, while replacing desktop rails with tap-friendly navigation. */
.client-mobile-bottom-nav,
.client-mobile-order-cards {
  display: none;
}

@media (max-width: 700px) {
  body.mobile-work-mode {
    background: #f3f7fb;
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  body.mobile-work-mode .topbar {
    position: sticky;
    top: 0;
    z-index: 110;
  }

  body.mobile-work-mode .topbar-inner {
    align-items: center;
    min-height: 56px;
    padding: 8px 12px;
  }

  body.mobile-work-mode .account-menu {
    max-width: 48vw;
  }

  body.mobile-work-mode .account-menu-button,
  body.mobile-work-mode #accountMenuName {
    min-width: 0;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.mobile-work-mode .page {
    padding: 12px 12px calc(94px + env(safe-area-inset-bottom));
  }

  body.mobile-work-mode .menu-row {
    display: none;
  }

  body.mobile-work-mode .workarea {
    display: block;
    min-width: 0;
  }

  body.mobile-work-mode .detail-pane {
    display: none;
  }

  body.mobile-work-mode .list-pane {
    min-width: 0;
  }

  body.mobile-work-mode .switches {
    gap: 8px;
    padding: 10px;
  }

  body.mobile-work-mode .list-field-toggle {
    min-width: calc(50% - 6px);
  }

  /* The existing table stays available to scripts; readable order cards are
     shown to people on a phone. */
  body.mobile-work-mode .list-pane > .legacy-table-wrap {
    display: none;
  }

  .client-mobile-order-cards {
    display: grid;
    gap: 10px;
    margin-top: 12px;
  }

  .client-mobile-order-card {
    display: block;
    padding: 14px;
    color: inherit;
    text-decoration: none;
    background: #fff;
    border: 1px solid #d8e3ee;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(38, 75, 110, .07);
  }

  .client-mobile-order-card:active {
    transform: scale(.992);
    background: #f7fbff;
  }

  .client-mobile-order-card.is-locked {
    background: #f5f7f9;
  }

  .client-mobile-order-head,
  .client-mobile-order-route,
  .client-mobile-order-meta,
  .client-mobile-order-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
  }

  .client-mobile-order-head strong {
    min-width: 0;
    color: #134b79;
    font-size: 16px;
    overflow-wrap: anywhere;
  }

  .client-mobile-order-status {
    flex: 0 0 auto;
    padding: 3px 7px;
    color: #245f90;
    font-size: 11px;
    background: #e7f1fb;
    border-radius: 999px;
  }

  .client-mobile-order-party {
    margin-top: 8px;
    color: #263f56;
    font-size: 13px;
    line-height: 1.45;
  }

  .client-mobile-order-party small,
  .client-mobile-order-meta small {
    margin-right: 5px;
    color: #7d91a5;
    font-size: 11px;
  }

  .client-mobile-order-route {
    margin-top: 10px;
    color: #285d89;
    font-size: 13px;
    font-weight: 700;
  }

  .client-mobile-order-route span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .client-mobile-order-meta {
    align-items: flex-start;
    margin-top: 10px;
    padding-top: 9px;
    color: #526b82;
    font-size: 12px;
    border-top: 1px solid #edf1f5;
  }

  .client-mobile-order-meta > span {
    min-width: 0;
  }

  .client-mobile-order-foot {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 10px;
    color: #5a6d80;
    font-size: 12px;
  }

  .client-mobile-order-event {
    width: 100%;
    padding: 7px 9px;
    color: #8b5a17;
    line-height: 1.4;
    background: #fff6e7;
    border-radius: 8px;
  }

  .client-mobile-order-empty {
    padding: 28px 14px;
    color: #7890a5;
    text-align: center;
    background: #fff;
    border: 1px dashed #c9d8e5;
    border-radius: 14px;
  }

  .client-mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 210;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: calc(62px + env(safe-area-inset-bottom));
    padding: 6px 5px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid #dbe6ef;
    box-shadow: 0 -5px 18px rgba(24, 55, 82, .08);
    backdrop-filter: blur(12px);
  }

  .client-mobile-bottom-nav button {
    display: grid;
    min-width: 0;
    gap: 2px;
    place-items: center;
    padding: 3px 1px;
    color: #668097;
    font: inherit;
    font-size: 11px;
    line-height: 1.2;
    background: transparent;
    border: 0;
  }

  .client-mobile-bottom-nav button > b {
    font-size: 18px;
    font-weight: 650;
    line-height: 1;
  }

  .client-mobile-bottom-nav button.is-active {
    color: #1767a9;
  }

  .client-mobile-bottom-nav button.is-active > b {
    display: grid;
    width: 30px;
    height: 24px;
    place-items: center;
    color: #fff;
    background: #2e77b2;
    border-radius: 999px;
  }

  body.mobile-work-mode #customerTaskQuickOpen {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: auto;
    min-width: 48px;
    min-height: 42px;
    padding: 7px 10px;
    border-radius: 999px;
  }

  /* Phone dialogs use the whole available screen and keep close/actions visible. */
  body.mobile-work-mode .modal-layer,
  body.mobile-work-mode .company-notice-layer {
    z-index: 320;
  }

  body.mobile-work-mode .modal-layer .preorder-modal,
  body.mobile-work-mode .modal-layer .track-modal,
  body.mobile-work-mode .modal-layer .client-export-modal,
  body.mobile-work-mode .modal-layer .ship-schedule-modal,
  body.mobile-work-mode .modal-layer .vessel-motion-modal,
  body.mobile-work-mode .company-notice-modal {
    inset: 8px;
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    min-height: 0;
    max-height: calc(100dvh - 16px);
    border-radius: 14px;
  }

  body.mobile-work-mode .ship-schedule-frame-shell,
  body.mobile-work-mode #shipScheduleFrame {
    min-height: min(70dvh, 620px);
  }

  body.mobile-work-mode.order-detail-page .order-detail-page-shell {
    padding: 10px 10px calc(18px + env(safe-area-inset-bottom));
  }

  body.mobile-work-mode.order-detail-page .order-detail-layout,
  body.mobile-work-mode.order-detail-page .detail-side,
  body.mobile-work-mode.order-detail-page .detail-main {
    display: block;
    min-width: 0;
    max-width: 100%;
  }

  body.mobile-work-mode.order-detail-page .detail-side-section {
    margin-top: 12px;
  }

  body.mobile-work-mode.order-detail-page .order-detail-actions,
  body.mobile-work-mode.order-detail-page .operation-menu,
  body.mobile-work-mode.order-detail-page .timeline {
    max-width: 100%;
  }
}

/* Keep summary filters independently tappable in the narrow pre-shipment pane. */
@media (max-width: 700px) {
  #preOrderModal .preorder-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #preOrderModal .preorder-summary-card {
    min-width: 0;
    padding-inline: 6px;
  }
  #preOrderModal .preorder-summary-card :is(span, strong, em) {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}
