Totally isotropic subspaces for pairs of Hermitian forms and applications to Riccati equations