The first problem is a you problem though. There's nothing stopping you from dividing your global god-class into smaller ones. For example, you can have one state struct per windows. So windows wouldn't have access to the state of other windows.
The second problem is also the reason I don't often use imgui. Imgui is great for introducing UI to applications that would re-render every frame, like a video game. But for every other application, it feels like a waste. If I wanted to waste resources I would write it in python or JavaScript.
That's called immediately mode gui (or imgui). It has nothing to do with think about elements or pixels. You do have elements, it's just that they're rendered directly (immediately) instead of stored.
You have a panel+border+text "primitive" drawing functions. Nothing is stopping you from creating a single function that calls all 3 of those. You probably should, since it's probably a common pattern. You could call it
DrawBoxedText. There is no difference between a DrawBoxedText function and a BoxedText element with adraw()method.