Spain has been accused of imposing a more burdensome tax structure on non-residents, with Madrid referred to the EU's highest court.