/* ===== CSS Variables ===== */
:root {
  --bg:         #f1f5f9;
  --surface:    #ffffff;
  --surface-2:  #f8fafc;
  --border:     #e2e8f0;
  --border-mid: #cbd5e1;
  --text:       #0f172a;
  --text-2:     #475569;
  --text-3:     #94a3b8;
  --accent:     #f57c00;
  --accent-bg:  #fff3e0;
  --accent-bdr: #ffcc80;
  --green:      #10b981;
  --green-bg:   #dcfce7;
  --green-text: #15803d;
  --yellow:     #f59e0b;
  --yellow-bg:  #fef9c3;
  --yellow-text:#854d0e;
  --red:        #ef4444;
  --red-bg:     #fee2e2;
  --red-text:   #b91c1c;
  --header-h:   56px;
  --max-w:      1280px;
  --radius:     8px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06);
  --shadow:     0 2px 8px rgba(0,0,0,.08);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ===== Top header ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 4px;
}
.topbar-logo {
  height: 32px;
  width: auto;
  flex-shrink: 0;
  margin-right: 12px;
  display: block;
}
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: none; background: transparent;
  color: var(--text-3);
  font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-item i { font-size: 17px; line-height: 1; }
.nav-item:hover { background: var(--bg); color: var(--text-2); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

/* ===== Main ===== */
.main { margin-top: var(--header-h); min-height: calc(100vh - var(--header-h)); }
.content { max-width: var(--max-w); margin: 0 auto; padding: 24px; }

/* ===== Sections ===== */
.section { display: none; }
.section.active { display: block; }

/* ===== Auction Bar ===== */
.auction-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
/* Info block (left) — growable, wraps its children internally */
.ab-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}
.ab-view-btn     { flex-shrink: 0; white-space: nowrap; }
.ab-active-label { font-size: 11px; font-weight: 700; color: var(--green); white-space: nowrap; }
.ab-count        { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.ab-date         { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; }
.ab-date-short   { display: none; }  /* скрыт на десктопе */

.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}
.status-dot.inactive { background: var(--border-mid); box-shadow: none; }

/* ===== Type Badges ===== */
.type-badge {
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
}
.type-usd   { background: var(--accent-bg); color: #bf360c; border: 1px solid var(--accent-bdr); }
.type-extra { background: #ede9fe; color: #6d28d9; }
.type-sep   { background: #dbeafe; color: #1d4ed8; }
.type-adm   { background: #f1f5f9; color: #64748b; border: 1px solid var(--border); }

/* ===== Buttons ===== */
.btn {
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; border: none;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline  { background: var(--surface); border: 1px solid var(--border-mid); color: var(--text-2); }
.btn-outline:hover { border-color: var(--text-3); opacity: 1; }
.btn-link     { background: var(--accent-bg); border: 1px solid var(--accent-bdr); color: var(--accent); }
.btn-danger   { background: var(--red-bg); border: 1px solid #fca5a5; color: var(--red-text); }
.btn-sm { padding: 5px 12px; font-size: 12px; white-space: nowrap; }

/* ===== Filters ===== */
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.input-search {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  color: var(--text); font-size: 13px; outline: none;
  width: 260px; box-shadow: var(--shadow-sm);
}
.input-search::placeholder { color: var(--text-3); }
.input-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.filter-select {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  color: var(--text-2); font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.count-badge {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 14px;
  font-size: 12px; color: var(--text-3);
  margin-left: auto; box-shadow: var(--shadow-sm);
}

/* ===== Table ===== */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-sm);
}
/* Cars table — горизонтальный скролл при сжатии */
#carsTable .table-wrap { overflow-x: auto; }
#carsTable .data-table { min-width: 860px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--surface-2); padding: 10px 14px;
  text-align: left; font-size: 11px; font-weight: 700;
  color: var(--text-3); letter-spacing: .5px; text-transform: uppercase;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--surface-2);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--accent-bg); }
.data-table tbody tr:hover td .btn-outline { background: transparent; }
.data-table tbody tr:hover td .btn-link    { background: var(--accent-bg); }

/* ===== Car thumbnail ===== */
.car-thumb {
  width: 64px; height: 46px; border-radius: 6px;
  object-fit: cover; background: var(--bg); display: block;
}
.car-thumb-placeholder {
  width: 64px; height: 46px; border-radius: 6px;
  background: var(--bg); display: flex; align-items: center;
  justify-content: center; color: var(--border-mid);
}

/* ===== HP confidence ===== */
.hp-cell { display: flex; align-items: center; gap: 6px; }
.hp-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hp-dot.verified { background: var(--green); }
.hp-dot.medium   { background: var(--accent); }
.hp-dot.auto     { background: var(--yellow); }
.hp-dot.none     { background: var(--red); }

/* ===== Grade badges ===== */
.grade {
  display: inline-block; padding: 2px 8px;
  border-radius: 5px; font-size: 11px; font-weight: 700;
}
.grade-a { background: var(--green-bg); color: var(--green-text); }
.grade-b { background: var(--yellow-bg); color: var(--yellow-text); }
.grade-c { background: var(--red-bg); color: var(--red-text); }

/* ===== Spec confidence ===== */
.conf-badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 5px; font-size: 11px; font-weight: 600;
}
.conf-verified { background: var(--green-bg); color: var(--green-text); }
.conf-auto     { background: var(--yellow-bg); color: var(--yellow-text); }
.conf-medium   { background: var(--accent-bg); color: var(--accent); }

/* ===== Drawer ===== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 440px; background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 201; display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between;
}
.drawer-body {
  flex: 1; padding: 20px 24px;
  overflow-y: auto; display: flex;
  flex-direction: column; gap: 20px;
}
.drawer-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}

/* ===== Form fields ===== */
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
}
.field-hint { font-size: 11px; color: var(--text-3); }
.input-field {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  color: var(--text); font-size: 14px; outline: none; width: 100%;
}
.input-field:focus { border-color: var(--accent); background: var(--surface); }
textarea.input-field { resize: vertical; min-height: 72px; }
select.input-field { cursor: pointer; }

