* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6f9; --card: #fff; --border: #e2e6ec;
  --text: #1c2430; --muted: #6b7686; --accent: #2563eb; --accent-h: #1d4ed8;
  --green: #16a34a; --red: #dc2626;
}
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }

.topbar { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-bottom: 1px solid var(--border); padding: 12px 20px; position: sticky; top: 0; z-index: 20; }
.topbar .brand { font-weight: 700; font-size: 17px; }
.topbar .user { color: var(--muted); font-size: 14px; display: flex; gap: 12px; align-items: center; }

.container { max-width: 900px; margin: 0 auto; padding: 20px 16px 90px; }
.wide { max-width: 1100px; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 8px 16px; border: 1px solid var(--border); border-radius: 20px; background: var(--card); cursor: pointer; font-size: 14px; }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }

/* Аккордеон марок */
.brand-item { background: var(--card); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.brand-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; cursor: pointer; user-select: none; }
.brand-head:hover { background: #f8fafc; }
.brand-head .name { font-weight: 600; font-size: 15px; }
.brand-head .meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.brand-head .count { background: var(--accent); color: #fff; border-radius: 12px; padding: 1px 9px; font-size: 12px; }
.brand-head .chevron { transition: transform .15s; color: var(--muted); }
.brand-item.open .chevron { transform: rotate(90deg); }
.brand-body { display: none; border-top: 1px solid var(--border); padding: 6px 16px 12px; }
.brand-item.open .brand-body { display: block; }

.model-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed #eef1f5; flex-wrap: wrap; }
.model-row:last-child { border-bottom: none; }
.model-row label { display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 220px; font-size: 14px; }
.model-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.years { display: none; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.model-row.checked .years { display: flex; }
.years select { padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: #fff; }
.years input[type="number"] { width: 76px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: #fff; }
.years .mileage-label { margin-left: 14px; }

.savebar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--border); padding: 12px 20px; display: flex; justify-content: center; gap: 14px; align-items: center; z-index: 30; }
.savebar .summary { color: var(--muted); font-size: 14px; }

button.btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 10px 26px; font-size: 15px; cursor: pointer; }
button.btn:hover { background: var(--accent-h); }
button.btn.secondary { background: #eef1f5; color: var(--text); }
button.btn.danger { background: var(--red); }
button.btn.small { padding: 6px 12px; font-size: 13px; }
button.btn:disabled { opacity: .5; cursor: default; }

.toast { position: fixed; top: 64px; right: 20px; background: var(--green); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; opacity: 0; transition: opacity .25s; z-index: 50; }
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }

/* Логин */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 340px; }
.login-card h1 { font-size: 20px; margin-bottom: 18px; text-align: center; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; font-size: 15px; }
.login-card button { width: 100%; }
.login-card .err { color: var(--red); font-size: 13px; margin-bottom: 10px; min-height: 16px; }

/* Таблицы */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tr:hover td { background: #f8fafc; }
.badge { display: inline-block; background: #eef2ff; color: var(--accent); border-radius: 6px; padding: 2px 8px; font-size: 12px; margin: 2px 3px 2px 0; }
.pill { display: inline-block; border-radius: 10px; padding: 2px 10px; font-size: 12px; }
.pill.copart { background: #fef3c7; color: #92400e; }
.pill.iaai { background: #dbeafe; color: #1e40af; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }

.form-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.form-row label { font-size: 14px; min-width: 220px; }
.form-row input[type="number"], .form-row input[type="text"], .form-row input[type="password"] { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.switch { width: 18px; height: 18px; accent-color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; }
.search-box { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; margin-bottom: 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; font-size: 14px; }

/* ======= Вкладка Buy Now лотов ======= */
.upd-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.inner-tabs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.itab { padding: 6px 14px; font-size: 13px; cursor: pointer; background: transparent; border: 1px solid var(--border); border-radius: 20px; color: var(--muted); display: flex; align-items: center; gap: 5px; line-height: 1; }
.itab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.ibadge { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: rgba(0,0,0,.08); }
.itab.active .ibadge { background: rgba(255,255,255,.25); }
.info-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: rgba(0,0,0,.08); color: var(--muted); font-size: 11px; font-style: italic; font-weight: 700; font-family: Georgia, serif; cursor: default; }
.itab.active .info-icon { background: rgba(255,255,255,.25); color: #fff; }
.info-icon .info-tip { display: none; position: absolute; top: 130%; left: 0; z-index: 40; width: max-content; max-width: 220px; background: var(--text); color: #fff; font-size: 12px; font-style: normal; font-weight: 400; line-height: 1.4; padding: 8px 10px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.info-icon:hover .info-tip, .info-icon:focus .info-tip { display: block; }
.sort-ctrl { display: flex; gap: 6px; margin-left: auto; }
.sortbtn { padding: 6px 12px; font-size: 12px; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.sortbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.upd-source-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.page-size-lbl { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.page-size-select { padding: 4px 8px; font-size: 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); }
.page-nav { display: flex; align-items: center; gap: 10px; }
.pagebtn { padding: 5px 12px; font-size: 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer; }
.pagebtn:disabled { opacity: .4; cursor: default; }
.page-info { font-size: 13px; color: var(--muted); white-space: nowrap; }
.lot-cards { display: flex; flex-direction: column; gap: 8px; }
.lot-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; gap: 14px; }
.lot-card.is-new { border-left: 3px solid var(--accent); }
.lot-card.is-sold { opacity: .6; border-left: 3px solid var(--red); }
.lot-card.is-fav { background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
.lot-photos { position: relative; flex: 0 0 220px; width: 220px; height: 135px; display: flex; align-items: center; justify-content: center; }
.lot-photos-clip { position: relative; flex: 0 0 180px; width: 180px; height: 135px; border-radius: 8px; overflow: hidden; background: transparent; }
.lot-photos-track { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.lot-photos-track::-webkit-scrollbar { display: none; }
.lot-photo { flex: 0 0 180px; width: 180px; height: 135px; padding: 8px; box-sizing: border-box; object-fit: contain; scroll-snap-align: start; cursor: pointer; }
.lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.92); }
.lightbox-main { position: relative; z-index: 1; flex: 1; width: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; }
.lightbox-img { max-width: 92vw; max-height: 78vh; object-fit: contain; border-radius: 4px; }
.lightbox-close { position: absolute; top: 16px; right: 20px; z-index: 2; background: none; border: none; color: #fff; font-size: 34px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; background: rgba(255,255,255,.15); color: #fff; border: none; width: 48px; height: 48px; border-radius: 50%; font-size: 30px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lightbox-nav:hover { background: rgba(255,255,255,.3); }
.lightbox-nav.prev { left: 20px; }
.lightbox-nav.next { right: 20px; }
.lightbox-counter { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 2; color: #fff; font-size: 13px; background: rgba(0,0,0,.5); padding: 4px 14px; border-radius: 12px; }
.lightbox-thumbs { position: relative; z-index: 1; flex: 0 0 auto; display: flex; gap: 6px; padding: 12px 16px; max-width: 100vw; overflow-x: auto; scrollbar-width: thin; }
.lightbox-thumb { flex: 0 0 64px; width: 64px; height: 64px; object-fit: cover; border-radius: 4px; cursor: pointer; opacity: .5; border: 2px solid transparent; transition: opacity .15s, border-color .15s; }
.lightbox-thumb:hover { opacity: .85; }
.lightbox-thumb.active { opacity: 1; border-color: #fff; }
.photo-nav { position: absolute; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text); font-size: 22px; line-height: 1; padding: 4px; cursor: pointer; }
.photo-nav:hover { color: var(--accent); }
.photo-nav.prev { left: 0; }
.photo-nav.next { right: 0; }
.photo-count { position: absolute; bottom: 4px; right: 4px; background: rgba(0,0,0,.55); color: #fff; font-size: 9px; padding: 1px 5px; border-radius: 8px; }
.lot-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lot-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.lot-title { font-size: 15px; font-weight: 600; }
.lot-price { font-size: 14px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.lot-price.muted { color: var(--muted); font-weight: 400; }
.lot-meta { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 10px; }
.lot-row { font-size: 13px; }
.lot-lbl { color: var(--muted); }
.lot-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; }
.lot-date { color: var(--muted); font-size: 12px; }
.lot-link { color: var(--accent); }
.sold-badge { display: inline-block; background: #fee2e2; color: #991b1b; border-radius: 10px; padding: 2px 8px; font-size: 11px; font-weight: 600; margin-left: 6px; vertical-align: middle; }
.fav-star { background: none; border: none; cursor: pointer; font-size: 16px; line-height: 1; padding: 0; margin-left: 6px; vertical-align: middle; color: var(--muted); }
.fav-star.active { color: #f59e0b; }
.fav-star:hover { color: #f59e0b; }
.brand-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.bfbtn { padding: 5px 12px; font-size: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.bfbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.bfbtn.active .ibadge { background: rgba(255,255,255,.25); }
.model-filters { display: flex; flex-wrap: wrap; gap: 5px; margin: -4px 0 14px 14px; }
.mfbtn { padding: 3px 10px; font-size: 11px; border: 1px solid var(--border); border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.mfbtn.active { background: var(--text); color: #fff; border-color: var(--text); }
.mfbtn.active .ibadge { background: rgba(255,255,255,.25); }
