table
  border-collapse: collapse
  max-width: 100%
  width: 100%

  th
  td
    border-top: 1px solid $divider
    padding: 8px
    text-align: left
    vertical-align: top

  th
    font-weight: bold

  thead th
    vertical-align: bottom

  caption + thead tr:first-child th
  caption + thead tr:first-child td
  colgroup + thead tr:first-child th
  colgroup + thead tr:first-child td
  thead:first-child tr:first-child th
  thead:first-child tr:first-child td
    border-top: 0

  // Account for multiple tbody instances
  tbody + tbody
    border-top: 2px solid $divider

  &.condensed
    td
      padding: 2px 8px

  &.rounded
    border: 1px solid $divider
    border-collapse: separate
    *border-collapse: collapse
    border-left: 0
    border-radius: $radius

    th
    td
      border-left: 1px solid $divider

    // Prevent a double border
    caption + thead tr:first-child th
    caption + tbody tr:first-child th
    caption + tbody tr:first-child td
    colgroup + thead tr:first-child th
    colgroup + tbody tr:first-child th
    colgroup + tbody tr:first-child td
    thead:first-child tr:first-child th
    tbody:first-child tr:first-child th
    tbody:first-child tr:first-child td
      border-top: 0

    thead:first-child tr:first-child > th:first-child
    tbody:first-child tr:first-child > td:first-child
    tbody:first-child tr:first-child > th:first-child
      border-top-left-radius: $radius

    // For last th/td in the first row in the first thead or tbody
    thead:first-child tr:first-child > th:last-child
    tbody:first-child tr:first-child > td:last-child
    tbody:first-child tr:first-child > th:last-child
      border-top-right-radius: $radius

    // For first th/td (can be either) in the last row in the last thead, tbody,
    // and tfoot
    thead:last-child tr:last-child > th:first-child
    tbody:last-child tr:last-child > td:first-child
    tbody:last-child tr:last-child > th:first-child
    tfoot:last-child tr:last-child > td:first-child
    tfoot:last-child tr:last-child > th:first-child
      border-bottom-left-radius: $radius

    // For last th/td (can be either) in the last row in the last thead, tbody,
    // and tfoot
    thead:last-child tr:last-child > th:last-child
    tbody:last-child tr:last-child > td:last-child
    tbody:last-child tr:last-child > th:last-child
    tfoot:last-child tr:last-child > td:last-child
    tfoot:last-child tr:last-child > th:last-child
      border-bottom-right-radius: $radius


    // Clear border-radius for first and last td in the last row in the last tbody for table with tfoot
    tfoot + tbody:last-child tr:last-child td:first-child
      border-bottom-left-radius: 0

    tfoot + tbody:last-child tr:last-child td:last-child
      border-bottom-right-radius: 0

    // Special fixes to round the left border on the first td/th
    caption + thead tr:first-child th:first-child
    caption + tbody tr:first-child td:first-child
    colgroup + thead tr:first-child th:first-child
    colgroup + tbody tr:first-child td:first-child
      border-top-left-radius: $radius

    caption + thead tr:first-child th:last-child
    caption + tbody tr:first-child td:last-child
    colgroup + thead tr:first-child th:last-child
    colgroup + tbody tr:first-child td:last-child
      border-top-right-radius: $radius

  &.striped
    tbody
      > tr:nth-child(odd) > td
      > tr:nth-child(odd) > th
        background-color: lighten($divider, 80%)

  &.hover
    tbody
      tr:hover > td
      tr:hover > th
        background-color: lighten($divider, 50%)
