.market-page {
    min-height: calc(100vh - 80px);
    background: #0b1016;
    color: #e8edf2;
    padding: 0;
}

.market-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    min-height: calc(100vh - 120px);
}

.market-sidebar {
    background: linear-gradient(180deg, #10161d 0%, #0b1016 100%);
    border: 1px solid rgba(255, 255, 255, .08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.market-search-wrap {
    display: grid;
    grid-template-columns: 1fr 56px;
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .02);
}

.market-search-input {
    width: 100%;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: #141b23;
    color: #fff;
    padding: 0 12px;
    outline: none;
}

.market-search-input::placeholder {
    color: rgba(255, 255, 255, .45);
}

.market-search-btn {
    height: 42px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-left: 0;
    background: #26313d;
    color: #fff;
    cursor: pointer;
}

.market-tree {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 8px 0;
}

.tree-major {
    border-bottom: 1px solid rgba(255, 255, 255, .05);
}

.tree-major-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    user-select: none;
    color: #d5dde5;
    transition: background .15s ease;
}

.tree-major-header:hover {
    background: rgba(255, 255, 255, .04);
}

.tree-arrow {
    width: 16px;
    text-align: center;
    color: #c8d1d9;
    font-size: 12px;
    flex: 0 0 16px;
}

.tree-major-name {
    font-size: 24px;
}

.tree-minor-list {
    padding: 0 0 10px 0;
}

.tree-minor-item {
    display: block;
    margin: 4px 8px 4px 40px;
    padding: 12px 14px;
    color: #c6d0da;
    text-decoration: none;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all .15s ease;
}

.tree-minor-item:hover {
    background: rgba(255, 255, 255, .04);
    color: #fff;
}

.tree-minor-item.active {
    background: linear-gradient(90deg, rgba(212, 116, 43, .28) 0%, rgba(212, 116, 43, .10) 100%);
    border-left-color: #d4742b;
    color: #ffb378;
}

.market-content {
    background: radial-gradient(circle at top, rgba(39, 52, 67, .28), transparent 35%), linear-gradient(180deg, #0e1319 0%, #090d12 100%);
    border: 1px solid rgba(255, 255, 255, .08);
    padding: 8px;
    min-height: 600px;
}

.market-content-header {
    margin-bottom: 14px;
}

.market-content-title {
    margin: 0;
    font-size: 34px;
    font-weight: 600;
    color: #f2f5f8;
}

.market-item-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.market-item-card {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    background: #081019;
    border: 1px solid rgba(255, 255, 255, .10);
    overflow: hidden;
    min-height: 270px;
}

.market-item-left {
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, .08);
    background: linear-gradient(180deg, #08131f 0%, #06101a 100%);
}

.market-item-name {
    min-height: 56px;
    padding: 10px 16px;
    display: flex;
    align-items: flex-start;
    color: #eef4fa;
    font-size: 20px;
    line-height: 1.25;
    word-break: break-word;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.market-item-image-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    min-height: 150px;
    /* 讓 wrapper 形成可填滿的區域（image 以 width/height 100% 填滿） */
    position: relative;
}

.market-item-image {
    /* 改為填滿 wrapper 並保留長寬比 */
    width: 50%;
    height: 50%;
    object-fit: contain;
    display: block;
}

.market-item-image-placeholder {
    width: 100%;
    height: 100%;
    border: 1px dashed rgba(255, 255, 255, .15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, .35);
    font-size: 20px;
    background: rgba(255, 255, 255, .02);
}

.market-item-lowest {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    color: #f5f8fb;
    font-size: 18px;
    background: rgba(255, 255, 255, .03);
}

.market-item-lowest-label {
    color: rgba(255, 255, 255, .78);
    margin-right: 6px;
}

.market-item-lowest-value {
    font-size: 28px;
    font-weight: 700;
}

.market-item-right {
    display: grid;
    grid-template-rows: 1fr auto;
    min-width: 0;
}

.market-item-chart {
    padding: 14px 16px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.market-durability-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.market-durability-btn {
    border: 1px solid rgba(255, 255, 255, .2);
    background: rgba(255, 255, 255, .06);
    color: #d8e1ea;
    font-size: 13px;
    padding: 4px 12px;
    cursor: pointer;
    transition: all .15s ease;
}

.market-durability-btn:hover {
    border-color: #ff9a38;
    color: #fff0e0;
}

.market-durability-btn.active {
    background: linear-gradient(90deg, rgba(255, 141, 42, .35) 0%, rgba(255, 192, 111, .25) 100%);
    border-color: #ff9a38;
    color: #fff2df;
    font-weight: 700;
}

.market-item-chart-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    color: #d7dee5;
    font-size: 14px;
}

.market-item-count {
    color: #eaf1f7;
    font-weight: 600;
}

.market-item-price-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.price-bar-row {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr) 70px;
    gap: 10px;
    align-items: center;
}

.price-bar-label,
.price-bar-num {
    color: #cfd7df;
    font-size: 14px;
    white-space: nowrap;
}

.price-bar-wrap {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, .08);
    overflow: hidden;
    position: relative;
}

