.erd-ranking-table {
    --erd-table-border: #d9dee5;
    --erd-table-muted: #5f6b76;
    max-width: 100%;
}

.erd-ranking-table__header h2 { margin: 0 0 1.25rem; }

.erd-table-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    gap: .85rem;
    align-items: end;
    margin-bottom: 1rem;
}

.erd-table-filter label {
    display: block;
    margin-bottom: .3rem;
    color: var(--erd-table-muted);
    font-size: .82rem;
    font-weight: 600;
}

.erd-table-filter select,
.erd-table-filter input:not([type="hidden"]) {
    width: 100%;
    min-height: 42px;
    border: 1px solid #4f4f4f !important;
    border-radius: 4px;
    background: #fff !important;
    color: #111 !important;
}

.erd-table-filter--actions .button { min-height: 42px; }

/* Searchable listing filter styled to match a standard select control. */
.erd-listing-combobox {
    position: relative;
}

.erd-listing-combobox__toggle {
    position: relative;
    width: 100%;
    min-height: 42px;
    padding: .55rem 2.4rem .55rem .75rem;
    border: 1px solid #4f4f4f !important;
    border-radius: 4px;
    background: #fff !important;
    color: #111 !important;
    font: inherit;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
}

.erd-listing-combobox__toggle::after {
    position: absolute;
    top: 50%;
    right: .8rem;
    width: .55rem;
    height: .55rem;
    border-right: 2px solid #222;
    border-bottom: 2px solid #222;
    content: '';
    transform: translateY(-70%) rotate(45deg);
}

.erd-listing-combobox__toggle[aria-expanded="true"]::after {
    transform: translateY(-25%) rotate(225deg);
}

.erd-listing-combobox__toggle span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.erd-listing-combobox__panel {
    position: absolute;
    z-index: 1000;
    top: calc(100% + 3px);
    left: 0;
    width: 100%;
    overflow: hidden;
    border: 1px solid #4f4f4f;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .14);
}

.erd-listing-combobox__search {
    width: calc(100% - 1rem) !important;
    min-height: 38px !important;
    margin: .5rem !important;
    border: 1px solid #8a8a8a !important;
    border-radius: 3px !important;
    background: #fff !important;
}

.erd-listing-combobox__options {
    max-height: 240px;
    overflow-y: auto;
    border-top: 1px solid #e2e2e2;
}

.erd-listing-combobox__option {
    display: block;
    width: 100%;
    padding: .65rem .75rem;
    border: 0;
    border-bottom: 1px solid #eee;
    background: #fff;
    color: #111;
    font: inherit;
    font-weight: 400;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
}

.erd-listing-combobox__option:last-child { border-bottom: 0; }
.erd-listing-combobox__option:hover,
.erd-listing-combobox__option:focus,
.erd-listing-combobox__option[aria-selected="true"] {
    background: #f1f4f7 !important;
    color: #111 !important;
    outline: none;
}

.erd-table-summary {
    margin: 0 0 .65rem;
    color: var(--erd-table-muted);
    font-size: .9rem;
}

.erd-table-scroll {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--erd-table-border);
    border-radius: 8px;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}

