:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-alt: #101827;
  --text: #101826;
  --muted: #5f6f87;
  --primary: #0d6efd;
  --primary-deep: #084298;
  --accent: #f59e0b;
  --success: #198754;
  --danger: #dc3545;
  --warning: #f4b740;
  --border: #dfe6ec;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
}

.container {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0;
}

.logo {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary-deep);
}

.site-header nav {
  display: flex;
  gap: 20px;
  align-items: center;
  font-weight: 600;
  color: var(--muted);
}

.site-header nav a:hover {
  color: var(--primary);
}

.flash-container {
  padding-top: 20px;
}

.flash {
  margin: 10px auto 0;
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 600;
}

.flash-success { background: rgba(25, 135, 84, 0.12); color: var(--success); }
.flash-danger { background: rgba(220, 53, 69, 0.1); color: var(--danger); }
.flash-warning { background: rgba(244, 183, 64, 0.1); color: #8a6200; }

.hero-section {
  padding: 24px 0 14px;
}

.hero-carousel {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  box-shadow: var(--shadow);
  min-height: 460px;
  background: #101827;
}

.hero-slide {
  display: none;
  position: relative;
  min-height: 460px;
}

.hero-slide.active {
  display: block;
}

.hero-slide img {
  width: 100%;
  height: 460px;
  object-fit: cover;
  filter: brightness(0.72);
}

.hero-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 60px;
  max-width: 640px;
  color: white;
}

.hero-content span {
  display: inline-block;
  width: fit-content;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 6px 12px;
  margin-bottom: 18px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-content h1 {
  font-size: clamp(2.2rem, 4vw, 4rem);
  margin: 0 0 14px;
}

.hero-content p {
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.6;
  margin: 0 0 24px;
}

.hero-actions {
  display: flex;
  gap: 12px;
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  transition: 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #3d8bfd);
  color: white;
}

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.full-width {
  width: 100%;
}

.search-form {
  display: grid;
  grid-template-columns: 2.1fr 1.2fr 1.2fr 1fr 0.85fr 0.85fr 0.9fr auto;
  gap: 14px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-top: 20px;
}

.search-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-group label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.search-group input,
.search-group select,
.field input,
.field select,
.field textarea,
.request-inline-form select,
.request-inline-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: white;
  color: var(--text);
}

.search-button {
  height: 48px;
}

.brands-section, .catalog-section {
  padding: 50px 0;
}

.section-header {
  margin-bottom: 24px;
}

.section-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

.brands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 18px;
}

.brand-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  background: linear-gradient(135deg, #0d1b2a, #1b2e4a);
  color: white;
  border-radius: 18px;
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
}

.vehicle-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: 0.2s ease;
}

.vehicle-card:hover {
  transform: translateY(-4px);
}

.vehicle-card.unavailable {
  filter: grayscale(0.2) saturate(0.7);
  opacity: 0.82;
  position: relative;
}

.vehicle-image-wrap {
  position: relative;
  min-height: 220px;
}

.vehicle-image-wrap img {
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.stock-banner {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(220, 53, 69, 0.9);
  color: white;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
}

.stock-banner.large {
  top: 20px;
  left: 20px;
  font-size: 0.86rem;
}

.vehicle-body {
  padding: 18px;
}

.vehicle-topline {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(13, 110, 253, 0.1);
  color: var(--primary-deep);
  padding: 6px 10px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge.muted {
  background: rgba(16, 24, 39, 0.06);
  color: var(--muted);
}

.vehicle-body h3 {
  margin: 0 0 10px;
  font-size: 1.5rem;
}

.vehicle-body p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.vehicle-meta {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
}

.vehicle-footer {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.vehicle-footer strong {
  font-size: 1.3rem;
}

.empty-state {
  grid-column: 1 / -1;
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.detail-section {
  padding: 52px 0 70px;
}

.detail-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 30px;
  align-items: center;
}

.detail-image-panel {
  position: relative;
  border-radius: 26px;
  overflow: hidden;
  background: white;
  box-shadow: var(--shadow);
}

.detail-image-panel img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.detail-gallery-stage {
  position: relative;
  min-height: 220px;
  background: #101827;
}

.detail-gallery-slide {
  width: 100%;
}

.detail-gallery-slide[hidden] {
  display: none;
}

.detail-gallery-slide > img,
.detail-gallery-slide > video,
.detail-gallery-slide .gallery-zoom-trigger,
.detail-image-fallback {
  display: block;
  width: 100%;
}

.detail-gallery-slide > img,
.detail-gallery-slide > video,
.detail-gallery-slide .gallery-zoom-trigger img,
.detail-image-fallback img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  background: #101827;
}

.gallery-zoom-trigger {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.gallery-arrow {
  position: absolute;
  z-index: 2;
  top: 50%;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(16, 24, 39, 0.7);
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.gallery-arrow:hover {
  background: rgba(13, 110, 253, 0.95);
  transform: translateY(-50%) scale(1.05);
}

.gallery-previous { left: 14px; }
.gallery-next { right: 14px; }

.gallery-counter {
  position: absolute;
  right: 14px;
  bottom: 14px;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(16, 24, 39, 0.72);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
}

.detail-gallery-thumbnails {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px;
  background: white;
}

.gallery-thumbnail {
  position: relative;
  flex: 0 0 92px;
  overflow: hidden;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #101827;
  cursor: pointer;
}

.gallery-thumbnail.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.18);
}

.gallery-thumbnail img,
.gallery-thumbnail video {
  display: block;
  width: 100%;
  height: 62px;
  aspect-ratio: auto;
  object-fit: cover;
}

.thumbnail-video-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  text-shadow: 0 1px 5px #000;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 50px 80px;
  background: rgba(3, 8, 18, 0.94);
}

.image-lightbox.open {
  display: flex;
}

.image-lightbox[aria-hidden="true"] {
  display: none;
}

.image-lightbox > img {
  max-width: min(100%, 1400px);
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 24px;
  z-index: 3;
  border: 0;
  background: transparent;
  color: white;
  font-size: 2.8rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-previous { left: 20px; }
.lightbox-next { right: 20px; }

body.lightbox-open {
  overflow: hidden;
}

.detail-info {
  background: white;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: 28px;
}

.detail-info h1 {
  margin: 14px 0 8px;
  font-size: clamp(2rem, 3vw, 3rem);
}

.detail-subtitle {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.detail-vehicle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.detail-vehicle-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5fa;
}

.detail-price {
  margin: 18px 0;
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-deep);
}

.detail-specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 18px;
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin: 20px 0;
}

