:root {
  --navy: #0f1e33;
  --navy-2: #1b2f4d;
  --accent: #f2a900;
  --accent-dark: #c98a00;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5d6b7e;
  --line: #dde3ea;
  --green: #1f8a4c;
  --amber: #b86e00;
  --red: #c0392b;
  --blue: #2a6db0;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(15, 30, 51, 0.08);
}

* { box-sizing: border-box; }

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

a { color: var(--blue); }
img { max-width: 100%; display: block; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header / footer ---------- */
.site-header { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
.logo { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 44px; height: 44px; flex-shrink: 0; }
.logo em { font-style: normal; color: var(--accent); }
.logo small { display: block; font-weight: 500; font-size: 0.7rem; color: #9fb0c8; letter-spacing: 0.02em; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: #d7e0ec; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-weight: 500; font-size: 0.95rem; }
.nav a:hover, .nav a.active { background: var(--navy-2); color: #fff; }
.nav a.admin-link { color: var(--accent); }

.site-footer { background: var(--navy); color: #9fb0c8; margin-top: 56px; padding: 32px 0; font-size: 0.9rem; }
.site-footer .container { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; }
.site-footer h4 { color: #fff; margin: 0 0 8px; }
.site-footer a { color: #d7e0ec; }
.site-footer p { margin: 4px 0; }
.legal { border-top: 1px solid var(--navy-2); margin-top: 24px; padding-top: 16px; font-size: 0.8rem; grid-column: 1 / -1; }

/* ---------- Hero ---------- */
.hero { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff; padding: 48px 0 40px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(1.7rem, 4vw, 2.6rem); letter-spacing: -0.02em; }
.hero p { margin: 0; color: #c4d0e0; max-width: 640px; }
.hero .badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hero .badges span { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 8px; padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--navy); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-dark { background: var(--navy); color: #fff; }
.btn-outline { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn-danger { background: #fff; color: var(--red); border: 1px solid #f0c5c0; }
.btn-sm { padding: 6px 10px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------- Filters ---------- */
.filters { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: -24px 0 24px; position: relative; display: grid; grid-template-columns: 2fr repeat(5, 1fr); gap: 10px; }
.filters input, .filters select { width: 100%; }
.results-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; color: var(--muted); font-size: 0.95rem; }

input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

/* ---------- Car cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.car-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; transition: transform 0.15s, box-shadow 0.15s; }
.car-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(15, 30, 51, 0.14); }
.car-card .thumb { position: relative; aspect-ratio: 4 / 3; background: #e8edf3; }
.car-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.condition-pill { background: var(--accent); color: var(--navy); font-weight: 700; font-size: 0.85rem; padding: 4px 10px; border-radius: 6px; }
.writeoff { display: inline-flex; align-items: center; font-weight: 700; font-size: 0.8rem; padding: 3px 9px; border-radius: 999px; background: var(--red); color: #fff; white-space: nowrap; }
.writeoff-tag { position: absolute; right: 10px; top: 10px; background: var(--red); color: #fff; font-weight: 800; font-size: 0.78rem; padding: 4px 9px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,0.25); }
.condition-tag { position: absolute; left: 10px; top: 10px; background: var(--accent); color: var(--navy); font-weight: 700; font-size: 0.78rem; padding: 4px 9px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.photo-count { position: absolute; right: 10px; bottom: 10px; background: rgba(15,30,51,0.8); color: #fff; font-size: 0.78rem; padding: 3px 8px; border-radius: 6px; }
.car-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.car-card h3 { margin: 0; font-size: 1.08rem; }
.car-card .variant { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.price { font-size: 1.35rem; font-weight: 800; color: var(--navy); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 0.8rem; color: var(--muted); }
.id-block { border-top: 1px dashed var(--line); padding-top: 10px; display: grid; gap: 6px; font-size: 0.85rem; margin-top: auto; }
.id-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.id-row .k { color: var(--muted); }
.vin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; letter-spacing: 0.04em; }

/* UK number plate */
.plate { display: inline-flex; align-items: stretch; border-radius: 4px; overflow: hidden; border: 1.5px solid #222; font-family: "Charles Wright", "Arial Narrow", Arial, sans-serif; font-weight: 800; background: #f7d117; color: #111; line-height: 1; }
.plate .gb { background: #1f4fa3; color: #fff; font-size: 0.55em; display: flex; align-items: flex-end; padding: 0 3px 3px; font-weight: 700; }
.plate .num { padding: 4px 8px; letter-spacing: 0.06em; white-space: nowrap; }
.plate-lg { font-size: 1.5rem; }

/* MOT badge */
.mot { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.8rem; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.mot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mot-valid { background: #e5f5ec; color: var(--green); }
.mot-soon { background: #fff2dc; color: var(--amber); }
.mot-expired { background: #fbe6e3; color: var(--red); }
.mot-notdue, .mot-exempt { background: #e4eefa; color: var(--blue); }

/* ---------- Detail page ---------- */
.breadcrumb { margin: 20px 0 14px; font-size: 0.9rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.detail { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.gallery-main { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: #e8edf3; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(15,30,51,0.65); color: #fff; border: 0; width: 42px; height: 42px; border-radius: 50%; font-size: 1.3rem; cursor: pointer; }
.gallery-nav.prev { left: 12px; }
.gallery-nav.next { right: 12px; }
.gallery-count { position: absolute; left: 12px; bottom: 12px; background: rgba(15,30,51,0.75); color: #fff; padding: 3px 10px; border-radius: 6px; font-size: 0.85rem; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-top: 10px; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; aspect-ratio: 4 / 3; background: #e8edf3; }
.thumbs button.active { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.detail h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.01em; }
.detail .variant { color: var(--muted); margin: 4px 0 12px; }
.detail .price { font-size: 2rem; margin-bottom: 14px; }
.spec-table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.spec-table th, .spec-table td { text-align: left; padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.spec-table th { color: var(--muted); font-weight: 500; width: 44%; }
.description { white-space: pre-line; }
.features { columns: 2; padding-left: 18px; margin: 0; }
.features li { margin-bottom: 4px; break-inside: avoid; }
.stack > * + * { margin-top: 16px; }
.id-panel { display: grid; gap: 12px; }
.id-panel .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.id-panel .label { color: var(--muted); font-size: 0.9rem; }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 24px; }
.about-grid .panel h3 { margin-top: 0; }
.prose { max-width: 760px; }
.prose h2 { margin-top: 36px; }

/* ---------- Admin ---------- */
.notice { background: #fff8e6; border: 1px solid #f5d98c; color: #6b4e00; border-radius: 8px; padding: 12px 14px; font-size: 0.9rem; margin: 20px 0; }
.form-section { margin-bottom: 20px; }
.form-section h2 { font-size: 1.1rem; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.85rem; font-weight: 600; }
.field .hint { font-size: 0.78rem; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.combo { display: flex; gap: 6px; }
.combo > * { min-width: 0; }
.combo input { text-transform: uppercase; }
.preview-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.error { color: var(--red); font-size: 0.8rem; min-height: 1em; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 400; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: #fafbfd; }
.dropzone.over { border-color: var(--accent); background: #fff8e6; }
.photo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.photo-item { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; background: #e8edf3; border: 2px solid transparent; }
.photo-item.main { border-color: var(--accent); }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-item .tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 4px; background: linear-gradient(transparent, rgba(0,0,0,0.6)); }
.photo-item .tools button { background: rgba(255,255,255,0.92); border: 0; border-radius: 4px; font-size: 0.72rem; padding: 2px 6px; cursor: pointer; }
.photo-item .tag { position: absolute; top: 4px; left: 4px; background: var(--accent); color: var(--navy); font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.stock-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.stock-table th, .stock-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.stock-table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.table-wrap { overflow-x: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow); z-index: 50; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .search { grid-column: 1 / -1; }
  .detail { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .site-header .container { height: auto; padding-top: 10px; padding-bottom: 10px; flex-direction: column; align-items: flex-start; gap: 6px; }
  .nav a { padding: 6px 8px; }
  .features { columns: 1; }
  .site-header { position: static; }
}
