input {
    text-align: center;
}

/* ── Card Name Header ──────────────────────────────────────────────────── */

#card-name-contents {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(90deg, #1D3557 0%, #22406b 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    padding: 14px 28px;
    color: white;
    flex-direction: row;
}

#card-name-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#series-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    opacity: 0.75;
    font-weight: 500;
    letter-spacing: 0.02em;
}

#series-container div {
    display: flex;
    align-items: center;
}

#card-name-container {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
    color: white;
}

#series-name { font-size: inherit; }
#set-name { font-size: inherit; }
#series-name a, #set-name a { color: inherit; }

#card-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.2px;
}

#variety {
    font-size: 0.82rem;
    font-weight: 500;
    opacity: 0.7;
}

.heart-icon {
    height: 30px;
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.heart-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* ── Top Row ───────────────────────────────────────────────────────────── */

#top-row-card {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 380px;
    justify-content: space-evenly;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 0;
}

#calculator {
    width: 55%;
    min-width: 700px;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

#calculator-left {
    min-width: 700px;
}

/* ── Cost Inputs ───────────────────────────────────────────────────────── */

#costs {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    gap: 12px;
    padding: 0 8px 16px;
    border-bottom: 1px solid #e8edf5;
}

#costs input {
    margin-top: 6px;
    height: 32px;
    border-radius: 7px;
    border: 1px solid #dde3ed;
    background-color: #f1f5f9;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1D3557;
    transition: border-color 0.15s ease;
}

#costs input:focus {
    outline: none;
    border-color: #83000A;
    background-color: #fff;
}

.cost-container {
    width: 22%;
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cost-container input {
    width: 100%;
}

/* ── Calculator settings hint ──────────────────────────────────────────── */

#calc-settings-hint {
    text-align: center;
    font-size: 0.72rem;
    color: #94a3b8;
    font-weight: 400;
    padding: 6px 0 4px;
}

#calc-settings-hint a {
    color: #83000A;
    font-weight: 600;
}

/* ── Calculator Table ──────────────────────────────────────────────────── */

#table-div {
    width: 100%;
    margin-top: 20px;
}

#calculator-table {
    width: 100%;
    text-align: center;
    border-collapse: collapse;
}

#calculator-table .table-header th {
    background-color: #1D3557;
    color: white;
    padding: 10px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    width: 16.6666%;
}

#calculator-table tr {
    height: 42px;
}

.table-data td {
    border: 1px solid #e8edf5;
    font-size: 0.875rem;
}

.table-data:nth-child(odd) td {
    background-color: #fff;
}

.table-data:nth-child(even) td {
    background-color: #f7f9fc;
}

#calculator-table tbody {
    width: 100%;
}

#calculator-table td {
    height: 100%;
    width: 16.6666%;
}

#calculator-table td input {
    width: 100%;
    height: 42px;
    border: none;
    text-align: center;
    background-color: transparent;
    font-size: 0.875rem;
    font-weight: 600;
    color: #1D3557;
}

.table-data .no-border {
    border: none;
}

/* ── Calculator Summary ────────────────────────────────────────────────── */

.calculator-summary-row {
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
    width: 100%;
    text-align: center;
    border-top: 2px solid #e8edf5;
    margin-top: 4px;
    padding-top: 4px;
}

.calculator-summary {
    flex: 1;
    padding: 12px 8px;
    border-right: 1px solid #e8edf5;
}

.calculator-summary:last-child {
    border-right: none;
}

.calculator-summary div:not(.summary-val) {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 4px;
}

.summary-val {
    font-size: 1.3rem;
    font-weight: 800;
    color: #1D3557;
}

/* ── Sales Container ───────────────────────────────────────────────────── */

#sales-container {
    width: 40%;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    margin-top: 20px;
    gap: 16px;
}

#sales-rates {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

#sales-rates table {
    width: 100%;
    text-align: center;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #dde3ed;
}

#sales-rates tr {
    height: 34px;
}

#sales-rates th {
    width: 25%;
    background-color: #1D3557;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 8px 6px;
}

#sales-rates td {
    width: 25%;
    text-align: center;
    border: 1px solid #e8edf5;
    font-size: 0.875rem;
    font-weight: 600;
}

#sales-rates tr:nth-child(odd) td {
    background-color: #fff;
}

#sales-rates tr:nth-child(even) td {
    background-color: #f7f9fc;
}

