:root {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --text: #141413;
  --muted: #5c5b57;
  --line: rgba(20, 20, 19, 0.12);
  --accent: #1d4ed8;
  --accent-soft: rgba(29, 78, 216, 0.1);
  --radius: 12px;
  --font: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --panel-width: 400px;
  --panel-width-expanded: 800px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

.top {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-self: end;
}

.btn-auth {
  appearance: none;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn-auth:hover {
  background: var(--bg);
  border-color: rgba(15, 23, 42, 0.2);
}

.user-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem 0.35rem 0.35rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.user-chip-btn:hover {
  background: var(--bg);
}

.user-avatar {
  display: inline-flex;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}

.user-avatar.lg {
  width: 56px;
  height: 56px;
  font-size: 1.2rem;
}

.user-email {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.stats {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: right;
  display: flex;
  gap: 1.25rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.stats-item {
  white-space: nowrap;
}

.stats strong {
  color: var(--text);
  font-weight: 600;
}

.stats-placeholder {
  opacity: 0.7;
}

.banner {
  padding: 0.75rem 1.25rem;
  margin: 0 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.banner-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  margin-top: 0.75rem;
}

.hidden {
  display: none !important;
}

/** Layout: карта на всю ширину, панель — плавающая карточка справа поверх карты. */
.layout {
  position: relative;
  height: calc(100vh - 96px);
  min-height: 420px;
}

.map-wrap {
  position: absolute;
  inset: 0;
}

.map {
  width: 100%;
  height: 100%;
}

/** Плавающая карточка с информацией дилера / списком группы.
 *  Привязана к правому краю с отступом ~24px и закруглением. Внутри прокручивается. */
.panel {
  position: absolute;
  top: 20px;
  right: 20px;
  bottom: 20px;
  width: var(--panel-width);
  max-width: calc(100vw - 40px);
  background: var(--surface);
  border-radius: 18px;
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.18),
    0 4px 12px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(15, 23, 42, 0.06);
  overflow: visible;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel.is-expanded {
  width: min(var(--panel-width-expanded), calc(100vw - 40px));
}

/** Кнопка «раздвинуть» на левом краю панели по центру. */
.panel-expand-btn {
  position: absolute;
  left: 0;
  top: 50%;
  z-index: 3;
  transform: translate(-100%, -50%);
  width: 26px;
  height: 52px;
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-right: none;
  border-radius: 10px 0 0 10px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  box-shadow: -4px 0 12px rgba(15, 23, 42, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    color 0.15s,
    box-shadow 0.15s;
}

.panel-expand-btn:hover {
  background: var(--bg);
  color: var(--text);
  box-shadow: -6px 0 16px rgba(15, 23, 42, 0.12);
}

.panel-expand-icon {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel.is-expanded .panel-expand-icon {
  transform: rotate(180deg);
}

/** Внутренние состояния панели — занимают всю высоту и прокручиваются самостоятельно. */
.panel > .panel-empty,
.panel > .panel-group,
.panel > .panel-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: inherit;
  background: var(--surface);
}

/* ---------- Раскладка в расширенной панели (≈2× ширины) ---------- */
.panel.is-expanded .kv.grid-2 {
  grid-template-columns: repeat(4, 1fr);
}

.panel.is-expanded .dealer-head h2 {
  font-size: 1.25rem;
}

.panel.is-expanded .stat-primary {
  font-size: 1.5rem;
}

.panel.is-expanded .vehicle-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.panel.is-expanded .vehicle-list li {
  flex-direction: column;
  height: 100%;
}

.panel.is-expanded .vehicle-list img {
  width: 100%;
  height: 108px;
}

.panel.is-expanded .group-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.panel.is-expanded .panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.panel.is-expanded .panel-actions .btn.secondary {
  margin-top: 0;
}

.panel-empty {
  padding: 2rem 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.panel-empty .hint {
  font-size: 0.82rem;
  margin-top: 1rem;
}

.panel-content {
  padding: 1.5rem;
  padding-top: 3rem;
  animation: fade 0.2s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.icon-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.icon-close:hover {
  background: var(--bg);
  color: var(--text);
}

.dealer-head {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.avatar {
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--bg);
}

.dealer-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.muted {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.desc {
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0 0 1rem;
}

.kv {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.kv .label {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kv .value {
  font-weight: 500;
}

.kv.grid-2 {
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}

.num {
  font-variant-numeric: tabular-nums;
}

.kv .span-2 {
  grid-column: 1 / -1;
}

.stat-primary {
  font-size: 1.35rem;
  font-weight: 600;
}

.hint.warn {
  color: var(--warn, #b45309);
}

.source-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--pill-bg, #e8f4fc);
  color: var(--pill-fg, #0c4a6e);
  vertical-align: middle;
}

.source-pill.monolith {
  background: #fef3c7;
  color: #92400e;
}

.phone {
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}

.link-encar {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 1.25rem;
  text-decoration: none;
}

.link-encar:hover {
  text-decoration: underline;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn.primary {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.btn.primary:hover {
  opacity: 0.92;
}

.btn.secondary {
  margin-top: 0.65rem;
}

.panel-actions {
  display: flex;
  flex-direction: column;
}

.btn.secondary:hover {
  background: rgba(20, 20, 19, 0.05);
}

.vehicle-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.vehicle-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.vehicle-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.vehicle-list li {
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg);
}

.vehicle-list img {
  width: 88px;
  height: 66px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: #ddd;
}

.vehicle-list .body {
  flex: 1;
  min-width: 0;
}

.vehicle-list .title {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 0.25rem;
}

.vehicle-list .meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.vehicle-list a {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  display: inline-block;
  margin-top: 0.35rem;
}

.vehicle-list a:hover {
  text-decoration: underline;
}

/* ---------- Map markers (HTML-overlay через naver.maps.Marker icon.content) ---------- */
.dealer-pin {
  position: relative;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  cursor: pointer;
  will-change: transform;
}

.dealer-pin-dot {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  transform-origin: center;
  transition:
    background-color 0.15s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.dealer-pin.cluster .dealer-pin-dot {
  background: #475569;
}

.dealer-pin.cluster .dealer-pin-count {
  font-size: 12px;
  letter-spacing: -0.02em;
}

.dealer-pin.is-selected {
  z-index: 5;
}

/* Выделение выбранного маркера: красный, x2, прыжок на месте. */
.dealer-pin.is-selected .dealer-pin-dot {
  background: #dc2626;
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.45);
  animation: dealer-pin-bounce 0.9s ease-in-out infinite;
}

@keyframes dealer-pin-bounce {
  0%,
  100% {
    transform: scale(2) translateY(0);
  }
  50% {
    transform: scale(2) translateY(-6px);
  }
}

/* ---------- Панель группы дилеров (cluster) ---------- */
.panel-group {
  padding: 1.5rem;
  padding-top: 3rem;
  position: relative;
  animation: fade 0.2s ease;
}

.panel-group h2 {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.group-addr {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.group-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.group-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.group-card:hover,
.group-card:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.group-card .avatar-mini {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: #ddd;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.group-card .body {
  flex: 1;
  min-width: 0;
}

.group-card .title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-card .sub {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
  margin: 0.2rem 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-card .stats-mini {
  font-size: 0.78rem;
  color: var(--text);
  margin: 0.3rem 0 0;
}

.group-card .stats-mini strong {
  font-weight: 600;
}

/* «Назад к списку» внутри панели дилера */
.btn-back {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  padding: 0;
  margin: 0 0 0.75rem;
  cursor: pointer;
}

.btn-back:hover {
  text-decoration: underline;
}

/* ---------- Нижняя поисковая панель ---------- */
.search-dock {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 1500;
  pointer-events: none;
}

.search-bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: min(720px, calc(100vw - 32px));
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.16),
    0 4px 10px rgba(15, 23, 42, 0.08);
}

.search-icon {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}

.search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  padding: 0.45rem 0;
  outline: none;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-filter-btn,
.search-submit {
  appearance: none;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: var(--surface);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.search-filter-btn:hover {
  background: var(--bg);
}

.search-submit {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
  padding: 0.55rem 1.25rem;
}

.search-submit:hover {
  opacity: 0.92;
}

/* ---------- Модальные окна ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: dl-fadein 0.18s ease-out;
}

.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: 18px;
  box-shadow:
    0 24px 56px rgba(15, 23, 42, 0.28),
    0 6px 16px rgba(15, 23, 42, 0.12);
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 2rem 1.75rem 1.5rem;
}

.modal-card.filter-card {
  max-width: 560px;
}

.modal-card.results-card {
  max-width: 920px;
  display: flex;
  flex-direction: column;
  padding: 1.75rem;
}

.modal-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

/* Auth */
.auth-tabs {
  display: flex;
  gap: 0.25rem;
  margin: 1rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  appearance: none;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0.5rem 0.75rem 0.6rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.auth-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.field input,
.field select {
  font: inherit;
  font-size: 0.92rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.form-error {
  margin: 0;
  font-size: 0.82rem;
  color: #b91c1c;
}

.auth-hint {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Google OAuth-кнопка и разделитель */
.oauth-block {
  margin-top: 0.5rem;
}
.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #d1d5db;
  padding: 0.65rem 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.google-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.google-btn:active {
  background: #f3f4f6;
}
.g-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.g-label {
  line-height: 1;
}
.oauth-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.9rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.oauth-divider::before,
.oauth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

/* Поле с кодом */
#auth-code {
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0.6rem 0.5rem;
}
.auth-code-hint {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}
.auth-code-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.65rem;
  gap: 0.5rem;
}
.auth-extra-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* ───────── Сравнение автомобилей ───────── */
.fav-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.6rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}
.fav-toolbar-text {
  color: #334155;
  font-size: 0.9rem;
}
.fav-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.btn-link {
  background: none;
  border: 0;
  padding: 0;
  color: #475569;
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
}
.btn-link:hover {
  color: #1e293b;
}
.btn-compare {
  padding: 0.45rem 0.95rem;
}
.btn-compare:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.fav-item {
  position: relative;
}
.fav-compare-check {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: border-color 0.15s, background 0.15s;
  padding: 0;
}
.fav-compare-check.is-on {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.fav-compare-check svg {
  width: 14px;
  height: 14px;
  display: none;
}
.fav-compare-check.is-on svg {
  display: block;
}

.compare-card {
  width: min(96vw, 1100px);
  max-height: 88vh;
  padding: 1.4rem 1.6rem 1.4rem;
}
.compare-head {
  margin-bottom: 0.9rem;
}
.compare-scroll {
  overflow: auto;
  max-height: calc(88vh - 110px);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.compare-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
}
.compare-table th,
.compare-table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
  background: #fff;
}
.compare-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
  text-align: left;
  font-weight: 600;
}
.compare-table tbody th {
  position: sticky;
  left: 0;
  background: #f8fafc;
  z-index: 1;
  text-align: left;
  font-weight: 600;
  width: 170px;
  white-space: nowrap;
  color: #475569;
}
.compare-table tr:hover td {
  background: #f9fafb;
}
.compare-thumb {
  width: 160px;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: #f3f4f6;
}
.compare-cell-best {
  color: #166534;
  font-weight: 600;
}
.compare-cell-worst {
  color: #991b1b;
}
.compare-cell-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.compare-cell-actions .rc-btn {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
}
@media (max-width: 720px) {
  .compare-card {
    width: 96vw;
    padding: 1rem;
  }
  .compare-table tbody th {
    width: 120px;
    font-size: 0.85rem;
  }
  .compare-thumb {
    width: 120px;
    height: 80px;
  }
}

/* Сохранённые поиски: переключатель уведомлений */
.saved-notify {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  background: #f1f5f9;
  color: #334155;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}
.saved-notify input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
}
.saved-notify:hover {
  background: #e2e8f0;
}
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent, #2563eb);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: none;
}
.link-btn:hover {
  text-decoration: underline;
}
.link-btn:disabled {
  color: var(--muted);
  cursor: not-allowed;
  text-decoration: none;
}

/* Profile (legacy small layout — оставлено для совместимости) */
.profile-head {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin: 0 0 1.25rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0 0 1.5rem;
  font-size: 0.88rem;
}

.profile-grid dt {
  color: var(--muted);
}

.profile-grid dd {
  margin: 0;
  font-weight: 500;
}

/* ─── Личный кабинет (новый layout) ─── */
.modal-card.account-card {
  max-width: 1000px;
  width: 100%;
  padding: 0;
  overflow: hidden;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.account-card .icon-close {
  z-index: 2;
}

.account-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 540px;
  height: 100%;
}

.account-side {
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  border-right: 1px solid var(--line);
  padding: 1.5rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.account-side-head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.account-side-meta {
  min-width: 0;
  flex: 1;
}

.account-side-name {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-side-email {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-plan-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text);
}

.account-plan-pill.is-pro {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
}

.account-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.account-nav-item {
  appearance: none;
  background: transparent;
  border: none;
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  transition: background 0.12s, color 0.12s;
}

.account-nav-item:hover {
  background: rgba(15, 23, 42, 0.05);
}

.account-nav-item.is-active {
  background: var(--surface);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
  color: var(--accent);
  font-weight: 600;
}

.account-nav-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.account-nav-badge {
  margin-left: auto;
  font-size: 0.72rem;
  background: rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-weight: 500;
  min-width: 22px;
  text-align: center;
}

.account-side-logout {
  appearance: none;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: var(--surface);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  margin-top: auto;
  transition: background 0.12s;
}

.account-side-logout:hover {
  background: var(--bg);
}

.account-content {
  padding: 1.5rem 1.75rem 1.75rem;
  overflow: auto;
  min-width: 0;
}

.account-pane {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.account-pane.is-active {
  display: flex;
}

.account-pane-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.85rem;
}

.account-pane-head .modal-title {
  margin: 0;
}

.account-pane-head .muted {
  margin: 0;
  flex: 1;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 480px;
}

.account-meta-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0;
  font-size: 0.85rem;
}

.account-meta-grid dt {
  color: var(--muted);
}

.account-meta-grid dd {
  margin: 0;
  font-weight: 500;
}

.account-form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.form-success {
  margin: 0;
  font-size: 0.82rem;
  color: #047857;
}

.btn-link {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

.account-empty {
  margin: 0;
  padding: 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.account-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Favorites grid */
.fav-tabs {
  display: flex;
  gap: 0.4rem;
}

.fav-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
}

.fav-tab span {
  font-size: 0.72rem;
  color: var(--muted);
}

.fav-tab.is-active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.fav-tab.is-active span {
  color: rgba(255, 255, 255, 0.7);
}

.fav-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}

.fav-item {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.fav-item-dealer {
  flex-direction: row;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.75rem;
}

.fav-thumb {
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: #e2e8f0;
  display: block;
}

.fav-item-dealer .fav-thumb {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--muted);
  background: #eef2f7;
}

.fav-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  background: #eef2f7;
}

.fav-body {
  padding: 0.6rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}

.fav-item-dealer .fav-body {
  padding: 0;
}

.fav-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.fav-price {
  margin: 0.15rem 0 0;
  font-weight: 700;
  font-size: 1rem;
}

.fav-actions {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.4rem;
}

/* Saved searches / history rows */
.saved-row,
.hist-row {
  display: flex;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  align-items: center;
}

.saved-info,
.hist-info {
  flex: 1;
  min-width: 0;
}

.saved-name,
.hist-name {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.saved-params,
.saved-meta,
.hist-meta {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.saved-actions {
  display: flex;
  gap: 0.35rem;
}

/* Plans */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.plan-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.4rem 1.25rem 1.25rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: relative;
  overflow: hidden;
}

.plan-card.is-pro {
  border-color: transparent;
  background: linear-gradient(160deg, #1f2937 0%, #111827 100%);
  color: #f8fafc;
}

.plan-card.is-pro .plan-name,
.plan-card.is-pro .plan-price,
.plan-card.is-pro .plan-features li {
  color: #f8fafc;
}

.plan-card.is-pro .plan-price .muted {
  color: rgba(248, 250, 252, 0.7);
}

.plan-card.is-pro::before {
  content: "";
  position: absolute;
  inset: -40% -40% auto auto;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.45) 0%, transparent 70%);
  pointer-events: none;
}

.plan-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.plan-tag {
  font-size: 0.7rem;
  background: rgba(245, 158, 11, 0.18);
  color: #f59e0b;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.plan-price {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.plan-features li {
  padding-left: 1.25rem;
  position: relative;
}

.plan-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #10b981;
  font-weight: 700;
}

.plan-cta {
  margin-top: auto;
}

.plan-card.is-pro .plan-cta {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-color: transparent;
  color: #fff;
}

/* Звёзды в карточках поиска */
.rc-photo-wrap {
  position: relative;
}

.rc-fav {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  backdrop-filter: blur(4px);
}

.rc-fav:hover {
  transform: scale(1.05);
  background: rgba(15, 23, 42, 0.75);
}

.rc-fav.is-on {
  background: #fff;
  color: #f59e0b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Звезда у дилера */
.dealer-head {
  align-items: flex-start;
}

.dealer-head-main {
  flex: 1;
  min-width: 0;
}

.dealer-fav {
  appearance: none;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: var(--surface);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.dealer-fav:hover {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.08);
}

.dealer-fav.is-on {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.12);
}

@media (max-width: 760px) {
  .modal-card.account-card {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .account-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .account-side {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 0.85rem 1rem;
    gap: 0.55rem;
  }

  .account-side-head {
    border-bottom: none;
    padding-bottom: 0;
    flex-shrink: 0;
  }

  .account-nav {
    flex-direction: row;
    flex: none;
    gap: 0.25rem;
  }

  .account-nav-item {
    white-space: nowrap;
  }

  .account-side-logout {
    flex-shrink: 0;
    margin-top: 0;
  }

  .account-content {
    padding: 1rem 1rem 1.25rem;
  }
}

/* Filters */
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
  margin: 1rem 0 1.5rem;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.filter-actions .btn {
  width: auto;
}

/* Results */
.results-head {
  margin-bottom: 1rem;
}

.results-grid {
  list-style: none;
  margin: 0;
  padding: 0 4px 4px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.85rem;
  overflow: auto;
  flex: 1;
  min-height: 240px;
}

.result-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  list-style: none;
}

.result-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.rc-photo {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: #e2e8f0;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  display: block;
}

.rc-photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.78rem;
  height: 150px;
  background: #eef2f7;
}

.rc-body {
  padding: 0.7rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.rc-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rc-trim {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rc-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.rc-price {
  margin: 0.2rem 0 0.1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.rc-seller {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-actions {
  margin-top: auto;
  padding-top: 0.55rem;
  display: flex;
  gap: 0.4rem;
}

.rc-btn {
  flex: 1;
  appearance: none;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  border: 1px solid transparent;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.rc-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.rc-btn-primary:hover {
  filter: brightness(1.05);
}

.rc-btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: rgba(15, 23, 42, 0.15);
}

.rc-btn-secondary:hover {
  background: var(--bg);
  border-color: rgba(15, 23, 42, 0.28);
}

.results-pager {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.results-pager .btn {
  width: auto;
  padding: 0.45rem 1rem;
}

.results-page {
  font-size: 0.85rem;
  color: var(--muted);
}

/* На мобильных search-bar поднимается выше плавающей панели дилера */
@media (max-width: 900px) {
  .search-dock {
    bottom: calc(55vh + 24px);
  }

  .top {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-self: start;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .layout {
    height: calc(100vh - 120px);
  }

  /** На мобильных панель «прилипает» к низу экрана как bottom-sheet, занимая до 55% высоты. */
  .panel {
    top: auto;
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    max-height: 55vh;
    border-radius: 16px;
  }

  .panel.is-expanded {
    width: auto;
  }

  .panel-expand-btn {
    display: none !important;
  }

  .panel.is-expanded .vehicle-list,
  .panel.is-expanded .group-list {
    grid-template-columns: 1fr;
  }

  .panel.is-expanded .kv.grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  .stats {
    text-align: left;
    width: 100%;
  }
}

/* On-demand dealer refresh overlay — показывается, пока обновляются данные кликнутого дилера. */
.dealer-loading {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: dl-fadein 0.18s ease-out;
}

.dealer-loading.hidden {
  display: none;
}

@keyframes dl-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dl-card {
  width: min(380px, 90vw);
  padding: 22px 26px 20px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.28);
  text-align: center;
}

/** Кольцо загрузки вокруг аватара дилера. */
.dl-spinner-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 4px auto 14px;
}

.dl-spinner-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid rgba(20, 20, 19, 0.12);
  border-top-color: var(--accent);
  animation: dl-spin 0.85s linear infinite;
  box-sizing: border-box;
}

.dl-avatar {
  position: absolute;
  inset: 6px;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--line);
}

@keyframes dl-spin {
  to { transform: rotate(360deg); }
}

.dl-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.dl-bar {
  height: 6px;
  width: 100%;
  background: rgba(20, 20, 19, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0 10px;
}

.dl-bar-fill {
  height: 100%;
  width: 6%;
  background: linear-gradient(90deg, var(--accent), #38bdf8);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.dl-sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
