A fluctuation theory for Markov chains