/* AutoBid — нейтральное оформление поверх Bootstrap 5 */
:root {
  --ab-brand: #1d4ed8;
  --ab-brand-rgb: 29, 78, 216;
  --ab-ink: #0f172a;
  --ab-bg: #f3f5f9;
  --ab-surface: #ffffff;
  --ab-muted: #64748b;
  --ab-line: rgba(15, 23, 42, .08);
  --ab-radius: .75rem;
  --bs-primary: #1d4ed8;
  --bs-primary-rgb: 29, 78, 216;
  --bs-link-color: #1d4ed8;
  --bs-link-color-rgb: 29, 78, 216;
  --bs-link-hover-color: #1e40af;
}

body { background: var(--ab-bg); }
.btn-primary { --bs-btn-bg: #1d4ed8; --bs-btn-border-color: #1d4ed8; --bs-btn-hover-bg: #1e40af; --bs-btn-hover-border-color: #1e40af; --bs-btn-active-bg: #1e3a8a; --bs-btn-disabled-bg: #1d4ed8; --bs-btn-disabled-border-color: #1d4ed8; }
.btn-outline-primary { --bs-btn-color: #1d4ed8; --bs-btn-border-color: #1d4ed8; --bs-btn-hover-bg: #1d4ed8; --bs-btn-hover-border-color: #1d4ed8; --bs-btn-active-bg: #1d4ed8; --bs-btn-active-border-color: #1d4ed8; }
.nav-pills { --bs-nav-pills-link-active-bg: #1d4ed8; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.min-w-0 { min-width: 0; }
.text-bg-light { border: 1px solid rgba(15, 23, 42, .12); }
.fw-medium { font-weight: 500; }

/* ---------- Шапка ---------- */
.ab-navbar { background: var(--ab-ink); }
.ab-brand { display: inline-flex; align-items: center; gap: .55rem; color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: .01em; }
.ab-brand:hover { color: #fff; }
.ab-brand-mark { width: 32px; height: 32px; border-radius: 9px; display: inline-grid; place-items: center; font-size: .78rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); }
.ab-navbar .nav-link { color: rgba(255, 255, 255, .72); border-radius: .5rem; padding: .45rem .75rem; }
.ab-navbar .nav-link:hover, .ab-navbar .nav-link:focus { color: #fff; background: rgba(255, 255, 255, .07); }
.ab-navbar .nav-link.active { color: #fff; background: rgba(255, 255, 255, .14); }
.ab-navbar .nav-link { white-space: nowrap; }
.ab-topstrip { background: #020617; color: rgba(255, 255, 255, .75); font-size: .8rem; padding: .3rem 0; }
.ab-topstrip b { color: #fff; font-weight: 600; }
.ab-user-btn { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Заголовки и карточки ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; color: var(--ab-ink); }
.section-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ab-muted); margin: 1.25rem 0 .6rem; }
.section-title:first-child { margin-top: 0; }
.card { border: 1px solid var(--ab-line); border-radius: var(--ab-radius); box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.card-header { background: transparent; border-bottom-color: var(--ab-line); font-weight: 600; padding: .75rem 1rem; }
.card-footer { border-top-color: var(--ab-line); }

.stat { display: block; height: 100%; padding: .75rem 1rem; border-radius: var(--ab-radius); background: var(--ab-surface); border: 1px solid var(--ab-line); color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
a.stat:hover { border-color: rgba(var(--ab-brand-rgb), .4); }
.stat.active { border-color: var(--ab-brand); box-shadow: inset 0 0 0 1px var(--ab-brand); }
.stat-label { font-size: .8rem; color: var(--ab-muted); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.mini-stat { background: #f8fafc; border-radius: .6rem; padding: .5rem .7rem; height: 100%; }
.mini-stat.is-danger { background: #fef2f2; color: #b91c1c; }

.dl-grid { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: .4rem 1rem; margin: 0; }
.dl-grid dt { font-weight: 400; color: var(--ab-muted); }
.dl-grid dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.empty-state i { color: #cbd5e1; }

/* ---------- Таблицы ---------- */
.table-card { background: var(--ab-surface); border: 1px solid var(--ab-line); border-radius: var(--ab-radius); overflow: hidden; }
.table-card .table { margin: 0; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ab-muted); font-weight: 600; white-space: nowrap; background: #f8fafc; }
.table-sm > :not(caption) > * > * { padding: .4rem .6rem; }
.results.htmx-request, #bid-results.htmx-request, #car-results.htmx-request, #queue.htmx-request { opacity: .55; transition: opacity .15s; }
.row-updated > * { animation: row-flash 1.4s ease-out; }
@keyframes row-flash { from { background-color: #fef3c7; } to { background-color: transparent; } }

/* Таблицы-карточки на телефоне */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-card:has(> .table-stack) { background: transparent; border: 0; overflow: visible; }
  .table-stack tr { background: var(--ab-surface); border: 1px solid var(--ab-line); border-radius: var(--ab-radius); margin-bottom: .6rem; padding: .55rem .85rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
  .table-stack > :not(caption) > * > * { border: 0; padding: .28rem 0; box-shadow: none; background: transparent; }
  .table-stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; text-align: right; }
  .table-stack td::before { content: attr(data-label); flex-shrink: 0; color: var(--ab-muted); font-size: .82rem; text-align: left; }
  .table-stack td:not([data-label])::before { content: none; }
  .table-stack td.stack-head { display: block; text-align: left; font-size: 1rem; padding-bottom: .45rem; margin-bottom: .2rem; border-bottom: 1px dashed var(--ab-line); }
  .table-stack td.stack-actions { justify-content: flex-end; flex-wrap: wrap; gap: .4rem; padding-top: .5rem; }
  .card .table-stack tr { margin: .6rem; }
}

/* ---------- Таймлайн этапов машины ---------- */
.stage-timeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); }
.stage-step { position: relative; text-align: center; padding: 0 .2rem; }
.stage-step::before { content: ""; position: absolute; top: 18px; left: -50%; width: 100%; height: 3px; background: #e2e8f0; }
.stage-step:first-child::before { display: none; }
.stage-step.is-done::before, .stage-step.is-current::before { background: #16a34a; }
.stage-dot { position: relative; z-index: 1; width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; background: #e2e8f0; color: #64748b; font-size: 1rem; }
.stage-step.is-done .stage-dot { background: #16a34a; color: #fff; }
.stage-step.is-current .stage-dot { background: var(--ab-brand); color: #fff; box-shadow: 0 0 0 5px rgba(var(--ab-brand-rgb), .18); }
.stage-label { font-size: .78rem; line-height: 1.2; margin-top: .45rem; font-weight: 500; }
.stage-step.is-todo .stage-label { color: var(--ab-muted); font-weight: 400; }
.stage-date { font-size: .72rem; color: var(--ab-muted); font-variant-numeric: tabular-nums; }
@media (max-width: 767.98px) {
  .stage-timeline { grid-template-columns: 1fr; row-gap: .5rem; }
  .stage-step { display: flex; align-items: center; gap: .75rem; text-align: left; padding: 0; }
  .stage-step::before { top: calc(-50% - .25rem); left: 17px; width: 3px; height: calc(100% + .5rem); }
  .stage-dot { width: 36px; height: 36px; flex-shrink: 0; }
  .stage-label { margin: 0; font-size: .92rem; }
}

/* ---------- Фото ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.photo-item { position: relative; border-radius: .55rem; overflow: hidden; background: #e2e8f0; aspect-ratio: 4 / 3; }
.photo-item > a { display: block; width: 100%; height: 100%; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.photo-item a:hover img { transform: scale(1.04); }
.photo-item .photo-delete { position: absolute; top: .35rem; right: .35rem; }
.photo-item .photo-delete .btn { --bs-btn-padding-y: .1rem; --bs-btn-padding-x: .35rem; }
.thumbs { display: inline-flex; gap: .25rem; }
.thumbs img, .thumb-placeholder { width: 52px; height: 39px; object-fit: cover; border-radius: .35rem; }
.thumb-placeholder { display: inline-grid; place-items: center; background: #e2e8f0; color: #94a3b8; }
.viewer-stage { background: #000; min-height: 40vh; display: grid; place-items: center; }
.viewer-img { max-width: 100%; max-height: 78vh; object-fit: contain; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.25rem; }
.viewer-nav:hover { background: rgba(255, 255, 255, .3); }
.viewer-prev { left: .75rem; }
.viewer-next { right: .75rem; }

/* ---------- Байер ---------- */
.day-header { position: sticky; top: 56px; z-index: 5; background: var(--ab-bg); padding: .5rem 0; margin: 0 0 .5rem; }
.auction-block + .auction-block { margin-top: 1.25rem; }
.lot-card { display: block; background: var(--ab-surface); border: 1px solid var(--ab-line); border-radius: var(--ab-radius); padding: .85rem 1rem; }
.lot-card.border-danger { border-color: #dc3545; }
.lot-time { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.lot-amount { font-size: 1.3rem; font-weight: 700; color: var(--ab-brand); }
.final-price { max-width: 230px; }

/* ---------- Нижняя навигация дилера (телефон) ---------- */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; background: var(--ab-surface); border-top: 1px solid var(--ab-line); padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(15, 23, 42, .06); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; font-size: .72rem; color: var(--ab-muted); text-decoration: none; padding: .15rem 0; }
.bottom-nav a i { font-size: 1.3rem; line-height: 1.2; }
.bottom-nav a.active { color: var(--ab-brand); font-weight: 600; }
.bottom-nav .bottom-nav-primary i { width: 2.2rem; height: 1.75rem; border-radius: 999px; display: grid; place-items: center; background: var(--ab-brand); color: #fff; font-size: 1.1rem; }
@media (max-width: 767.98px) { body.has-bottom-nav { padding-bottom: 4.75rem; } }

/* ---------- Вход ---------- */
.login-page main { min-height: 100vh; display: grid; place-items: center; }
.login-wrap { width: 100%; max-width: 420px; }
.login-page .ab-brand { color: var(--ab-ink); font-size: 1.6rem; }
.demo-login { cursor: pointer; }
.demo-login:hover { background: #f1f5f9; }

@media (max-width: 575.98px) {
  .page-title { font-size: 1.3rem; }
  .stat-value { font-size: 1.35rem; }
  main.container-xl { padding-left: .75rem; padding-right: .75rem; }
}
