/* Compatibility fixes for the existing legacy CSS cascade. */
html body #mainheader .v2-menu-toggle { display:none; }
html body #mainheader::after,
html body #mainheader > .main-container::after { display:none!important; }
html body #mainheader,
html body #mainheader > .main-container { background-image:none!important; }
html body #mainheader { overflow:visible!important; }
html body #mainheader .v2-menu-toggle:focus-visible,
html body #v2-main-menu a:focus-visible { outline:2px solid #a2dd2a;outline-offset:3px; }

@media(max-width:1024px) {
    html body #mainheader { position:relative!important;z-index:10001!important;height:80px!important; }
    html body #mainheader > .main-container { display:flex!important;align-items:center!important;justify-content:space-between!important;position:relative!important;width:100%!important;max-width:none!important;height:80px!important;margin:0!important;padding:0 15px!important;box-sizing:border-box!important;transform:none!important; }
    html body #mainheader .top-logo { position:static!important;float:none!important;display:flex!important;align-items:center!important;width:auto!important;height:80px!important;margin:0!important;padding:0!important; }
    html body #mainheader .top-logo img { width:170px!important;height:auto!important; }
    html body #mainheader .header-menu { position:static!important;float:none!important;width:auto!important;height:auto!important;line-height:normal!important;margin:0!important;padding:0!important;transform:none!important; }
    html body #mainheader .v2-menu-toggle { display:flex!important;flex-direction:column;align-items:center;justify-content:center;gap:7px;width:44px;height:44px;padding:8px;border:0;background:transparent;cursor:pointer; }
    html body #mainheader .v2-menu-toggle span { display:block;width:28px;height:2px;background:#dcddde; }
    html body #mainheader #v2-main-menu { display:none!important;position:absolute!important;top:80px!important;left:0!important;right:0!important;width:100%!important;height:auto!important;max-height:calc(100dvh - 80px);overflow-y:auto;box-sizing:border-box;float:none!important;margin:0!important;padding:12px 15px!important;background:#58595b;box-shadow:0 5px 10px #0003; }
    html body #mainheader.v2-menu-open #v2-main-menu { display:flex!important;flex-direction:column;align-items:stretch!important;gap:0!important; }
    html body #mainheader #v2-main-menu li { display:block!important;float:none!important;width:auto!important;margin:0!important;padding:0!important; }
    html body #mainheader #v2-main-menu a { display:flex;align-items:center;min-height:44px;padding:0 12px;font-size:15px!important;line-height:1.4!important;color:#e9e9e9!important; }
    html body #logodiv { width:100%!important;max-width:100%!important; }
}

