* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background: #f7f7f5;
    color: #222;
}

header {
    background: #1b2a3a;
    color: #fff;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header a { color: #fff; text-decoration: none; }
.brand { margin: 0; font-size: 1.4rem; font-weight: bold; }
header nav a { margin-left: 1rem; }

.page-title-band {
    background: #1b2a3a;
    height: 225px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem;
    text-align: center;
}

.page-title-band h1 {
    color: #fff;
    margin: 0;
    font-size: 2rem;
    max-width: 900px;
}

main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 1.5rem;
}

input, select, button {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 1rem;
}

button {
    background: #1b2a3a;
    color: #fff;
    border: none;
    cursor: pointer;
}

.layout {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-top: 1rem;
}

.sidebar {
    flex: 0 0 25%;
    max-width: 25%;
    position: sticky;
    top: 1rem;
    background: #fff;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.sidebar-filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-filters label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: #555;
}

.sidebar-filters input,
.sidebar-filters select,
.sidebar-filters button {
    width: 100%;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-group-label {
    font-size: 0.85rem;
    color: #555;
}

.range-slider {
    position: relative;
    height: 20px;
    margin: 0.35rem 0;
}

.range-slider-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    height: 4px;
    background: #ddd;
    border-radius: 2px;
}

.range-slider-fill {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    background: #1b2a3a;
    border-radius: 2px;
}

.range-slider input[type="range"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20px;
    margin: 0;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    z-index: 1;
}

.range-slider input[type="range"]::-webkit-slider-runnable-track {
    -webkit-appearance: none;
    background: transparent;
    height: 20px;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: auto;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    border-radius: 50%;
    background: #1b2a3a;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    cursor: pointer;
}

.range-slider input[type="range"]::-moz-range-track {
    background: transparent;
    height: 20px;
    border: none;
}

.range-slider input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #1b2a3a;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    cursor: pointer;
}

.range-slider .range-max {
    z-index: 2;
}

.range-values {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.range-values input {
    width: 100%;
    min-width: 0;
}

.range-values span {
    color: #999;
}

.results {
    flex: 1 1 0;
    min-width: 0;
}

.sort-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #eef0f2;
    color: #333;
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
    border-radius: 999px;
}

.filter-chip-remove {
    color: #888;
    text-decoration: none;
    font-weight: bold;
    line-height: 1;
}

.filter-chip-remove:hover {
    color: #a30000;
}

.sort-form label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #555;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.pagination .page-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.per-page-form {
    display: flex;
    align-items: center;
}

.per-page-form label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #555;
}

@media (max-width: 800px) {
    .layout {
        flex-direction: column;
    }
    .sidebar {
        flex: 1 1 auto;
        max-width: 100%;
        position: static;
    }
}

@media (min-width: 1400px) {
    .sidebar {
        flex: 0 0 15%;
        max-width: 15%;
    }
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.card {
    position: relative;
    background: #fff;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.source-badge {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}

.card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.card h3 { margin: 0.25rem 0; font-size: 1.05rem; }
.card h3 a { color: #1b2a3a; text-decoration: none; }
.card p { margin: 0.15rem 0; color: #555; font-size: 0.9rem; }
.card small { color: #888; }

.badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    background: #eee;
}
.badge-sold { background: #ffe1e1; color: #a30000; }
.badge-active { background: #e1ffe4; color: #0a7d1e; }
.badge-reserve_not_met { background: #fff3d6; color: #8a6300; }

.listing {
    max-width: 1100px;
    margin: 0 auto;
}

.gallery-main {
    position: relative;
}

.listing .vehicle-image {
    display: block;
    width: 100%;
    max-height: 600px;
    object-fit: contain;
    background: #eee;
    border-radius: 8px;
    cursor: zoom-in;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 2;
}

.gallery-nav:hover { background: rgba(0,0,0,0.75); }
.gallery-nav.prev { left: 0.75rem; }
.gallery-nav.next { right: 0.75rem; }

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.lightbox.open {
    display: flex;
}

.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.25rem;
    line-height: 1;
    cursor: pointer;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    z-index: 1001;
}

.lightbox-nav:hover { background: rgba(255,255,255,0.3); }
.lightbox-nav.prev { left: 1.5rem; }
.lightbox-nav.next { right: 1.5rem; }

.vehicle-thumbs-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.vehicle-thumbs {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
}

.vehicle-thumbs::-webkit-scrollbar {
    display: none;
}

.thumbs-nav {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #1b2a3a;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.vehicle-thumbs-row.has-overflow .thumbs-nav {
    display: flex;
}

.vehicle-thumb {
    flex: 0 0 auto;
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.7;
    border: 2px solid transparent;
}

.vehicle-thumb:hover {
    opacity: 1;
}

.vehicle-thumb.active {
    opacity: 1;
    border-color: #1b2a3a;
}

.listing .price {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0.75rem 0;
}

.listing .specs p { margin: 0.25rem 0; }

.listing .description {
    margin-top: 1rem;
    line-height: 1.5;
}

.button {
    display: inline-block;
    margin-top: 1rem;
    background: #1b2a3a;
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
}

footer {
    text-align: center;
    padding: 1.5rem;
    color: #888;
    font-size: 0.85rem;
}
