Relational Macrostate Theory for Understanding and Designing Complex Systems