The ideal of maximal flags of a poset