#sales-rates .wider-td {
    width: 30%;
    text-align: center;
    font-weight: 700;
    font-size: 0.78rem;
    color: #1D3557;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Pop Delta ─────────────────────────────────────────────────────────── */

#pop-delta {
    width: 100%;
}

/* ── Purchase Buttons ──────────────────────────────────────────────────── */

#purchasing {
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.buy-container {
    border: none;
    border-radius: 8px;
    flex: 1;
    height: 58px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    background: #83000A;
    color: white;
    gap: 3px;
    text-decoration: none;
    transition: opacity 0.15s ease, transform 0.12s ease;
    box-shadow: 0 2px 6px rgba(131, 0, 10, 0.3);
}

.buy-container:hover {
    opacity: 0.88;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(131, 0, 10, 0.35);
}

.raw-price {
    font-weight: 800;
    font-size: 0.95rem;
}

/* ── Graph Row ─────────────────────────────────────────────────────────── */

#graph-row {
    margin-top: 24px;
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
}

#graph-container {
    width: 93.5%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 20px;
    padding: 20px 20px 12px;
}

/* ── Range Selector ────────────────────────────────────────────────────── */

#range-selector-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}

.range-label {
    font-size: 0.72rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#range-selector {
    display: flex;
    gap: 3px;
}

.range-pill {
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    border-radius: 20px;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    background: #fff;
    transition: all 0.12s ease;
    user-select: none;
}

.range-pill:hover {
    color: #1D3557;
    border-color: #cbd5e1;
}

.range-pill-active {
    background: #1D3557;
    color: #fff !important;
    border-color: #1D3557;
}

/* ── Data freshness ────────────────────────────────────────────────────── */

#data-freshness {
    font-size: 0.73rem;
    color: #94a3b8;
    font-weight: 400;
    text-align: center;
    padding: 6px 0 0;
    font-style: italic;
}

/* ── Graph Tabs ────────────────────────────────────────────────────────── */

.graph-selector-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    justify-content: center;
    gap: 4px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.graph-selector {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    border-radius: 20px;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    background: #fff;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.graph-selector:hover {
    color: #1D3557;
    border-color: #1D3557;
}

.graph-selected-active {
    background: #1D3557;
    color: #fff;
    border-color: #1D3557;
    text-decoration: none;
}

.graph-selected-active:hover {
    color: #fff;
    opacity: 0.9;
}

.graphs {
    width: 100%;
    height: 420px;
    position: relative;
}

/* Graph loading skeleton */
#graph-loading {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: linear-gradient(90deg, #e8edf5 25%, #f4f7fb 50%, #e8edf5 75%);
    background-size: 1200px 100%;
    animation: shimmer 1.4s infinite linear;
    z-index: 1;
    pointer-events: none;
}

@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}

.hidden {
    display: none !important;
}

tr {
    width: 100%;
    height: 40px;
}

/* ── Grade Selector ────────────────────────────────────────────────────── */

#grade-selector {
    display: flex;
    flex-direction: row;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
}

.grade-selector {
    padding: 6px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1D3557;
    border-radius: 20px;
    cursor: pointer;
    border: 1.5px solid #dde3ed;
    background: #fff;
    transition: all 0.15s ease;
}

.grade-selector:hover {
    border-color: #1D3557;
}

.grade-selector-active {
    background: #1D3557;
    color: #fff;
    border-color: #1D3557;
    text-decoration: none;
}

/* ── eBay Listings ─────────────────────────────────────────────────────── */

#ebay-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
    margin-top: 8px;
}

#ebay-subcontainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#listings-top {
    width: 93.5%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

#listings-top > div:first-child {
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 400;
    text-align: center;
}

#listings {
    width: calc(93.5% + 40px);
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
}

.listing-container {
    max-height: 600px;
    min-width: 600px;
    width: 47.25%;
    overflow-y: auto;
    margin-bottom: 20px;
    margin-top: 8px;
    border-radius: 10px;
}

.listing-container::-webkit-scrollbar {
    width: 8px;
}

.listing-container::-webkit-scrollbar-track {
    border-radius: 8px;
    background-color: #f1f5f9;
}

.listing-container::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background-color: #83000A;
}

#current-listings, #sold-listings {
    padding: 20px;
}

