"""Clean control for the refund review exercise. Integers are cents."""


def remaining_after_refund(paid_cents, refunded_cents, request_cents):
    """Return the balance after a valid refund; reject an invalid request."""
    available = paid_cents - refunded_cents
    if request_cents < 0 or request_cents > available:
        raise ValueError("refund must be between zero and the available balance")
    return available - request_cents
