/* ============================================================================
   AvtoDvorGE — Desktop & Standalone Web Optimization Layer (v1)
   Strictly isolated so mobile Telegram Mini App (<768px / not .is-web)
   remains 100% untouched.
   - Universal web fixes (html.is-web) contain ONLY non-layout fixes
     (color-scheme, modal close button, undefined .upsell-card, scrollbars).
   - ALL desktop grids, containers, sticky header bleed, tab badges,
     2-col detail layout, and hover rules live strictly inside @media blocks.
   ============================================================================ */

/* ---------- 1. Universal Web Fixes (safe on both mobile & desktop web) ---------- */
html.is-web {
  color-scheme: dark;
  scrollbar-color: rgba(255, 255, 255, 0.2) #09090b;
  scrollbar-width: thin;
}

/* Fix unstyled .sheet-close buttons & h3 headers in web modals
   (#auth-modal, #account-sheet, #notif-sheet, #legal-sheet) */
.sheet-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.sheet-close:active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-main);
}
.sheet-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-main);
}

/* Compact icon wrapper for header notification bell badge */
.notif-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}
.notif-icon-wrap .header-notif-badge {
  position: absolute;
  top: -7px;
  right: -8px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  border: 2px solid #0a0a0e;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Fix undefined .upsell-card in Services -> Selection form */
.upsell-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  cursor: pointer;
  margin-bottom: 10px;
}

/* Hidden on mobile; revealed only on desktop >= 960px */
.detail-thumbs {
  display: none;
}

/* Consistent keyboard focus-visible indicator in web mode */
html.is-web :is(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid rgba(229, 181, 103, 0.85);
  outline-offset: 2px;
}

/* ---------- 2. Pointer / Mouse Hover & Dark Scrollbars ---------- */
@media (hover: hover) and (pointer: fine) {
  * {
    scrollbar-color: rgba(255, 255, 255, 0.2) #0a0a0d;
    scrollbar-width: thin;
  }
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: #0a0a0d; }
  ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 99px; }
  ::-webkit-scrollbar-thumb:hover { background: rgba(229, 181, 103, 0.62); }

  /* Fix broken hover transition on .car-card (beats styles.css:3205 !important) */
  .car-card,
  .rental-card,
  .sel-car-card {
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s ease, box-shadow 0.2s ease !important;
  }
  .car-card:hover,
  .rental-card:hover,
  .sel-car-card:hover {
    transform: translateY(-3px);
    border-color: rgba(229, 181, 103, 0.44) !important;
    box-shadow: 0 16px 34px -14px rgba(0, 0, 0, 0.82), inset 0 1px 0 rgba(255, 255, 255, 0.12) !important;
  }

  /* Fix dead hover on .tabs-pill .tab-btn (beats background: transparent !important) */
  .tabs-pill .tab-btn:hover:not(.active) {
    color: var(--text-main) !important;
    background: rgba(255, 255, 255, 0.065) !important;
  }

  .sheet-close:hover,
  .car-picker-close:hover,
  .detail-circle-btn:hover,
  .btn-header-notif:hover {
    background: rgba(255, 255, 255, 0.13);
    border-color: rgba(229, 181, 103, 0.42);
    color: var(--text-main);
  }

  .q-pill,
  .btn-filter-trigger,
  .btn-alert-icon,
  .admin-subtab-btn,
  .adm-q-pill,
  .tag-chip,
  .seg-btn,
  .vip-option-btn,
  .bargain-opt-btn,
  .brand-select-btn,
  .custom-select-btn,
  .active-filter-chip,
  .car-picker-item,
  .btn-my-action,
  .btn-adm-ok,
  .btn-adm-sold,
  .btn-adm-edit,
  .admin-quick-pill,
  .admin-sys-btn-sec,
  .btn-detail-primary,
  .btn-detail-secondary,
  .btn-detail-vin-inline,
  .btn-detail-post-bottom,
  .ct-link-btn,
  .vin-copy-card,
  .ct-num-row,
  .similar-card,
  .seller-showcase-btn,
  .vincheck-auction-item,
  .btn-sheet-reset,
  .btn-sheet-apply {
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.14s ease;
  }

  .q-pill:hover:not(.active),
  .btn-filter-trigger:hover,
  .btn-alert-icon:hover,
  .admin-subtab-btn:hover:not(.active),
  .adm-q-pill:hover:not(.active),
  .tag-chip:hover:not(.active),
  .seg-btn:hover:not(.active-amber):not(.active-green),
  .vip-option-btn:hover:not(.active),
  .bargain-opt-btn:hover:not(.active),
  .brand-select-btn:hover,
  .custom-select-btn:hover:not(:disabled),
  .admin-quick-pill:hover,
  .admin-sys-btn-sec:hover,
  .btn-sheet-reset:hover {
    border-color: rgba(229, 181, 103, 0.42);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
  }

  .car-picker-item:hover,
  .vin-copy-card:hover,
  .ct-num-row:hover,
  .seller-showcase-btn:hover,
  .vincheck-auction-item:hover {
    border-color: rgba(229, 181, 103, 0.42);
    background: rgba(255, 255, 255, 0.065);
  }

  .similar-card:hover {
    transform: translateY(-2px);
    border-color: rgba(229, 181, 103, 0.42);
  }

  .ct-link-btn:hover {
    background: rgba(229, 181, 103, 0.22);
    border-color: rgba(229, 181, 103, 0.55);
  }
  .ct-link-btn.is-port:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.48);
  }

  .btn-detail-vin-inline:hover,
  .btn-detail-post-bottom:hover {
    border-color: rgba(229, 181, 103, 0.48);
    background: rgba(229, 181, 103, 0.14);
  }

  .btn-my-action:hover,
  .btn-adm-edit:hover {
    filter: brightness(1.1);
  }
  .btn-adm-ok:hover {
    filter: brightness(1.08);
  }
  .btn-adm-sold:hover {
    background: rgba(239, 68, 68, 0.22);
  }
  .btn-sheet-apply:hover,
  .btn-detail-primary:hover,
  .admin-sys-btn-primary:hover {
    filter: brightness(1.06);
  }
}

