*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --orange:     #e8682a;
  --orange-dk:  #cc5720;
  --orange-lt:  #fff5f0;
  --bg:         #f2f4f8;
  --card-bg:    #ffffff;
  --header-bg:  #1c2340;
  --text-main:  #1e2235;
  --text-soft:  #7b8499;
  --border:     #e8eaf0;
  --radius:     14px;
  --shadow-sm:  0 2px 10px rgba(0,0,0,0.055);
  --shadow-md:  0 10px 32px rgba(0,0,0,0.10);
  --transition: 0.3s cubic-bezier(.4,0,.2,1);
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
}

header {
  background: linear-gradient(135deg, #1c2340 0%, #2a3260 100%);
  color: white;
  padding: 28px 30px 24px;
  text-align: center;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 8px 16px;
  background: var(--orange);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  transition: background var(--transition);
}
.back-btn:hover { background: var(--orange-dk); }

header h1 {
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #f0f0f0;
}

header p {
  margin-top: 4px;
  font-size: 13px;
  color: #9ca3af;
}

.controls-wrap {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(242,244,248,0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.search-wrap {
  width: 95%;
  max-width: 520px;
  margin: 0 auto 12px;
  position: relative;
}
.search-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  pointer-events: none;
}
#searchInput {
  width: 100%;
  padding: 11px 16px 11px 42px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: 14px;
  background: white;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
#searchInput:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(240,94,28,0.12);
}
#searchInput::placeholder { color: #9ca3af; }

.tabs-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 16px 4px;
}
.tabs-scroll::-webkit-scrollbar { display: none; }
.tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  width: max-content;
  min-width: 100%;
  justify-content: center;
}
.tab {
  flex-shrink: 0;
  padding: 0 18px;
  height: 38px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  transition: all var(--transition);
  user-select: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
  box-sizing: border-box;
}

.tab span {
  display: inline;
  line-height: 1;
  font-size: 13px;
  vertical-align: middle;
}
.tab:hover { border-color: var(--orange); color: var(--orange); background: var(--orange-lt); }
.tab.active {
  background: var(--orange);
  border-color: var(--orange);
  color: white;
  box-shadow: 0 2px 10px rgba(232,104,42,0.28);
}

.container {
  width: 95%;
  max-width: 1400px;
  margin: 28px auto 80px;
  scroll-margin-top: 120px;
}

.result-count {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 18px;
}

.loading-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-soft);
  gap: 16px;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state p {
  font-size: 14px;
  font-weight: 500;
}

.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px,1fr));
  gap: 22px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 18px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
  animation: fadeUp 0.35s ease both;
  min-height: 320px;
}
@keyframes fadeUp {
  from { opacity:0; transform:translateY(16px); }
  to   { opacity:1; transform:translateY(0); }
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-md); }

.card-img-wrap {
  width: 100%;
  height: 168px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #f8f9fb, #f0f2f6);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
}
.card-img-wrap img {
  max-width: 88%;
  max-height: 88%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform 0.4s ease;
}
.card:hover .card-img-wrap img { transform: scale(1.05); }

.card h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 9px;
  line-height: 1.3;
  min-height: 2.6em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fuel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 14px;
  min-height: 26px;
  white-space: nowrap;
}
.fuel-diesel   { background:#fff3cd; color:#856404; }
.fuel-petrol   { background:#d1fae5; color:#065f46; }
.fuel-electric { background:#dbeafe; color:#1e40af; }
.fuel-battery  { background:#ede9fe; color:#5b21b6; }
.fuel-mixed    { background:#fce7f3; color:#9d174d; }
.fuel-na       { background:#f3f4f6; color:#6b7280; }

.card-btn {
  margin-top: auto;
  padding: 10px 0;
  width: 100%;
  background: var(--orange);
  border: none;
  color: white;
  font-weight: 700;
  font-size: 13.5px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.card-btn:hover { background: var(--orange-dk); transform: scale(1.02); }

.no-results {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-soft);
}
.no-results span { font-size: 40px; display: block; margin-bottom: 12px; }

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(10,10,20,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
  will-change: opacity;
}
.viewer.open  { opacity: 1; }
.viewer.closing { opacity: 0; pointer-events: none; }

.viewer-content {
  background: white;
  width: 1100px;
  max-width: 96%;
  max-height: 90vh;
  border-radius: 16px;
  display: flex;
  overflow: hidden;
  position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  transform: translateY(22px) scale(0.97);
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
}
.viewer.open .viewer-content { transform: translateY(0) scale(1); }

.viewer-image {
  flex: 1.1;
  background: linear-gradient(145deg, #f5f6fa, #edf0f5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  min-height: 460px;
  overflow: hidden;
}
.viewer-image img {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 440px;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}

.viewer-details {
  flex: 1.2;
  padding: 36px 36px 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  border-left: 1px solid var(--border);
}

.category-badge {
  display: inline-block;
  background: #fff3eb;
  color: var(--orange);
  border: 1.5px solid #fcd9c0;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.viewer-details h2 {
  font-size: 21px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 10px;
  line-height: 1.25;
}

.specs-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 14px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #fff0e8;
}

.specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.specs p {
  font-size: 13px;
  color: var(--text-main);
  padding: 7px 10px 7px 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}
.specs p:nth-child(even) {
  padding-left: 14px;
  border-left: 1px solid var(--border);
}
.specs p b {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 2px;
  letter-spacing: 0.3px;
}

.close-btn {
  position: absolute;
  top: 14px; right: 16px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #f3f4f6;
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  transition: background var(--transition), color var(--transition);
  z-index: 10;
}
.close-btn:hover { background: #fee2e2; color: #dc2626; }

.quote-btn {
  display: inline-block;
  margin-top: 22px;
  padding: 12px 22px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 9px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition);
  align-self: flex-start;
}
.quote-btn:hover { background: var(--orange-dk); transform: scale(1.02); }

#backToTop {
  position: fixed;
  bottom: 30px; right: 28px;
  width: 44px; height: 44px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(240,94,28,0.4);
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  z-index: 500;
  opacity: 0;
}
#backToTop:hover { background: var(--orange-dk); transform: scale(1.1); }
#backToTop.visible { display: flex; opacity: 1; }

@media (max-width: 700px) {
  .viewer-content { flex-direction: column; max-height: 92vh; overflow-y: auto; }
  .viewer-image { min-height: 160px; max-height: 220px; padding: 14px; flex-shrink: 0; }
  .viewer-details { padding: 16px 16px 24px; overflow-y: visible; }
  .specs { grid-template-columns: 1fr; }
  .specs p:nth-child(even) { border-left: none; padding-left: 0; }
  .products { grid-template-columns: repeat(auto-fill, minmax(155px,1fr)); gap: 14px; }
  #backToTop { bottom: max(20px, env(safe-area-inset-bottom, 20px)); right: 16px; }
  .viewer-details h2 { font-size: 17px; }
  .quote-btn { width: 100%; text-align: center; margin-top: 16px; }
}
