+1 for the Courier. It's also an excellent multirole small ship, although it's very sensitive to mass increases, so you'd probably want to switch modules.
Jump range maxes out there only if you're on the stock tank, which is rather oversized for the Courier, and quite a lot of dead weight. For comparison, here's
my current Courier build, 50 ly on a full tank, 455 / 618 m/s.
That said, there is something to keep in mind about surviving gankers: don't fly in a straight line! Doesn't matter if you're speeding away quick in a Courier, or any other ship: railguns engineered for long range can easily hit you up to 6 km. (I tried this out with someone else, and they could pop my Courier before I got away.) In fact, it's easier to hit a more distant target that's flying in a straight line. So, evade, be unpredictable, zig-zag and so on, and only fly in a straight line once your FSD is ready and you have to point at your destination.
Of course, surviving hostile NPCs in a Courier is a much simpler thing: press the boost button, and that's it.
Minor note on the Phantom: it doesn't really fit your criteria of being under 40 million, as the ship itself costs 37 MCr, and then you have to do outfitting. Maybe an Imperial Clipper would (best fuel scooping in the game, excellent supercruise handling, great cockpit visibility, lots of internals, very speedy for its size), but even that's a bit iffy.
That said, credits are easy enough to come by, so I think you can aim higher than 40 million.