:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-dark: #0a0a0a;
  --bg-card: #ffffff;
  --text: #0f1419;
  --text-muted: #5b6470;
  --text-faint: #9ca3af;
  --border: #e8eaed;
  --border-strong: #d1d5db;
  --accent: #cc0000;
  --accent-hover: #a30000;
  --green: #15803d;
  --green-bg: #dcfce7;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 3px rgb(0 0 0 / 0.06);
  --shadow: 0 4px 12px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.12);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --max-w: 1200px;
  --header-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* ───── HEADER ─────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}
.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.015em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.site-nav { display: flex; gap: 28px; align-items: center; }
.site-nav a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: color 150ms ease;
}
.site-nav a:hover { color: var(--text); }
.site-nav .btn { color: white; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--bg-dark);
  color: white !important;
  border-radius: 999px;
  font-weight: 500;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.btn:hover { background: #1f2937; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ───── HERO ─────────────────────────── */
.hero {
  position: relative;
  min-height: 460px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.35) 100%), url("/static/cybertruck.jpg");
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  color: white;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 70%, rgba(255, 255, 255, 1) 100%);
  pointer-events: none;
}
.hero .container { position: relative; z-index: 1; padding-top: 60px; padding-bottom: 80px; }
.hero .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 13px;
  margin-bottom: 24px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.hero .badge .pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgb(34 197 94 / 0.7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0.7); }
  70% { box-shadow: 0 0 0 8px rgb(34 197 94 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0); }
}
.hero h1 {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin-bottom: 18px;
  max-width: 800px;
}
.hero h1 .accent { color: #ff5d5d; }
.hero p {
  font-size: 18px;
  max-width: 620px;
  opacity: 0.92;
  margin-bottom: 28px;
}
.hero .cta-row { display: flex; flex-wrap: wrap; gap: 12px; }
.hero .btn { background: white; color: var(--text) !important; }
.hero .btn:hover { background: rgba(255, 255, 255, 0.92); }
.hero .btn-accent { background: var(--accent); color: white !important; }
.hero .btn-accent:hover { background: var(--accent-hover); }

.hero-compact { min-height: 280px; }
.hero-compact h1 { font-size: clamp(30px, 4.5vw, 44px); }

/* ───── STATS BAR ─────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px;
  margin: -50px auto 56px;
  position: relative;
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}
.stat .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.stat .value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat .value .unit { color: var(--text-muted); font-size: 16px; font-weight: 500; margin-left: 2px; }
.stat .value .accent { color: var(--accent); }
.stat .value .green { color: var(--green); }

/* ───── SECTION ─────────────────────────── */
section { padding: 0 0 56px; }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.section-head h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.section-head p { color: var(--text-muted); font-size: 15px; }

/* ───── REFERRAL ─────────────────────────── */
.referral-card {
  background: linear-gradient(135deg, #0a0a0a 0%, #1f2937 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  box-shadow: var(--shadow);
}
.referral-card .label {
  font-size: 12px;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  font-weight: 600;
}
.referral-card .value { font-size: 17px; font-weight: 600; word-break: break-all; }
.referral-card .value a { color: white; border-bottom: 1px dashed rgba(255, 255, 255, 0.4); }
.referral-card .value a:hover { border-bottom-color: white; }

/* ───── FILTERS ─────────────────────────── */
.filters {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.filters select, .filters input {
  font: inherit;
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: white;
  color: var(--text);
  cursor: pointer;
  transition: border 150ms ease, box-shadow 150ms ease;
  min-width: 160px;
}
.filters select:focus, .filters input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(204 0 0 / 0.1);
}
.results-count {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}
.results-count strong { color: var(--text); font-weight: 700; }

/* ───── TABLE ─────────────────────────── */
.table-wrap {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 48px;
}
.table-scroll { overflow-x: auto; }
table.inv {
  width: 100%;
  border-collapse: collapse;
}
.inv thead { background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.inv th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 14px 18px;
  font-weight: 700;
  white-space: nowrap;
}
.inv th.sortable { cursor: pointer; user-select: none; }
.inv th.sortable:hover { color: var(--text); }
.inv th.sortable::after { content: " ↕"; opacity: 0.3; font-size: 10px; }
.inv th.sort-asc::after { content: " ↑"; opacity: 1; color: var(--accent); }
.inv th.sort-desc::after { content: " ↓"; opacity: 1; color: var(--accent); }
.inv td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
.inv tbody tr:last-child td { border-bottom: none; }
.inv tbody tr { transition: background 100ms ease; }
.inv tbody tr:hover { background: #fafbfc; }
.inv .model-cell { font-weight: 600; }
.inv .price {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}
.inv .discount {
  color: var(--green);
  background: var(--green-bg);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: inline-block;
  font-size: 13px;
  white-space: nowrap;
}
.inv .discount.zero { background: var(--bg-soft); color: var(--text-muted); }
.inv .features { color: var(--text-muted); font-size: 13px; }
.inv .states { color: var(--text-muted); font-size: 13px; max-width: 220px; }
.inv .order-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: var(--accent);
  color: white !important;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: background 150ms ease, transform 150ms ease;
  white-space: nowrap;
}
.inv .order-link:hover { background: var(--accent-hover); transform: translateY(-1px); }
.inv .order-link::after { content: " →"; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h3 { color: var(--text); margin-bottom: 8px; font-size: 20px; }

/* ───── VEHICLE PAGE ─────────────────────────── */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
  margin: 24px 0;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { opacity: 0.5; }
.breadcrumb .current { color: var(--text); font-weight: 500; }

.vehicle-hero {
  background: linear-gradient(135deg, #0a0a0a, #1f2937);
  color: white;
  border-radius: var(--radius-lg);
  padding: 48px;
  margin-bottom: 32px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: center;
  box-shadow: var(--shadow);
}
.vehicle-hero .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.65;
  font-weight: 600;
  margin-bottom: 8px;
}
.vehicle-hero h1 {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
  line-height: 1.05;
}
.vehicle-hero .vin {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  opacity: 0.7;
  word-break: break-all;
}
.vehicle-hero .price-block { text-align: right; min-width: 220px; }
.vehicle-hero .price-block .price {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 8px;
}
.vehicle-hero .price-block .savings {
  display: inline-block;
  background: var(--green);
  color: white;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.vehicle-cta {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.vehicle-cta .btn { padding: 14px 28px; font-size: 16px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}
.detail-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.detail-card h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 700;
}
.detail-card .features-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}
.detail-card .features-list li {
  background: var(--bg-soft);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
}
.detail-card .state-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
}
.detail-card .state-list a {
  background: var(--bg-soft);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: background 150ms ease;
}
.detail-card .state-list a:hover { background: var(--bg-card); border-color: var(--accent); color: var(--accent); }

/* ───── SUBSECTIONS / LINKS GRID ─────────────────────────── */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 48px;
}
.link-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.link-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.link-card .name { font-weight: 600; }
.link-card .count {
  background: var(--bg-soft);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ───── FOOTER ─────────────────────────── */
.site-footer {
  background: var(--bg-dark);
  color: white;
  padding: 48px 0 32px;
  margin-top: 64px;
}
.site-footer .footer-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 32px;
  margin-bottom: 32px;
}
.site-footer h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 14px;
  font-weight: 700;
}
.site-footer ul { list-style: none; }
.site-footer li { margin-bottom: 8px; }
.site-footer a {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  transition: color 150ms ease;
}
.site-footer a:hover { color: white; }
.site-footer .brand { color: white; margin-bottom: 12px; }
.site-footer .tagline { color: rgba(255, 255, 255, 0.6); font-size: 14px; max-width: 320px; }
.site-footer .copyright {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 24px;
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

/* ───── DISCLAIMER ─────────────────────────── */
.disclaimer {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 14px;
  color: #92400e;
}

/* ───── RESPONSIVE ─────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .site-nav { gap: 16px; }
  .site-nav a:not(.btn) { display: none; }
  .hero { min-height: 400px; }
  .hero .container { padding-top: 40px; padding-bottom: 60px; }
  .stats { padding: 20px; gap: 16px; margin-top: -40px; }
  .stat .value { font-size: 22px; }
  .vehicle-hero {
    grid-template-columns: 1fr;
    padding: 28px;
    gap: 24px;
  }
  .vehicle-hero .price-block { text-align: left; }
  .site-footer .footer-grid { grid-template-columns: 1fr 1fr; }

  .table-scroll { overflow: visible; }
  table.inv { display: block; }
  .inv thead { display: none; }
  .inv tbody, .inv tbody tr { display: block; }
  .inv tbody tr {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }
  .inv td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border: none;
    text-align: right;
  }
  .inv td::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    margin-right: 12px;
    text-align: left;
  }
  .inv td.actions { justify-content: flex-end; padding-top: 12px; }
  .inv td.actions::before { display: none; }
}
