.aprg-card-viewer-best-list,
.aprg-ranked-card-wrapper,
.aprg-ranked-card-wrapper * {
    box-sizing: border-box;
}

.aprg-card-viewer-best-list {
    clear: both;
    margin: 24px 0 34px;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.aprg-ranked-card-wrapper {
    margin: 24px 0 32px;
    overflow: visible;
    border: 1px solid #e2ded6;
    border-radius: 8px;
    background: #fff;
}

.aprg-card-viewer-best-list .aprg-ranked-card-wrapper:first-child {
    border-color: #248c95;
}

.aprg-ranked-card {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr) 184px;
    gap: 20px;
    align-items: center;
    min-height: 138px;
    margin: 0;
    padding: 16px 20px 14px 28px;
    border: 0;
    border-radius: 8px;
    background: #fff;
}

.aprg-ranked-card__left {
    position: relative;
    width: 110px;
    text-align: center;
}

.aprg-ranked-card__rank {
    position: absolute;
    top: 92px;
    left: -42px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #df2635;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}

.aprg-ranked-card__image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 110px;
    height: 110px;
}

.aprg-ranked-card__image img {
    width: 110px;
    height: 110px;
    object-fit: contain;
}

.aprg-ranked-card__middle {
    min-width: 0;
}

.aprg-ranked-card__badge,
.aprg-product-availability {
    display: inline-block;
    margin: 0 7px 8px 0;
    padding: 4px 8px;
    border-radius: 4px;
    background: #e7f8ed;
    color: #088849;
    font-size: 9px;
    line-height: 1;
    font-weight: 800;
    text-transform: uppercase;
}

.aprg-product-availability {
    background: #fff1f2;
    color: #be123c;
}

.aprg-ranked-card__title {
    margin: 0 0 8px;
    font-size: 18px;
    line-height: 1.4;
    font-weight: 800;
}

.aprg-ranked-card__title a {
    color: #050b18 !important;
    text-decoration: none !important;
}

.aprg-ranked-card__title a:hover {
    text-decoration: underline !important;
}

.aprg-ranked-card__excerpt {
    margin: 0 0 8px;
    color: #586170;
    font-size: 12px;
    line-height: 1.45;
}

.aprg-ranked-card__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
    color: #586170;
    font-size: 11px;
    line-height: 1.2;
}

.aprg-ranked-card__score {
    color: #111827;
    font-weight: 800;
}

.aprg-ranked-card__brand {
    display: none;
}

.aprg-ranked-card__score small {
    margin-left: 3px;
    color: #586170;
    font-size: 10px;
    font-weight: 500;
}

.aprg-ranked-card__right {
    width: 184px;
    text-align: right;
}

.aprg-ranked-card__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 9px 14px;
    border-radius: 7px;
    background: #ef9200;
    color: #fff !important;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none !important;
}

.aprg-ranked-card__cta:hover {
    background: #d98200;
}

.aprg-ranked-card__cta.is-out-of-stock {
    background: #64748b;
    cursor: default;
}

.aprg-card-viewer-panel {
    border-top: 1px solid #e7e2da;
    background: #fff;
}

.aprg-card-viewer-panel summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 46px;
    padding: 0 16px;
    color: #121826;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
}

.aprg-card-viewer-panel summary::-webkit-details-marker {
    display: none;
}

.aprg-card-viewer-panel summary span {
    color: #3f4756;
    font-size: 11px;
    font-weight: 500;
}

.aprg-card-viewer-panel summary span::after {
    content: " +";
}

.aprg-card-viewer-panel[open] summary span::after {
    content: " −";
}

.aprg-card-viewer-panel__content {
    padding: 16px 18px 18px;
    border-top: 1px solid #eee9e1;
    color: #374151;
    font-size: 14px;
    line-height: 1.65;
}

.aprg-card-viewer-panel__content > :first-child {
    margin-top: 0;
}

.aprg-card-viewer-panel__content > :last-child {
    margin-bottom: 0;
}

.aprg-card-viewer-pros-cons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.aprg-card-viewer-pros-cons ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

/*
 * Compatibility for ranked cards already stored as APRG HTML. These rows use
 * an inline class toggle, so Card Viewer must own the hidden/open states after
 * the main APRG plugin (and its stylesheet) is disabled.
 */
.aprg-best-product-list .aprg-accordion-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 46px;
    padding: 0 16px;
    border-top: 1px solid #e7e2da;
    background: #fff;
    color: #121826;
    cursor: pointer;
    user-select: none;
}

.aprg-best-product-list .aprg-accordion-row__label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #121826;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .01em;
}

.aprg-best-product-list .aprg-accordion-row__icon,
.aprg-best-product-list .aprg-accordion-row__icon svg {
    display: inline-flex;
    flex: 0 0 auto;
}

