Weight of undergraduate grades when applying for a Ph.D
There can't be any sort of general answer, as the criteria used by individual schools vary quite a bit. In the end, the decisions are taken by admission committees, who do look at numbers (i.e., GPA, grades in detail, ranking of undergraduate program, ...) but should (and will!) also look at more soft measures, be it grades in "selected" courses, strength of recommendation letters, ranking of high school of origin, evidence of not just academic interest (i.e., was part of the debate club, ...). But it is probably the case that a first filter is on "hard" data (specially if the school gets many more applications than places available).

This is a question only the current members of said committees at the schools that interest you could possibly answer, and probably will never do, not even in private.