M1911
I find that hard to believe. .223 penetrating less than 9mm? With all due respect, please quote some references.
People think shotgun, they think 00 buck. #4 buck is .22 in caliber, and touted by some. More projectiles, but not the momentum, and consequent overpenetration. In an urban environment, the nod goes to the shotgun.
Hate to pander to stereotypes, but the shotgun has legendary deterent effects with its distinctive racking sound. BG wouldn't know you were armed with an AR-15, until the moment of truth comes.
The operative constraint here is "apartment". You are resonsible for every projectile you send downrange. Other situations would make the AR the first choice.
That said, Mossberg 500 is loaded by the bed in my apartment, but Galil in .223 is also ready to go. I like options, given the situation.