  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;700&display=swap');

  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface2: #1e2530;
    --border: #2a3441;
    --accent: #00e5a0;
    --accent-dim: rgba(0, 229, 160, 0.12);
    --accent-glow: rgba(0, 229, 160, 0.25);
    --text: #e6edf3;
    --text-muted: #7d8fa3;
    --text-dim: #4a5568;
    --tag-bg: #1e3a2f;
    --tag-text: #00e5a0;
    --red: #ff4d6d;
    --yellow: #ffd166;
    --blue: #4da6ff;
    --overlay-bg: rgba(0,0,0,0.7);
    --header-bg: rgba(13,17,23,0.92);
  }

  html[data-theme="light"] {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface2: #eef1f5;
    --border: #d8dee5;
    --accent: #00a876;
    --accent-dim: rgba(0, 168, 118, 0.10);
    --accent-glow: rgba(0, 168, 118, 0.25);
    --text: #14171a;
    --text-muted: #5b6573;
    --text-dim: #8b95a1;
    --tag-bg: #e2f5ec;
    --tag-text: #00875f;
    --red: #d6304a;
    --yellow: #b8860b;
    --blue: #1c6fd9;
    --overlay-bg: rgba(0,0,0,0.35);
    --header-bg: rgba(246,248,250,0.92);
  }

  html, body { transition: background 0.2s ease, color 0.2s ease; }
  *, *::before, *::after { transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; }

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

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
  }

  /* HEADER */
  header {
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    z-index: 100;
  }

  .logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
  }

  .logo span { color: var(--accent); }

  .result-badge {
    background: var(--accent-dim);
    border: 1px solid var(--accent-glow);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 0.3px;
  }

  /* LAYOUT */
  .layout {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 60px);
  }

  /* SIDEBAR */
  aside {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    padding: 24px;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
  }

  .filter-section { margin-bottom: 28px; }

  .filter-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .filter-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
  }

  /* Category-tinted section labels (light touch — text + divider only) */
  .filter-label.cat-label-safety   { color: var(--blue); }
  .filter-label.cat-label-driver   { color: var(--red); }
  .filter-label.cat-label-charging { color: var(--accent); }
  .filter-label.cat-label-tech     { color: #b084ff; }
  .filter-label.cat-label-comfort  { color: var(--yellow); }

  .filter-label.cat-label-safety::after   { background: linear-gradient(90deg, rgba(77,166,255,0.35), transparent); }
  .filter-label.cat-label-driver::after   { background: linear-gradient(90deg, rgba(255,77,109,0.35), transparent); }
  .filter-label.cat-label-charging::after { background: linear-gradient(90deg, rgba(0,229,160,0.35), transparent); }
  .filter-label.cat-label-tech::after     { background: linear-gradient(90deg, rgba(176,132,255,0.35), transparent); }
  .filter-label.cat-label-comfort::after  { background: linear-gradient(90deg, rgba(255,209,102,0.35), transparent); }

  html[data-theme="light"] .filter-label.cat-label-safety   { color: #1c5fb8; }
  html[data-theme="light"] .filter-label.cat-label-driver   { color: #c0203c; }
  html[data-theme="light"] .filter-label.cat-label-tech     { color: #7a3fd9; }
  html[data-theme="light"] .filter-label.cat-label-comfort  { color: #a06a00; }

  select, input[type="text"] {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    appearance: none;
    outline: none;
    transition: border-color 0.15s;
  }

  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237d8fa3' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
  }

  select:focus, input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
  }

  /* RANGE SLIDERS */
  .slider-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
  }

  .slider-val { color: var(--accent); font-weight: 600; }

  input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 4px;
    background: var(--border);
    outline: none;
    appearance: none;
    cursor: pointer;
    margin-bottom: 4px;
  }

  input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 0 3px var(--accent-dim);
    transition: box-shadow 0.15s;
  }

  input[type="range"]::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 5px var(--accent-glow);
  }

  /* CHECKBOXES */
  .feature-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
  }

  .feature-grid::-webkit-scrollbar { width: 4px; }
  .feature-grid::-webkit-scrollbar-track { background: transparent; }
  .feature-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  .checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 6px;
    transition: background 0.1s;
  }

  .checkbox-item:hover { background: var(--surface2); }

  .checkbox-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
  }

  .checkbox-item label {
    font-size: 12.5px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1.3;
  }

  /* Category-tinted checkboxes — matches .ftag colors on the cards */
  .checkbox-item.cat-safety  input[type="checkbox"] { accent-color: var(--blue); }
  .checkbox-item.cat-tech    input[type="checkbox"] { accent-color: #b084ff; }
  .checkbox-item.cat-comfort input[type="checkbox"] { accent-color: var(--yellow); }
  .checkbox-item.cat-charging input[type="checkbox"] { accent-color: var(--accent); }
  .checkbox-item.cat-driver  input[type="checkbox"] { accent-color: var(--red); }
  .checkbox-item.cat-info    input[type="checkbox"] { accent-color: #4dd9e5; }

  .checkbox-item.cat-safety:hover  { background: rgba(77,166,255,0.08); }
  .checkbox-item.cat-tech:hover    { background: rgba(176,132,255,0.08); }
  .checkbox-item.cat-comfort:hover { background: rgba(255,209,102,0.08); }
  .checkbox-item.cat-charging:hover { background: var(--accent-dim); }
  .checkbox-item.cat-driver:hover  { background: rgba(255,77,109,0.08); }
  .checkbox-item.cat-info:hover    { background: rgba(77,217,229,0.08); }

  .checkbox-item.cat-safety  input:checked ~ label { color: var(--blue); }
  .checkbox-item.cat-tech    input:checked ~ label { color: #b084ff; }
  .checkbox-item.cat-comfort input:checked ~ label { color: var(--yellow); }
  .checkbox-item.cat-charging input:checked ~ label { color: var(--accent); }
  .checkbox-item.cat-driver  input:checked ~ label { color: var(--red); }
  .checkbox-item.cat-info    input:checked ~ label { color: #4dd9e5; }

  /* SEARCH BAR */
  .search-wrap {
    position: relative;
    margin-bottom: 28px;
  }

  .search-icon {
    position: absolute;
    left: 12px;
    top: 19px;
    transform: translateY(-50%);
    color: var(--text-muted);
  }

  .search-wrap input { padding-left: 36px; }

  /* YEAR MULTI-SELECT PILLS */
  .year-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .year-pill {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 11px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
  }

  .year-pill:hover {
    border-color: var(--accent);
    color: var(--text);
  }

  .year-pill.selected {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
  }

  /* SEARCH HINT */
  .search-hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 6px;
    padding-left: 2px;
  }

  /* RESET BUTTON */
  .btn-reset {
    width: 100%;
    padding: 9px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
    margin-top: 8px;
  }

  .btn-reset:hover {
    border-color: var(--red);
    color: var(--red);
  }

  /* MAIN CONTENT */
  main {
    flex: 1;
    padding: 24px;
    overflow: hidden;
  }

  /* SORT ROW */
  .sort-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
  }

  .sort-row label {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
  }

  .sort-row select {
    width: auto;
    flex: 1;
    max-width: 220px;
  }

  /* VIEW TOGGLE */
  .view-toggle {
    display: flex;
    gap: 4px;
    margin-left: auto;
  }

  .view-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
  }

  .view-btn.active, .view-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
  }

  /* ACTIVE FILTER PILLS */
  #active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    min-height: 0;
  }

  #active-filters:empty { margin-bottom: 0; }

  .active-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-glow);
    color: var(--accent);
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px 3px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
  }

  .active-pill:hover {
    background: rgba(255, 77, 109, 0.12);
    border-color: rgba(255, 77, 109, 0.4);
    color: var(--red);
  }

  .active-pill .pill-x {
    font-size: 13px;
    line-height: 1;
    opacity: 0.7;
  }

  .pill-clear-all {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Inter', sans-serif;
  }

  .pill-clear-all:hover {
    border-color: var(--red);
    color: var(--red);
  }

  /* CARD GRID */
  #results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
  }

  #results-grid.list-view { grid-template-columns: 1fr; }

  /* EV CARD */
  .ev-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
  }

  .ev-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.15s;
  }

  .ev-card:hover {
    border-color: rgba(0, 229, 160, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  }

  .ev-card:hover::before { opacity: 1; }

  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .car-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
  }

  .car-year {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
  }

  .body-style-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
  }

  /* STAT GRID */
  .stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }

  .stat {
    background: var(--surface2);
    border-radius: 8px;
    padding: 8px 10px;
  }

  .stat-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 2px;
  }

  .stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
  }

  .stat-value.highlight { color: var(--accent); }

  .stat-value .price-high {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
  }

  /* FEATURE TAGS */
  .feature-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .ftag {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--tag-bg);
    color: var(--tag-text);
    border: 1px solid rgba(0, 229, 160, 0.2);
  }

  .ftag.safety { background: #1a2a3a; color: var(--blue); border-color: rgba(77,166,255,0.2); }
  .ftag.tech { background: #2a1a3a; color: #b084ff; border-color: rgba(176,132,255,0.2); }
  .ftag.comfort { background: #2a2a1a; color: var(--yellow); border-color: rgba(255,209,102,0.2); }
  .ftag.charging { background: #1a3a2f; color: var(--accent); border-color: rgba(0,229,160,0.2); }
  .ftag.driver { background: #2a1a1a; color: var(--red); border-color: rgba(255,77,109,0.2); }
  .ftag.info { background: #1a2a2a; color: #4dd9e5; border-color: rgba(77,217,229,0.2); }

  html[data-theme="light"] .ftag.safety { background: #e3effc; color: #1c5fb8; border-color: rgba(28,95,184,0.2); }
  html[data-theme="light"] .ftag.tech { background: #f1e9fc; color: #7a3fd9; border-color: rgba(122,63,217,0.2); }
  html[data-theme="light"] .ftag.comfort { background: #fdf2da; color: #a06a00; border-color: rgba(160,106,0,0.2); }
  html[data-theme="light"] .ftag.charging { background: #dcf5ea; color: #00875f; border-color: rgba(0,135,95,0.2); }
  html[data-theme="light"] .ftag.driver { background: #fbe2e6; color: #c0203c; border-color: rgba(192,32,60,0.2); }
  html[data-theme="light"] .ftag.info { background: #dcf3f5; color: #16808c; border-color: rgba(22,128,140,0.2); }

  html[data-theme="light"] .checkbox-item.cat-safety  input[type="checkbox"] { accent-color: #1c5fb8; }
  html[data-theme="light"] .checkbox-item.cat-tech    input[type="checkbox"] { accent-color: #7a3fd9; }
  html[data-theme="light"] .checkbox-item.cat-comfort input[type="checkbox"] { accent-color: #a06a00; }
  html[data-theme="light"] .checkbox-item.cat-driver  input[type="checkbox"] { accent-color: #c0203c; }
  html[data-theme="light"] .checkbox-item.cat-info    input[type="checkbox"] { accent-color: #16808c; }

  html[data-theme="light"] .checkbox-item.cat-safety  input:checked ~ label { color: #1c5fb8; }
  html[data-theme="light"] .checkbox-item.cat-tech    input:checked ~ label { color: #7a3fd9; }
  html[data-theme="light"] .checkbox-item.cat-comfort input:checked ~ label { color: #a06a00; }
  html[data-theme="light"] .checkbox-item.cat-driver  input:checked ~ label { color: #c0203c; }
  html[data-theme="light"] .checkbox-item.cat-info    input:checked ~ label { color: #16808c; }

  .ftag-more {
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
  }

  .ftag-more:hover {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
  }

  /* search match highlight */
  .search-match { background: rgba(0,229,160,0.15); border-radius: 2px; padding: 0 1px; }

  /* MODAL */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalIn 0.18s ease;
  }
  @keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }
  .modal::-webkit-scrollbar { width: 4px; }
  .modal::-webkit-scrollbar-track { background: transparent; }
  .modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
  .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px 24px 16px;
    position: sticky;
    top: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 1;
  }
  .modal-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
  }
  .modal-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
  .modal-close {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
    margin-left: 16px;
  }
  .modal-close:hover { border-color: var(--red); color: var(--red); }
  .modal-body { padding: 20px 24px 24px; }
  .modal-specs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 24px;
  }
  .modal-spec { background: var(--surface2); border-radius: 10px; padding: 12px; }
  .modal-spec-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 4px;
  }
  .modal-spec-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
  }
  .modal-spec-value.highlight { color: var(--accent); }
  .modal-spec-value .price-high {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
  }
  .modal-section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .modal-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
  .modal-feature-group { margin-bottom: 18px; }
  .modal-feature-group-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 7px;
  }
  .modal-feature-tags { display: flex; flex-wrap: wrap; gap: 6px; }

  .modal-disclaimer {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
  }
  @media (max-width: 480px) {
    .modal-specs { grid-template-columns: repeat(2, 1fr); }
  }

  /* LIST VIEW CARD */
  .list-view .ev-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: start;
  }

  .list-view .card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .list-view .stat-grid {
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 0;
  }

  .list-view .card-side {
    text-align: right;
    min-width: 120px;
  }

  /* EMPTY STATE */
  .empty {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
    grid-column: 1 / -1;
  }

  .empty-icon { font-size: 48px; margin-bottom: 16px; }
  .empty h3 { font-size: 18px; margin-bottom: 8px; color: var(--text); }

  /* LOADING */
  .loading {
    text-align: center;
    padding: 80px;
    color: var(--text-muted);
    grid-column: 1/-1;
  }

  /* SCROLLBAR */
  aside::-webkit-scrollbar { width: 4px; }
  aside::-webkit-scrollbar-track { background: transparent; }
  aside::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  /* RESPONSIVE */
  @media (max-width: 768px) {
    .layout { flex-direction: column; }
    aside { width: 100%; position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .list-view .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .list-view .ev-card { grid-template-columns: 1fr; }
    .list-view .card-side { text-align: left; }
  }
