There is no perfect solution.
That said, check out this sticky in the E-Book Formats > Workshop section:
https://www.mobileread.com/forums/sh...d.php?t=295102
Keep in mind that final formatting should not be done in a word processing app (e.g. MS Word, ...), but instead done in an appropriate editor (e.g. Sigil, calibre's Editor, ...) after conversion to an editable ebook format (e.g. ePub, AZW3).
Also "mobi" generally refers to the older and extremely limited MobiPocket format, which Amazon acquired years ago. For modern Kindles (Kindle Keyboard and newer) and Fire Tablets the newer AZW3 format is generally prefered. The older mobi format (aka KF8) has far fewer formatting options than newer formats and a lot of formatting will be stripped out when converting to the old mobi/KF8 format.