/* ===== Days selector ===== */
.days-row { display: flex; gap: 6px; }
.day-btn {
  flex: 1; padding: 8px 4px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface-2);
  color: var(--text-3); font-size: 13px; text-align: center;
}
.day-btn.selected {
  background: var(--accent-bg); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

/* ===== Photo grid ===== */
.photos-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; }
.photo-pick {
  aspect-ratio: 4/3; border-radius: 6px;
  border: 2px solid var(--border); cursor: pointer;
  overflow: hidden; position: relative; background: var(--bg);
}
.photo-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pick.selected { border-color: var(--accent); }
.photo-pick.selected::after {
  content: '✓'; position: absolute; top: 3px; right: 5px;
  font-size: 11px; color: var(--accent); font-weight: 700;
  text-shadow: 0 0 4px rgba(255,255,255,.9);
}

/* ===== Field toggles ===== */
.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.field-toggle {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; cursor: pointer;
  user-select: none;
}
.field-toggle.off { opacity: .45; }
.toggle-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
}
.field-toggle.off .toggle-dot { background: var(--border-mid); }

/* ===== Section head ===== */
.section-head {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

/* ===== Empty / Loading ===== */
.loading-cell { text-align: center; color: var(--text-3); padding: 40px !important; }
.empty-state { text-align: center; color: var(--text-3); padding: 60px 20px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 18px;
  font-size: 13px; z-index: 500; box-shadow: var(--shadow);
  transform: translateY(20px); opacity: 0;
  transition: all .25s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }

/* ===== Burger button ===== */
.burger-btn {
  display: none;
  margin-left: auto;
  background: none; border: none;
  color: var(--text-2);
  font-size: 24px; line-height: 1;
  padding: 4px 6px;
  border-radius: var(--radius);
  transition: background .15s;
}
.burger-btn:hover { background: var(--bg); }

/* ===== Mobile dropdown menu ===== */
.mobile-menu {
  display: none;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.mobile-menu.open { display: flex; }

.mobile-nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 20px;
  background: none; border: none;
  color: var(--text-2);
  font-size: 15px; font-weight: 500;
  text-align: left;
  transition: background .12s, color .12s;
}
.mobile-nav-item i { font-size: 20px; color: var(--text-3); flex-shrink: 0; }
.mobile-nav-item:hover { background: var(--bg); }
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item.active i { color: var(--accent); }

/* ===== Mobile/Desktop helpers ===== */
.m-only { display: none; }

/* ===== Icon-only button ===== */
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background .12s, color .12s;
  display: inline-flex; align-items: center;
}
.btn-icon:hover { background: var(--bg); color: var(--text-2); }
/* Cars filter funnel — только на мобиле */
.cars-filter-btn { display: none !important; }

