from reportlab.platypus import Table, TableStyle
from reportlab.lib import colors

def bordered_table(data, col_widths=None, bg_rows=None):
    t = Table(data, colWidths=col_widths, repeatRows=1)

    style = [
        ("GRID", (0, 0), (-1, -1), 0.7, colors.black),
        ("ALIGN", (0, 0), (-1, -1), "CENTER"),
        ("VALIGN", (0, 0), (-1, -1), "MIDDLE"),
    ]

    if bg_rows:
        for row, color in bg_rows.items():
            style.append(("BACKGROUND", (0, row), (-1, row), color))

    t.setStyle(TableStyle(style))
    return t

