So you will get a job on paper with a low salary, on which you will pay 24% tax and you will have some director for your company outside of Spain?
But if you do work from Spain, how can you be sure they won't say that your company has a PE in Spain?
The Portugal NHR setups work in just the same way, but you don't need a local job. You just have your company outside of Portugal with some substance and capital gains/dividends are exempt from tax in Portugal.
The risk seems quite comparable to me? The biggest difference of course being that,︀ if you don't have to declare anything, it might raise fewer questions in Spain than︁ in Portugal, where I think you have to declare capital gains, but they are not︂ taxed.