.aprg-best-product-list .aprg-accordion-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #3f4756;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
}

.aprg-best-product-list .aprg-accordion-toggle__hide {
    display: none;
}

.aprg-best-product-list .aprg-accordion-toggle__chevron {
    transition: transform .2s ease;
}

.aprg-best-product-list .aprg-accordion-toggle[aria-expanded="true"] .aprg-accordion-toggle__view {
    display: none;
}

.aprg-best-product-list .aprg-accordion-toggle[aria-expanded="true"] .aprg-accordion-toggle__hide {
    display: inline;
}

.aprg-best-product-list .aprg-accordion-toggle[aria-expanded="true"] .aprg-accordion-toggle__chevron {
    transform: rotate(180deg);
}

.aprg-best-product-list .aprg-accordion-panel {
    display: none;
    overflow: hidden;
    background: #fff;
}

.aprg-best-product-list .aprg-accordion-panel.aprg-accordion-panel--open {
    display: block;
}

.aprg-best-product-list .aprg-accordion-panel__inner {
    padding: 16px 20px 20px;
    border-top: 1px solid #eee9e1;
    color: #374151;
    font-size: 14px;
    line-height: 1.65;
}

.aprg-best-product-list table.aprg-pros-cons-table {
    width: 100%;
    margin: 0;
    border: 1px solid #e5e7eb;
    border-collapse: collapse;
    table-layout: fixed;
}

.aprg-best-product-list table.aprg-pros-cons-table th,
.aprg-best-product-list table.aprg-pros-cons-table td {
    width: 50%;
    padding: 16px;
    border: 1px solid #e5e7eb;
    vertical-align: top;
    text-align: left;
}

