:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1c1c1c;
  --border: #2a2a2a;
  --text: #f4f4f4;
  --muted: #888;
  --dim: #555;
  --primary: #d5001c;
  --primary-hover: #b50018;
  --error: #ef4444;
  --radius: 6px;
  --gap: 14px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ─── Header ───────────────────────────────── */

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo h1 { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -0.5px; }
.logo .dot { width: 10px; height: 10px; background: var(--primary); border-radius: 50%; }
.logo .tag {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; margin-left: 6px;
}

/* ─── Buttons ──────────────────────────────── */

button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover { background: #252525; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--primary-hover); }
button.ghost { background: transparent; }
button.danger { color: var(--primary); border-color: #4a1a1a; }
button.danger:hover { background: #2a0a0a; }
button.small { padding: 5px 10px; font-size: 12px; }

/* ─── Layout ───────────────────────────────── */

main {
  max-width: 1100px; margin: 0 auto; padding: 28px;
  display: grid; gap: 28px;
}
.hidden { display: none !important; }

/* ─── Profiles List ────────────────────────── */

.profiles-list { display: grid; gap: var(--gap); }
.empty-state {
  text-align: center; padding: 60px 20px;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state h2 { margin: 0 0 8px; font-weight: 500; }
.empty-state p { color: var(--muted); margin: 0; }

.profile-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel);
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  gap: 20px;
}
.profile-card.inactive { opacity: 0.55; }
.card-main { flex: 1; min-width: 0; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.card-title strong { font-size: 15px; }
.badge {
  font-size: 10px; padding: 2px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted);
}
.badge.inactive { color: #aa6600; border-color: #553300; }
.card-summary {
  color: var(--muted); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

.profile-matches {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px 20px;
  margin-top: -1px;
}
.profile-matches.hidden { display: none; }
.matches-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.profile-card-wrapper { display: block; }
.profile-card-wrapper > .profile-card { border-radius: var(--radius); }
.profile-card-wrapper:has(.profile-matches:not(.hidden)) > .profile-card {
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}

/* ─── Editor ───────────────────────────────── */

.editor {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
}
.editor-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.editor-header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.editor-header button { font-size: 24px; padding: 0 12px; line-height: 1; }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 18px;
  padding: 14px 18px 18px;
  background: var(--panel-2);
}
legend {
  padding: 0 8px; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted);
}

label { display: block; margin-bottom: 12px; }
label > span {
  display: block; font-size: 12px; color: var(--muted);
  margin-bottom: 4px;
}
label.check {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
label.check span { margin: 0; color: var(--text); font-size: 13px; }
label.check input { width: auto; margin: 0; }

input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.grid2 label { margin-bottom: 0; }

.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ─── Preview Results ──────────────────────── */

.preview-results { margin-top: 28px; }
.preview-results h3 {
  margin: 0 0 14px; font-weight: 500;
  color: var(--muted); font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.loading { color: var(--muted); }
.error { color: var(--error); }
.empty { color: var(--muted); padding: 30px; text-align: center; }

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.vehicle-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
}
.vehicle-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.vehicle-card img {
  width: 100%; height: 160px; object-fit: cover;
  display: block; background: #0a0a0a;
}
.vehicle-card .no-img {
  width: 100%; height: 160px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--dim); font-size: 12px;
}
.vc-body { padding: 12px; }
.vc-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.vc-price { color: var(--primary); font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.vc-meta { font-size: 12px; color: var(--muted); }
.vc-meta.dim { color: var(--dim); margin-top: 2px; }

/* ─── Toast ────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--panel);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  pointer-events: none;
  z-index: 100;
  max-width: 90%;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast[data-kind="error"] { border-color: var(--error); color: #ffaaaa; }

/* ─── Mobile ───────────────────────────────── */

@media (max-width: 640px) {
  header { padding: 14px 16px; }
  main { padding: 16px; gap: 18px; }
  .editor { padding: 18px 16px; }
  .profile-card { flex-direction: column; align-items: stretch; gap: 12px; }
  .card-actions { justify-content: flex-end; }
  .grid2 { grid-template-columns: 1fr; }
}
