@mixin markdown-table(
  $row: #fff,
  $head: #f6f8fa,
  $stripe: #fbfcfd,
  $edges: #dfe2e5,
) {
  table {
    display: table;
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
    color: var(--table-text);

    thead {
      color: var(--table-head-text, inherit);
    }

    thead tr {
      background: var(--table-head, #{$head});
    }

    tr {
      background-color: var(--table-row, #{$row});
      & + tr {
        border-top: 1px solid var(--table-edges, #{$edges});
      }
    }

    th,
    thead td {
      font-weight: 600;
      &:empty {
        padding: 0;
      }
    }

    td,
    th {
      padding: 0;
      color: inherit;
      vertical-align: middle;
      border: 1px solid var(--table-edges, #{$edges});
      padding: 6px 13px;
      > :first-child, > :only-child { margin-top:    0 !important }
      > :last-child, > :only-child  { margin-bottom: 0 !important }
    }

    &:not(.plain) tr:nth-child(2n) {
      background-color: var(--table-stripe, #{$stripe});
    }
  }
}

.markdown-body {
  @include markdown-table;

  .rdmd-table {
    $border-wrap-width: 1px;

    & {
      display: block;
      position: relative;
    }

    &-inner {
      box-sizing: content-box;
      min-width: 100%;
      overflow: auto;
      width: 100%;
    }

    table {
      border: 1px solid var(--table-edges, #dfe2e5);

      &:only-child {
        margin: 0 !important;

        thead th {
          background: inherit;
        }

        td:last-child,
        th:last-child {
          border-right: none;
        }

        thead tr,
        thead th:last-child {
          box-shadow: 3px 0 0 var(--table-head);
        }
      }
    }
  }
}
