Projectability disentanglement for accurate and automated electronic-structure Hamiltonians