/* ===== Auction table status column ===== */
.col-status { width: 90px; white-space: nowrap; }

/* ===== Responsive — Medium (планшет/узкий десктоп) ===== */
@media (max-width: 1050px) {
  /* Скрываем вторичную инфу в ячейках авто */
  .car-vin-line   { display: none; }
  .car-reg-line   { display: none; }
  .car-specs-line { display: none; }
  /* Компактнее ячейки */
  #carsTable .data-table th,
  #carsTable .data-table td { padding: 10px 8px; }
}

@media (max-width: 1000px) {
  /* Кнопки «Открыть» и «+ Ссылка» → только иконки */
  .car-btn-open  .car-btn-text { display: none; }
  .car-btn-link  .car-btn-text { display: none; }
  .car-btn-open::before { content: '\f06e'; font-family: 'Phosphor'; }
  /* проще: просто уменьшить padding кнопок */
  #carsTable .btn-sm { padding: 5px 8px; font-size: 11px; }
}

/* ===== Responsive — Mobile ===== */
@media (max-width: 767px) {
  .topbar-nav { display: none; }
  .burger-btn { display: flex; align-items: center; }
  .drawer { width: 100%; }
  .content { padding: 16px; }

  /* Mobile/desktop helpers */
  .d-mobile { display: none !important; }
  .m-only   { display: flex; align-items: center; }
  .cars-filter-btn { display: inline-flex !important; }

  /* Compact table cells */
  .data-table th { padding: 8px 6px; font-size: 10px; }
  .data-table td { padding: 10px 6px; }

  /* Status column — narrow, centred */
  .col-status { width: 28px; text-align: center; padding-left: 8px !important; padding-right: 2px !important; }
}

/* ===== Auction picker dropdown ===== */
.auction-picker {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  max-width: 320px;
  box-shadow: var(--shadow-sm);
}
.auction-picker:focus { outline: none; border-color: var(--accent); }

/* ===== Auction ID cell ===== */
.id-cell {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: .2px;
}

/* ===== Desktop/Mobile layout switcher ===== */
.table-desktop { display: block; }
.cards-mobile  { display: none !important; }

/* ===== Car Cards (mobile) ===== */
.cars-list { display: flex; flex-direction: column; gap: 10px; }

/* ===== Car card (mobile) — v2: номер-герой, цена демотирована ===== */
.car-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.car-card-top {
  display: flex;
  gap: 12px;
  padding: 12px;
  align-items: stretch;  /* обёртка фото растягивается на высоту текста */
}
.car-card-photo-wrap {
  width: 100px;
  min-height: 74px;
  flex-shrink: 0;
  align-self: stretch;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg);
  position: relative;
}
.car-card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  inset: 0;
}
.car-card-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border-mid);
}
.car-card-info { flex: 1; min-width: 0; }

/* Шапка: гос.номер (герой) + лот + оценка */
.car-card-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px; flex-wrap: nowrap;
}
.car-card-plate {
  /* Это кнопка — сбрасываем дефолтные стили */
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  /* Собственные стили */
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .2px;
  flex-shrink: 0;
  transition: color .12s;
}
.car-card-plate:hover,
.car-card-plate:active { color: var(--accent); }

.car-card-lot {
  font-family: monospace;
  font-size: 13px;
  color: var(--text-3);
  font-weight: 500;
  flex-shrink: 0;
}
.car-card-header .grade {
  font-size: 10px; font-weight: 600;
  padding: 1px 5px;
  margin-left: auto;  /* прижимаем оценку к правому краю */
}

.car-card-name {
  font-weight: 600; font-size: 14px;
  line-height: 1.3; color: var(--text);
  margin-bottom: 4px;
}
/* Строка спеков: год · пробег · ~цена */
.car-card-specs {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text-2); font-weight: 500;
  flex-wrap: wrap;
}
.car-card-price-inline {
  color: var(--text-3);
  font-weight: 400;
}