.price-bar {
    height: 100%;
    background: linear-gradient(90deg, #c7ccd2 0%, #f2f4f7 100%);
    min-width: 1px;
}

.price-bar-row-highlight .price-bar-label,
.price-bar-row-highlight .price-bar-num {
    color: #ff9a38;
    font-weight: 700;
}

.price-bar-row-highlight .price-bar {
    background: linear-gradient(90deg, #ff8d2a 0%, #ffc06f 100%);
}

.no-price {
    color: rgba(255, 255, 255, .48);
    padding: 8px 0;
}

.market-item-desc {
    padding: 10px 16px;
    color: rgba(255, 255, 255, .58);
    font-size: 14px;
    line-height: 1.6;
    background: rgba(255, 255, 255, .03);
    min-height: 76px;
    display: flex;
    align-items: center;
}

.market-empty {
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, .55);
    font-size: 28px;
    border: 1px dashed rgba(255, 255, 255, .12);
}

@media (max-width: 991.98px) {
    .market-layout {
        grid-template-columns: 1fr;
    }

    .market-tree {
        max-height: 320px;
    }

    .market-content-title {
        font-size: 28px;
    }

    .market-item-card {
        grid-template-columns: 1fr;
    }

    .market-item-left {
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, .08);
    }

    .market-item-name {
        min-height: auto;
        font-size: 18px;
    }

    .market-item-lowest-value {
        font-size: 24px;
    }

    .price-bar-row {
        grid-template-columns: 72px minmax(0, 1fr) 56px;
        gap: 8px;
    }

    .price-bar-label,
    .price-bar-num,
    .market-item-chart-summary {
        font-size: 13px;
    }

    .market-item-desc {
        font-size: 13px;
    }
}


.market-price-icon {
    height: 30px;
    width: auto;
    display: inline-block;
}

.market-item-lowest {
    display: flex;
    align-items: center;
    gap: 10px;
}


.market-item-chart-columns {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr) 70px;
    gap: 10px;
    align-items: center;
    color: rgba(255, 255, 255, .55);
    font-size: 13px;
    margin-bottom: 8px;
}

.market-item-chart-columns .col-num {
    text-align: right;
}

.market-item-snapshot-time {
    color: #b7c2ce;
}

.market-item-history {
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding-top: 8px;
}

.market-item-history>summary {
    color: #d8e1ea;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    list-style: none;
}

.market-item-history>summary::-webkit-details-marker {
    display: none;
}

.market-item-history>summary::before {
    content: "▶ ";
    color: #9fb2c6;
}

.market-item-history[open]>summary::before {
    content: "▼ ";
}

.market-item-history-table-wrap {
    margin-top: 8px;
    overflow-x: auto;
    max-height: 240px;
    overflow-y: auto;
}

.market-item-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.market-item-history-table th,
.market-item-history-table td {
    border: 1px solid rgba(255, 255, 255, .09);
    padding: 5px 8px;
    white-space: nowrap;
}

.market-item-history-table th {
    color: #b8c5d1;
    background: rgba(255, 255, 255, .03);
    font-weight: 600;
}

.market-item-history-table td {
    color: #e6edf4;
}

.market-item-history-chart {
    position: relative;
    margin-top: 8px;
}

.market-history-range-tabs {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.market-history-range-btn {
    border: 1px solid rgba(255, 255, 255, .2);
    background: rgba(255, 255, 255, .04);
    color: #c8d3de;
    font-size: 12px;
    padding: 3px 10px;
    cursor: pointer;
}

.market-history-range-btn.active {
    border-color: #ff9a38;
    color: #fff4e6;
    background: rgba(255, 154, 56, .2);
}

.market-history-line-chart {
    width: 100%;
    height: 280px;
    background: #0c0e12;
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 8px;
}

.market-history-hit {
    cursor: crosshair;
}

.market-history-loading {
    text-align: center;
    color: rgba(255, 255, 255, .6);
}

.market-history-tooltip {
    position: absolute;
    display: none;
    z-index: 3;
    min-width: 180px;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(12, 14, 20, .92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #f2f5f8;
    font-size: 12px;
    line-height: 1.6;
    pointer-events: none;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
    border-radius: 8px;
}

.market-history-tooltip.show {
    display: block;
}

.market-history-tooltip .tt-time {
    color: rgba(255, 255, 255, .55);
    font-size: 11px;
}

.market-history-tooltip strong {
    color: #ff7a6e;
    font-weight: 700;
}
