Judge blasts social services for 'failing teenage girl'