{% for scan in scans %}
{# LOGIC FIX: Determine CSS class based on weight difference #}
{% set row_class = scan.master_status %}
{% if scan.duplicate_status and scan.duplicate_status != '00' %}
{% set row_class = 'duplicate-' + scan.duplicate_status %}
{% elif scan.master_status == 'match' and scan.master_expected_weight and (scan.actual_weight - scan.master_expected_weight)|abs >= 0.01 %}
{# If it is a match but weight is off, force class to weight_discrepancy #}
{% set row_class = 'weight_discrepancy' %}
{% endif %}