Virtual classes of character stacks