EU ruling could cost member states billions