Just like anything else, it’s possible to get away with, but there are ways to make it more difficult. And just like in anything else, people think they’re smarter than they are. If you think you’re going to make it “virtually impossible to prove in court,” you’re sometimes going to find out that you didn’t know that much about what it’s like to prove a thing in court.
Take the cases described in the OP. You’ve got your lesbian, your black guy, and your woman (L, B and W). We don’t have to read anyone’s mind about real reasons, all we have to do is the following magic trick: Hey, L/B/W says you discriminated against him/her. Why didn’t you hire him/her?
And then they have to answer the question. If the answer is she was rejected just like the 28 others, OK, cool. Can I see the applications? What’s the hiring process? What’s the job description? Who made the decision?
If the answer is, sure he had a bachelor’s but this guy had a higher GPA in computer courses, OK, cool. Can I see their resumes? Can I see the job posting? Have you hired into this position before? What were those people’s qualifications?
If the answer is, she was the most qualified but her personality was irritating, who made that decision? Who else has that person hired/fired over the last, oh I dunno, five years? How many men, how many women?
The employer, it turns out, by law has a burden of demonstrating that it had a legitimate and non-discriminatory reason for making the hiring decision it made. If it can do that, then we’re done, unless the person who is claiming they were discriminated against has enough evidence to demonstrate that the asserted reason is a pretext for some discriminatory ulterior motive. I don’t want to be a Pollyanna about it – discrimination that exists in the grey areas will pass muster just by virtue of being in the grey area – but you certainly aren’t going to get away with not hiring from an entire certain class of qualified people for long. At some point, you’re either skillfully operating on the margins so much that you’re forced not to discriminate, or alternatively you’re still discriminating but it isn’t on the margins anymore, and you’re fucked.