Kind of two different issues - flirting and friends of the opposite sex.
I’ll focus on the first one, because I find Capital sins (I referred to them as Deadly Sins) of particular interest.
If you ever notice, a baby can flirt with you, he or she will bat his/her eyelashes, smile, giggle look away bashfully - it just isn’t anything sexual in nature. But it’s kind of a flirt for you to get to engage them socially. It’s just part of being human.
That being said, I do beleive Envy, while a Capital sin, is there for a reason. I think part of being in love is to “patrol your mate” to a certain extent. It makes them think he/she is valuable to the other and feel loved. It shouldn’t consume you, which is why I suppose it is a capital sin.
So, in short, if flirting is bothering your spouse, you should respect that basic emotion of envy and back off. It’s a form of respect to the marriage.
But, if a husband walks into a room at a golf club he belongs too where 3 women are sitting at a table, let’s say, and says, “Wow! Look at all these hot women in here!” (or something else boorish as men can often be )as a genuine kind of compliment to the female gender, I don’t see anything wrong in that.
It’s sticky, I’ll admit. I think you cross the line when you flirt in order to get control over another person - to get them interested in your physically/romantically.
Friends of the opposite sex is easy. Friends = okay. More than friends = not okay.