.aprg-best-product-list table.aprg-pros-cons-table th {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.aprg-best-product-list table.aprg-pros-cons-table th:first-child {
    border-bottom: 3px solid #66bb6a;
    background: #ecfdf3;
    color: #237a3b;
}

.aprg-best-product-list table.aprg-pros-cons-table th:last-child {
    border-bottom: 3px solid #ef5350;
    background: #fff1f2;
    color: #b4232c;
}

@media (max-width: 720px) {
    .aprg-card-viewer-best-list {
        margin: 20px 0 28px;
    }

    .aprg-ranked-card-wrapper {
        margin: 28px 0 34px;
        overflow: visible;
        border-color: #e4e1dc;
        border-radius: 12px;
        box-shadow: 0 2px 5px rgba(15, 23, 42, .05);
    }

    .aprg-ranked-card {
        display: flex;
        flex-direction: column;
        gap: 13px;
        min-height: 0;
        padding: 48px 16px 16px;
        border-radius: 12px 12px 0 0;
        text-align: center;
    }

    .aprg-ranked-card-wrapper > .aprg-ranked-card:last-child {
        border-radius: 12px;
    }

    .aprg-ranked-card__left,
    .aprg-ranked-card__image,
    .aprg-ranked-card__image img {
        width: 100%;
    }

    .aprg-ranked-card__left {
        position: relative;
    }

    .aprg-ranked-card__image {
        height: 190px;
    }

    .aprg-ranked-card__image img {
        width: 190px;
        height: 190px;
        margin: 0 auto;
    }

    .aprg-ranked-card__rank {
        top: -65px;
        left: 50%;
        width: 34px;
        height: 34px;
        transform: translateX(-50%);
        font-size: 16px;
    }

    .aprg-ranked-card__middle {
        width: 100%;
        text-align: center;
    }

    .aprg-ranked-card__badge,
    .aprg-product-availability {
        margin: 0 4px 7px;
        padding: 5px 7px;
        border-radius: 4px;
        background: #fff0ef;
        color: #f05b52;
        font-size: 10px;
    }

    .aprg-product-availability {
        background: #fff1f2;
        color: #be123c;
    }

    .aprg-ranked-card__title {
        max-width: 360px;
        margin: 0 auto 8px;
        font-size: 18px;
        line-height: 1.25;
    }

    .aprg-ranked-card__title a::after {
        content: " ↗";
        color: #6b7280;
        font-size: .8em;
        font-weight: 500;
    }

    .aprg-ranked-card__excerpt {
        display: none;
    }

    .aprg-ranked-card__meta {
        justify-content: center;
        gap: 8px 14px;
        font-size: 11px;
    }

    .aprg-ranked-card__brand {
        display: inline-flex;
        align-items: center;
        color: #374151;
        font-weight: 700;
    }

    .aprg-ranked-card__brand::before {
        content: "✓";
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 12px;
        height: 12px;
        margin-right: 4px;
        border-radius: 50%;
        background: #1f2937;
        color: #fff;
        font-size: 8px;
    }

    .aprg-ranked-card__score::before {
        content: "▥";
        margin-right: 4px;
        color: #374151;
        font-size: 11px;
    }

    .aprg-ranked-card__updated {
        flex-basis: 100%;
        margin-top: 3px;
        color: #9ca3af;
    }

    .aprg-ranked-card__updated::before {
        content: "◷ ";
    }

    .aprg-ranked-card__right {
        width: 100%;
        padding-top: 2px;
        text-align: center;
    }

    .aprg-ranked-card__cta {
        width: 100%;
        min-height: 58px;
        padding: 14px 18px;
        border-radius: 8px;
        background: #ee982b;
        font-size: 19px;
        line-height: 1.2;
    }

    .aprg-card-viewer-panel {
        overflow: hidden;
    }

    .aprg-card-viewer-panel:last-child {
        border-radius: 0 0 12px 12px;
    }

    .aprg-card-viewer-panel summary {
        min-height: 58px;
        padding: 0 16px;
        font-size: 14px;
    }

    .aprg-card-viewer-panel summary span {
        font-size: 13px;
    }

    .aprg-card-viewer-panel summary span::after {
        content: "⌄";
        margin-left: 7px;
        font-size: 16px;
    }

    .aprg-card-viewer-panel[open] summary span::after {
        content: "⌃";
    }

    .aprg-card-viewer-pros-cons {
        grid-template-columns: 1fr;
    }

    .aprg-best-product-list .aprg-accordion-row {
        min-height: 58px;
        padding: 0 16px;
        touch-action: manipulation;
    }

    .aprg-best-product-list .aprg-accordion-row__label,
    .aprg-best-product-list .aprg-accordion-toggle {
        font-size: 14px;
    }

    .aprg-best-product-list .aprg-accordion-panel__inner {
        padding: 14px 16px 18px;
    }

    /* Flatten the old table and group all Pros before all Cons on mobile. */
    .aprg-best-product-list table.aprg-pros-cons-table {
        display: flex;
        flex-direction: column;
        gap: 0;
        overflow: hidden;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        background: #fff;
    }

    .aprg-best-product-list table.aprg-pros-cons-table thead,
    .aprg-best-product-list table.aprg-pros-cons-table tbody,
    .aprg-best-product-list table.aprg-pros-cons-table tr {
        display: contents;
    }

    .aprg-best-product-list table.aprg-pros-cons-table th,
    .aprg-best-product-list table.aprg-pros-cons-table td {
        display: block;
        width: 100%;
        padding: 13px 15px;
        border: 0;
        border-bottom: 1px solid #e5e7eb;
        background: #fff;
        font-size: 14px;
        line-height: 1.55;
    }

    .aprg-best-product-list table.aprg-pros-cons-table th:first-child {
        order: 1;
        border-bottom: 2px solid #66bb6a;
    }

    .aprg-best-product-list table.aprg-pros-cons-table td:first-child {
        order: 2;
        padding-left: 42px;
        background: #fbfffc;
    }

    .aprg-best-product-list table.aprg-pros-cons-table td:first-child::before {
        content: "✓";
        float: left;
        width: 20px;
        height: 20px;
        margin: 1px 0 0 -27px;
        border-radius: 50%;
        background: #dcfce7;
        color: #15803d;
        font-size: 12px;
        font-weight: 800;
        line-height: 20px;
        text-align: center;
    }

    .aprg-best-product-list table.aprg-pros-cons-table th:last-child {
        order: 3;
        margin-top: 10px;
        border-top: 1px solid #e5e7eb;
        border-bottom: 2px solid #ef5350;
    }

    .aprg-best-product-list table.aprg-pros-cons-table td:last-child {
        order: 4;
        padding-left: 42px;
        background: #fffdfd;
    }

    .aprg-best-product-list table.aprg-pros-cons-table td:last-child::before {
        content: "−";
        float: left;
        width: 20px;
        height: 20px;
        margin: 1px 0 0 -27px;
        border-radius: 50%;
        background: #ffe4e6;
        color: #be123c;
        font-size: 15px;
        font-weight: 800;
        line-height: 18px;
        text-align: center;
    }

    .aprg-best-product-list table.aprg-pros-cons-table tbody tr:last-child td:last-child {
        border-bottom: 0;
    }
}

@media (max-width: 390px) {
    .aprg-ranked-card {
        padding-right: 13px;
        padding-left: 13px;
    }

    .aprg-ranked-card__image,
    .aprg-ranked-card__image img {
        height: 170px;
    }

    .aprg-ranked-card__image img {
        width: 170px;
    }

    .aprg-ranked-card__title {
        font-size: 17px;
    }

    .aprg-ranked-card__cta {
        font-size: 17px;
    }
}
