:root {
  --navy: #14233b;
  --blue: #1a56db;
  --blue-dark: #123f9e;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--navy);
}
.brand:hover { text-decoration: none; }
.site-nav a {
  margin-left: 24px;
  color: var(--text);
  font-weight: 500;
}

/* Flash messages */
.flash {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.breadcrumb { padding-top: 20px; font-size: .9rem; }

/* Listings grid (home page) */
.listings-page { padding: 32px 24px 64px; }
.listings-page h1 { margin-top: 0; }

.listing-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 28px;
}
.listing-search input {
  flex: 1;
  max-width: 360px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
}
.listing-search .btn { margin-top: 0; }

.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  margin-top: 24px;
}
.listing-card {
  display: block;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: box-shadow .15s ease, transform .15s ease;
}
.listing-card:hover {
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(20, 35, 59, .12);
  transform: translateY(-2px);
}
.listing-card-photo {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  background: var(--bg-soft);
}
.listing-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2f7, #dfe7f0);
}
.listing-card-placeholder img { height: 90px; width: auto; object-fit: contain; }
.listing-card-body { padding: 14px 16px; }
.listing-card-price { font-weight: 800; font-size: 1.2rem; color: var(--navy); }
.listing-card-address { font-size: .9rem; margin-top: 2px; }
.listing-card-facts { color: var(--muted); font-size: .82rem; margin-top: 6px; }
.listing-card-reward {
  display: inline-block;
  margin-top: 8px;
  font-weight: 700;
  font-size: .78rem;
  color: #0a7a3d;
  background: #e6f7ec;
  border: 1px solid #b9e6c9;
  border-radius: 999px;
  padding: 2px 10px;
}

/* Sold styling -- shared across the home page, dashboard, and car detail page */
.sold-label {
  display: block;
  color: #991b1b;
  font-weight: 800;
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.price-sold {
  text-decoration: line-through;
  color: var(--muted) !important;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 32px;
  font-size: .9rem;
}
.pagination-current { color: var(--muted); }

/* Hero */
.hero {
  position: relative;
  width: 100%;
  height: 420px;
  overflow: hidden;
  background: var(--bg-soft);
}
.hero-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  background: linear-gradient(135deg, #eef2f7, #dfe7f0);
}
.placeholder-illustration {
  height: 240px;
  width: auto;
  object-fit: contain;
}
.hero-overlay-top {
  position: absolute;
  left: 0; right: 0; top: 0;
  z-index: 2;
  padding-top: 20px;
  padding-bottom: 32px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,.55);
  background: linear-gradient(to bottom, rgba(0,0,0,.45), transparent);
  pointer-events: none;
}
.price-tag {
  font-size: 2.25rem;
  font-weight: 800;
}
.address-tag {
  font-size: 1.05rem;
}

/* Photo carousel */
.carousel {
  position: relative;
}
.carousel-track {
  position: relative;
  width: 100%;
  height: 100%;
}
.carousel-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .35s ease;
}
.carousel-slide.active {
  opacity: 1;
  z-index: 1;
}
.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.carousel-prev, .carousel-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 35, 59, .55);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}
.carousel-prev:hover, .carousel-next:hover { background: rgba(20, 35, 59, .8); }
.carousel-prev { left: 16px; }
.carousel-next { right: 16px; }
.carousel-dots {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.carousel-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .5);
  cursor: pointer;
}
.carousel-dot.active { background: #fff; }
.carousel-counter {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  background: rgba(20, 35, 59, .55);
  color: #fff;
  font-size: .78rem;
  padding: 3px 10px;
  border-radius: 999px;
}

/* Fact bar */
.fact-bar {
  display: flex;
  gap: 32px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-top: 8px;
}
.fact {
  display: flex;
  flex-direction: column;
}
.fact strong { font-size: 1.4rem; color: var(--navy); }
.fact span { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: .03em; }

/* Reward banner */
.reward-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-top: 20px;
  padding: 16px 20px;
  background: #e6f7ec;
  border: 1px solid #b9e6c9;
  border-radius: 10px;
}
.reward-banner-amount {
  font-weight: 800;
  font-size: 1.15rem;
  color: #0a7a3d;
}
.reward-banner-detail {
  color: #14532d;
  font-size: .9rem;
}

/* Listing body */
.listing-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 40px;
  padding: 32px 24px 64px;
}
.listing-main h1 { margin-top: 0; font-size: 1.6rem; }
.listing-main h2 { font-size: 1.15rem; margin-top: 32px; }
.description { color: var(--text); }
.highlights { padding-left: 20px; }
.highlights li { margin-bottom: 6px; }

