:root {
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #222222);
    --hint: var(--tg-theme-hint-color, #999999);
    --btn: var(--tg-theme-button-color, #248bcf);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --sec-bg: var(--tg-theme-secondary-bg-color, #f5f5f5);
    --price-main: #31b545;
    --border: rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 12px;
    transition: padding-top 0.3s ease-out;
}

.flex-center { display: flex; align-items: center; gap: 8px; }

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg);
    z-index: 110;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.tabs { display: flex; padding: 10px 12px 5px; gap: 8px; }

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border-radius: 10px;
    background: var(--sec-bg);
    color: var(--hint);
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
}

.tab.active { background: var(--btn); color: var(--btn-text); }

.filter-panel { border-top: 1px solid rgba(0, 0, 0, 0.05); }

.filter-toggle {
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    color: var(--text);
    background: var(--sec-bg);
}

.filter-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg);
    overflow: hidden;
    max-height: 260px;
    opacity: 1;
    transition: max-height 0.28s ease, opacity 0.22s ease, padding 0.28s ease;
}

.filter-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

.filter-row { display: flex; gap: 8px; width: 100%; }

select,
.filter-row input {
    padding: 10px;
    border-radius: 8px;
    width: 100%;
    background: var(--sec-bg);
    color: var(--text);
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}

#brand-select, #model-select, #date-select { flex: 1; }
#search-bid { width: 30%; flex: none; }
#search-frame { width: calc(70% - 8px); flex: none; }

.filter-actions { display: flex; gap: 8px; width: 100%; margin-top: 2px; }

.search-btn,
.reset-btn,
.detail-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 14px;
    border: none;
    cursor: pointer;
    box-sizing: border-box;
}

.search-btn { flex: 2; background: var(--btn); color: var(--btn-text); }
.reset-btn { flex: 1; background: var(--sec-bg); color: var(--text); border: 1px solid rgba(0, 0, 0, 0.1); }

.card {
    background: var(--sec-bg);
    border-radius: 16px;
    margin-bottom: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.img-container {
    width: 100%;
    aspect-ratio: 4 / 3;
    position: relative;
    overflow: hidden;
    background: var(--sec-bg);
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.4s;
}

.card img.loaded { opacity: 1; }
.card .swiper { width: 100%; height: 100%; }
.card .swiper-slide { height: 100%; display: flex; align-items: center; justify-content: center; }

.no-photo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: rgba(128, 128, 128, 0.1);
    color: var(--hint);
    gap: 12px;
}

.no-photo i { font-size: 3.5em; opacity: 0.3; }
.no-photo span { font-size: 13px; font-weight: bold; opacity: 0.5; letter-spacing: 0.5px; }

