:root {
  color-scheme: light;
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --line: #dedfe2;
  --line-soft: #ececef;
  --text: #18191c;
  --muted: #73767d;
  --red: #d71934;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.topbar {
  height: 72px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  padding: 0 max(24px, calc((100% - 1080px) / 2));
}
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; }
.brand-mark, .vehicle-symbol {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #fff;
  background: var(--red);
  font-weight: 700;
}
.brand > span:last-child { display: flex; gap: 5px; align-items: baseline; }
.brand strong { font-size: 18px; }
.brand small { color: var(--muted); font-size: 13px; }

main { width: min(1080px, calc(100% - 40px)); margin: 0 auto; }
.search-section { padding: 64px 0 42px; }
.search-shell {
  display: flex;
  align-items: center;
  height: 62px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid #cfd1d5;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(20, 22, 26, .05);
}
.search-shell:focus-within { border-color: #9b9da3; box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.search-icon { width: 18px; height: 18px; margin: 0 18px 0 14px; border: 2px solid #777a81; border-radius: 50%; position: relative; flex: 0 0 auto; }
.search-icon::after { content: ""; position: absolute; right: -5px; bottom: -3px; width: 7px; height: 2px; background: #777a81; transform: rotate(45deg); }
.search-shell input { flex: 1; min-width: 0; height: 48px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 17px; }
.search-shell input::placeholder { color: #96999f; }
.search-button { height: 48px; padding: 0 24px; border: 0; border-radius: 8px; background: var(--text); color: #fff; font-weight: 600; cursor: pointer; }
.search-button:hover { background: #303238; }
.clear-button { display: none; padding: 5px 12px; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.search-shell.has-value .clear-button { display: block; }
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.filter-button { padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }
.filter-button:hover { border-color: #b9bbc0; }
.filter-button span:not(:empty) { display: inline-grid; place-items: center; min-width: 19px; height: 19px; margin-left: 5px; padding: 0 5px; border-radius: 10px; background: #292b30; color: #fff; font-size: 10px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.active-filter { padding: 7px 9px; border: 0; border-radius: 7px; background: #e9e9eb; color: #4f5258; font-size: 11px; cursor: pointer; }
.active-filter::after { content: " ×"; color: #8b8e94; }

.home-overview { padding: 24px 0 80px; border-top: 1px solid var(--line); }
.database-count { margin-bottom: 30px; color: var(--muted); font-size: 14px; }
.database-count strong { color: var(--text); font-size: 20px; }
.recent-heading { margin-bottom: 14px; }

.results-section { padding: 28px 0 80px; border-top: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading span { color: var(--muted); font-size: 13px; }
.result-grid { display: flex; flex-direction: column; gap: 8px; }
.vehicle-card {
  width: 100%;
  min-height: 92px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  display: grid;
  grid-template-columns: 70px minmax(220px, 1.3fr) minmax(180px, 1fr) minmax(135px, .7fr) 24px;
  gap: 16px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}
.vehicle-card:hover { border-color: #b8bac0; background: #fdfdfd; }
.card-top { display: block; }
.model-year { display: inline-block; padding: 6px 8px; border-radius: 6px; background: #f1f1f2; font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.match-tags { display: none; }
.card-main { min-width: 0; }
.vehicle-card h3 { margin: 0 0 6px; font-size: 16px; line-height: 1.25; }
.card-vin { margin: 0; color: var(--muted); font: 500 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
.card-specs { display: contents; }
.card-specs div { min-width: 0; }
.card-specs span { display: block; margin-bottom: 5px; color: #8b8e95; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.card-specs strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
.card-specs div:last-child { text-align: left; }
.card-arrow { color: #8b8e95; font-size: 18px; }
.skeleton { pointer-events: none; }
.skeleton > * { opacity: .18; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.empty-state > span { display: none; }
.empty-state h3 { margin: 0 0 8px; color: var(--text); font-size: 16px; }
.empty-state p { margin: 0; font-size: 13px; }
.load-more { display: block; margin: 20px auto 0; padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }

.filter-layer, .detail-layer { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; visibility: hidden; pointer-events: none; }
.filter-layer.open, .detail-layer.open { visibility: visible; pointer-events: auto; }
.modal-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(0,0,0,.42); opacity: 0; transition: opacity .16s; }
.filter-layer.open .modal-backdrop, .detail-layer.open .modal-backdrop { opacity: 1; }
.filter-panel, .detail-panel { position: relative; z-index: 1; width: min(720px, 100%); max-height: calc(100vh - 48px); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 18px 60px rgba(0,0,0,.18); opacity: 0; transform: translateY(10px) scale(.985); transition: opacity .16s, transform .16s; overflow: hidden; }
.filter-layer.open .filter-panel, .detail-layer.open .detail-panel { opacity: 1; transform: translateY(0) scale(1); }
.modal-header { min-height: 64px; padding: 14px 18px 14px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 18px; }
.filter-panel form { max-height: calc(100vh - 113px); overflow-y: auto; }
.filter-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px 22px; }
.filter-fields label, .filter-field { display: flex; flex-direction: column; gap: 7px; }
.filter-fields label > span, .filter-field > span { color: #62656c; font-size: 12px; font-weight: 600; }
.filter-fields input, .filter-fields select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); outline: 0; }
.filter-fields input:focus, .filter-fields select:focus { border-color: #8f9298; box-shadow: 0 0 0 3px rgba(0,0,0,.04); }
.wide-field { grid-column: 1 / -1; }
.year-field > div { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.year-field b { color: #aaa; font-weight: 400; }
.brand-section { padding: 0 22px 20px; }
.brand-section h3 { margin: 0 0 10px; font-size: 12px; color: #62656c; }
.brand-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.brand-option { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 7px 9px; border: 1px solid var(--line-soft); border-radius: 7px; font-size: 12px; cursor: pointer; }
.brand-option input { accent-color: #292b30; }
.brand-option small { margin-left: auto; color: #999ca2; }
.filter-loading { color: var(--muted); font-size: 12px; }
.filter-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface); }
.filter-actions button { height: 40px; padding: 0 17px; border-radius: 7px; font-weight: 600; cursor: pointer; }
.reset-button { border: 1px solid var(--line); background: var(--surface); }
.apply-button { border: 1px solid #292b30; background: #292b30; color: #fff; }
.detail-panel { width: min(820px, 100%); }
.detail-header { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 28px 64px 24px 28px; border-bottom: 1px solid var(--line); }
.detail-close { position: absolute; top: 18px; right: 18px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 22px; cursor: pointer; }
.vehicle-symbol { width: 42px; height: 42px; flex: 0 0 auto; }
.detail-heading { min-width: 0; }
.detail-heading > p { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 600; }
.detail-heading h2 { margin: 0 0 9px; font-size: 24px; line-height: 1.2; }
.vin-copy { padding: 0; border: 0; background: transparent; color: #62656c; font: 500 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer; }
.vin-copy::after { content: "  ⎘"; color: #9a9ca2; }
.detail-tabs { height: 58px; display: flex; gap: 4px; padding: 9px 20px; border-bottom: 1px solid var(--line); }
.detail-tab { padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.detail-tab.active { background: #f0f0f1; color: var(--text); }
.detail-tab span { margin-left: 3px; color: #9b9da3; }
.detail-content { max-height: calc(100vh - 225px); overflow-y: auto; padding: 24px 28px 50px; }
.detail-section { margin-bottom: 26px; }
.detail-section h3 { margin: 0 0 12px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.key-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.key-item { min-width: 0; padding: 15px; background: var(--surface); border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.key-item span { display: block; margin-bottom: 6px; color: #8c8f95; font-size: 10px; }
.key-item strong { display: block; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.filter-line { position: relative; margin-bottom: 12px; }
.filter-line::before { content: "⌕"; position: absolute; left: 13px; top: 10px; color: var(--muted); }
.filter-line input { width: 100%; height: 42px; padding: 0 13px 0 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); outline: 0; }
.list-stack { display: flex; flex-direction: column; gap: 7px; }
.pr-item, .module-item { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.pr-item { display: grid; grid-template-columns: 58px 1fr; gap: 12px; padding: 13px 15px; }
.pr-code, .module-address { color: var(--red); font: 600 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.pr-item h4, .module-item h4 { margin: 0 0 4px; font-size: 13px; line-height: 1.35; }
.pr-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.module-toggle { width: 100%; display: grid; grid-template-columns: 58px 1fr auto; gap: 10px; align-items: center; padding: 14px 15px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.module-toggle h4 { margin: 0; }
.module-chevron { color: #999ca2; transition: transform .15s; }
.module-item.open .module-chevron { transform: rotate(90deg); }
.module-data { display: none; padding: 0 15px 14px 73px; }
.module-item.open .module-data { display: block; }
.module-data dl { margin: 0; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.module-data div { display: grid; grid-template-columns: minmax(115px, .8fr) 1.2fr; gap: 10px; padding: 7px 0; }
.module-data dt { color: var(--muted); font-size: 11px; }
.module-data dd { margin: 0; font: 500 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.list-empty { padding: 30px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); text-align: center; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 26px; transform: translate(-50%, 12px); opacity: 0; background: #25272c; color: #fff; padding: 10px 14px; border-radius: 7px; font-size: 12px; transition: .15s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 800px) {
  .vehicle-card { grid-template-columns: 58px minmax(180px, 1fr) minmax(130px, .8fr) 22px; }
  .card-specs div:last-child { display: none; }
}
@media (max-width: 600px) {
  .topbar { height: 62px; padding: 0 16px; }
  main { width: calc(100% - 24px); }
  .search-section { padding: 28px 0 28px; }
  .search-shell { height: 56px; padding: 5px; }
  .search-shell input { height: 44px; font-size: 15px; }
  .search-icon { margin-left: 10px; margin-right: 13px; }
  .search-button { height: 44px; padding: 0 14px; }
  .filter-bar { align-items: flex-start; }
  .results-section { padding-top: 20px; }
  .vehicle-card { grid-template-columns: 52px 1fr 18px; gap: 10px; min-height: 82px; padding: 13px; }
  .card-specs { display: none; }
  .vehicle-card h3 { font-size: 15px; }
  .filter-layer, .detail-layer { padding: 8px; }
  .filter-panel, .detail-panel { max-height: calc(100vh - 16px); }
  .filter-fields { grid-template-columns: 1fr; padding: 16px; }
  .wide-field { grid-column: auto; }
  .brand-section { padding-left: 16px; padding-right: 16px; }
  .brand-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-actions { padding: 12px 16px; }
  .detail-header { padding: 20px 54px 18px 16px; }
  .detail-close { top: 13px; right: 12px; }
  .detail-heading h2 { font-size: 20px; }
  .detail-tabs { padding-left: 8px; padding-right: 8px; overflow-x: auto; }
  .detail-tab { flex: 1 0 auto; padding: 0 10px; }
  .detail-content { padding: 18px 14px 40px; }
  .key-grid { grid-template-columns: 1fr; }
  .module-data { padding-left: 14px; }
  .module-data div { grid-template-columns: 1fr; gap: 3px; }
}
