First, the seven days after the flow stops are midirabannan - a rabbinic enactment - and they are part of the Eleven days of Zivah.
The d'oraysah cycle is 7 days niddah, regardless of how long the flow actually lasts, and then eleven days within which if she sees blood it is considered zivah. After the eleven days if there is any flow that will be considered that her monthly flow came early, and that will reset the cycle.
See Rambam, Issurei Biah, chapter 6 https://www.sefaria.org.il/Mishneh_Torah%2C_Forbidden_Intercourse.6.1?lang=bi&with=all&lang2=enRambam, Issurei Biah 6.