:root {
  --primary-red: #ef5350;
  --border-color: #dfdfdf;
  --bg-light: #f9f9f9;
  --bg-alt-section: #f5f5f5;
  --text-dark: #333;
  --text-muted: #777;
  --section-col-width: 90px;
  --label-col-width: 116px;
  --catalog-filter-height: 0px;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 20px;
  background-color: #fff;
  color: var(--text-dark);
}

h1 {
  text-align: center;
  color: var(--primary-red);
  margin-bottom: 30px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.compare-container {
  max-width: 1300px;
  margin: 0 auto;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.catalog-filters {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--border-color);
  border-bottom: none;
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.catalog-filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.catalog-filter-label {
  flex: 0 0 auto;
  min-width: 42px;
  font-size: 11px;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.catalog-filter-chip {
  appearance: none;
  border: 1px solid #ccc;
  background: #fff;
  color: var(--text-dark);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
}

.catalog-filter-chip:hover {
  border-color: #999;
}

.catalog-filter-chip.is-active {
  background: var(--primary-red);
  border-color: var(--primary-red);
  color: #fff;
}

.catalog-filter-clear {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.catalog-filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.catalog-filter-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
}

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

.catalog-filter-clear:hover:not(:disabled) {
  color: var(--primary-red);
  cursor: pointer;
}

.catalog-filter-clear:disabled {
  opacity: 0.35;
  cursor: default;
}

.slot-clear {
  align-self: flex-end;
  margin-top: -1px;
  margin-bottom: 0;
  padding: 0 2px;
  font-size: 10px;
  line-height: 1.2;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border-color);
}

th,
td {
  padding: 12px 6px;
  border: 1px solid var(--border-color);
  vertical-align: middle;
}

/* Sticky model/trim row only — image row scrolls away */
#compareTable thead th {
  background-color: #fff;
  text-align: center;
  width: 25%;
}

#selector-row th {
  background-color: #fff;
}

#selector-row th.selector-section-spacer,
#image-row th.selector-section-spacer {
  background-color: var(--bg-light);
  width: var(--section-col-width);
  min-width: var(--section-col-width);
  max-width: var(--section-col-width);
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  z-index: 4;
}

#image-row th.image-row-spacer {
  background-color: var(--bg-light);
  width: var(--label-col-width);
  min-width: var(--label-col-width);
  max-width: var(--label-col-width);
  position: -webkit-sticky;
  position: sticky;
  left: var(--section-col-width);
  z-index: 3;
}

#selector-row th.selector-label {
  position: -webkit-sticky;
  position: sticky;
  top: var(--catalog-filter-height);
  left: var(--section-col-width);
  z-index: 20;
  background-color: var(--bg-light);
  vertical-align: middle;
  width: var(--label-col-width);
  min-width: var(--label-col-width);
  max-width: var(--label-col-width);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.08);
}

#selector-row th.selector-section-spacer {
  top: var(--catalog-filter-height);
  z-index: 21;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.08);
}

.selector-label-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.selector-field-label {
  display: flex;
  align-items: center;
  min-height: 35px;
  color: #555;
  font-weight: bold;
  font-size: 13px;
  text-align: left;
  padding: 0 4px;
  box-sizing: border-box;
}

#selector-row th.selector-slot {
  position: -webkit-sticky;
  position: sticky;
  top: var(--catalog-filter-height);
  overflow: hidden;
  padding-bottom: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#selector-row th.selector-slot[data-slot="0"] {
  z-index: 16;
}

#selector-row th.selector-slot[data-slot="1"] {
  z-index: 15;
}

#selector-row th.selector-slot[data-slot="2"] {
  z-index: 14;
}

#image-row th {
  background-color: #fff;
  z-index: 1;
}

#compareTable thead th:first-child {
  background-color: var(--bg-light);
}

.search-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  overflow: visible;
}

.selector-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 95%;
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-weight: bold;
  font-size: 12px;
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-red);
}

.model-field:focus-within {
  outline: none;
  border-color: var(--primary-red);
}

.model-field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  cursor: text;
}

.model-field-cluster {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  width: max-content;
  overflow: hidden;
}

.model-field-input {
  flex: 0 1 auto;
  box-sizing: content-box;
  width: auto;
  min-width: 6em;
  max-width: 100%;
  field-sizing: content;
  border: 0;
  outline: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: bold;
  font-size: 12px;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-field-tags {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
}

.model-field-tags .dropdown-tag {
  padding: 0 3px;
  font-size: 10px;
  line-height: 1.25;
}

.search-input:disabled,
.trim-trigger:disabled {
  opacity: 0.7;
  cursor: default;
}

.trim-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  background: #fff;
  color: var(--text-dark);
}