/* Нижняя строка действий — только кнопки */
.car-card-actions {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.car-card-actions .btn { flex: 1; justify-content: center; }
.car-card-actions .car-card-copy-btn { flex: 0 0 auto; }

/* ===== Filter Bottom Sheet ===== */
.filter-sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300; opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.filter-sheet-overlay.open { opacity: 1; pointer-events: all; }

.filter-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--border);
  z-index: 301;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 -4px 24px rgba(0,0,0,.14);
}
.filter-sheet.open { transform: translateY(0); }

.filter-sheet-handle {
  width: 40px; height: 4px;
  background: var(--border-mid);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}
.filter-sheet-header {
  padding: 12px 20px 10px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.filter-sheet-body {
  flex: 1; overflow-y: auto;
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.filter-sheet-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ===== Mobile overrides ===== */
@media (max-width: 767px) {
  /* Таблица → карточки */
  .table-desktop { display: none !important; }
  .cards-mobile  { display: flex !important; }

  /* Фильтры: скрываем селекты, оставляем поиск + кнопка фильтра + счётчик */
  .filters .filter-select { display: none; }
  .filters .count-badge   { flex-shrink: 0; }
  .filters .input-search  { flex: 1; }

  /* Auction bar — компактный на мобиле */
  .auction-bar { padding: 10px 14px; gap: 10px; }
  .ab-main { width: 100%; }   /* инфо-блок на всю строку */
  .ab-date-long  { display: none; }   /* длинная дата скрыта */
  .ab-date-short { display: inline; } /* короткая дата видна */
  .ab-date { font-size: 13px; }
  /* Кнопка "Смотреть авто" — во всю ширину на новой строке */
  .auction-bar > .btn { width: 100%; justify-content: center; }
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.site-footer a {
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color .15s;
}
.site-footer a:hover { color: var(--accent); }
.footer-dot { opacity: .4; }

/* ===== Utility: section states (loading / error / empty) ===== */
.state-loading, .state-error, .state-empty {
  padding: 20px;
  font-size: 13px;
}
.state-loading { color: var(--text-3); }
.state-error   { color: var(--red); }
.state-empty   { color: var(--text-3); text-align: center; padding: 40px; }

/* ===== Car Detail Modal — overlay + dialog ===== */
.cdm-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.cdm-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.cdm-dialog {
  background: var(--bg);
  border-radius: 16px;
  width: 100%;
  max-width: 1160px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  transform: translateY(12px) scale(.98);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.cdm-overlay.open .cdm-dialog {
  transform: translateY(0) scale(1);
}

.cdm-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.cdm-header-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cdm-close-btn {
  background: none; border: none;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 20px; line-height: 1;
  border-radius: 6px; cursor: pointer; flex-shrink: 0;
}
.cdm-close-btn:hover { background: var(--bg); color: var(--text-2); }

.cdm-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}
.cdm-loader { padding: 60px; text-align: center; font-size: 14px; }

/* 2-column layout */
.cdm-layout {
  display: grid;
  grid-template-columns: minmax(0, 500px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.cdm-col-gallery {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: min(520px, calc(90vh - 120px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.cdm-col-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ── Gallery ── */
.cdm-gallery {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  min-height: 0;
}
.cdm-track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cdm-track::-webkit-scrollbar { display: none; }
.cdm-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
}
.cdm-slide img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  user-select: none;
}
.cdm-gcounter {
  position: absolute; bottom: 12px; right: 12px;
  background: rgba(0,0,0,.55); color: #fff;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px;
  pointer-events: none;
}
.cdm-gnav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.4); border: none; color: #fff;
  font-size: 22px; line-height: 1; padding: 10px 8px;
  border-radius: 6px; cursor: pointer;
  transition: background .15s;
}
.cdm-gnav:hover { background: rgba(0,0,0,.7); }
.cdm-gprev { left: 8px; }
.cdm-gnext { right: 8px; }

.cdm-thumbs {
  display: flex; gap: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  scrollbar-width: none;
  flex-shrink: 0;
}
.cdm-thumbs::-webkit-scrollbar { display: none; }
.cdm-thumb {
  width: 52px; height: 38px;
  flex-shrink: 0; border-radius: 5px;
  overflow: hidden; cursor: pointer;
  border: 2px solid transparent;
  background: var(--bg);
  transition: border-color .15s;
}
.cdm-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cdm-thumb.active { border-color: var(--accent); }

.cdm-no-photos {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; color: var(--text-3); font-size: 14px;
}
.cdm-no-photos i { font-size: 48px; }

/* ── Info panel ── */
.cdm-hero { display: flex; flex-direction: column; gap: 6px; }
.cdm-hero-top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.cdm-plate {
  background: none; border: none; padding: 0;
  cursor: pointer; font-family: inherit;
  font-size: 22px; font-weight: 800;
  color: var(--text); letter-spacing: .3px;
  transition: color .12s;
}
.cdm-plate:hover { color: var(--accent); }
.cdm-lot { font-family: monospace; font-size: 14px; color: var(--text-3); font-weight: 500; }
.cdm-car-name { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.3; }
.cdm-hero-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--text-2); flex-wrap: wrap;
}
.cdm-dot { color: var(--border-mid); }

/* ── Price block ── */
.cdm-price-block {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.cdm-price-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cdm-price-lbl {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.cdm-price-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: .2px;
  white-space: nowrap;
}
.cdm-price-val.cdm-price-accent { color: var(--accent); }

.cdm-section-head {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

.cdm-specs-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.cdm-spec { display: flex; flex-direction: column; gap: 2px; }
.cdm-spec-label { font-size: 11px; color: var(--text-3); font-weight: 500; }
.cdm-spec-value { font-size: 14px; font-weight: 600; color: var(--text); }

.cdm-grades-row { display: flex; gap: 20px; flex-wrap: wrap; }
.cdm-grade-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 5px;
}
.cdm-grade-label { font-size: 11px; color: var(--text-3); }

/* Компактные чипы истории аварий */
.cdm-acc-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cdm-acc-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid;
  font-size: 12px;
  font-weight: 500;
}
.cdm-acc-chip b {
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
}
.cdm-acc-chip.good    { background: var(--green-bg); border-color: #86efac; color: var(--green-text); }
.cdm-acc-chip.bad     { background: var(--red-bg);   border-color: #fca5a5; color: var(--red-text); }
.cdm-acc-chip.neutral { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }

/* ===== Condition selector ===== */
.cdm-condition-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px;
}
.cdm-cond-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.cdm-cond-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.cdm-cond-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cdm-cond-btn[data-code="BBK"].active,
.cdm-cond-btn[data-code="TOTAL"].active {
  background: var(--red); border-color: var(--red);
}

.cdm-ins-list {
  display: flex; flex-direction: column; gap: 6px;
}
.cdm-ins-item {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px;
}
.cdm-ins-date  { color: var(--text-3); flex-shrink: 0; }
.cdm-ins-desc  { flex: 1; color: var(--text-2); }
.cdm-ins-cost  { color: var(--accent); font-weight: 600; flex-shrink: 0; }

.cdm-repair-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cdm-repair-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
}
.cdm-repair-tag.bad  { background: var(--red-bg);    color: var(--red-text); }
.cdm-repair-tag.warn { background: var(--yellow-bg); color: var(--yellow-text); }

/* ===== Lightbox ===== */
.cdm-lightbox {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.96);
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.cdm-lightbox.open { opacity: 1; pointer-events: all; }

.lb-stage {
  flex: 1; min-height: 0;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 20px 60px 10px;
}
#lbImg {
  max-width: 100%; max-height: 100%;
  object-fit: contain; display: block;
  user-select: none; -webkit-user-drag: none;
}
.lb-close {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,255,255,.12); border: none;
  color: #fff; font-size: 24px; line-height: 1;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; cursor: pointer;
  transition: background .15s; z-index: 2;
}
.lb-close:hover { background: rgba(255,255,255,.25); }

