How banking regulations can fairly allocate losses and avert future crises.