Quantum line defects and refined BPS spectra