GPA for top colleges

I’m not the best student when it comes to finishing all my hw and doing other school stuff but I have pretty good grades nonetheless. My UW gpa is slightly low because of classes I took in middle school that I didn’t know counted and classes like health, theatre, etc. My main question is, if I finish with a respectable gpa in a decently high ranked public high school with high standardized test scores and class rank am I fine? I’m also very interested in Math but I did slack on a couple of semesters and ended up with some B+'s. If I took a math subject test and scored high on it would that compensate to let colleges know I know the math. Also, how do colleges look at coass rank? Do they only care if you’re in the top 5% ( in my case would 15 or so /460 be good)? Or do they care how ahead the people in front lf you are? Thanks for reading and answering this pile of questions.

Obviously the higher the GPA, the better your chances are for top schools. Lower GPA doesn’t mean you’ll get rejected, it’ll just be harder for you.

Top 5% is pretty good, so if your high school is pretty high-ranked, I think you should be fine.