h6 {
    padding-top: 10px;
}

.client-table {
    padding-top: 20px;
    max-height: calc(100vh - 248px); /* Adjust based on header, title, padding, and search input */
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    scrollbar-color: #4169E1 #e0e0e0; /* Firefox: thumb and track */
    scrollbar-width: thin;
}

.client-table-meta {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: #6c757d;
    font-size: 13px;
    font-weight: 500;
    width: 100%;
}

.client-table-inner {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 12px;
}

.table-record-count {
    background-color: #f1f5ff;
    color: #0d6efd;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    letter-spacing: 0.3px;
}

.client-table-content {
    min-width: 800px;
}

/* Webkit browsers (Chrome, Safari, Edge) - Horizontal scrollbar */
.client-table-inner::-webkit-scrollbar {
    height: 8px;
}

.client-table-inner::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 4px;
}

.client-table-inner::-webkit-scrollbar-thumb {
    background: #4169E1;
    border-radius: 4px;
}

.client-table-inner::-webkit-scrollbar-thumb:hover {
    background: #3151B8;
}

#clientsTable {
    margin-bottom: 0;
    width: 100%;
    min-width: 800px; /* Minimum width to enable horizontal scroll on mobile */
    border-collapse: collapse;
    table-layout: fixed;
}

#clientsTable thead {
    display: table;
    width: 100%;
    min-width: 800px; /* Match table min-width */
    table-layout: fixed;
}

#clientsTable thead tr {
    display: table-row;
}

#clientsTable thead th {
    background-color: #f8f9fa !important;
    border-bottom: 2px solid #dee2e6;
    display: table-cell;
}

#clientsTable thead th:nth-child(1) { width: 12%; }
#clientsTable thead th:nth-child(2) { width: 12%; }
#clientsTable thead th:nth-child(3) { width: 10%; }
#clientsTable thead th:nth-child(4) { width: 12%; }
#clientsTable thead th:nth-child(5) { width: 10%; }
#clientsTable thead th:nth-child(6) { width: 10%; }
#clientsTable thead th:nth-child(7) { width: 10%; }
#clientsTable thead th:nth-child(8) { width: 12%; }
#clientsTable thead th:nth-child(9) { width: 12%; }

#clientsTable tbody {
    display: block;
    overflow-y: auto;
    overflow-x: visible;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100vh - 308px); /* Adjust based on header, title, padding, search input, and table header */
    width: 100%;
    scrollbar-color: #4169E1 #e0e0e0; /* Firefox: thumb and track */
    scrollbar-width: thin;
}

/* Webkit browsers (Chrome, Safari, Edge) - Vertical scrollbar */
#clientsTable tbody::-webkit-scrollbar {
    width: 8px;
}

#clientsTable tbody::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 4px;
}

#clientsTable tbody::-webkit-scrollbar-thumb {
    background: #4169E1;
    border-radius: 4px;
}

#clientsTable tbody::-webkit-scrollbar-thumb:hover {
    background: #3151B8;
}

#clientsTable tbody tr {
    display: table;
    width: 100%;
    min-width: 800px; /* Match table min-width */
    table-layout: fixed;
}

#clientsTable tbody td {
    display: table-cell;
}

#clientsTable tbody td:nth-child(1) { width: 12%; }
#clientsTable tbody td:nth-child(2) { width: 12%; }
#clientsTable tbody td:nth-child(3) { width: 10%; }
#clientsTable tbody td:nth-child(4) { width: 12%; }
#clientsTable tbody td:nth-child(5) { width: 10%; }
#clientsTable tbody td:nth-child(6) { width: 10%; }
#clientsTable tbody td:nth-child(7) { width: 10%; }
#clientsTable tbody td:nth-child(8) { width: 12%; }
#clientsTable tbody td:nth-child(9) { width: 12%; }

.action-buttons {
    display: flex;
    gap: 5px;
}

.action-buttons .btn {
    padding: 2px 8px;
    font-size: 12px;
}

.client-search-container {
    padding: 15px 0;
}

.client-search-input {
    max-width: 400px;
}

.client-activity-filters {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 0;
    font-size: 0.9rem;
}

/* Loyalty snapshot cards (client × product) */
.client-loyalty-section {
    width: 100%;
    max-width: 100%;
}

.client-loyalty-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.client-loyalty-glance-summary {
    flex: 1;
    min-width: 200px;
}

.loyalty-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    max-height: calc(100vh - 230px);
    overflow-y: auto;
    padding-bottom: 72px;
    scrollbar-color: #4169E1 #e0e0e0;
    scrollbar-width: thin;
}

.loyalty-cards-grid::-webkit-scrollbar {
    width: 8px;
}

.loyalty-cards-grid::-webkit-scrollbar-thumb {
    background: #4169E1;
    border-radius: 4px;
}

.loyalty-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.loyalty-card-products {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.loyalty-card-product-row {
    border-radius: 8px;
    padding: 10px 10px 10px 12px;
    background: var(--product-soft, #f8fafc);
    border-left: 4px solid var(--product-bar, #3b82f6);
}

.loyalty-card-product-row-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-bottom: 8px;
}

.loyalty-card-product-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--product-bar, #3b82f6);
}

.loyalty-card-product-label {
    flex: 1;
    min-width: 120px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--product-accent, #334155);
}

.loyalty-card-product-fraction {
    font-size: 0.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--product-accent, #0f172a);
    flex-shrink: 0;
    white-space: nowrap;
}

.loyalty-card-progress--themed {
    background: rgba(15, 23, 42, 0.08);
}

.loyalty-card-progress--themed > span {
    background: linear-gradient(90deg, var(--product-bar, #3b82f6), color-mix(in srgb, var(--product-bar, #3b82f6) 75%, #000));
}

.loyalty-card-product-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
}

.loyalty-card-product-badge--near {
    background: #dc2626;
    color: #ffffff;
    border: 1px solid #991b1b;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.loyalty-card-product-badge--full {
    background: #dcfce7;
    color: #166534;
}

.loyalty-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
}

.loyalty-card-header-main {
    min-width: 0;
}

.loyalty-card-header-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    max-width: 55%;
}

.loyalty-card-header-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: var(--product-bar, #3b82f6);
    border: 1px solid color-mix(in srgb, var(--product-bar, #3b82f6) 70%, #000);
    font-variant-numeric: tabular-nums;
}

.loyalty-card-client-name {
    font-weight: 600;
    font-size: 1rem;
    color: #0f172a;
    line-height: 1.3;
}

.loyalty-card-cell {
    font-size: 0.85rem;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

.loyalty-card-body {
    padding: 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.loyalty-card-progress {
    height: 8px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.loyalty-card-progress > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    transition: width 0.25s ease;
}

.loyalty-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-top: 1px solid #f1f5f9;
    font-size: 0.8rem;
    color: #64748b;
    margin-top: auto;
}

.loyalty-card-footer-meta {
    flex: 1;
    min-width: 0;
    line-height: 1.35;
}

.loyalty-card-footer-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    align-self: flex-end;
}

.loyalty-card-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.loyalty-card-action-btn:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.loyalty-card-action-btn--edit:hover {
    color: #0d6efd;
    background: #eff6ff;
}

.loyalty-card-action-btn--delete:hover {
    color: #dc2626;
    background: #fef2f2;
}

@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .loyalty-card-progress--themed > span {
        background: var(--product-bar, #3b82f6);
    }
    .loyalty-card-header-badge {
        border-color: rgba(0, 0, 0, 0.2);
    }
}
