Contagion and tail risk in complex financial networks