How correlated are grades in math courses with potential for research?
Like most things, there is some correlation, but it's not perfect. In other words, good grades are an indicator of future success, but not proof.
This is why most places look at a wide variety of things, not just GPA or individual grades. In the US, letters of recommendation carry quite a lot of weight, for example.
No, a few B grades probably won't hurt (much), especially if they are in a topic that you don't intend to pursue further. Note that true insight into mathematics isn't uniform across sub fields. For example, I had great insight into real analysis and point-set topology, but very little in algebra or even in some other aspects of analysis. But I did fine, since I worked in an area where my insight was deep.
I'll note that when I took the GRE subject test in mathematics I was extremely discouraged when I left the test center. There were so many questions that I had no insight in to at all. But that was really because mathematics is so broad that no one (anymore) can understand all of it (not since the early 20th century, I think). I did well and got into good graduate programs.
However, don't neglect the fact that good programs are very competitive.
The key is to put together a complete application (including letters) through which a reader can have confidence in making a  prediction of your future success. If you get to write a Statement of Purpose (SoP), make it forward looking, not just a recapitulation of what is in the CV. Goals, plans, ...