Self-consistent spin-wave theory of layered Heisenberg magnets