Allrounder's century lifted Derbyshire from ruin after the Indian leg spinner took 3 in 11 balls