html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

table th {
    user-select: none;
    position: relative;
}

table th[data-col]::after {
    content: '';
    display: inline-block;
    margin-left: 4px;
    opacity: 0.3;
    font-size: 0.65rem;
}

table th[data-col].sort-asc::after {
    content: '\25B2';
    opacity: 1;
}

table th[data-col].sort-desc::after {
    content: '\25BC';
    opacity: 1;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #f9fafb;
}

tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

tbody tr:nth-child(even).bg-green-50 {
    background-color: #f0fdf4;
}

.filter-chip.active {
    background-color: #2563eb;
    color: white;
    border-color: #2563eb;
}

.cheapest-badge {
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

.product-thumb {
    width: 4rem;
    height: 4rem;
    border-radius: 0.375rem;
    object-fit: contain;
    background: #f3f4f6;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 640px) {
    .overflow-x-auto {
        overflow: visible;
        border: none !important;
        box-shadow: none !important;
    }

    #results-table,
    #results-table thead,
    #results-table tbody,
    #results-table tr,
    #results-table td {
        display: block;
    }

    #results-table thead {
        display: none;
    }

    #results-table tbody tr {
        margin-bottom: 0.75rem;
        border: 1px solid #e5e7eb;
        border-radius: 0.75rem;
        padding: 0.5rem 0.75rem;
        background: white;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }

    #results-table tbody tr.opacity-70 {
        opacity: 0.55 !important;
    }

    #results-table tbody tr.bg-green-50 {
        background: #f0fdf4 !important;
    }

    #results-table td {
        padding: 0.3rem 0;
        border: none;
        text-align: left;
        display: flex;
        align-items: flex-start;
        gap: 0.5rem;
    }

    #results-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        min-width: 4.5rem;
        flex-shrink: 0;
        padding-top: 0.15rem;
    }

    #results-table td[data-label=""]::before {
        content: none;
    }

    #results-table td[data-label=""] {
        padding-top: 0.5rem;
        margin-top: 0.3rem;
        border-top: 1px solid #f3f4f6;
        justify-content: stretch;
    }

    #results-table td[data-label=""] a {
        display: block;
        width: 100%;
        text-align: center;
        padding: 0.45rem 0;
        background: #eff6ff;
        border-radius: 0.5rem;
        font-size: 0.8rem;
        font-weight: 600;
    }

    #results-table td[data-label="Product"] .line-clamp-2 {
        -webkit-line-clamp: unset;
        display: block;
    }

    #results-table td[data-label="Product"] .sku-text {
        display: block;
        margin-left: 0;
        margin-top: 0.15rem;
    }

    #results-table td[data-label="Price"] {
        align-items: center;
    }

    #results-table td .cheapest-badge {
        flex-shrink: 0;
    }

    thead th {
        position: static;
    }

    tbody tr:nth-child(even) {
        background-color: white;
    }

    tbody tr:nth-child(even).bg-green-50 {
        background-color: #f0fdf4;
    }
}