/* ---------- 3. Tablet & Small Laptop (>= 768px) ---------- */
@media (min-width: 768px) {
  html.is-web {
    scrollbar-gutter: stable;
  }

  body {
    overflow-x: clip;
  }

  /* Block background mouse-wheel scroll behind open modals on desktop web */
  html.is-web body.has-bottom-sheet,
  html.is-web body.sheet-open {
    overflow: hidden;
  }

  #app-shell {
    max-width: 1280px;
    margin: 0 auto;
  }

  /* Full-bleed sticky top header across 1024px–2560px (never chopped off at edges) */
  .top-header {
    width: 100vw;
    margin: 0 calc(50% - 50vw) 16px calc(50% - 50vw) !important;
    padding: 12px 24px !important;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .top-header .brand-row {
    max-width: 1280px;
    margin: 0 auto;
    gap: 16px;
  }
  .header-actions {
    gap: 10px;
  }

  /* Equal-height catalog & rental cards */
  .catalog-list {
    align-items: stretch !important;
  }
  .catalog-list .car-card,
  .rental-grid .rental-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin-bottom: 0 !important;
  }
  .catalog-list .car-body {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  .catalog-list .car-cta {
    margin-top: auto;
  }
  .catalog-list .car-title-row {
    align-items: flex-start;
  }
  .catalog-list .car-title {
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .catalog-list .car-spec-line {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .catalog-list .car-skel-card {
    margin-bottom: 0;
  }

  /* Center #rental-detail-modal as desktop dialog instead of bottom drawer */
  .rental-modal-overlay {
    align-items: center !important;
    justify-content: center !important;
    padding: 24px;
  }
  .rental-modal-sheet {
    width: min(640px, calc(100vw - 48px)) !important;
    max-width: 640px !important;
    max-height: 88dvh !important;
    border-radius: 22px !important;
    border: 1px solid var(--border-strong) !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85) !important;
  }

  /* Hide leftover mobile drag handle in car-picker-sheet */
  .car-picker-sheet .car-picker-handle {
    display: none !important;
  }
  .car-picker-sheet.is-select-mode {
    height: auto !important;
    max-height: min(560px, 76dvh) !important;
  }
  .brand-logo-badge.size-md {
    width: 44px;
    height: 32px;
  }
  .active-filter-chip:hover {
    background: rgba(229, 181, 103, 0.22);
    border-color: rgba(229, 181, 103, 0.56);
  }
  .active-filter-chip.is-reset:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(229, 181, 103, 0.4);
    color: var(--text-main);
  }

  /* Ensure consistent modal max-height */
  .bottom-sheet {
    max-height: 90vh !important;
    max-height: 90dvh !important;
  }

  /* Fix .calc-footer stretching 100vw & align overlay headers with their content columns */
  .calc-footer {
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
    border-radius: 16px 16px 0 0;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  #calc-overlay .compare-header,
  #vincheck-overlay .vincheck-header {
    padding-left: max(20px, calc((100vw - 820px) / 2)) !important;
    padding-right: max(20px, calc((100vw - 820px) / 2)) !important;
  }
  #compare-overlay .compare-header {
    padding-left: max(20px, calc((100vw - 1200px) / 2)) !important;
    padding-right: max(20px, calc((100vw - 1200px) / 2)) !important;
  }

  /* Services -> Selection verified cars: proper 2-col grid & 16/10 cover (no 7:1 sliver!) */
  .sel-car-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 16px !important;
  }
  .sel-car-cover {
    height: auto !important;
    aspect-ratio: 16 / 10 !important;
  }
  .rnt-subtabs {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
  }
}