@media(max-width:1600px) {
    html body .search-box:has(.v2-search-form) { position:relative!important;height:auto!important;min-height:0!important;max-height:none!important;padding:28px 15px!important;overflow:visible!important;box-sizing:border-box!important; }
    html body .search-box .main-container:has(.v2-search-form),
    html body .search-box .filter:has(.v2-search-form),
    html body .search-box .v2-search-form { position:static!important;inset:auto!important;float:none!important;width:100%!important;max-width:none!important;height:auto!important;min-height:0!important;max-height:none!important;margin:0!important;padding:0!important;box-sizing:border-box!important; }
    html body .v2-search-form .v2-search-title { display:block!important;position:static!important;transform:none!important;width:auto!important;height:auto!important;margin:0 0 20px!important;padding:0!important;line-height:1.2!important; }
    html body .v2-search-form .field-data { position:static!important;inset:auto!important;display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;grid-template-rows:none!important;grid-auto-rows:auto!important;gap:12px!important;width:100%!important;max-width:none!important;height:auto!important;margin:0!important;padding:0!important;box-sizing:border-box!important; }
    html body .v2-search-form .field-data > :is(.v2-field,.cancel-btn,.send-btn) { position:static!important;float:none!important;grid-column:auto!important;grid-row:auto!important;width:100%!important;min-width:0!important;height:44px!important;margin:0!important;padding:0!important; }
    html body .v2-search-form .field-data select,
    html body .v2-search-form .field-data input { display:block!important;box-sizing:border-box!important;width:100%!important;min-width:0!important;max-width:100%!important;height:44px!important;font-size:16px!important; }
    html body .resultlist { position:relative!important;top:auto!important;float:none!important;width:100%!important;max-width:100%!important;margin:0!important;box-sizing:border-box!important; }
    html body .resultlist .v2-market { position:relative!important;left:auto!important;width:calc(100% - 30px)!important;max-width:none!important;margin:0 15px 45px!important;transform:none!important;box-sizing:border-box!important; }
    html body .v2-market .v2-offer-grid { display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:15px!important; }
    html body .v2-market .v2-offer-card { width:auto!important;max-width:100%!important;height:auto!important;box-sizing:border-box!important; }
    html body .v2-market .v2-offer-card > img,
    html body .v2-market .v2-offer-card > i { width:100%!important;height:auto!important;aspect-ratio:4/3;object-fit:cover; }
    html body .v2-market #v2-compare-bar { width:min(370px,100%)!important;max-width:100%!important;margin:24px 0!important;float:none!important;box-sizing:border-box!important; }
    html body .v2-market .v2-market-pages { flex-wrap:wrap; }
    html body .v2-market .v2-market-pages > * { display:inline-flex!important; }
}
@media(min-width:601px) and (max-width:900px) {
    html body .v2-search-form .field-data { grid-template-columns:repeat(2,minmax(0,1fr))!important; }
}
@media(max-width:900px) {
    html body .v2-market .v2-market-head { display:none!important; }
    html body .v2-market .v2-market-row { display:flex!important;width:100%!important;height:auto!important;min-height:79px!important;box-sizing:border-box!important; }
    html body .v2-market .v2-market-car { display:flex!important;flex:1;min-width:0;width:auto!important;height:auto!important;gap:12px!important;padding:9px!important;box-sizing:border-box!important; }
    html body .v2-market .v2-market-car span { overflow-wrap:anywhere; }
    html body .v2-market .v2-market-car b { display:block!important; }
    html body .v2-market .v2-market-cell { display:none!important; }
    html body .v2-market .v2-market-compare { display:block!important;flex:0 0 44px;width:44px!important;min-height:44px; }
    html body .v2-market .v2-offer-grid { grid-template-columns:minmax(0,1fr)!important; }
    html body .v2-market .v2-offer-card { display:grid!important;grid-template-columns:82px minmax(0,1fr);gap:15px;min-height:83px; }
    html body .v2-market .v2-offer-card > img,
    html body .v2-market .v2-offer-card > i { width:82px!important;height:60px!important; }
    html body .v2-market .v2-offer-card b:last-child { position:static!important; }
}
@media(max-width:600px) {
    html body .v2-search-form .field-data { grid-template-columns:repeat(2,minmax(0,1fr))!important; }
    html body .v2-search-form .field-data > .v2-field { grid-column:1 / -1!important; }
    html body .v2-search-form .field-data > .cancel-btn,
    html body .v2-search-form .field-data > .send-btn { margin-top:8px!important; }
    html body .v2-compare-footer { height:auto!important;min-height:500px;padding-bottom:25px; }
    html body .v2-compare-footer > p { width:auto!important;margin:40px 15px 25px!important;font-size:12px; }
    html body .v2-company-details { font-size:12px;overflow-wrap:anywhere; }
}
@media(min-width:1200px) and (max-width:1600px) {
html body .v2-search-form .field-data { grid-template-columns:repeat(6,minmax(0,1fr))!important; }
}

/* The legacy script assigns a viewport height to the results container.
   Let the complete list and asynchronously loaded offers establish its height. */
html body .resultlist:has(> .v2-market) {
    display:flow-root!important;height:auto!important;min-height:0!important;
    max-height:none!important;overflow:visible!important;
}
html body .resultlist .v2-market h1::after { content:none!important;display:none!important; }
html body:has(.v2-market) .footer-map,
html body:has(.v2-market) .footer-main { clear:both!important; }

