:root {
  --bg: #0f1222;
  --bg-soft: #171b30;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-2: #0ea5e9;
  --brand-grad: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(2, 6, 23, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #f1f5f9;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Public header ---- */
.site-header {
  background: var(--bg);
  color: #fff;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.site-header .wrap {
  max-width: 1080px; margin: 0 auto; padding: 0 18px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 800; font-size: 20px; letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand-grad);
  display: grid; place-items: center; font-size: 18px; box-shadow: var(--shadow);
}
.mini-search {
  margin-left: auto; display: flex; gap: 6px; flex: 1; max-width: 460px;
}
.mini-search input {
  flex: 1; border: 0; border-radius: 10px; padding: 11px 14px; font-size: 14px;
  background: #0b0e1c; color: #fff; border: 1px solid rgba(255,255,255,.08);
}
.mini-search input::placeholder { color: #94a3b8; }
.mini-search button {
  border: 0; background: var(--brand-grad); color: #fff; font-weight: 700;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
}
.header-nav { display: flex; align-items: center; gap: 14px; }
.header-nav a { color: #cbd5e1; font-size: 14px; font-weight: 600; }
.header-nav a:hover { color: #fff; text-decoration: none; }

/* ---- Hero ---- */
.hero {
  background: radial-gradient(1200px 400px at 80% -10%, rgba(14,165,233,.35), transparent),
              var(--bg);
  color: #fff; padding: 64px 0 56px; text-align: center;
}
.hero h1 { font-size: clamp(26px, 4vw, 42px); margin: 0 0 10px; letter-spacing: -.02em; }
.hero p { color: #cbd5e1; max-width: 640px; margin: 0 auto 26px; font-size: 17px; }
.search-card {
  max-width: 620px; margin: 0 auto; background: #fff; color: var(--ink);
  border-radius: var(--radius); padding: 8px; display: flex; gap: 8px;
  box-shadow: var(--shadow);
}
.search-card input {
  flex: 1; border: 0; padding: 14px 16px; font-size: 16px; border-radius: 10px; outline: none;
  font-family: inherit; letter-spacing: .04em; text-transform: uppercase;
}
.search-card button {
  border: 0; background: var(--brand-grad); color: #fff; font-weight: 800;
  padding: 0 26px; border-radius: 10px; cursor: pointer; font-size: 15px;
}
.hero .hint { color: #94a3b8; font-size: 13px; margin-top: 14px; }

/* ---- Layout helpers ---- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }
.section { padding: 44px 0; }
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 820px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: 0 4px 14px rgba(2,6,23,.04);
}
.card h3 { margin: 0 0 8px; font-size: 17px; }
.card p { color: var(--muted); margin: 0; font-size: 14px; }
.icon { width: 40px; height: 40px; border-radius: 10px; background: #eff6ff; display: grid; place-items: center; font-size: 20px; margin-bottom: 12px; }

.section-title { text-align: center; font-size: 24px; margin: 0 0 6px; }
.section-sub { text-align: center; color: var(--muted); margin: 0 0 30px; }

/* ---- Notice ---- */
.notice {
  max-width: 620px; margin: 18px auto 0; padding: 14px 18px; border-radius: 12px;
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; font-size: 14px;
}
.notice.success { background: #ecfdf5; border-color: #bbf7d0; color: #065f46; }

/* ---- Car page ---- */
.car-hero { background: #fff; border-bottom: 1px solid var(--line); }
.car-hero .wrap { padding: 28px 18px; }
.car-hero h1 { margin: 0 0 6px; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.02em; }
.car-hero .vin-tag {
  display: inline-block; font-family: ui-monospace, "Cascadia Code", monospace;
  background: #0f172a; color: #fff; padding: 3px 10px; border-radius: 7px; font-size: 13px;
}
.car-meta { color: var(--muted); font-size: 14px; margin-top: 8px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 18px 0; }
.gallery img { width: 100%; height: 140px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.gallery-empty { color: var(--muted); font-style: italic; }

/* ---- Photo slider ---- */
.slider { max-width: 720px; margin: 18px 0; }
.slider-viewport { position: relative; border-radius: 14px; overflow: hidden; background: #0f172a; box-shadow: var(--shadow); }
.slider-track { display: flex; transition: transform .4s cubic-bezier(.22,.61,.36,1); will-change: transform; }
.slider-track .slide { flex: 0 0 100%; width: 100%; }
.slider-track .slide img { width: 100%; height: 100%; max-height: 60vh; object-fit: cover; display: block; }

.slider-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: rgba(15,23,42,.55); color: #fff; font-size: 26px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; transition: background .15s ease, opacity .15s ease; backdrop-filter: blur(2px);
}
.slider-nav:hover { background: rgba(15,23,42,.8); }
.slider-nav.prev { left: 12px; } .slider-nav.next { right: 12px; }
.slider-nav:disabled { opacity: .25; cursor: default; }

.slider-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.slider-dots { display: flex; gap: 6px; }
.slider-dots .dot { width: 9px; height: 9px; border-radius: 50%; border: 0; background: #cbd5e1; cursor: pointer; padding: 0; transition: background .15s ease, transform .15s ease; }
.slider-dots .dot.active { background: var(--brand); transform: scale(1.25); }
.slider-count { font-size: 13px; color: var(--muted); }

/* ---- Car cards grid ---- */
.section-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:22px; gap:12px; flex-wrap:wrap; }
.car-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap:18px; }
.car-card { display:flex; flex-direction:column; background:#fff; border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; color:var(--ink); transition:transform .15s ease, box-shadow .15s ease; }
.car-card:hover { text-decoration:none; transform:translateY(-3px); box-shadow:var(--shadow); }
.car-card-photo { width:100%; aspect-ratio:16/10; background:#0f172a; display:grid; place-items:center; overflow:hidden; }
.car-card-photo img { width:100%; height:100%; object-fit:cover; }
.car-card-noimg { font-size:40px; filter:grayscale(.3); opacity:.5; }
.car-card-body { padding:14px 16px; display:flex; flex-direction:column; gap:6px; }
.car-card-body h3 { margin:0; font-size:16px; }
.car-card-meta { display:flex; flex-wrap:wrap; gap:8px; font-size:12px; color:var(--muted); }
.car-card-vin { font-size:12px; color:var(--muted); }

/* ---- Browse filters ---- */
.filter-card { background:#fff; border:1px solid var(--line); border-radius:var(--radius); padding:18px; box-shadow:0 4px 14px rgba(2,6,23,.04); margin-bottom:20px; }
.filter-row { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:14px; align-items:end; margin-bottom:14px; }
.filter-row:last-child { margin-bottom:0; }
.filter-card label { display:block; font-size:12px; font-weight:600; color:#334155; margin-bottom:4px; text-transform:uppercase; letter-spacing:.04em; }
.filter-card select, .filter-card input { width:100%; padding:10px 12px; border:1px solid var(--line); border-radius:10px; font-size:14px; font-family:inherit; background:#fff; }
.filter-actions { display:flex; gap:8px; align-items:end; }
.filter-summary { margin-bottom:18px; font-size:14px; color:var(--muted); display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.filter-summary .chip { display:inline-block; padding:3px 10px; border-radius:999px; background:#eff6ff; color:#1e40af; font-size:12px; }

/* ---- Make chips ---- */
.make-chips { display:flex; flex-wrap:wrap; gap:10px; justify-content:center; }
.make-chips a { padding:9px 18px; border-radius:999px; background:#fff; border:1px solid var(--line); font-weight:600; color:var(--ink); transition:all .15s ease; }
.make-chips a:hover { background:var(--brand); color:#fff; border-color:var(--brand); text-decoration:none; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.kv .row { background: #fff; padding: 12px 16px; }
.kv .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kv .v { font-weight: 600; margin-top: 2px; }

.block h2 { font-size: 18px; margin: 0 0 10px; }
.block { margin: 26px 0; }
.block p { white-space: pre-line; color: #334155; }

/* ---- Contact form ---- */
.contact-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow); margin-top: 26px;
}
.contact-card h2 { margin-top: 0; }
.form-grid { display: grid; gap: 14px; }
.form-grid label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 4px; }
.form-grid input, .form-grid textarea, .form-grid select {
  width: 100%; padding: 11px 13px; font-size: 14px; border: 1px solid var(--line);
  border-radius: 10px; font-family: inherit; outline: none;
}
.form-grid input:focus, .form-grid textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-grid textarea { min-height: 100px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .two { grid-template-columns: 1fr; } }
.btn {
  border: 0; background: var(--brand-grad); color: #fff; font-weight: 700;
  padding: 12px 22px; border-radius: 10px; cursor: pointer; font-size: 15px;
}
.btn.secondary { background: #e2e8f0; color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.field-hint { color: var(--muted); font-size: 12px; }

/* ---- Footer ---- */
.site-footer { background: var(--bg); color: #94a3b8; padding: 30px 0; margin-top: 40px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px; }
.site-footer a { color: #cbd5e1; }
.site-footer h4 { color: #fff; margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }

/* ---- Auth ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; }
.auth-card .sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.error-msg { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.success-msg { background: #ecfdf5; border: 1px solid #bbf7d0; color: #065f46; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

/* ---- Admin layout ---- */
.admin { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; background: #f1f5f9; }
.admin-side { background: var(--bg); color: #cbd5e1; padding: 20px 0; position: sticky; top: 0; height: 100vh; }
.admin-side .logo { color: #fff; font-weight: 800; padding: 0 20px 18px; font-size: 18px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.07); }
.admin-side nav a { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: #cbd5e1; font-size: 14px; }
.admin-side nav a:hover, .admin-side nav a.active { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.admin-main { padding: 24px 28px; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.admin-topbar h1 { margin: 0; font-size: 24px; }
.admin-topbar .user { font-size: 13px; color: var(--muted); }
@media (max-width: 760px) { .admin { grid-template-columns: 1fr; } .admin-side { position: static; height: auto; } .admin-side nav a { padding: 8px 20px; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.stat .num { font-size: 28px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 13px; }

table.tbl { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.tbl th, table.tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
table.tbl th { background: #f8fafc; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.actions a { margin-right: 8px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.hidden { background: #fef9c3; color: #854d0e; }
.badge.new { background: #dbeafe; color: #1e40af; }
.badge.processing { background: #fef9c3; color: #854d0e; }
.badge.done { background: #dcfce7; color: #166534; }
.badge.rejected { background: #fee2e2; color: #991b1b; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar a, .toolbar form { display: inline-flex; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips a { padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 13px; color: var(--ink); }
.chips a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.thumb { position: relative; }
.thumb img { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.thumb label { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; padding: 3px 7px; font-size: 12px; cursor: pointer; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: #ecfdf5; border: 1px solid #bbf7d0; color: #065f46; }
.flash.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Code", monospace; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.inline-form { display: inline; }

/* ---- Support chat widget ---- */
.chat-widget { position: fixed; right: 20px; bottom: 20px; z-index: 9999; font-family: inherit; }
.chat-fab {
  width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand-grad); color: #fff; box-shadow: 0 12px 28px rgba(2,6,23,.28);
  display: grid; place-items: center; transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
}
.chat-fab:hover { transform: translateY(-2px) scale(1.04); }
.chat-fab-icon { font-size: 26px; line-height: 1; }
.chat-fab-badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px;
  background: #ef4444; color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #fff;
}
.chat-fab[aria-expanded="true"] { transform: scale(.9); opacity: 0; pointer-events: none; }

.chat-panel {
  width: 350px; max-width: calc(100vw - 32px); max-height: 520px;
  background: #fff; border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(2,6,23,.28); border: 1px solid var(--line);
  display: flex; flex-direction: column; position: absolute; right: 0; bottom: 70px;
  animation: chatPop .2s ease;
}
@keyframes chatPop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.chat-panel[hidden] { display: none; }

.chat-head {
  background: var(--brand-grad); color: #fff; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
}
.chat-avatar { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; font-size: 20px; }
.chat-head-info { flex: 1; display: flex; flex-direction: column; }
.chat-head-info strong { font-size: 15px; }
.chat-status { font-size: 12px; display: flex; align-items: center; gap: 5px; opacity: .95; }
.chat-status i { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; display: inline-block; box-shadow: 0 0 0 3px rgba(74,222,128,.25); }
.chat-close { background: rgba(255,255,255,.18); border: 0; color: #fff; width: 30px; height: 30px; border-radius: 8px; font-size: 20px; line-height: 1; cursor: pointer; }

.chat-body { flex: 1; overflow-y: auto; padding: 16px; background: #f8fafc; display: flex; flex-direction: column; gap: 8px; min-height: 180px; max-height: 320px; }
.chat-msg { max-width: 80%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.chat-msg.bot { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; align-self: flex-start; }
.chat-msg.user { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }

.chat-cta { padding: 10px 14px 0; }
.chat-tg { width: 100%; text-align: center; background: #229ED9; color: #fff; }
.chat-tg:hover { text-decoration: none; filter: brightness(1.05); }

.chat-typing { padding: 4px 16px 8px; font-size: 12px; color: var(--muted); font-style: italic; }
.chat-typing[hidden] { display: none; }

.chat-input { display: flex; gap: 8px; padding: 12px 14px 14px; border-top: 1px solid var(--line); background: #fff; }
.chat-input input {
  flex: 1; border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; font-size: 14px; outline: none; font-family: inherit;
}
.chat-input input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.chat-input button { border: 0; background: var(--brand-grad); color: #fff; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 16px; display: grid; place-items: center; }

@media (max-width: 480px) {
  .chat-widget { right: 12px; bottom: 12px; }
  .chat-fab { width: 54px; height: 54px; }
  .chat-panel { bottom: 66px; }
}

/* ---- Admin chat conversation ---- */
.conv-meta { margin-bottom: 12px; font-size: 13px; }
.conv {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  max-height: 56vh; overflow-y: auto; margin-bottom: 16px;
}
.conv .chat-msg { max-width: 72%; }
.conv .chat-msg i { display: block; font-style: normal; font-size: 10px; opacity: .55; margin-top: 3px; text-align: right; }
.conv-input { max-width: none; border: 0; background: #fff; padding: 0; }
.conv-input input { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.conv-input .btn { padding: 12px 22px; }
