/* Custom padding and border for all tables */
.md-typeset__table table:not([class]) td,
.md-typeset__table table:not([class]) th {
    min-width: 0;
    padding: 5px;
    border: 1px solid var(--md-typeset-table-color);
}

/*
    Style for the merged header cell or for just centering.
    Had to be specifically crafter to have the same specificity
    as the theme's overriding rule (.md-typeset table:not([class]) th:not([align])).
*/
.md-typeset table:not([class]) th.table-header,
.md-typeset table:not([class]) td.table-header {
    text-align: center;
    font-weight: bold;
    vertical-align: middle;
    padding: 1px;
    background-color: transparent;
    border-bottom: none;
    white-space: nowrap;
}

/*
    Fix for extra padding under nested tables.
    This targets the theme's wrapper div (.md-typeset__table) only when
    it appears inside a table cell (td), removing its bottom margin.
*/
.md-typeset td .md-typeset__table {
    margin-bottom: 0;
}

/* Align tabel content to center and middle */
.md-typeset table:not([class]) td:not([align]),
.md-typeset table:not([class]) th:not([align]) {
    text-align: center;
    vertical-align: middle;
}

/*
    Target the actual <table> element when nested.
    Changing its display to 'block' collapses the mysterious
    extra space that 'display: table' can render at the bottom.
    This forces the parent containers to calculate their height correctly.
*/
.md-typeset td .md-typeset__table table {
    display: block;
}

/*
    This targets the parent TD holding the nested table.
    Since the nested flexbox broke the TD's default vertical-align,
    we turn the TD itself into a flex container to regain alignment control.
*/
.md-typeset td .md-typeset__scrollwrap {
    display: flex;
}

/* Fix alignment for nested tables after scrollwarp display=flex broke it. */
.md-typeset td:has(.md-typeset__table) {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Disable bolding for table headers */
.md-typeset table:not([class]) th {
    font-weight: normal;
}