html body .v2-compare-details > summary { display:none; }
.v2-visually-hidden { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0; }
@media(max-width:1024px) {
    html body .sub-header { height:clamp(90px,25vw,180px)!important;min-height:0!important;overflow:hidden!important; }
    html body .sub-header > img:first-child {
        display:block!important;visibility:visible!important;width:100%!important;
        height:100%!important;object-fit:cover!important;object-position:center;
    }
}
@media(max-width:760px) {
    html body:has(.v2-compare-page) .sub-header { display:none!important; }
    html body .v2-compare-page { padding:24px 15px 35px!important; }
    html body .v2-compare-shell { width:100%!important;min-width:0; }
    html body .v2-compare-tools { flex-wrap:wrap;gap:12px;margin-bottom:24px!important; }
    html body .v2-compare-page h1 { margin-bottom:20px!important; }
    html body .v2-compare-cards { display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:16px!important;overflow:visible!important;padding:0!important; }
    html body .v2-compare-card {
        display:grid!important;grid-template-columns:96px minmax(0,1fr);gap:8px 12px;
        width:100%!important;min-width:0;box-sizing:border-box;padding:16px!important;
        align-items:start;
    }
    html body .v2-compare-card > img,
    html body .v2-compare-card > .v2-compare-no-photo {
        grid-column:1;grid-row:1 / 3;width:96px!important;height:72px!important;
        margin:0!important;object-fit:cover;
    }
    html body .v2-compare-card > .v2-compare-name {
        grid-column:2;grid-row:1;min-height:0!important;margin:0!important;
        padding:0 30px 0 0!important;font-size:14px!important;line-height:1.35;
        overflow-wrap:anywhere;
    }
    html body .v2-compare-card > .v2-compare-spec {
        grid-column:2;grid-row:2;min-height:0!important;padding:0!important;border:0;
    }
    html body .v2-compare-card > .v2-compare-remove {
        right:5px!important;top:5px!important;width:36px;min-height:36px;
    }
    html body .v2-compare-details { grid-column:1 / -1;min-width:0;margin-top:4px; }
    html body .v2-compare-details > summary {
        display:list-item;box-sizing:border-box;min-height:44px;padding:12px;
        background:#eef0e9;cursor:pointer;font-size:14px;font-weight:bold;
    }
    html body .v2-compare-details > summary:focus-visible { outline:2px solid #658b15;outline-offset:2px; }
    html body .v2-compare-details .v2-compare-spec { min-height:0!important;padding:10px 12px!important;overflow-wrap:anywhere; }
}

/* Keep latest-car thumbnails independent of vehicle-name length on phones. */
@media (max-width:760px) {
    html body .main-container .right-sidebar .side-box-list .item {
        display:grid!important;grid-template-columns:96px minmax(0,1fr);
        column-gap:12px;row-gap:4px;align-items:start;
    }
    html body .main-container .right-sidebar .side-box-list .item > .car-img {
        grid-column:1;grid-row:1 / 3;width:96px!important;height:72px!important;
        min-width:96px;max-width:96px;object-fit:cover;object-position:center;margin:0!important;
    }
    html body .main-container .right-sidebar .side-box-list .item > .car-name {
        grid-column:2;grid-row:1;min-width:0;width:auto!important;height:auto!important;padding:0!important;overflow-wrap:anywhere;
    }
    html body .main-container .right-sidebar .side-box-list .item > .car-price {
        grid-column:2;grid-row:2;position:static!important;width:auto!important;height:auto!important;padding:0!important;margin:0!important;text-align:left!important;
    }
}

/* Constrain the legacy info-page tables and give both text edges equal space. */
@media (max-width:760px) {
    html body .custom-container:has(.main-info) {
        width:90%!important;max-width:90%!important;margin-left:auto!important;margin-right:auto!important;
    }
    html body .custom-container:has(.main-info) .full-content,
    html body .custom-container:has(.main-info) table {
        width:100%!important;max-width:100%!important;table-layout:fixed;
    }
    html body .main-info > .main-container {
        width:90%!important;max-width:90%!important;margin-left:auto!important;margin-right:auto!important;
        overflow-wrap:anywhere;
    }
}

@media (max-width:760px) {
    html body .custom-container:has(.main-info) td { width:auto!important;min-width:0!important; }
}
