A unified first law of black-hole dynamics and relativistic thermodynamics is derived in spherically symmetric general relativity. This equation expresses the gradient of the active gravitational energy E according to the Einstein equation, divided into energy-supply and work terms. Projecting the equation along the flow of thermodynamic matter and along the trapping horizon of a black hole yield, respectively, first laws of relativistic thermodynamics and black-hole dynamics. In the black-hole case, this first law has the same form as the first law of black-hole statics, with static perturbations replaced by the derivative along the horizon. In particular, there is the expected term involving the area and surface gravity, where the dynamic surface gravity is defined by substituting the Kodama vector and trapping horizon for the Killing vector and Killing horizon in the standard definition of static surface gravity. The remaining work term is consistent with, for instance, electromagnetic work in special relativity. The dynamic surface gravity vanishes for degenerate trapping horizons and satisfies certain inequalities involving the area and energy which have the same form as for stationary black holes. Turning to the thermodynamic case, the quasi-local first law has the same form, apart from a relativistic factor, as the classical first law of thermodynamics, involving heat supply and hydrodynamic work, but with E replacing the internal energy. Expanding E in the Newtonian limit shows that it incorporates the Newtonian mass, kinetic energy, gravitational potential energy and thermal energy (internal energy with fixed zero). There is also a weak type of unified zeroth law: a Gibbs-like definition of thermal equilibrium requires constancy of an effective temperature, generalizing the Tolman condition and the particular case of Hawking radiation, while gravithermal equilibrium further requires constancy of surface gravity. Finally, it is suggested that the energy operator of spherically symmetric quantum gravity is determined by the Kodama vector, which encodes a dynamic time related to E.