Calculating span margin benefit

When we short Bank Nifty call 31000 we are charged a span+exposure margin of ~ 83000 and when we add a counter position say a long 31100 call, we get some margin benefit

How this margin benefit is calculated?

My second question is that we also get margin benefit in calendar spreads, but that is revoked when the near month has 3 days left on expiry, how would that work out on bank nifty weekly and next weekly expiries?