.erd-data-table {
    width: 100%;
    min-width: 1280px;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.erd-data-table th,
.erd-data-table td {
    padding: .7rem .65rem;
    border: 0;
    border-right: 1px solid var(--erd-table-border);
    border-bottom: 1px solid var(--erd-table-border);
    vertical-align: top;
    color: #111;
    font-size: .875rem;
    line-height: 1.35;
    text-align: left;
}

.erd-data-table th:last-child,
.erd-data-table td:last-child { border-right: 0; }
.erd-data-table tbody tr:last-child td { border-bottom: 0; }

.erd-data-table th {
    background: #f5f7f9;
    font-size: .82rem;
    font-weight: 700;
    white-space: normal;
}

.erd-data-table th:nth-child(1) { width: 125px; }
.erd-data-table th:nth-child(2) { width: 220px; }
.erd-data-table th:nth-child(3) { width: 180px; }
.erd-data-table th:nth-child(4),
.erd-data-table th:nth-child(5) { width: 110px; }
.erd-data-table th:nth-child(6) { width: 150px; }
.erd-data-table th:nth-child(7),
.erd-data-table th:nth-child(8),
.erd-data-table th:nth-child(9) { width: 145px; }

.erd-data-table th button {
    position: relative;
    width: 100%;
    padding: 0 1rem 0 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.erd-data-table th button::after {
    position: absolute;
    right: 0;
    content: '↕';
    color: #7b8490;
    font-weight: 400;
}
.erd-data-table th button.is-sorted[aria-sort="ascending"]::after { content: '↑'; }
.erd-data-table th button.is-sorted[aria-sort="descending"]::after { content: '↓'; }

.erd-listing-text {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: #111;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.erd-cell-highlight { background: #e5f8e6; }
.erd-status-cell { font-weight: 700; }
.erd-status-cell--active { background: #fbeab0; }
.erd-status-cell--complete { background: #b0fbf8; }
.erd-status-cell--refunded { background: #dfc3c3; }
.erd-status-cell--cancelled { background: #dcdad5; }

.erd-table-empty {
    padding: 2rem !important;
    text-align: center !important;
    color: var(--erd-table-muted) !important;
}

.erd-table-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    align-items: center;
    margin-top: 1rem;
}

.erd-table-pagination button {
    min-width: 38px;
    min-height: 38px;
    padding: .35rem .6rem;
    border: 1px solid #bfc6ce;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}
.erd-table-pagination button.is-current {
    border-color: #387ec5;
    background: #387ec5;
    color: #fff;
}
.erd-table-pagination button:disabled { cursor: default; opacity: .5; }

@media (max-width: 900px) {
    .erd-table-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
    .erd-table-filters { grid-template-columns: 1fr; }
    .erd-table-scroll {
        overflow: visible;
        border: 0;
        background: transparent;
    }
    .erd-data-table,
    .erd-data-table tbody,
    .erd-data-table tr,
    .erd-data-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }
    .erd-data-table { table-layout: auto; }
    .erd-data-table thead { display: none; }
    .erd-data-table tr {
        margin-bottom: 1rem;
        overflow: hidden;
        border: 1px solid var(--erd-table-border);
        border-radius: 8px;
        background: #fff;
        box-shadow: 0 1px 2px rgba(0,0,0,.04);
    }
    .erd-data-table td {
        display: grid;
        grid-template-columns: minmax(115px, 42%) minmax(0, 1fr);
        gap: .75rem;
        padding: .7rem .8rem;
        border-right: 0;
        border-bottom: 1px solid var(--erd-table-border);
        overflow-wrap: anywhere;
    }
    .erd-data-table td::before {
        content: attr(data-label);
        color: var(--erd-table-muted);
        font-size: .78rem;
        font-weight: 700;
    }
    .erd-data-table tr td:last-child { border-bottom: 0; }
    .erd-listing-text { white-space: normal; overflow-wrap: anywhere; }
    .erd-table-empty { display: block !important; }
    .erd-table-empty::before { content: none !important; }
}


/* Ranking Table endpoint only: widen the account layout while retaining the menu beside the table. */
body.erd-ranking-table-page .woocommerce {
    position: relative;
    left: 50%;
    width: min(1600px, calc(100vw - 48px));
    max-width: none;
    transform: translateX(-50%);
}

body.erd-ranking-table-page .woocommerce-MyAccount-navigation {
    width: 14%;
    min-width: 150px;
}

body.erd-ranking-table-page .woocommerce-MyAccount-content {
    width: calc(86% - 28px);
    max-width: none;
}

body.erd-ranking-table-page .woocommerce-MyAccount-content .erd-ranking-table {
    width: 100%;
    max-width: none;
}

@media (max-width: 900px) {
    body.erd-ranking-table-page .woocommerce {
        left: auto;
        width: 100%;
        max-width: 100%;
        transform: none;
    }

    body.erd-ranking-table-page .woocommerce-MyAccount-navigation,
    body.erd-ranking-table-page .woocommerce-MyAccount-content {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        float: none;
    }
}
