/* Фильтр каталога: панель-тулбар с дропдаунами + мобильный bottom-sheet.
   Классы с префиксом cf- — только для этого блока. */
.cf-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.cf-form {
  margin: 0;
}
.cf-fields {
  display: contents;
}

/* --- контролы-«пилюли» --- */
.cf-select {
  position: relative;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.cf-select:hover {
  border-color: #cbd5e1;
}
.cf-select[open] {
  border-color: #35b729;
  box-shadow: 0 0 0 3px rgba(53, 183, 41, .12);
}
.cf-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  font-size: 13px;
  color: #6b7280;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  user-select: none;
}
.cf-trigger::-webkit-details-marker {
  display: none;
}
.cf-t-val.has-value {
  color: #111827;
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cf-chev {
  font-size: 18px;
  color: #9ca3af;
  transition: transform .18s ease;
}
.cf-select[open] .cf-chev {
  transform: rotate(180deg);
}
.cf-sort-ic {
  font-size: 16px;
  color: #9ca3af;
}

/* --- выпадающие меню --- */
.cf-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  max-width: min(320px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .14);
  z-index: 60;
  overflow: hidden;
  animation: cf-in .16s ease;
}
.cf-menu-right {
  left: auto;
  right: 0;
}
@keyframes cf-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.cf-options {
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
}
.cf-options-years {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
}
.cf-options-years .cf-opt:first-child {
  grid-column: 1 / -1;
  justify-content: center;
  white-space: nowrap;
}
.cf-options-years .cf-opt {
  justify-content: center;
  padding: 8px 4px;
}
.cf-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
}
.cf-opt:hover {
  background: #f3f4f6;
}
.cf-opt input {
  appearance: none;
  width: 15px;
  height: 15px;
  flex: none;
  margin: 0;
  border: 1.5px solid #d1d5db;
  border-radius: 50%;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cf-opt input:checked {
  border-color: #35b729;
  background: #35b729;
  box-shadow: inset 0 0 0 2.5px #fff;
}
.cf-opt input:checked + span {
  color: #111827;
  font-weight: 600;
}

/* --- счётчик машин у опции --- */
.cf-count {
  color: #35b729;
  font-size: 11.5px;
  font-style: normal;
  font-weight: 600;
}
.cf-opt .cf-count {
  margin-left: auto;
  padding-left: 10px;
}
.cf-chip .cf-count {
  margin-left: 3px;
}
.cf-chip input:checked + span .cf-count {
  color: rgba(255, 255, 255, .92);
}
.cf-menu-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px;
  padding: 8px 10px;
  background: #f3f4f6;
  border-radius: 8px;
}
.cf-menu-search .material-icons {
  font-size: 16px;
  color: #9ca3af;
}
.cf-menu-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  width: 100%;
  color: #111827;
}

/* --- поиск по VIN --- */
.cf-vin {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 190px;
  height: 38px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.cf-vin:focus-within {
  border-color: #35b729;
  box-shadow: 0 0 0 3px rgba(53, 183, 41, .12);
}
.cf-vin .material-icons {
  font-size: 17px;
  color: #9ca3af;
}
.cf-vin input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  height: 100%;
  font-size: 13px;
  color: #111827;
}
.cf-vin input::placeholder {
  color: #9ca3af;
}

/* --- кнопка «Найти» --- */
.cf-submit {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: #35b729;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease;
}
.cf-submit:hover {
  background: #2ea323;
}
.cf-submit .material-icons {
  font-size: 17px;
}