.listing-sidebar {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-self: start;
}
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.refer-card h3, .test-drive-card h3, .sold-notice h3 { margin-top: 0; }
.refer-card p, .test-drive-card p, .sold-notice p { color: var(--muted); font-size: .92rem; }
.refer-card form, .test-drive-card form { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.refer-card label, .test-drive-card label { font-size: .85rem; font-weight: 600; margin-top: 6px; }
.refer-card input, .test-drive-card input, .test-drive-card textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
  font-family: inherit;
}
.test-drive-card textarea { resize: vertical; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
}
.btn-primary { background: var(--blue); color: #fff; margin-top: 14px; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--bg-soft); color: var(--navy); border: 1px solid var(--border); }

/* Dashboard */
.dashboard { padding: 40px 24px; }

.dashboard-car-card {
  display: flex;
  align-items: stretch;
  gap: 20px;
  margin: 20px 0 28px;
  padding: 0;
  overflow: hidden;
  color: var(--text);
}
.dashboard-car-card:hover {
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(20, 35, 59, .12);
  transform: translateY(-2px);
}
.dashboard-car-card-photo {
  width: 220px;
  min-width: 220px;
  height: 160px;
  object-fit: cover;
  display: block;
  background: var(--bg-soft);
}
.dashboard-car-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2f7, #dfe7f0);
}
.dashboard-car-card-placeholder img { height: 80px; width: auto; object-fit: contain; }
.dashboard-car-card-body {
  padding: 16px 20px 16px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.dashboard-car-card-name { font-weight: 800; font-size: 1.2rem; color: var(--navy); }
.dashboard-car-card-price { font-weight: 700; font-size: 1rem; color: var(--navy); }
.dashboard-car-card-facts { color: var(--muted); font-size: .85rem; }
.dashboard-car-card-reward {
  display: inline-block;
  width: fit-content;
  margin-top: 6px;
  font-weight: 700;
  font-size: .78rem;
  color: #0a7a3d;
  background: #e6f7ec;
  border: 1px solid #b9e6c9;
  border-radius: 999px;
  padding: 2px 10px;
}
.dashboard-car-card-link {
  margin-top: 8px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--blue);
}

.share-link-card {
  margin: 20px 0 28px;
  padding: 26px 30px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--navy), #1d3a63);
  box-shadow: 0 6px 20px rgba(20, 35, 59, .22);
}
.share-link-label {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #9db4dd;
  margin-bottom: 12px;
}
.share-link-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.share-link-row code {
  flex: 1 1 320px;
  min-width: 0;
  word-break: break-all;
  font-size: 1.05rem;
  color: #fff;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 8px;
  padding: 12px 16px;
}
.share-link-copy {
  flex-shrink: 0;
  margin-top: 0;
  min-width: 140px;
  padding: 12px 22px;
  font-size: .98rem;
  background: #fff;
  color: var(--navy);
}
.share-link-copy:hover { background: #eef2f7; }
.share-link-hint {
  margin: 16px 0 0;
  font-size: .85rem;
  color: #cfdaf0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.stat {
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
}
.stat strong { display: block; font-size: 1.6rem; color: var(--navy); }
.stat span { color: var(--muted); font-size: .85rem; }

.referral-list { list-style: none; padding: 0; }
.referral-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.muted { color: var(--muted); font-size: .85rem; }

/* Referral tree */
.tree-page { padding: 40px 24px; }
.back-link { display: inline-block; margin-bottom: 16px; font-size: .9rem; }

ul.tree, ul.tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}
ul.tree { margin-top: 24px; }
ul.tree-children {
  position: relative;
  padding-left: 32px;
  margin-left: 10px;
  border-left: 3px solid var(--blue);
  border-radius: 0 0 0 6px;
}
/* trim the trailing tail of the vertical line below the last child's branch */
.tree-children > .tree-node:last-child::after {
  content: "";
  position: absolute;
  left: -35px;
  top: 24px;
  bottom: 0;
  width: 3px;
  background: var(--bg);
}

.tree-node { position: relative; padding: 10px 0; }
.tree-children > .tree-node { padding-left: 20px; }
.tree-children > .tree-node::before {
  content: "";
  position: absolute;
  left: -32px;
  top: 24px;
  width: 32px;
  height: 0;
  border-top: 3px solid var(--blue);
}

