One of the basic principles of fiqh that were mentioned by the scholars (may Allah have mercy on them) is the principle that every incident is presumed to have begun at the closest time.
What this principle means is that if something happens, and it may have happened at a time that is closer or a time that is further, and there is nothing to suggest which of the two times is most likely, then we assume that it happened that the closer of the two times, because this is the time at which we may be certain that it happened, whereas the other is the subject of some doubt.
One of the applications of this principle is that if a person sees maniy (semen) on his garment, and he knows that it is the result of a wet dream, but he does not remember any wet dream, in that case he may attribute it to the latest time that he slept and repeat any prayer that he offered after that sleep.
This principle was stated by az-Zarkashi in his book al-Manthoor fi’l-Qawaa‘id and as-Suyooti in al-Ashbaah wa’l-Nadhaa’ir; they also discussed some minor issues connected to it, which you may read in either of the two sources mentioned for further information.
Based on that, if a woman saw menstrual blood and does not know when it began, was it before Maghrib or after, then in this case she should assume that the bleeding began at the closer of the two times. The closer of the two times in your case leads to the conclusion that it began after Maghrib.
It says in al-Mawsoo‘ah al-Fiqhiyyah (26/194): Under this heading comes the idea that was narrated from the fuqaha’: if a woman sees menstrual blood and does not know when it began, she comes under the same ruling as a man who sees maniy (semen) on his garment and does not know when it happened. That is, he has to do ghusl and repeat the prayers from when he last slept. This is the least complicated and the clearest of the scholarly opinions. End quote.
Shaykh Muhammad ibn Saalih al-Mukhtaar ash-Shanqeeti (may Allah preserve him) was asked about a woman who saw some menstrual blood after Maghrib prayer, and she does not know whether it came before Maghrib or after – what is the ruling on her prayer and fasting?
He replied: If she saw the blood and thinks it most likely that it came before Maghrib, then there is no doubt that the fast of that day is invalid and she has to make it up.
But if she thinks it most likely that the blood is fresh and that it happened after Maghrib, then there is no doubt that her fast is valid and she has to pray Maghrib when she becomes pure (i.e., her period ends and she does ghusl); she should make it up and offer that prayer.
But if she is uncertain, then the basic principle according to the scholars (may Allah have mercy on them) is that it should be attributed to the closest time. The basic principle is that the fast remains valid unless there is evidence to prove that it is not valid, and the basic principle is that she has fasted a whole day and has done what is required of her, unless we are certain that there is any evidence to the contrary. So in this case her fast is deemed to be valid. As for the blood, it does not affect that day. On the other hand, if you say that her fast is valid, she has to make up Maghrib, and if you say that her fast is not valid, she does not have to make up Maghrib, so if her fast is valid she has to make up Maghrib, because the time of Maghrib began when she was not menstruating, and her menses began after that, so she has to make up Maghrib, because what matters is the beginning of the time (for Maghrib), not the end.
End quote from Sharh Zaad al-Mustaqni‘ by Shaykh ash-Shanqeeti
To sum up: your fast is valid so long as you are not certain that the bleeding started before Maghrib.
And Allah knows best.