```python
def region_totals(grid: list, queries: list) -> list:
    """
    Compute the sum of cells in rectangular regions defined by queries on a grid.
    
    Args:
        grid: A non-empty list of rows, each row a non-empty list of integers,
              all rows having the same length.
        queries: A list of queries, each being a list of four integers [top, left, bottom, right].
        
    Returns:
        A list of sums corresponding to each query.
        
    Raises:
        ValueError: If the grid or queries are invalid.
    """
    # Validate grid structure
    if not isinstance(grid, list) or not grid:
        raise ValueError("grid must be a non-empty list of rows")
    
    width = len(grid[0])
    if width == 0:
        raise ValueError("rows must be non-empty lists")
        
    height = len(grid)
    
    for row in grid:
        if not isinstance(row, list) or len(row) != width:
            raise ValueError("rows must all share one length")
        for cell in row:
            # Check for bool first because bool is a subclass of int
            if isinstance(cell, bool) or not isinstance(cell, int):
                raise ValueError("cells must be integers")
                
    # Validate queries
    if not isinstance(queries, list):
        raise ValueError("queries must be a list")
        
    for q in queries:
        if not isinstance(q, list) or len(q) != 4:
            raise ValueError("each query must be a list of exactly four integers")
        for val in q:
            if isinstance(val, bool) or not isinstance(val, int):
                raise ValueError("query coordinates must be integers")
                
        top, left, bottom, right = q
        
        if top >= bottom or left >= right:
            raise ValueError("top must be less than bottom and left less than right")
            
        if top < 0 or bottom > height or left < 0 or right > width:
            raise ValueError("query must be within grid bounds")

    # Build prefix sum table
    # prefix_sum[i][j] is the sum of the rectangle from (0,0) to (i-1, j-1)
    # Dimensions: (height + 1) x (width + 1)
    prefix_sum = [[0] * (width + 1) for _ in range(height + 1)]
    
    for i in range(1, height + 1):
        row_sum = 0
        for j in range(1, width + 1):
            row_sum += grid[i - 1][j - 1]
            prefix_sum[i][j] = prefix_sum[i - 1][j] + row_sum
            
    # Answer queries
    results = []
    for q in queries:
        top, left, bottom, right = q
        # Sum of rectangle from (top, left) to (bottom-1, right-1)
        # Using inclusion-exclusion on prefix sums:
        # sum = P(bottom, right) - P(top, right) - P(bottom, left) + P(top, left)
        total = prefix_sum[bottom][right] - prefix_sum[top][right] - prefix_sum[bottom][left] + prefix_sum[top][left]
        results.append(total)
        
    return results
```