/* --- чипы активных фильтров --- */
.cf-chips {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.cf-chip-x {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px 5px 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  font-size: 12px;
  color: #374151;
  transition: border-color .15s, color .15s;
}
.cf-chip-x:hover {
  border-color: #f87171;
  color: #dc2626;
}
.cf-chip-x .material-icons {
  font-size: 14px;
  color: #9ca3af;
}
.cf-chip-x:hover .material-icons {
  color: #dc2626;
}
.cf-chip-reset {
  margin-left: 4px;
  font-size: 12px;
  color: #6b7280;
  text-decoration: underline;
}
.cf-chip-reset:hover {
  color: #111827;
}

/* --- мобильный ряд: Фильтры + Сортировка --- */
.cf-mobile-row {
  display: none;
  align-items: stretch;
  gap: 10px;
  flex-basis: 100%;
}
.cf-sheet-toggle {
  flex: 1.2;
}
.cf-filters-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: #111827;
  color: #fff;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.cf-filters-btn::-webkit-details-marker {
  display: none;
}
.cf-filters-btn .material-icons {
  font-size: 19px;
}
.cf-badge {
  min-width: 20px;
  padding: 2px 6px;
  background: #35b729;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}
.cf-sheet-toggle[open] .cf-filters-btn {
  background: #1f2937;
}
.cf-sort-m {
  flex: 1;
}
.cf-sort-m .cf-trigger {
  height: 100%;
}

/* --- мобильный bottom-sheet --- */
.cf-sheet {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.cf-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  animation: cf-fade .2s ease;
}
@keyframes cf-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.cf-sheet-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 86vh;
  background: #fff;
  border-radius: 18px 18px 0 0;
  animation: cf-up .28s cubic-bezier(.32, .72, .34, 1);
}
@keyframes cf-up {
  from { transform: translateY(45%); opacity: .5; }
  to { transform: none; opacity: 1; }
}
.cf-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #f3f4f6;
}
.cf-sheet-head h3 {
  margin: 0;
  font-size: 17px;
  color: #111827;
}
.cf-sheet-x {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #374151;
}
.cf-sheet-x .material-icons {
  font-size: 18px;
}
.cf-sheet-body {
  overflow-y: auto;
  padding: 4px 16px 12px;
  -webkit-overflow-scrolling: touch;
}
.cf-sec {
  padding: 14px 0;
  border-bottom: 1px solid #f3f4f6;
}
.cf-sec:last-child {
  border-bottom: none;
}
.cf-sec h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #6b7280;
}
.cf-sec .cf-menu-search {
  margin: 0 0 10px;
}
.cf-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}
.cf-chip {
  position: relative;
}
.cf-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.cf-chip span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 6px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.25;
  text-align: center;
  color: #374151;
  cursor: pointer;
  transition: all .15s ease;
}
.cf-chip span:hover {
  border-color: #cbd5e1;
  background: #f9fafb;
}
.cf-chip input:checked + span {
  background: #35b729;
  border-color: #35b729;
  color: #fff;
  font-weight: 600;
}
.cf-chip input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(53, 183, 41, .25);
}
.cf-chip-years {
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
}
.cf-vin-m {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  color: #111827;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.cf-vin-m:focus {
  border-color: #35b729;
  box-shadow: 0 0 0 3px rgba(53, 183, 41, .12);
}
.cf-sheet-foot {
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid #f3f4f6;
  background: #fff;
}
.cf-reset {
  flex: 1;
  padding: 12px;
  background: #f3f4f6;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
}
.cf-reset:active {
  background: #e5e7eb;
}
.cf-apply {
  flex: 2;
  padding: 12px;
  background: #35b729;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}
.cf-apply:active {
  background: #2ea323;
}
body.cf-lock {
  overflow: hidden;
}

/* --- десктоп: скрыть мобильные элементы --- */
.cf-sort-m,
.cf-mobile-row {
  display: none;
}

/* --- мобильные и планшетные экраны --- */
@media (max-width: 768px) {
  .cf-fields,
  .cf-sort-d,
  .cf-submit {
    display: none;
  }
  .cf-mobile-row {
    display: flex;
  }
  .cf-sort-m {
    display: block;
  }
  .cf-bar {
    margin-bottom: 14px;
  }
  .cf-chips {
    gap: 6px;
  }
}

/* --- средние экраны: Vin-поле не должно сжиматься в ноль --- */
@media (max-width: 1100px) {
  .cf-t-val.has-value {
    max-width: 120px;
  }
  .cf-vin {
    min-width: 150px;
  }
}
