/**
 * Quản lý lô hàng — desktop modal
 */

@media (min-width: 769px) {
  .pur-manage-lots-desktop-btn {
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    box-sizing: border-box;
  }

  .pur-manage-lots-desktop-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    transform: translateY(-1px);
  }

  .pur-manage-lots-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #475569;
  }

  .pur-manage-lots-desktop-btn {
    display: inline-flex;
  }

  .pur-filter-actions {
    justify-content: space-between;
  }

  .pur-filter-actions-end {
    width: auto;
    margin-left: auto;
  }

  .pur-filter-actions .pur-filter-btn {
    align-self: auto;
  }

  .lots-manage-overlay {
    z-index: 8100;
  }

  .lots-manage-dialog {
    width: min(1320px, 88vw);
    max-width: none;
    max-height: 86vh;
    padding: 24px 28px 28px;
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.14);
  }

  .lots-manage-dialog--detail {
    width: min(1320px, 88vw);
  }

  .lots-manage-header {
    align-items: flex-start;
    margin-bottom: 18px;
    flex-shrink: 0;
    padding-right: 4px;
  }

  .lots-manage-header-text h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #0f172a;
  }

  .lots-manage-subtitle {
    margin: 4px 0 0;
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.35;
  }

  .lots-manage-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 10px;
    margin-right: -2px;
  }

  .receipt-detail-content {
    max-width: 1180px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  #lots-manage-list-view .receipt-detail-content {
    gap: 14px;
    min-height: min(100%, 100%);
  }

  .lots-manage-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) 160px auto;
    gap: 10px;
    align-items: end;
    flex-shrink: 0;
  }

  .lots-m-filter-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
    margin: 0;
  }

  .lots-m-filter-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.02em;
  }

  .lots-m-filter-field input,
  .lots-m-filter-field select {
    width: 100%;
    height: 40px;
    min-height: 40px;
    padding: 0 0.7rem;
    font-size: 0.8125rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    box-sizing: border-box;
  }

  .lots-m-filter-field input:focus,
  .lots-m-filter-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }

  .lots-m-filter-btn {
    height: 40px;
    min-height: 40px;
    padding: 0 1rem;
    font-size: 0.8125rem;
  }

  .lots-manage-table-wrap {
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    box-shadow: none;
    overflow: visible;
    padding-right: 12px;
  }

  #lots-manage-list-view .lots-manage-table-wrap {
    overflow: auto;
    max-height: min(56vh, 640px);
    padding-right: 16px;
  }

  .lots-manage-table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    font-size: 0.8125rem;
  }

  .lots-manage-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    padding: 0.6rem 0.85rem;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
  }

  .lots-manage-table tbody td {
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #0f172a;
  }

  .lots-manage-list-table {
    table-layout: fixed;
  }

  .lots-manage-list-table col.col-date {
    width: 10%;
  }

  .lots-manage-list-table col.col-receipt {
    width: 18%;
  }

  .lots-manage-list-table col.col-qty {
    width: 9%;
  }

  .lots-manage-list-table col.col-cost {
    width: 14%;
  }

  .lots-manage-list-table col.col-status {
    width: 13%;
  }

  .lots-manage-list-table col.col-actions {
    width: 80px;
  }

  .lots-manage-list-table thead th,
  .lots-manage-list-table tbody td {
    padding: 0.55rem 0.75rem;
  }

  .lots-manage-list-table .col-date,
  .lots-manage-list-table .col-receipt {
    text-align: left;
  }

  .lots-manage-list-table .col-date {
    white-space: nowrap;
  }

  .lots-manage-list-table .col-qty,
  .lots-manage-list-table .col-cost,
  .lots-manage-list-table .col-status,
  .lots-manage-list-table .col-actions {
    text-align: center;
  }

  .lots-manage-list-table .num {
    text-align: center;
  }

  .lots-manage-table tbody tr.lots-manage-row {
    cursor: pointer;
    transition: background 0.15s ease;
  }

  .lots-manage-table tbody tr.lots-manage-row:hover {
    background: #f8fafc;
  }

  .lots-manage-table tbody tr.lots-manage-row:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  .lots-receipt-code-link {
    font-weight: 700;
    color: #0f172a;
    cursor: pointer;
    transition: color 0.12s ease, text-decoration-color 0.12s ease;
    text-decoration: underline transparent;
    text-underline-offset: 2px;
  }

  .lots-manage-table tbody tr.lots-manage-row:hover .lots-receipt-code-link,
  .lots-receipt-code-link:hover {
    color: var(--accent);
    text-decoration-color: var(--accent);
  }

  .lots-manage-table .num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .lots-manage-list-table .col-actions {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    text-align: center;
    cursor: default;
  }

  .lots-manage-list-table thead th.col-actions {
    text-align: center;
  }

  .lots-detail-items-table .num {
    text-align: right;
  }

  .lots-manage-table .lots-m-name {
    font-weight: 600;
    max-width: 200px;
    word-break: break-word;
  }

  .lots-manage-table .receipt-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8125rem;
  }

  .lots-manage-table .receipt-link:hover {
    text-decoration: underline;
  }

  .lots-row-menu-wrap {
    position: relative;
    display: inline-flex;
    justify-content: center;
    margin-right: 16px;
  }

  .lots-row-menu-btn {
    width: 38px;
    height: 38px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    color: #475569;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.12s ease, border-color 0.12s ease;
  }

  .lots-row-menu-btn:hover,
  .lots-row-menu-btn[aria-expanded="true"] {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #0f172a;
  }

  .lots-row-menu {
    min-width: 220px;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
  }

  .lots-row-menu.hidden {
    display: none;
  }

  .lots-row-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    color: #0f172a;
    cursor: pointer;
  }

  .lots-menu-item-icon {
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
    font-size: 0.9rem;
    line-height: 1;
  }

  .lots-menu-item-label {
    flex: 1;
    min-width: 0;
  }

  .lots-row-menu button:hover:not(:disabled) {
    background: #f1f5f9;
  }

  .lots-row-menu button.danger {
    color: #b91c1c;
  }

  .lots-row-menu button.danger:hover:not(:disabled) {
    background: #fef2f2;
  }

  .lots-row-menu button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }

  .lots-detail-back-link {
    align-self: flex-start;
    border: none;
    background: transparent;
    color: #2563eb;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    padding: 0 0 4px;
    margin-bottom: 4px;
    flex-shrink: 0;
  }

  .lots-detail-back-link:hover {
    text-decoration: underline;
  }

  .lots-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    overflow-y: auto;
    min-height: 0;
    flex: 1;
    padding-right: 2px;
  }

  .lots-detail-card {
    border-radius: 18px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
    padding: 14px 16px;
  }

  .lots-detail-card--full {
    grid-column: 1 / -1;
  }

  .lots-detail-card h4 {
    margin: 0 0 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
  }

  .lots-detail-rows {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .lots-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.8125rem;
    line-height: 1.35;
  }

  .lots-detail-row span:first-child {
    color: #64748b;
    font-weight: 600;
    flex-shrink: 0;
  }

  .lots-detail-row span:last-child {
    text-align: right;
    font-weight: 600;
    color: #0f172a;
    word-break: break-word;
  }

  .lots-detail-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .lots-detail-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #eef2f6;
  }

  .lots-detail-stat-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
  }

  .lots-detail-stat-value {
    font-size: 0.9375rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
  }

  .lots-manage-detail {
    min-height: 0;
  }

  #lots-manage-detail-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
  }

  .lots-receipt-code {
    color: #0f172a;
    font-weight: 700;
  }

  .lots-detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }

  .lots-receipt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 2px;
  }

  .lots-receipt-header-main {
    min-width: 0;
    flex: 1;
  }

  .lots-receipt-header-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
  }

  .lots-receipt-code-lg {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
    line-height: 1.2;
  }

  .lots-receipt-header-date {
    margin: 8px 0 0;
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
  }

  .lots-receipt-header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
  }

  .lots-receipt-header-actions .lots-copy-menu-wrap {
    display: inline-flex;
  }

  .lots-copy-menu-panel {
    min-width: 220px;
  }

  .lots-receipt-return-btn,
  .lots-receipt-copy-btn {
    height: 40px;
    min-height: 40px;
    padding: 0 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 10px;
    white-space: nowrap;
  }

  .lots-receipt-header-menu-wrap {
    margin-right: 0;
  }

  .lots-receipt-menu-btn {
    width: 40px;
    height: 40px;
    font-size: 1.35rem;
    letter-spacing: -0.08em;
  }

  .lots-receipt-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 12px;
    max-width: 100%;
  }

  .lots-receipt-kpi {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 16px;
    min-height: 76px;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
  }

  .lots-receipt-kpi-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
  }

  .lots-receipt-kpi-value {
    font-size: 1.0625rem;
    font-weight: 800;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
  }

  .lots-receipt-section--info {
    padding: 16px 18px 18px;
  }

  .lots-receipt-section--info .lots-receipt-section-head {
    margin-bottom: 12px;
  }

  .lots-receipt-meta-dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 24px;
    margin: 0;
    padding: 0;
  }

  .lots-receipt-meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
  }

  .lots-receipt-meta-item dt {
    margin: 0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
  }

  .lots-receipt-meta-item dd {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
    word-break: break-word;
    line-height: 1.4;
  }

  .lots-receipt-section {
    border-radius: 18px;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 18px 20px 20px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
    max-width: 100%;
  }

  .lots-receipt-section--products {
    padding: 18px;
    border-radius: 20px;
  }

  .lots-receipt-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
  }

  .lots-receipt-section-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
  }

  .lots-receipt-section-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f1f5f9;
    white-space: nowrap;
  }

  .lots-receipt-section--products .lots-detail-items-wrap {
    border: none;
    border-radius: 12px;
    background: #fafbfc;
    margin: 0;
    overflow: visible;
    padding-right: 12px;
  }

  .lots-detail-items-table {
    table-layout: fixed;
    width: 100%;
  }

  .lots-detail-items-table .col-product {
    width: 30%;
  }

  .lots-detail-items-table .col-qty-in,
  .lots-detail-items-table .col-qty-remain {
    width: 12%;
  }

  .lots-detail-items-table .col-cost-unit,
  .lots-detail-items-table .col-price-sale {
    width: 16%;
  }

  .lots-detail-items-table .col-status-cell {
    width: 10%;
  }

  .lots-detail-items-table col.col-actions {
    width: 64px;
  }

  .lots-detail-items-table .col-actions {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
    padding-left: 4px;
    padding-right: 4px;
    text-align: center;
  }

  .lots-detail-items-table .lots-detail-item-row td {
    height: 60px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    vertical-align: middle;
  }

  .lots-detail-items-table .lots-row-menu-wrap {
    margin-right: 0;
  }

  .lots-item-product-cell {
    min-width: 0;
    overflow: hidden;
  }

  .lots-item-product-name {
    font-weight: 700;
    font-size: 0.8125rem;
    color: #0f172a;
    line-height: 1.35;
    word-break: break-word;
  }

  .lots-item-product-meta {
    margin-top: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #94a3b8;
    text-transform: uppercase;
  }

  .lots-detail-items-wrap {
    min-height: auto;
    max-height: none;
  }

  .lots-detail-items-table thead th.num,
  .lots-detail-items-table tbody td.num {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .lots-return-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 28px 20px;
    border-radius: 14px;
    border: 1px dashed #e2e8f0;
    background: #f8fafc;
  }

  .lots-return-empty--compact {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 14px 16px;
    text-align: left;
  }

  .lots-return-empty--compact .lots-return-empty-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    margin-bottom: 0;
  }

  .lots-return-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    font-size: 1.25rem;
    color: #94a3b8;
    margin-bottom: 10px;
    flex-shrink: 0;
  }

  .lots-return-empty-title {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #64748b;
  }

  .lots-return-empty-hint {
    margin: 4px 0 0;
    font-size: 0.75rem;
    color: #94a3b8;
  }

  .lots-receipt-section--returns {
    padding: 16px 18px 18px;
  }

  .lots-return-history-wrap {
    max-height: 200px;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid #eef2f6;
    background: #fafbfc;
    padding-right: 12px;
  }

  .lots-return-history-table {
    width: 100%;
    font-size: 0.75rem;
    border-collapse: collapse;
  }

  .lots-return-history-table th,
  .lots-return-history-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
    text-align: left;
  }

  .lots-refund-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
  }

  .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; }

  .lots-refund-remaining {
    color: #dc2626;
    font-weight: 700;
  }

  .lots-return-history-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .lots-return-refund-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 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: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 6px;
    font-size: 0.72rem;
  }

  .lots-return-refund-card-rows div {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .lots-return-refund-card-rows span {
    color: #64748b;
    font-weight: 600;
  }

  .lots-return-refund-card-remaining strong {
    color: #dc2626;
  }

  .lots-return-refund-card-reason {
    margin: 0;
    font-size: 0.75rem;
    color: #475569;
  }

  .lots-return-overlay {
    z-index: 8200;
  }

  .lots-return-dialog {
    width: min(520px, calc(100vw - 32px));
    max-height: 88vh;
    border-radius: 22px;
    overflow-y: auto;
    padding: 20px 22px;
  }

  .lots-return-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .lots-return-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
  }

  .lots-return-field input,
  .lots-return-field select,
  .lots-return-field textarea {
    font-weight: 400;
    padding: 0.5rem 0.65rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.8125rem;
  }

  .lots-return-lines-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
  }

  .lots-return-line {
    display: grid;
    grid-template-columns: 1fr auto 80px;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.8125rem;
  }

  .lots-return-line-name {
    font-weight: 600;
    color: #0f172a;
  }

  .lots-return-line-remain {
    color: #64748b;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .lots-return-actions {
    justify-content: flex-end;
    margin-top: 4px;
  }
}

@media (max-width: 768px) {
  .pur-manage-lots-desktop-btn,
  #lots-manage-modal {
    display: none !important;
  }
}