.auction-timer {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: bold;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: bold;
    color: #fff;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-sold { background: #31b545; }
.status-not-sold { background: #f44336; }
.status-available { background: #248bcf; }
.status-not-inspected { background: #9e9e9e; }

.info { padding: 18px; }
.title { font-size: 1.15em; font-weight: bold; margin-bottom: 8px; }
.specs { font-size: 0.9em; color: var(--hint); line-height: 1.5; margin-bottom: 16px; }

.price-container {
    background: rgba(49, 181, 69, 0.05);
    padding: 12px;
    border-radius: 10px;
    border-left: 4px solid var(--price-main);
    margin-bottom: 15px;
}

.price-item { margin-bottom: 4px; }
.price-item.final-price { font-size: 1.15em; color: var(--price-main); font-weight: bold; }
.price-item.final-price b { font-size: 1.1em; font-weight: 900; margin-left: 5px; }
.price-item.start-price { font-size: 1.1em; color: var(--text); }
.price-item.start-price b { font-weight: 900; margin-left: 5px; }
.price-avg { font-size: 0.9em; color: var(--hint); margin-top: 6px; border-top: 1px solid rgba(0, 0, 0, 0.05); padding-top: 6px; }

.card-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }

.detail-btn {
    width: 100%;
    background: linear-gradient(135deg, #10253a, #274866);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.detail-columns {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.detail-column {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
}

.detail-column-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.buy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    background: var(--btn);
    color: var(--btn-text);
    text-decoration: none;
    border-radius: 12px;
    font-weight: bold;
    box-sizing: border-box;
    border: none;
    cursor: pointer;
}

.auction-meta {
    margin-top: 10px;
    color: var(--hint);
    font-size: 12px;
    text-align: center;
}

#full-photo {
    display: none;
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 2000;
}

.full-swiper { width: 100%; height: 100%; }
.swiper-zoom-container { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.swiper-zoom-container img { max-width: 100%; max-height: 100%; object-fit: contain; }

.close-full,
.detail-close {
    border: none;
    background: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
}

.close-full {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2020;
}

.full-photo-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px;
    color: #fff;
    z-index: 2010;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    text-align: left;
}

.full-photo-header .bike-name { font-weight: bold; color: #fff !important; }
.full-photo-header .lot-num { color: #fff !important; opacity: 0.8; font-size: 0.9em; }
.full-photo-header .photo-caption { color: #fff !important; opacity: 0.85; font-size: 0.9em; margin-top: 6px; }

.date-divider { text-align: center; margin: 25px 0 15px; position: relative; }
.date-divider::before { content: ""; position: absolute; width: 100%; height: 1px; background: var(--hint); opacity: 0.2; top: 50%; left: 0; }
.date-divider span { background: var(--bg); padding: 0 15px; color: var(--hint); font-size: 12px; font-weight: bold; z-index: 2; position: relative; }

#loading {
    text-align: center;
    color: var(--hint);
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

#loading i { font-size: 2em; opacity: 0.7; }

#lot-detail {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1800;
}

.detail-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
}

.detail-panel {
    position: absolute;
    inset: 12px;
    background: var(--bg);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--btn), #0b5f96);
    color: #fff;
}

.detail-kicker {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.8;
    margin-bottom: 6px;
}

.detail-title {
    font-size: 19px;
    font-weight: 800;
    line-height: 1.1;
}

.detail-subtitle {
    margin-top: 6px;
    font-size: 12px;
    opacity: 0.85;
}

.detail-content {
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-section {
    background: var(--sec-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
}

.detail-section-title {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.detail-split-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.detail-field {
    background: var(--bg);
    border-radius: 12px;
    padding: 9px 10px;
    border: 1px solid var(--border);
}

.detail-field span {
    display: block;
    font-size: 11px;
    color: var(--hint);
    margin-bottom: 5px;
}

.detail-field strong {
    display: block;
    font-size: 14px;
    line-height: 1.3;
}

.detail-field-wide {
    grid-column: 1 / -1;
}

.detail-gallery-grid,
.detail-sheet-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.detail-sheet-list {
    grid-template-columns: 1fr;
}

.detail-main-swiper {
    width: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: #d7d7d7;
    padding-bottom: 34px;
}

.detail-gallery-slide {
    position: relative;
    display: block;
    background: #d7d7d7;
    min-height: 100%;
}

.detail-gallery-hero {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #d7d7d7;
    cursor: pointer;
}

.detail-photo-caption {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 42px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 12px;
    color: #fff;
    text-align: center;
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(4px);
}

.detail-rank-swiper {
    margin-top: 10px;
    border-radius: 14px;
    overflow: hidden;
    background: #d7d7d7;
    padding-bottom: 34px;
}

.detail-main-swiper .swiper-pagination {
    bottom: 18px !important;
}

.detail-rank-swiper .swiper-pagination {
    bottom: 18px !important;
}

.detail-gallery-thumb,
.detail-sheet-image {
    width: 100%;
    border-radius: 12px;
    background: #d9d9d9;
    cursor: pointer;
}

.detail-gallery-thumb {
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.detail-sheet-image {
    max-height: 70vh;
    object-fit: contain;
    background: #fff;
}

.detail-chip-row,
.detail-rank-values {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-chip-row {
    margin-top: 10px;
}

.detail-chip {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(36, 139, 207, 0.08);
    border: 1px solid rgba(36, 139, 207, 0.18);
    color: var(--text);
    font-size: 12px;
}

.detail-chip.is-active {
    background: rgba(36, 139, 207, 0.14);
    border-color: rgba(36, 139, 207, 0.28);
    color: var(--text);
}

.detail-chip.is-inactive {
    background: rgba(145, 158, 171, 0.12);
    border-color: rgba(145, 158, 171, 0.22);
    color: var(--hint);
}

.detail-chip-row-wide {
    margin-top: 0;
}

.detail-subsection {
    margin-top: 12px;
}

.detail-subsection-title {
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 8px;
}

.detail-note-list,
.detail-rank-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detail-note-item,
.detail-rank-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

.detail-note-label,
.detail-rank-name {
    font-size: 12px;
    color: var(--hint);
    margin-bottom: 6px;
}

.detail-note-value {
    line-height: 1.5;
    font-size: 14px;
}

.detail-bullet-list {
    margin: 0;
    padding-left: 18px;
}

.detail-bullet-list li + li {
    margin-top: 6px;
}

.detail-empty {
    color: var(--hint);
    font-size: 14px;
}

.detail-guide {
    margin-top: 12px;
    border: 1px solid rgba(36, 139, 207, 0.18);
    border-radius: 14px;
    background: rgba(36, 139, 207, 0.06);
    overflow: hidden;
}

.detail-guide summary {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 44px 12px 14px;
    cursor: pointer;
    font-weight: 700;
    color: var(--btn);
    list-style: none;
    user-select: none;
}

.detail-guide summary::-webkit-details-marker {
    display: none;
}

.detail-guide summary::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.85;
    transition: transform 0.2s ease;
}

.detail-guide[open] summary::after {
    transform: translateY(-50%) rotate(180deg);
}

.detail-guide[open] summary {
    border-bottom: 1px solid rgba(36, 139, 207, 0.14);
    background: rgba(36, 139, 207, 0.08);
}

.detail-guide-content {
    padding: 12px 14px 14px;
    color: var(--text);
    line-height: 1.55;
    font-size: 14px;
}

.detail-guide-content p {
    margin: 0 0 10px;
}

.detail-video-card {
    position: relative;
    display: block;
    text-decoration: none;
    color: inherit;
}

.detail-link-card {
    min-height: 76px;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, #8b0000, #d92323);
}

.detail-video-play {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.68);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

@media (max-width: 640px) {
    .detail-panel {
        inset: 0;
        border-radius: 0;
    }

    .detail-gallery-grid,
    .detail-sheet-list {
        grid-template-columns: 1fr;
    }

    .detail-header {
        padding: 12px 14px;
    }

    .detail-title {
        font-size: 18px;
    }

    .detail-column {
        padding: 8px;
    }

    .detail-column-title {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .detail-grid,
    .detail-split-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .detail-field {
        padding: 8px;
    }

    .detail-field strong {
        font-size: 13px;
    }
}
