/**
 * Quản lý lô hàng — mobile pages (/lots)
 */

@media (max-width: 768px) {
  #page-lots.page.active {
    padding: 0 14px 16px;
    box-sizing: border-box;
  }

  #page-lot-detail.page.active {
    padding: 0 16px calc(96px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
  }

  .pur-mob-toolbar {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
    width: 100%;
    max-width: 100%;
  }

  .pur-mob-toolbar .pur-mobile-filter-btn,
  .pur-mob-toolbar .pur-manage-lots-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    box-sizing: border-box;
  }

  .pur-mob-toolbar .pur-manage-lots-btn {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #0f172a;
  }

  .lots-page-head,
  .lot-detail-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 12px;
    padding-top: 4px;
  }

  .lots-back-btn,
  .lot-detail-back-btn {
    align-self: flex-start;
    min-height: 40px;
    padding: 0 4px;
    border: none;
    background: transparent;
    color: #2563eb;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
  }

  .lots-page-head h1,
  .lot-detail-head h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
  }

  .lot-detail-subtitle {
    margin: 2px 0 0;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    line-height: 1.35;
  }

  .lots-list,
  #lot-detail-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .lots-loading,
  .lots-muted {
    margin: 0;
    font-size: 0.875rem;
    color: #64748b;
  }

  .lots-card {
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
    padding: 10px 12px;
    box-sizing: border-box;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .lots-card:active {
    transform: scale(0.99);
  }

  .lots-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
  }

  .lots-card-code {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
    word-break: break-word;
  }

  .lots-card-date {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
  }

  .lots-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
  }

  .lots-card-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .lots-card-stat--full {
    grid-column: 1 / -1;
  }

  .lots-card-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
  }

  .lots-card-value {
    font-size: 0.8125rem;
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
    word-break: break-word;
  }

  .lots-card-status.lots-status--ok {
    color: #15803d;
  }

  .lots-card-status.lots-status--sold {
    color: #64748b;
  }

  .lots-card-status.lots-status--returned {
    color: #7c3aed;
  }

  .lots-card-status.lots-status--partial {
    color: #b45309;
  }

  .lots-card-grid--4 {
    grid-template-columns: 1fr 1fr;
  }

  .lots-card-note {
    margin: 6px 0 0;
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.35;
  }

  .lots-item-return-btn {
    margin-top: 8px;
    width: 100%;
    min-height: 36px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
  }

  .lots-return-history-wrap {
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: #fff;
  }

  .lots-return-history-table {
    width: 100%;
    min-width: 520px;
    font-size: 0.75rem;
    border-collapse: collapse;
  }

  .lots-return-history-table th,
  .lots-return-history-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
  }

  .lots-return-history-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .lots-return-refund-card {
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 14px;
    padding: 12px;
    background: #fff;
  }

  .lots-return-refund-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
  }

  .lots-return-refund-card-meta {
    margin: 0 0 8px;
    font-size: 0.75rem;
    color: #64748b;
  }

  .lots-return-refund-card-rows {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 0.78rem;
  }

  .lots-return-refund-card-rows div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
  }

  .lots-return-refund-card-remaining strong {
    color: #dc2626;
  }

  .lots-refund-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 0.65rem;
    font-weight: 600;
  }

  .lots-refund-badge--pending { background: #fef3c7; color: #b45309; }
  .lots-refund-badge--partial { background: #dbeafe; color: #1d4ed8; }
  .lots-refund-badge--done { background: #dcfce7; color: #15803d; }
  .lots-refund-badge--none { background: #f1f5f9; color: #64748b; }

  .lot-mob-kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .lot-mob-kpi {
    border-radius: 18px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }

  .lot-mob-kpi-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
  }

  .lot-mob-kpi-value {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .lot-mob-actions {
    display: flex;
    align-items: stretch;
    gap: 8px;
  }

  .lot-mob-actions .lots-copy-menu-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
  }

  .lot-mob-actions .lots-copy-menu-btn.lot-mob-action-btn {
    width: 100%;
  }

  .lots-copy-menu-panel {
    min-width: 220px;
  }

  .lot-mob-action-btn {
    flex: 1;
    min-height: 40px;
    padding: 0 10px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    color: #0f172a;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
  }

  .lot-mob-action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }

  .lot-mob-actions-menu {
    flex: 0 0 44px;
    margin-right: 0;
  }

  .lot-mob-action-btn--icon {
    flex: none;
    width: 44px;
    min-width: 44px;
    padding: 0;
    font-size: 1.2rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .lot-items-title {
    margin: 4px 0 8px;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .lot-items-count {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: #64748b;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1f5f9;
  }

  .lot-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mobile-receipt-product-card {
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
    box-sizing: border-box;
  }

  .product-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
  }

  .product-name-group {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
    flex: 1;
  }

  .product-name {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.15;
    color: #0f172a;
    word-break: break-word;
  }

  .product-status-inline {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    line-height: 1.15;
    white-space: nowrap;
  }

  .product-type-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: #475569;
    padding: 2px 7px;
    border-radius: 6px;
    background: #f1f5f9;
    line-height: 1.2;
  }

  .product-meta {
    margin: 3px 0 0;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    line-height: 1.2;
  }

  .product-stats-row {
    margin-top: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 34px;
    align-items: center;
    gap: 6px;
  }

  .product-stat {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
  }

  .product-stat label {
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    line-height: 1;
    text-transform: none;
    letter-spacing: 0;
  }

  .product-stat strong {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
  }

  .product-more-wrap {
    margin-right: 0;
    justify-self: end;
  }

  .product-more-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 12px;
    font-size: 1rem;
  }

  #lot-detail-content .lots-row-menu-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
  }

  #lot-detail-content .lots-row-menu-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    color: #475569;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  #lot-detail-content .lots-row-menu {
    min-width: 168px;
    padding: 6px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  }

  #lot-detail-content .lots-row-menu.hidden {
    display: none;
  }

  #lot-detail-content .lots-row-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    color: #0f172a;
    cursor: pointer;
  }

  #lot-detail-content .lots-row-menu button.danger {
    color: #b91c1c;
  }

  #lot-detail-content .lots-row-menu button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }

  /* Ẩn modal chi tiết phiếu trên mobile khi dùng trang /lots */
  #purchase-receipt-detail-modal.show {
    display: none !important;
  }
}

@media (min-width: 769px) {
  #page-lots,
  #page-lot-detail,
  .pur-mob-toolbar {
    display: none !important;
  }
}
