/**
 * Hydra mobile — route Đơn hàng (restyle only, desktop unchanged)
 * Viewport: 430×932. Giữ đủ section DOM; chỉ skin Hydra Orange.
 */
@media (max-width: 900px) {
  body.use-new-ui.route-orders #contentScroll.content-scroll,
  body.use-new-ui.route-orders .content-scroll {
    /* TASK-615: shared FAB clearance token (safe-area once via hypercat) */
    padding-bottom: var(--mobile-scroll-bottom-clearance-fab, var(--hydra-mo-scroll-bottom-pad-fab)) !important;
  }

  body.use-new-ui.route-orders #mobileOwnerFab:not([hidden]) {
    right: calc(16px + env(safe-area-inset-right, 0px)) !important;
    /* total-h already includes safe-area (TASK-614) — do not add env() again */
    bottom: calc(var(--hydra-bottom-nav-total-h, var(--hydra-bottom-nav-h, 46px)) + 12px) !important;
    left: auto !important;
  }

  body.use-new-ui.route-orders .route-page.orders-page {
    display: flex;
    flex-direction: column;
    gap: 6px !important;
    width: 100% !important;
    max-width: none !important;
    margin-inline: 0 !important;
    padding: 0 0 8px !important;
    box-sizing: border-box !important;
  }

  body.use-new-ui.route-orders .orders-save-success-bar {
    order: 0;
    width: 100% !important;
    max-width: none !important;
    margin: 0 0 10px !important;
    border-radius: 18px;
    border: 1px solid var(--hydra-border-soft);
    background: var(--hydra-bg-warm-soft);
    box-shadow: var(--hydra-shadow);
    box-sizing: border-box;
  }

  /* Toolbar — wrapper CTA: hydra-mobile-polish-final (.orders-desk-top) */
  body.use-new-ui.route-orders .orders-desk-top {
    order: 1;
    margin-top: var(--hydra-mobile-filter-gap, 12px) !important;
  }

  body.use-new-ui.route-orders .orders-desk-top #hydraOrdersToolbar.orders-toolbar-mo,
  body.use-new-ui.route-orders .orders-desk-top .orders-toolbar-mo,
  body.use-new-ui.route-orders .orders-desk-top .toolbar.compact-toolbar {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
  }

  body.use-new-ui.route-orders .orders-desk-chips-host {
    order: 2;
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    margin-inline: 0 !important;
    box-sizing: border-box;
    overflow: visible;
  }

  /* KPI tổng 6 ô — ẩn mobile (trùng chip lọc + Thu/Lãi trên từng đơn); desktop ≥901px giữ */
  body.use-new-ui.route-orders #hydraOrdersSummary.orders-summary-cards,
  body.use-new-ui.route-orders .orders-page .orders-summary-cards {
    display: none !important;
    order: 3;
    width: 100% !important;
    max-width: none !important;
    margin: 0;
    padding: 0;
    min-height: 0;
    overflow: hidden;
  }

  /* List */
  body.use-new-ui.route-orders #hydraOrdersMobileWrap,
  body.use-new-ui.route-orders .orders-mobile-wrap {
    order: 4;
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 0 calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box !important;
  }

  body.use-new-ui.route-orders #hydraOrdersMobileList {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100% !important;
    max-width: none !important;
  }

  body.use-new-ui.route-orders .orders-pager-row {
    order: 5;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 10px 14px 12px !important;
    border-radius: 20px;
    border: 1px solid var(--hydra-border-soft);
    background: #fff;
    box-shadow: var(--hydra-shadow);
    justify-content: center;
    align-items: center;
    gap: 10px;
  }

  body.use-new-ui.route-orders .orders-pager-row .btn {
    min-height: 44px;
    border-radius: 12px;
    font-weight: 700;
  }

  body.use-new-ui.route-orders .orders-pager-row #hydraOrdersPagerLabel,
  body.use-new-ui.route-orders .orders-pager-row #hydraOrdersPagerMeta {
    font-size: 13px;
    font-weight: 600;
    color: var(--hydra-text-muted);
  }

  body.use-new-ui.route-orders .orders-table-shell {
    order: 99;
    display: none !important;
  }

  /* CTA: .mobile-primary-cta — hydra-mobile-polish-final.css */

  body.use-new-ui.route-orders .orders-toolbar-mo .orders-toolbar-cod-all,
  body.use-new-ui.route-orders #hydraOrdersToolbar .orders-toolbar-cod-all {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-height: 44px !important;
    margin: 0 !important;
    border-radius: 12px !important;
    font-weight: 700 !important;
    box-sizing: border-box !important;
  }

  body.use-new-ui.route-orders .orders-search-mo,
  body.use-new-ui.route-orders #ordersSearch.orders-search-mo,
  body.use-new-ui.route-orders #hydraOrdersToolbar .orders-search-mo,
  body.use-new-ui.route-orders #hydraOrdersToolbar #ordersSearch {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    min-height: 48px !important;
    height: 48px !important;
    max-height: 50px !important;
    margin: 0 !important;
    padding: 0 14px !important;
    border-radius: 12px !important;
    border: 1px solid var(--hydra-border-soft) !important;
    background: #fff !important;
    font-size: 16px !important;
    line-height: 1.2 !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
  }

  body.use-new-ui.route-orders .orders-search-mo::placeholder,
  body.use-new-ui.route-orders #ordersSearch.orders-search-mo::placeholder {
    color: var(--hydra-text-muted, #6b7280) !important;
    opacity: 1 !important;
  }

  /* Ẩn filter desktop trong toolbar mobile */
  body.use-new-ui.route-orders #hydraOrdersToolbar select,
  body.use-new-ui.route-orders #hydraOrdersToolbar .orders-toolbar-desktop-only {
    display: none !important;
  }

  body.use-new-ui.route-orders .orders-desk-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    max-width: none;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    /* TASK-616 / F004: trailing gutter so last chip fully clears + tappable (Storage st-tabs pattern) */
    padding: 0;
    padding-inline-end: 16px;
    scroll-padding-inline: 14px;
    scroll-padding-inline-end: 16px;
    margin: 0;
    scrollbar-width: none;
    box-sizing: border-box;
    /* Fade only leading edge as scroll affordance — do not fade trailing edge (clips last chip) */
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 100%);
  }

  body.use-new-ui.route-orders .orders-desk-chips::-webkit-scrollbar {
    display: none;
  }

  body.use-new-ui.route-orders .orders-desk-chip {
    flex: 0 0 auto;
    min-height: 38px !important;
    height: 38px !important;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 14px !important;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid var(--hydra-border-soft);
    background: #fff;
    color: var(--hydra-text-secondary);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
  }

  body.use-new-ui.route-orders .orders-desk-chip:last-child {
    margin-inline-end: 4px;
  }

  body.use-new-ui.route-orders .orders-desk-chip.is-active {
    border-color: var(--hydra-border-strong);
    background: var(--hydra-accent-softer, rgba(255, 237, 213, 0.9));
    color: var(--hydra-orange-800);
    box-shadow: var(--hydra-shadow);
  }

  body.use-new-ui.route-orders .orders-desk-chip[data-orders-desk-chip="today"] {
    display: none !important;
  }

  /* Order card — dense 3-row (~110–130px) */
  body.use-new-ui.route-orders .order-mobile-card {
    overflow: visible !important;
    max-height: none !important;
  }

  body.use-new-ui.route-orders #hydraOrdersMobileList {
    overflow: visible !important;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense {
    display: block;
    width: 100% !important;
    max-width: none !important;
    padding: 14px 15px !important;
    margin: 0 !important;
    background: #fff;
    border: 1px solid var(--hydra-border-soft);
    border-radius: 14px;
    box-shadow: var(--hydra-shadow);
    max-height: none !important;
    overflow: visible !important;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 1;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense.is-menu-open {
    z-index: 60;
    overflow: visible !important;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__main {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    width: 100%;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
  }

  /* Dòng 1: #id + tên | badge trạng thái */
  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__row--head {
    align-items: center;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__head-left {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 5px;
    flex: 1 1 auto;
    min-width: 0;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__id {
    font-size: 12px !important;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--hydra-orange-700) !important;
    flex-shrink: 0;
    line-height: 1.2;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__customer {
    font-size: 15px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    color: var(--hydra-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1 1 auto;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__head-right {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    max-width: 46%;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--v3 .order-mobile-card__head-right .order-mo-menu-wrap {
    margin-left: 0;
  }

  body.use-new-ui.route-orders .order-mobile-card__badge.order-mo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 20px;
    padding: 1px 8px;
    border-radius: 999px;
    border: 1px solid var(--hydra-border-soft);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
    box-sizing: border-box;
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.use-new-ui.route-orders .order-mobile-card__badge.order-mo-badge.status-done {
    background: rgba(220, 252, 231, 0.9);
    border-color: rgba(74, 222, 128, 0.45);
    color: #166534;
  }

  body.use-new-ui.route-orders .order-mobile-card__badge.order-mo-badge.status-cod,
  body.use-new-ui.route-orders .order-mobile-card__badge.order-mo-badge.order-mo-badge--cod-hot {
    background: rgba(254, 243, 199, 0.92);
    border-color: rgba(251, 191, 36, 0.5);
    color: #92400e;
  }

  body.use-new-ui.route-orders .order-mobile-card__badge.order-mo-badge.status-pending {
    background: rgba(241, 245, 249, 0.95);
    border-color: #e2e8f0;
    color: #475569;
  }

  body.use-new-ui.route-orders .order-mobile-card__badge.order-mo-badge.status-cancelled {
    background: rgba(254, 226, 226, 0.65);
    border-color: rgba(252, 165, 165, 0.45);
    color: #991b1b;
  }

  /* Dòng 2: thông tin đơn */
  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__row--info {
    align-items: center;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__meta-line {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--hydra-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Dòng 3: Thu + Lãi */
  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__row--money {
    align-items: baseline;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__money-inline {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    min-width: 0;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__money-pair {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__money-k {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--hydra-text-muted);
    line-height: 1.2;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__amount {
    font-size: 13px !important;
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    color: var(--hydra-text);
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__profit.profit-positive {
    color: #15803d;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__profit.profit-negative,
  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__profit.profit-bad {
    color: #b91c1c;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__profit.profit-low {
    color: #b45309;
  }

  /* Dòng foot (legacy) — ẩn trên layout v3 */
  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--v3 .order-mobile-card__row--foot {
    display: none !important;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__row--foot {
    align-items: center;
    gap: 6px;
  }

  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__time {
    flex: 1 1 auto;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--hydra-text-muted);
    white-space: nowrap;
  }

  body.use-new-ui.route-orders .order-mo-menu-wrap {
    position: relative;
    flex-shrink: 0;
    z-index: 2;
  }

  body.use-new-ui.route-orders .order-mo-menu-btn {
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
    color: var(--hydra-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  body.use-new-ui.route-orders .order-mo-menu-btn:active {
    background: var(--hydra-bg-warm-soft);
  }

  body.use-new-ui.route-orders .order-mo-menu-panel {
    position: absolute;
    top: calc(100% + 2px);
    right: 0;
    z-index: 80;
    min-width: 168px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--hydra-border-soft);
    background: #fff;
    box-shadow: var(--hydra-shadow-md, 0 8px 24px rgba(15, 23, 42, 0.12));
  }

  body.use-new-ui.route-orders .order-mo-menu-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    color: var(--hydra-text, #0f172a);
    cursor: pointer;
  }

  body.use-new-ui.route-orders .order-mo-menu-item:hover {
    background: var(--hydra-bg-warm-soft, #f8fafc);
  }

  body.use-new-ui.route-orders .order-mo-menu-item--danger {
    color: #b91c1c;
  }

  /* Legacy rows — ẩn nếu còn trong DOM */
  body.use-new-ui.route-orders .order-mobile-card__row--body,
  body.use-new-ui.route-orders .order-mobile-card__body-left,
  body.use-new-ui.route-orders .order-mobile-card__body-right,
  body.use-new-ui.route-orders .order-mobile-card__money:not(.order-mobile-card__money-inline) {
    display: none !important;
  }

  body.use-new-ui.route-orders .order-mobile-card .hydra-currency-unit {
    font-size: 0.58em;
    font-weight: 700;
    margin-left: 1px;
    opacity: 0.88;
    vertical-align: baseline;
    white-space: nowrap;
    line-height: 1;
  }

  body.use-new-ui.route-orders .orders-mobile-empty {
    width: 100% !important;
    max-width: none !important;
    padding: 24px 18px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid var(--hydra-border-soft);
    box-shadow: var(--hydra-shadow);
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--hydra-text-muted);
    line-height: 1.45;
    box-sizing: border-box;
  }

  body.use-new-ui.route-orders .orders-mobile-empty.orders-filter-empty-card .orders-filter-empty-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--hydra-text);
    margin-bottom: 6px;
  }

  body.use-new-ui.route-orders .orders-mobile-empty.orders-filter-empty-card .orders-filter-empty-desc {
    font-size: 13px;
    font-weight: 500;
    margin: 0 0 12px;
  }

  body.use-new-ui.route-inventory .inv-prod-mo-empty .btn,
  body.use-new-ui.route-products .inv-prod-mo-empty .btn {
    margin-top: 12px;
  }

  body.dark.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense,
  body.dark.use-new-ui.route-orders .orders-page .orders-summary-cards .card.orders-card,
  body.dark.use-new-ui.route-orders .orders-pager-row {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(148, 163, 184, 0.18);
  }

  body.dark.use-new-ui.route-orders .order-mo-menu-panel {
    background: rgba(30, 41, 59, 0.98);
    border-color: rgba(148, 163, 184, 0.22);
  }

  body.dark.use-new-ui.route-orders .order-mo-menu-item {
    color: #e2e8f0;
  }

  body.dark.use-new-ui.route-orders .order-mo-menu-item:hover {
    background: rgba(51, 65, 85, 0.55);
  }
}

@media (max-width: 430px) {
  body.use-new-ui.route-orders .order-mobile-card.order-mobile-card--dense .order-mobile-card__customer {
    font-size: 14px !important;
  }
}