.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.1); border: none;
  color: #fff; font-size: 28px; line-height: 1;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
  transition: background .15s;
}
.lb-nav:hover { background: rgba(255,255,255,.22); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-footer {
  flex-shrink: 0;
  padding: 10px 20px 16px;
  background: rgba(0,0,0,.3);
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
}
.lb-counter {
  color: #fff;
  font-size: 12px; font-weight: 600;
  padding: 4px 14px;
  background: rgba(255,255,255,.1);
  border-radius: 20px;
}
.lb-thumbs {
  display: flex; gap: 6px;
  overflow-x: auto;
  max-width: 100%;
  padding: 4px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.3) transparent;
}
.lb-thumbs::-webkit-scrollbar { height: 6px; }
.lb-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.25);
  border-radius: 3px;
}
.lb-thumb {
  width: 70px; height: 50px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: .55;
  transition: opacity .15s, border-color .15s;
}
.lb-thumb:hover { opacity: .85; }
.lb-thumb.active {
  border-color: var(--accent);
  opacity: 1;
}
.lb-thumb img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

/* ===== CDM — Mobile ===== */
@media (max-width: 767px) {
  .cdm-overlay { padding: 0; align-items: flex-end; }
  .cdm-dialog {
    border-radius: 16px 16px 0 0;
    max-height: 95vh;
    transform: translateY(20px);
  }
  .cdm-overlay.open .cdm-dialog { transform: translateY(0) scale(1); }

  .cdm-body { padding: 12px; }
  .cdm-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .cdm-col-gallery {
    position: static;
    height: 240px;
    border-radius: 10px;
  }
  .cdm-col-info { gap: 14px; }
  .cdm-plate    { font-size: 20px; }
  .cdm-car-name { font-size: 16px; }
  .cdm-price-val { font-size: 17px; }
  .cdm-price-block { gap: 16px; padding: 12px 14px; }

  .lb-stage  { padding: 16px 8px 6px; }
  .lb-thumb  { width: 54px; height: 40px; }
}

