:root {
  --red: #c8102e;
  --navy: #1f2a8a;
  --yellow: #f2d64b;
  --green: #1faa55;
  --ink: #16181d;
  --muted: #5e6470;
  --line: #e3e5ea;
  --bg: #f4f5f7;
  --card: #ffffff;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; }

/* Header */
.top {
  background: #fff;
  border-bottom: 4px solid var(--red);
  position: sticky; top: 0; z-index: 10;
}
.top-inner {
  max-width: 960px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 10px;
}
.top img { width: 52px; height: 48px; object-fit: contain; }
.brand { text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 18px; color: var(--navy); line-height: 1.1; }
.brand small { display: block; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--red); }
.top .back { margin-left: auto; white-space: nowrap; font-weight: 600; text-decoration: none; color: var(--navy); padding: 8px 4px; }

.wrap { max-width: 960px; margin: 0 auto; padding: 14px 16px 110px; }

/* Search */
.search {
  width: 100%; padding: 13px 14px; border: 2px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 17px;
}
.search:focus { outline: none; border-color: var(--navy); }
.count { color: var(--muted); font-size: 14px; margin: 10px 2px; }

/* Car grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.card {
  background: var(--card); border-radius: 12px; overflow: hidden; text-decoration: none;
  border: 1px solid var(--line); display: flex; flex-direction: column; position: relative;
}
.card .ph { aspect-ratio: 4/3; background: #dde0e6; width: 100%; object-fit: cover; }
.card .bd { padding: 8px 10px 10px; }
.card .t { font-weight: 700; font-size: 15px; line-height: 1.25; }
.card .p { font-weight: 800; font-size: 19px; color: var(--red); margin-top: 2px; }
.card .m { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card.sold .ph { filter: grayscale(1); opacity: .7; }
.card.sold .p { color: var(--muted); text-decoration: line-through; }
.sold-tag {
  position: absolute; top: 10px; left: -4px; background: var(--ink); color: #fff;
  font-weight: 800; font-size: 13px; letter-spacing: .1em; padding: 4px 10px; border-radius: 0 6px 6px 0;
}
.more { display: block; margin: 16px auto 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 13px 18px; font-weight: 700; font-size: 17px;
  cursor: pointer; text-decoration: none; background: var(--navy); color: #fff;
}
.btn:disabled { opacity: .5; }
.btn.wa { background: var(--green); }
.btn.red { background: var(--red); }
.btn.ghost { background: #fff; color: var(--navy); border: 2px solid var(--navy); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 8px; }
.btn svg { width: 22px; height: 22px; flex: none; }

/* Floating WhatsApp bar */
.wa-bar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line); z-index: 20;
}
.wa-bar .btn { width: 100%; max-width: 560px; margin: 0 auto; display: flex; font-size: 18px; padding: 15px; }

/* Car detail */
.gallery {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 6px;
  border-radius: 12px; background: #dde0e6; scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery img { flex: 0 0 100%; aspect-ratio: 4/3; object-fit: cover; scroll-snap-align: center; }
.dots { text-align: center; color: var(--muted); font-size: 13px; margin-top: 6px; }
.detail h1 { font-size: 24px; margin: 14px 0 0; line-height: 1.2; }
.detail .price { font-size: 30px; font-weight: 800; color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 14px; font-weight: 600; }
.raw {
  white-space: pre-wrap; word-wrap: break-word; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; margin: 12px 0; font-size: 17px;
}
.sold-banner { background: var(--ink); color: #fff; font-weight: 800; text-align: center; padding: 10px; border-radius: 10px; margin-top: 12px; letter-spacing: .08em; }
.posted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

.empty, .loading { text-align: center; color: var(--muted); padding: 40px 10px; }

/* Admin */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 10px; font-size: 20px; }
label { display: block; font-weight: 700; margin: 12px 0 6px; }
input[type=email], input[type=password], textarea {
  width: 100%; padding: 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
textarea { min-height: 260px; resize: vertical; }
.hint { color: var(--muted); font-size: 14px; }
.previews { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.previews img { aspect-ratio: 1; object-fit: cover; border-radius: 8px; width: 100%; }
.parsed { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 10px; }
.msg { margin-top: 10px; font-weight: 600; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--green); }
.alist .it { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.alist .it img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; flex: none; background: #dde0e6; }
.alist .it .info { flex: 1; min-width: 0; }
.alist .it .info b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alist .it .info span { font-size: 13px; color: var(--muted); }
.alist .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) { .alist .it { flex-wrap: wrap; } .alist .acts { width: 100%; justify-content: flex-start; } }
.hidden { display: none !important; }
/* Contact footer */
.foot { text-align: center; color: var(--muted); font-size: 14px; margin-top: 28px; line-height: 1.7; }
.foot a { color: var(--navy); font-weight: 600; word-break: break-all; }
.foot .credit { margin-top: 12px; font-size: 12px; }
.foot .credit a { color: inherit; font-weight: 600; }