.tree-node-label {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  padding: 10px 16px;
  box-shadow: 0 1px 4px rgba(20, 35, 59, .06);
  transition: box-shadow .15s ease, transform .15s ease;
}
.tree-node-label:hover {
  box-shadow: 0 4px 14px rgba(26, 86, 219, .18);
  transform: translateY(-1px);
}
.tree > .tree-node > .tree-node-label {
  border-left-width: 6px;
  background: var(--navy);
  border-left-color: var(--blue);
}
.tree > .tree-node > .tree-node-label .tree-name { color: #fff; }
.tree > .tree-node > .tree-node-label .tree-meta,
.tree > .tree-node > .tree-node-label .tree-email { color: #c3cede; }

.tree-name { font-weight: 700; color: var(--navy); }
.tree-meta, .tree-email { color: var(--muted); font-size: .8rem; }

.tree-reward {
  font-weight: 700;
  font-size: .8rem;
  color: #0a7a3d;
  background: #e6f7ec;
  border: 1px solid #b9e6c9;
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
.tree > .tree-node > .tree-node-label .tree-reward {
  color: #0a7a3d;
  background: #d6f5e2;
  border-color: #8fdcac;
}

/* Staff dashboard */
.staff-dashboard { padding: 40px 24px; }
.staff-dashboard .reward-banner { margin: 20px 0; }
.staff-stats { margin: 24px 0 32px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.staff-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.staff-search input {
  flex: 1;
  max-width: 360px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
}
.staff-search .btn { margin-top: 0; }
.clear-search { font-size: .85rem; color: var(--muted); }

.car-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.car-summary-card {
  display: block;
  color: var(--text);
}
.car-summary-card:hover {
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(20, 35, 59, .12);
  transform: translateY(-2px);
}
.car-summary-address { font-weight: 700; color: var(--navy); }
.car-summary-meta, .car-summary-stats {
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: .82rem;
  margin-top: 6px;
}
.tag-inactive, .tag-sold {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 999px;
  padding: 0 8px;
}
.tag-sold { font-weight: 700; }

.root-chain-card { margin-bottom: 28px; }
.buyer-chain-card { margin-bottom: 28px; border-color: var(--blue); }
.root-chain-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.root-chain-header h2 { margin: 0; font-size: 1.1rem; }
.root-chain-meta {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: .85rem;
}

/* Leaderboard */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}
.leaderboard-table th, .leaderboard-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.leaderboard-table th { color: var(--muted); font-size: .82rem; text-transform: uppercase; }

.empty-state { padding: 80px 24px; text-align: center; }

/* How It Works page */
.how-hero {
  background: linear-gradient(135deg, var(--navy), #1d3a63);
  color: #fff;
  padding: 64px 24px;
  text-align: center;
}
.how-hero h1 {
  margin: 0 auto 16px;
  max-width: 720px;
  font-size: 2rem;
}
.how-hero-sub {
  margin: 0 auto 28px;
  max-width: 640px;
  color: #cfdaf0;
  font-size: 1.05rem;
}

.how-section { padding: 48px 24px; }
.how-section h2 { font-size: 1.4rem; margin-top: 0; }
.how-section-sub { color: var(--muted); max-width: 720px; }

.how-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 24px;
}
.how-step {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}
.how-step h3 { margin: 16px 0 8px; font-size: 1.05rem; }
.how-step p { color: var(--text); font-size: .92rem; margin: 0; }

.step-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
}
.step-icon svg { width: 24px; height: 24px; }

.cascade {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 12px;
  margin-top: 24px;
}
.cascade-step {
  flex: 1 1 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.cascade-step-buyer { background: var(--navy); border-color: var(--navy); }
.cascade-step-buyer .cascade-name,
.cascade-step-buyer .cascade-role { color: #fff; }
.cascade-step-buyer .cascade-email { color: #cfdaf0; }
.cascade-name { font-weight: 700; color: var(--navy); }
.cascade-email { color: var(--muted); font-size: .78rem; word-break: break-all; }
.cascade-role { color: var(--muted); font-size: .8rem; margin-top: 4px; min-height: 32px; }
.cascade-amount {
  display: inline-block;
  margin-top: 12px;
  font-weight: 800;
  color: #0a7a3d;
  background: #e6f7ec;
  border: 1px solid #b9e6c9;
  border-radius: 999px;
  padding: 4px 12px;
}
.cascade-amount-buyer {
  color: #fff;
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.3);
}
.cascade-percent {
  display: block;
  margin-top: 6px;
  font-size: .72rem;
  color: var(--muted);
}
.cascade-step-buyer .cascade-percent { color: #cfdaf0; }
.cascade-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.4rem;
  flex: 0 0 auto;
}
.payout-pdf-link { display: inline-block; margin-top: 16px; }

.faq { margin-top: 20px; max-width: 720px; }
.faq details {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 10px;
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--navy);
}
.faq p { color: var(--text); margin: 10px 0 0; }

.how-cta {
  padding: 48px 24px 64px;
  text-align: center;
}
.how-cta h2 { margin-top: 0; }

.refer-card-hint { margin-top: 10px; font-size: .85rem; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  color: var(--muted);
  font-size: .85rem;
}

@media (max-width: 860px) {
  .listing-body { grid-template-columns: 1fr; }
  .listing-sidebar { position: static; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { height: 280px; }
  .dashboard-car-card { flex-direction: column; }
  .dashboard-car-card-photo { width: 100%; min-width: 0; height: 180px; }
  .dashboard-car-card-body { padding: 4px 16px 16px; }
  .share-link-row { flex-direction: column; align-items: stretch; }
  .share-link-copy { width: 100%; }
  .how-steps { grid-template-columns: 1fr; }
  .cascade { flex-direction: column; }
  .cascade-arrow { transform: rotate(90deg); }
}
