Workers put in £31 billion worth of unpaid overtime last year, with teachers and health and care managers working the longest hours for free, research suggests.