from __future__ import annotations


def print_table(headers: list[str], rows: list[list[str]]) -> None:
    widths = [len(header) for header in headers]
    for row in rows:
        for index, value in enumerate(row):
            widths[index] = max(widths[index], len(str(value)))

    def border(left: str, middle: str, right: str) -> str:
        return left + middle.join("─" * (width + 2) for width in widths) + right

    def line(values: list[str]) -> str:
        cells = [f" {str(value):<{widths[index]}} " for index, value in enumerate(values)]
        return "│" + "│".join(cells) + "│"

    print(border("┌", "┬", "┐"))
    print(line(headers))
    print(border("├", "┼", "┤"))
    for index, row in enumerate(rows):
        print(line([str(value) for value in row]))
        if index != len(rows) - 1:
            print(border("├", "┼", "┤"))
    print(border("└", "┴", "┘"))