.listing-header {
    text-align: center;
    margin-bottom: 16px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1D3557;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ebay-link {
    display: flex;
    justify-content: center;
    align-items: center;
}

.ebay-link div {
    font-size: 0.8rem;
    font-weight: 700;
    background: #83000A;
    color: white;
    width: 120px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 6px;
    transition: opacity 0.15s ease;
}

.ebay-link div:hover {
    opacity: 0.88;
}

.listing img {
    height: 80px;
    max-width: 80px;
    border-radius: 4px;
    object-fit: cover;
}

.active-display td {
    width: 20%;
}

.listing td {
    width: 20%;
}

#active-display th {
    width: 20%;
}

#sold-listings td {
    width: 20%;
}

#sold-listings td a {
    min-height: 40px;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

#current-body td a {
    height: 80px;
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
}

#sold-listings th {
    width: 20%;
}

.sortable {
    cursor: pointer;
}

#current-body tr {
    min-height: 90px;
}

/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    #card-name-contents {
        padding: 12px 16px;
    }

    #card-name {
        font-size: 1rem;
    }

    .heart-icon {
        height: 24px;
    }

    #calculator {
        width: 100%;
        min-width: 0;
    }

    #calculator-left {
        min-width: 0;
        width: 100%;
    }

    #top-row-right {
        width: 100%;
    }

    #costs {
        gap: 0;
        padding-bottom: 12px;
    }

    .cost-container {
        width: 33.33%;
        font-size: 0.68rem;
        padding: 4px 2px;
    }

    .cost-container input {
        font-size: 0.8rem;
        margin-top: 4px;
    }

    /* Hide Shipping Cost and Grading Cost on mobile */
    #calculator-table th:nth-child(4),
    #calculator-table td:nth-child(4),
    #calculator-table th:nth-child(5),
    #calculator-table td:nth-child(5) {
        display: none;
    }

    #calculator-table {
        font-size: 0.78rem;
        table-layout: fixed;
    }

    #calculator-table th,
    #calculator-table td {
        padding: 7px 4px;
    }

    /* 4 visible columns */
    #calculator-table th:nth-child(1), #calculator-table td:nth-child(1) { width: 18%; }
    #calculator-table th:nth-child(2), #calculator-table td:nth-child(2) { width: 22%; }
    #calculator-table th:nth-child(3), #calculator-table td:nth-child(3) { width: 27%; }
    #calculator-table th:nth-child(6), #calculator-table td:nth-child(6) { width: 33%; }

    .calculator-summary-row {
        margin-top: 0;
        padding-top: 8px;
    }

    .calculator-summary {
        padding: 6px 4px;
    }

    .calculator-summary div:not(.summary-val) {
        font-size: 0.6rem;
        margin: 0 0 3px;
    }

    .summary-val {
        font-size: 1rem !important;
    }

    .listing-container {
        min-width: 0;
        width: 100%;
    }

    #listings {
        width: 100%;
        gap: 0;
    }

    #graph-container {
        width: 100%;
    }

    .graphs {
        height: 280px;
    }

    #listings-top {
        width: 100%;
    }

    #sales-container {
        width: 100%;
        min-width: 0;
    }

    .graph-selector {
        font-size: 0.72rem;
        padding: 5px 10px;
    }

    .listing-container {
        overflow-x: hidden;
    }
}

/* ── Calculator Paywall ────────────────────────────────────────────────── */

.calculator-paywall {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    position: relative;
    overflow: hidden;
}

.calculator-paywall::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url('/static/img/calculator-bg.png');
    background-size: cover;
    background-position: center top;
    filter: blur(2px) brightness(0.42);
    transform: scale(1.04);
    z-index: 0;
}

.calculator-paywall-inner {
    text-align: center;
    padding: 32px 24px;
    position: relative;
    z-index: 1;
}

.calculator-paywall-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.calculator-paywall-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary, #e8eaf0);
    margin-bottom: 8px;
}

.calculator-paywall-text {
    font-size: 0.88rem;
    color: var(--text-secondary, #9aa5b4);
    line-height: 1.5;
    margin-bottom: 20px;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.calculator-paywall-btn {
    display: inline-block;
    padding: 9px 22px;
    border-radius: 7px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    margin: 0 6px 8px;
    transition: opacity 0.15s;
    background: #c0392b;
    color: #fff;
}

.calculator-paywall-btn:hover {
    opacity: 0.88;
}

.calculator-paywall-btn-secondary {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--text-primary, #e8eaf0);
}
