$x2many_2d_matrix_max_height: 450px;

.o_form_view .o_field_x2many_2d_matrix {
    .table-responsive {
        max-height: $x2many_2d_matrix_max_height;
        overflow-y: auto;
    }

    .o_input {
        padding: 1px 0px;
    }

    .table {
        > thead > tr > th {
            white-space: pre-line;
            position: sticky;
            top: 0;
            z-index: 1;

            &.total {
                right: 0;
            }
        }

        > tbody {
            > tr {
                &:nth-of-type(2n + 1) td.row-total,
                &:nth-of-type(2n) td.row-total,
                > td {
                    text-align: right;

                    .o_field_many2one_selection {
                        text-align: left;
                    }

                    &:first-child {
                        position: sticky;
                        left: 0;
                        text-align: left;
                        border-right-width: 1px;
                        border-right-color: $gray-300;
                        border-right-style: solid;
                    }
                    &.row-total {
                        padding: 0.5rem 0.75rem;
                        font-weight: bold;
                        position: sticky;
                        right: 0;
                        border-left-width: 1px;
                        border-left-color: $gray-300;
                        border-left-style: solid;
                    }
                }
            }
        }

        > tfoot > tr > th {
            text-align: right;
            position: sticky;
            bottom: 0;

            &.col-total {
                padding: 0.75rem;
                right: 0;
                border-left-width: 1px;
                border-left-color: $gray-300;
                border-left-style: solid;
            }
        }
    }
}
