Solar activity in all its varied manifestations is driven by the magnetic field. Particularly important for many purposes are two global quantities, the Suns total and open magnetic flux, which can be computed from sunspot number records using models. Such sunspot-driven models, however, do not take into account the presence of magnetic flux during grand minima, such as the Maunder minimum. Here we present a major update of a widely used simple model, which now takes into account the observation that the distribution of all magnetic features on the Sun follows a single power law. The exponent of the power law changes over the solar cycle. This allows for the emergence of small-scale magnetic flux even when no sunspots are present for multiple decades and leads to non-zero total and open magnetic flux also in the deepest grand minima, such as the Maunder minimum, thus overcoming a major shortcoming of the earlier models. The results of the updated model compare well with the available observations and reconstructions of the solar total and open magnetic flux. This opens up the possibility of improved reconstructions of sunspot number from time series of cosmogenic isotope production rate.