/* ---------- 4. Desktop (>= 960px) ---------- */
@media (min-width: 960px) {
  body {
    padding: 0 28px 48px 28px !important;
  }

  .top-header {
    padding: 13px 28px !important;
  }

  /* === FIX CRITICAL TAB COUNTER OVERLAP & NAVIGATION PILL === */
  .tabs-pill {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: fit-content !important;
    min-width: 0 !important;
    max-width: min(860px, calc(100% - 16px)) !important;
    gap: 4px !important;
    padding: 6px !important;
    border-radius: 15px !important;
    top: 66px !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    margin: 0 auto 20px auto !important;
  }
  .tabs-pill .nav-active-pill {
    border-radius: 11px !important;
  }
  .tabs-pill .tab-btn,
  .tabs-pill.has-admin .tab-btn,
  .tabs-pill.has-services .tab-btn,
  .tabs-pill.has-admin.has-services .tab-btn {
    flex: 0 0 auto !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 9px 16px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    border-radius: 11px !important;
    min-width: 0 !important;
  }
  .tabs-pill .tab-btn > span:not(.tab-count) {
    max-width: none !important;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
  }

  /* CRITICAL FIX: Inline counter badge strictly to the right of text (never position: absolute!) */
  .tabs-pill .tab-count,
  .tabs-pill .tab-count-alert {
    position: static !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    bottom: auto !important;
    transform: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 20px !important;
    height: 20px !important;
    padding: 0 6px !important;
    margin-left: 2px !important;
    border-radius: 999px !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    font-variant-numeric: tabular-nums !important;
    flex-shrink: 0 !important;
  }
  .tabs-pill .tab-count[style*="display: none"],
  .tabs-pill .tab-count[style*="display:none"] {
    display: none !important;
  }

  /* Fix Compare Dock specificity bug (beats #compare-dock at styles.css:3333) */
  #compare-dock.compare-dock {
    bottom: 24px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: min(560px, calc(100vw - 48px)) !important;
  }

  /* === DESKTOP CATALOG FILTER BAR === */
  .catalog-toolbar {
    gap: 10px;
    margin-bottom: 12px;
  }
  .search-input-wrap {
    max-width: 480px;
  }
  .quick-pills {
    flex-wrap: wrap !important;
    overflow-x: visible !important;
    gap: 8px !important;
    padding-bottom: 0 !important;
    margin-bottom: 16px !important;
  }
  .q-pill {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Constrain Catalog Selection CTA card so form/CTA doesn't stretch 1240px */
  .cat-sel-card {
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }

  /* === DESKTOP 2-COLUMN CAR DETAIL OVERLAY + THUMBNAILS === */
  .detail-overlay {
    padding: 20px 24px 0 24px;
    cursor: pointer;
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
  }
  .detail-scroll {
    cursor: default;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    max-width: 1160px !important;
    width: 100% !important;
    margin: 0 auto !important;
    background: #0d0d11 !important;
    border: 1px solid var(--border-strong);
    border-bottom: none;
    border-radius: 22px 22px 0 0;
    display: grid !important;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) !important;
    gap: 28px !important;
    align-items: start !important;
    padding: 22px 26px 28px 26px !important;
  }
  .detail-gallery-col {
    position: sticky;
    top: 20px;
    min-width: 0;
  }
  .detail-gallery-wrap {
    position: relative !important;
    top: auto !important;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #070709;
  }
  /* Remove leftover mobile fade gradient at bottom of photo */
  .detail-gallery-wrap::after {
    display: none !important;
    content: none !important;
  }
  .detail-gallery {
    max-height: 58vh;
    aspect-ratio: 16 / 11;
  }
  /* Make gallery prev/next arrows always discoverable on desktop */
  .detail-gal-nav {
    opacity: 0.78 !important;
    width: 38px !important;
    height: 38px !important;
  }

  /* Clickable Thumbnail Strip under Car Detail Gallery (Desktop only) */
  .detail-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
  }
  .detail-thumb-btn {
    position: relative;
    width: 72px;
    height: 52px;
    padding: 0;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: #141419;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.68;
    transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.14s ease;
  }
  .detail-thumb-btn:hover {
    opacity: 0.95;
    border-color: rgba(229, 181, 103, 0.55);
    transform: translateY(-1px);
  }
  .detail-thumb-btn.is-active {
    opacity: 1;
    border-color: var(--accent, #e5b567);
    box-shadow: 0 0 0 1px rgba(229, 181, 103, 0.35);
  }
  .detail-thumb-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .detail-thumb-video {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: linear-gradient(135deg, rgba(229, 181, 103, 0.2), rgba(20, 20, 26, 0.95));
    color: var(--accent-bright, #f5ce86);
    font-size: 9.5px;
    font-weight: 800;
  }

  /* Clean desktop detail footer docked outside scroll container (zero overlap) */
  .detail-footer {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    flex-shrink: 0 !important;
    cursor: default;
    max-width: 1160px !important;
    width: 100% !important;
    margin: 0 auto !important;
    background: rgba(13, 13, 17, 0.98) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-strong) !important;
    border-left: 1px solid var(--border-strong) !important;
    border-right: 1px solid var(--border-strong) !important;
    padding: 14px 26px !important;
    justify-content: flex-end;
    gap: 10px;
  }
  .detail-footer .btn-detail-primary,
  .detail-footer .btn-detail-secondary {
    max-width: 290px;
  }

  /* === FORMS & CABINET === */
  #view-sell {
    max-width: 800px !important;
    margin: 0 auto;
  }
  html.is-web #view-sell .sell-footer {
    align-items: center;
  }
  html.is-web #view-sell .btn-sell-submit {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  #view-my {
    max-width: 1140px !important;
    margin: 0 auto;
  }
  #my-cars-container,
  #my-incoming-container,
  #my-alerts-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }
  #my-cars-container > .empty-state,
  #my-cars-container > .my-section-divider,
  #my-cars-container > h4,
  #my-incoming-container > .empty-state,
  #my-alerts-container > .empty-state {
    grid-column: 1 / -1;
  }
  #my-cars-container .my-car-card,
  #my-incoming-container .incoming-card,
  #my-alerts-container .alert-card {
    margin-bottom: 0;
  }

  /* === SERVICES VIEW === */
  #view-services {
    max-width: 1220px !important;
    margin: 0 auto;
  }
  .srv-hero-card {
    padding: 20px !important;
  }
  .srv-disclaimer {
    margin-top: 14px;
    padding: 12px 16px;
    font-size: 12px;
  }
  .srv-perks {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  .srv-hero-card form,
  .srv-request-box {
    max-width: 780px;
  }

  /* === ADMIN PANEL ON DESKTOP === */
  #view-admin {
    max-width: 1220px !important;
    margin: 0 auto;
  }
  .admin-kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
  }
  .admin-card-quick-row {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)) !important;
  }
  .admin-subtabs {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 6px !important;
    overflow-x: visible !important;
  }
  .admin-subtabs .admin-subtab-btn {
    border: 1px solid transparent !important;
    border-radius: 10px !important;
    padding: 8px 14px !important;
    font-size: 12.5px !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
  }
  .admin-subtabs .admin-subtab-btn.active {
    border-color: rgba(229, 181, 103, 0.36) !important;
  }
  .adm-funnel-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  /* 2-column grid for Admin System / Queue / Cars cards (full-width controls span 1/-1) */
  #admin-content-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }
  #admin-content-container > .empty-state,
  #admin-content-container > .adm-q-filters,
  #admin-content-container > .adm-stats-toolbar,
  #admin-content-container > .adm-funnel-grid,
  #admin-content-container > .adm-period-bar,
  #admin-content-container > #adm-mkt-form-card,
  #admin-content-container > #adm-mkt-list-wrap,
  #admin-content-container > #adm-srv-wrap,
  #admin-content-container > .admin-banner-card {
    grid-column: 1 / -1;
  }
  #admin-content-container > .admin-card,
  #admin-content-container > .admin-sys-card {
    margin-bottom: 0 !important;
  }
  /* Keep Admin Market customs toggle vertically aligned in .grid-2 */
  #adm-mkt-form-card .grid-2 label.upsell {
    margin-bottom: 0 !important;
  }
}