/* Lightbox nav hidden on very narrow — swipe instead */
@media (max-width: 480px) {
  .lb-nav { display: none; }
}

/* ===== Drawer shared helpers ===== */
.drawer-title    { font-size: 16px; font-weight: 700; color: var(--text); }
.drawer-subtitle { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.drawer-x {
  background: none; border: none;
  color: var(--text-3); font-size: 24px; line-height: 1;
  padding: 0; cursor: pointer;
}
.drawer-x:hover { color: var(--text-2); }

/* ===== Models section ===== */
.models-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.models-title  { font-size: 15px; font-weight: 700; color: var(--text); }
.models-count  { font-size: 13px; color: var(--text-3); }
.models-warn   {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  color: var(--red-text);
  background: var(--red-bg); border: 1px solid #fca5a5;
  padding: 3px 10px; border-radius: 20px;
}

/* Строка без данных о мощности */
.model-row-nohp td { background: #fff8f8; }
.data-table tbody .model-row-nohp:hover td { background: var(--red-bg); }

.model-brand    { font-weight: 600; font-size: 13px; color: var(--text); }
.model-name     { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.model-cell     { font-size: 12px; color: var(--text-2); }
.model-cell-dim { font-size: 12px; color: var(--text-3); }

/* Используем span внутри td — не ломает табличный layout */
.model-hp-ok {
  font-size: 13px; font-weight: 700; color: var(--text);
}
.model-hp-missing {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  color: var(--red-text); white-space: nowrap;
}
.model-hp-missing i { font-size: 15px; flex-shrink: 0; }

/* Текущие данные в drawer редактирования */
.me-current { display: flex; flex-direction: column; gap: 8px; }
.me-current-vals { display: flex; gap: 6px; flex-wrap: wrap; }

/* Toolbar: фильтры + счётчик */
.models-toolbar {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.models-check {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text-2);
  cursor: pointer; user-select: none;
}
.models-check input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer;
  accent-color: var(--accent);
}
.models-shown {
  font-size: 12px; color: var(--text-3);
  margin-left: auto;
}

/* Сортируемые заголовки */
.th-sort {
  cursor: pointer; user-select: none;
  white-space: nowrap;
}
.th-sort:hover { color: var(--accent); }
.sort-icon {
  font-style: normal; font-size: 11px;
  color: var(--text-3); margin-left: 3px;
}

/* ===== Car row (desktop table) — классы вместо inline-стилей ===== */
.car-row-lot       { font-family: monospace; font-size: 12px; color: var(--text-3); font-weight: 700; }
.car-row-name      { font-weight: 600; font-size: 13px; line-height: 1.4; }
.car-row-vin       { font-family: monospace; font-size: 10px; color: var(--text-3); margin-top: 3px; }
.car-row-year      { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.car-row-plate     { font-size: 13px; font-weight: 600; color: var(--text); }
.car-row-regdate   { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.car-row-specs     { font-size: 12px; line-height: 1.8; color: var(--text-2); }
.car-row-mileage   { font-weight: 600; color: var(--text); }
.car-row-grade-row { margin-top: 5px; }
.car-row-price     { font-weight: 700; font-size: 14px; }
.car-row-actions   { display: flex; gap: 5px; align-items: center; }
