Appalling conditions caused by years of underfunding, mismanagement and neglect, inspector warns