/* ---------- 5. Wide Desktop (>= 1200px & >= 1440px) ---------- */
@media (min-width: 1200px) {
  #app-shell,
  .top-header .brand-row {
    max-width: 1320px;
  }
  .sel-car-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (min-width: 1440px) {
  body {
    padding: 0 32px 56px 32px !important;
  }
  .top-header {
    padding: 13px 32px !important;
  }
  #app-shell,
  .top-header .brand-row {
    max-width: 1360px;
  }
  .catalog-list {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 20px !important;
  }
  .rental-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 20px !important;
  }
}
/* ---------- 6. Mobile & Tablet Web Fixes (Android / iOS browsers, strictly html.is-web) ---------- */
html.is-web,
html.is-web body {
  max-width: 100%;
  overflow-x: clip;
}

/* Стабильный нижний док на мобильном и планшетном Web (без transform-лага при скролле) */
@media (max-width: 959px) {
  html.is-web .tabs-pill {
    position: fixed !important;
    left: 12px !important;
    right: 12px !important;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    width: auto !important;
    max-width: 460px !important;
    margin: 0 auto !important;
    transform: none !important;
    z-index: 50 !important;
  }

  html.is-web #compare-dock,
  html.is-web .compare-dock {
    left: 12px !important;
    right: 12px !important;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (max-width: 767px) {
  html.is-web body {
    width: 100%;
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: calc(108px + env(safe-area-inset-bottom, 0px));
  }

  /* 2-строчная компактная шапка Web: ряд 1 (бренд + язык), ряд 2 (растаможка + уведомления + вход) */
  html.is-web .top-header {
    margin: 0 -12px 12px -12px !important;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px 12px !important;
    transform: none !important;
  }
  html.is-web .top-header .brand-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    align-items: center;
    row-gap: 8px;
    column-gap: 6px;
    min-height: 0;
  }
  html.is-web .top-header .header-actions {
    display: contents;
  }
  html.is-web .top-header .brand-mark {
    grid-column: 1 / 2;
    grid-row: 1;
    font-size: 15.5px;
    gap: 7px;
    min-width: 0;
  }
  html.is-web .top-header .brand-mark > span:last-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  html.is-web .top-header .lang-switcher {
    grid-column: 2 / 5;
    grid-row: 1;
    justify-self: end;
  }
  html.is-web .top-header .btn-header-calc {
    grid-column: 1 / 2;
    grid-row: 2;
    justify-self: start;
    padding: 6px 10px;
    font-size: 11px;
  }
  html.is-web .top-header .btn-header-notif {
    grid-column: 2 / 3;
    grid-row: 2;
    justify-self: end;
  }
  html.is-web .top-header .btn-header-auth {
    grid-column: 3 / 4;
    grid-row: 2;
    justify-self: end;
    max-width: 112px;
    padding: 5px 9px;
    overflow: hidden;
  }
  html.is-web .top-header .btn-header-vin {
    grid-column: 4 / 5;
    grid-row: 2;
    justify-self: end;
    padding: 5px 9px;
    font-size: 11px;
  }
  html.is-web .top-header .btn-header-auth > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Защита всех сеток и тулбаров от горизонтального раздувания */
  html.is-web .grid-2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  html.is-web .grid-2 > *,
  html.is-web .search-wrap,
  html.is-web .catalog-toolbar,
  html.is-web .car-body,
  html.is-web .detail-content {
    min-width: 0;
  }
  html.is-web .detail-footer-single > button {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Полноэкранные оверлеи строго в динамической высоте 100dvh */
  html.is-web .detail-overlay,
  html.is-web .calc-overlay,
  html.is-web .compare-overlay,
  html.is-web .vincheck-overlay,
  html.is-web .lightbox-overlay {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden;
  }

  /* Безопасная верхняя зона под бар браузера для Калькулятора, Сравнения и VIN */
  html.is-web .compare-header,
  html.is-web .vincheck-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px)) !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Кнопка «Назад» в карточке авто: закреплена внутри оверлея, скролл строго над панелью действий */
  html.is-web .detail-scroll {
    contain: style !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
    overflow-y: auto !important;
    padding-bottom: 28px !important;
  }
  html.is-web .detail-topbar {
    position: fixed !important;
    top: calc(14px + env(safe-area-inset-top, 0px)) !important;
    left: 12px !important;
    right: 12px !important;
    z-index: 30 !important;
  }

  /* Безопасный нижний отступ для футеров оверлеев */
  html.is-web .detail-footer {
    position: relative !important;
    flex-shrink: 0 !important;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
  }
  html.is-web .calc-footer,
  html.is-web .compare-footer,
  html.is-web .vincheck-footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
  }
}