Lots of history to these incongruities. In the case of the Tenderloin, 30 years ago it was being rapidly gentrified as tourist hotels spread out from Union Square (the Hilton being the premier example). But that displaced low income residents of the existing "Single Room Occupancy" residential hotels and was thought to be a prime cause of the increasing homeless population so the Board of Supervisors stopped it cold by zoning the area with a height limit of 8 stories (the new hotels were 40+). So these days the Tenderloin begins where the the gentrification stopped, however I don’t mind because the area has since become a focus of southeast and south Asian food as newer immigrants have moved in. An amazing number of new Indian and Pakistani places these days, and the Vietnamese have been around a decade or so.
As for the area around Ti Couz, the worst area is near the BART station at 16th and Mission. That’s because, frankly, BART makes it convenient for drug dealers, hookers and other baddies from all over the Bay Area to come there and set up shop. You would think it would also focus the attention of the police, but to my thinking the SFPD is remarkably inneffective stopping this type of criminal activity, possibly because the force is so small and possibly because of the local attitude of tolerance. But once you travel even one block north and west of this corner, you are into increasingly high-priced real estate, mostly Victorian homes that have been renovated interspersed with commercial strips like Valencia and 16th St (where Ti Couz sits) that cater to the people living in the Victorians.