.trim-trigger-main {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.trim-trigger-label {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trim-trigger-chevron {
  flex-shrink: 0;
  font-size: 10px;
  color: #888;
  line-height: 1;
}

.trim-dropdown {
  padding: 0;
}

.trim-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  font-family: inherit;
  font-weight: bold;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  color: var(--text-dark);
  box-sizing: border-box;
}

.trim-option-text {
  min-width: 0;
}

.trim-trigger-tags {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  min-width: 0;
  overflow: hidden;
}

.trim-trigger-tags .dropdown-tag {
  padding: 0 3px;
  font-size: 10px;
  line-height: 1.25;
}

.trim-option:last-child {
  border-bottom: none;
}

.trim-option:hover:not(:disabled) {
  background-color: #f5f5f5;
}

.trim-option.is-selected {
  background-color: #e8e8e8;
  color: var(--text-dark);
}

.trim-option.is-selected:hover:not(:disabled) {
  background-color: #e8e8e8;
}

.trim-option.is-disabled,
.trim-option:disabled {
  color: #999;
  font-style: italic;
  cursor: default;
  opacity: 0.7;
}

.trim-option.is-disabled:hover,
.trim-option:disabled:hover {
  background-color: #fff;
}

.search-dropdown {
  position: fixed;
  background-color: #fff;
  border: 1px solid var(--border-color);
  max-height: min(320px, 50vh);
  overflow-y: auto;
  z-index: 9999 !important;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
  display: none;
  text-align: left;
  border-radius: 0 0 4px 4px;
  box-sizing: border-box;
}

.search-dropdown.show {
  display: block;
}

.dropdown-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s ease;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background-color: #f5f5f5;
}

.dropdown-text {
  font-size: 13px;
  font-weight: bold;
  color: var(--text-dark);
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.dropdown-tags {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 2px;
}

.dropdown-tag {
  display: inline-block;
  flex: 0 0 auto;
  padding: 1px 4px;
  border-radius: 3px;
  background: #f0f2f5;
  border: 1px solid #e3e6eb;
  color: #555;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.dropdown-tag-muted {
  background: #f7f7f8;
  border-color: #ececec;
  color: #888;
  font-weight: 500;
}

.dropdown-tag-hybrid {
  background: #e8f3fb;
  border-color: #c5daf0;
  color: #2a628f;
}

.dropdown-tag-dealer {
  background: #e8f5ec;
  border-color: #c5e3d0;
  color: #2a6b45;
}

.dropdown-tag-market {
  background: #fbf3d9;
  border-color: #edd89a;
  color: #8a6a12;
}

.no-results {
  padding: 12px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

.image-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
}

.car-image {
  width: 100%;
  max-width: 200px;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
  display: block;
}

.image-fallback {
  width: 200px;
  height: 100px;
  background: linear-gradient(135deg, #eeeeee, #cccccc);
  color: #444;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  padding: 10px;
  box-sizing: border-box;
  border: 1px dashed #aaa;
}

.image-fallback.slot-empty {
  color: #666;
  font-weight: 500;
  font-size: 12px;
}

.trim-trigger-label.is-placeholder {
  color: #888;
}

th.section-header {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  z-index: 4;
  width: var(--section-col-width);
  min-width: var(--section-col-width);
  max-width: var(--section-col-width);
  background-color: var(--bg-light);
  color: var(--primary-red);
  font-weight: bold;
  text-transform: uppercase;
  font-size: 12px;
  text-align: left;
  border-right: 2px solid var(--primary-red);
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}

/* Full-width red rule between spec sections */
tr.section-spacer td {
  padding: 0;
  height: 2px;
  line-height: 0;
  font-size: 0;
  border: none;
  background-color: var(--primary-red);
}

td.row-label {
  position: -webkit-sticky;
  position: sticky;
  left: var(--section-col-width);
  z-index: 3;
  width: var(--label-col-width);
  min-width: var(--label-col-width);
  max-width: var(--label-col-width);
  background-color: var(--bg-light);
  font-weight: bold;
  color: #555;
  font-size: 13px;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}

td.data-cell {
  text-align: center;
  font-size: 13px;
  color: #444;
  line-height: 1.4;
}

tr.section-even td.data-cell {
  background-color: #fff;
}

tr.section-odd td.data-cell {
  background-color: var(--bg-alt-section);
}

tr.section-odd td.row-label {
  background-color: #f2f2f2;
}

a.price-link {
  color: var(--primary-red);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dotted var(--primary-red);
}

a.price-link:hover {
  text-decoration: underline;
}

.verify-legend {
  margin: 16px 4px 0;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.verify-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.verify-legend-desc {
  line-height: 1.4;
}

.verified-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0 5px;
  border-radius: 4px;
  background: #e3f2fd;
  color: #1565c0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  flex-shrink: 0;
  border: 1px solid rgba(21, 101, 192, 0.25);
  cursor: pointer;
  text-transform: lowercase;
  text-decoration: none;
  box-sizing: border-box;
}

.verified-badge:hover {
  background: #d2e3fc;
  text-decoration: underline;
}

.verify-legend .verified-badge-sample {
  cursor: default;
  pointer-events: none;
}

.feature-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  min-width: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-sizing: border-box;
}

.feature-pill-yes {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid rgba(46, 125, 50, 0.25);
}

.feature-pill-no {
  background: #ffebee;
  color: #c62828;
  border: 1px solid rgba(198, 40, 40, 0.25);
}

.feature-unknown {
  color: var(--muted, #888);
}

.feature-unknown-inline {
  margin: 0 0.25em;
}

.feature-not-applicable {
  color: var(--muted, #888);
  font-style: italic;
}

.feature-not-applicable-cell {
  color: var(--muted, #888);
  font-style: italic;
}

.feature-not-applicable-inline {
  font-style: italic;
  margin: 0 0.25em;
}