.detail-specs span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.detail-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-details {
  margin-top: 26px;
}

.detail-details h3 {
  margin-bottom: 12px;
}

.detail-details ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.8;
  color: var(--muted);
}

.site-footer {
  background: var(--panel-alt);
  color: rgba(255, 255, 255, 0.8);
  padding: 40px 0;
  margin-top: 60px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 26px;
}

.site-footer h3,
.site-footer h4 {
  color: white;
}

.social-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.payment-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.payment-badges span {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 10px;
}

.auth-section {
  padding: 80px 0;
}

.auth-box {
  max-width: 500px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px;
  margin: 0 auto;
}

.auth-box h1 {
  margin-top: 0;
}

.auth-form,
.form-panel form {
  display: grid;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.admin-shell {
  padding: 50px 0 80px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 26px;
}

.narrow-layout {
  grid-template-columns: 220px minmax(0, 1fr);
}

.admin-sidebar {
  background: var(--panel-alt);
  color: white;
  border-radius: 20px;
  padding: 24px 18px;
  height: fit-content;
  box-shadow: var(--shadow);
}

.admin-sidebar h3 {
  margin-top: 0;
}

.admin-sidebar nav {
  display: grid;
  gap: 8px;
}

.admin-sidebar nav a {
  display: block;
  color: rgba(255,255,255,0.84);
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
}

.admin-sidebar nav a.active,
.admin-sidebar nav a:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.admin-main {
  display: grid;
  gap: 22px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 2.6rem);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
}

.stat-card strong {
  font-size: 2rem;
}

.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 14px 10px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.row-unavailable {
  background: rgba(220, 53, 69, 0.03);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-pill.ok {
  background: rgba(25, 135, 84, 0.12);
  color: var(--success);
}

.status-pill.danger {
  background: rgba(220, 53, 69, 0.12);
  color: var(--danger);
}

.action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-form {
  display: inline-block;
}

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  background: #edf3ff;
  color: var(--primary-deep);
}

.mini-btn.positive {
  background: rgba(25, 135, 84, 0.12);
  color: var(--success);
}

.mini-btn.negative {
  background: rgba(220, 53, 69, 0.12);
  color: var(--danger);
}

.mini-btn.danger {
  background: rgba(220, 53, 69, 0.12);
  color: var(--danger);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.catalog-add {
  width: fit-content;
  border: 0;
  background: transparent;
  color: var(--primary-deep);
  padding: 2px 0;
  font-weight: 700;
  cursor: pointer;
}

.catalog-add[hidden] {
  display: none;
}

.field small {
  color: var(--muted);
  line-height: 1.5;
}

.admin-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.admin-media-item {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.admin-media-item img,
.admin-media-item video {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #101827;
}

.admin-media-item span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  padding: 16px;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  overscroll-behavior: contain;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: min(620px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: white;
  border-radius: 22px;
  padding: 24px;
  position: relative;
  box-shadow: var(--shadow);
  margin: auto;
}

.modal-content h3 {
  margin: 4px 48px 18px 0;
}

.modal-content form {
  display: grid;
  gap: 12px;
}

.modal-content .form-row {
  gap: 12px;
}

.modal-content .field textarea {
  min-height: 80px;
}

.inline-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 22px;
}

.inline-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.inline-options input[type="radio"] {
  width: auto;
  margin: 0;
}

.modal-close {
  position: sticky;
  display: block;
  top: 0;
  margin: -8px -6px -38px auto;
  z-index: 2;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.form-message {
  min-height: 20px;
  margin: 12px 0 0;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .search-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .nav-bar {
    flex-direction: column;
    gap: 12px;
  }

  .site-header nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .search-form,
  .stats-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-content {
    padding: 0 24px;
  }

  .image-lightbox {
    padding: 52px 12px;
  }

  .gallery-arrow {
    width: 38px;
    height: 38px;
  }

  .lightbox-previous { left: 8px; }
  .lightbox-next { right: 8px; }
}
