:root {
  --accent: #ff7a1a;
  --accent-ink: #1a1206;
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-2: #f0efed;
  --border: #e4e2df;
  --text: #1c1b1a;
  --muted: #6f6c68;
  --ok: #1f9d55;
  --warn: #d64545;
  --info: #2f6fdb;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: #1b1c1f;
    --surface-2: #24262a;
    --border: #2e3035;
    --text: #f1f1f0;
    --muted: #9a9ca3;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }
.logo { font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.logo span { color: var(--accent); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { padding: 4px 10px 18px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  text-decoration: none; color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); }
.nav a.active svg { color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .spacer { flex: 1; }
.account { padding: 10px; border-top: 1px solid var(--border); font-size: 13px; }
.account .name { font-weight: 600; }
.account .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
main { padding: 28px 32px 48px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .grow { flex: 1; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; height: auto; flex-direction: row; align-items: center; padding: 10px 12px;
    border-right: 0; border-bottom: 1px solid var(--border); z-index: 5; overflow-x: auto;
  }
  .sidebar .logo { padding: 0 8px 0 4px; font-size: 18px; }
  .nav { display: flex; gap: 2px; }
  .nav a span { display: none; }
  .sidebar .spacer, .account .name, .account .muted { display: none; }
  .account { border: 0; padding: 0; }
  .account .row { margin: 0; }
  main { padding: 18px 16px 40px; }
  .search { width: 100%; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); padding: 8px 14px;
  border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.96); }
.btn.danger { color: var(--warn); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.link { border: 0; background: none; padding: 0; color: var(--muted); font-weight: 500; }
.input {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 9px 12px; min-width: 0; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.search { width: 260px; max-width: 100%; }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---------- cards & stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { padding: 14px 16px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.alert .value { color: var(--warn); }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.car { overflow: hidden; cursor: pointer; transition: transform .12s ease, border-color .12s ease; text-decoration: none; display: block; }
.car:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.thumb { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg.placeholder { width: 64px; color: var(--muted); opacity: .6; }
.car .body { padding: 12px 14px 14px; }
.car .vin { font-weight: 600; font-size: 14px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 8px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips .regen { order: 99; margin-left: auto; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.chip.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chip.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.chip.info { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.chip.accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: color-mix(in srgb, var(--accent) 80%, var(--text)); }
/* status chip on top of a photo: solid so it stays readable on any image */
.thumb .chip { position: absolute; top: 8px; left: 8px; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.thumb .chip.ok { background: var(--ok); color: #fff; }
.thumb .chip.warn { background: var(--warn); color: #fff; }
.thumb .chip.info { background: var(--info); color: #fff; }
.alert-box {
  font-size: 13px; font-weight: 500; color: var(--warn); border-radius: 8px; padding: 8px 10px;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}

.empty { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty svg { width: 72px; opacity: .5; }

/* ---------- car detail ---------- */
.back { text-decoration: none; color: var(--muted); font-size: 14px; display: inline-flex; gap: 6px; margin-bottom: 10px; }
.meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin-top: 6px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.shot { overflow: hidden; }
.shot .thumb { cursor: zoom-in; }
.shot .body { padding: 10px 12px; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.shot .body .name { flex: 1; font-size: 14px; font-weight: 500; }
.shot .error { padding: 0 12px 10px; font-size: 13px; color: var(--warn); }
.shot .error details { margin-top: 6px; color: var(--muted); font-size: 12px; word-break: break-word; }
.shot .error summary { cursor: pointer; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent); animation: spin .9s linear infinite;
}
.thumb .overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(8,8,9,.92); z-index: 20; display: grid;
  grid-template-rows: auto 1fr auto; padding: 16px; gap: 12px;
}
.lightbox .top { display: flex; justify-content: space-between; color: #eee; align-items: center; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; display: block; min-height: 0; }
.lightbox .stage { min-height: 0; display: grid; position: relative; }
.lightbox .top .muted { margin: 0 auto 0 12px; }
.lightbox .nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 32px; line-height: 1; cursor: pointer; z-index: 1;
}
.lightbox .nav:disabled { display: none; }
.lightbox .nav.prev { left: 8px; }
.lightbox .nav.next { right: 8px; }
.segmented { display: inline-flex; background: #24262a; border-radius: 99px; padding: 4px; margin: 0 auto; }
.segmented button { border: 0; background: none; color: #ddd; padding: 7px 16px; border-radius: 99px; cursor: pointer; font-weight: 600; }
.segmented button.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- showrooms ---------- */
.showroom .body { padding: 12px 14px; display: grid; gap: 10px; }
.showroom .title { display: flex; align-items: center; gap: 8px; }
.showroom .title strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.showroom .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.car-plate { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.dealer-showrooms { padding: 16px 18px; margin-bottom: 18px; display: grid; gap: 12px; }
.dealer-showrooms > .title { display: flex; justify-content: space-between; align-items: center; }
.dealer-showrooms .hint { margin: 0; }
.dealer-showrooms .new-showroom { margin: 0; padding: 0; }
img.angle { object-fit: contain; }
.card.empty img.angle { width: 200px; height: 150px; }
.thumb img.angle { width: 70%; height: 70%; margin: auto; }
.plates { padding: 16px 18px; margin-bottom: 18px; display: grid; gap: 12px; }
.plates h2 { margin: 0; }
.plates .hint { margin: 0; }
.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
.plate-logo { display: flex; gap: 14px; align-items: center; }
.plate-logo .grow { flex: 1; }
.plate-logo .actions { display: flex; gap: 8px; margin-top: 8px; }
.plate-preview { width: 156px; height: 34px; flex: none; border-radius: 4px; background: #f4f4f0; border: 2px solid #26262a;
  display: grid; place-items: center; overflow: hidden; }
.plate-preview img { max-width: 86%; max-height: 70%; object-fit: contain; }
.new-showroom { padding: 16px; display: grid; gap: 12px; grid-template-columns: 1fr 1fr auto; align-items: end; margin-bottom: 18px; }
@media (max-width: 820px) { .new-showroom { grid-template-columns: 1fr; } }
.hint { font-size: 13px; color: var(--muted); margin: -8px 0 16px; max-width: 720px; }

/* ---------- credits ---------- */
.balance { padding: 22px; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.balance .big { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
td.num.plus { color: var(--ok); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; display: grid; gap: 16px; }
.login .logo { font-size: 32px; }
.error-text { color: var(--warn); font-size: 14px; min-height: 20px; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  transition: all .2s ease; pointer-events: none; z-index: 30; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- team / admin / billing ---------- */
.inline-form { padding: 16px; display: grid; gap: 12px; grid-template-columns: 1fr auto; align-items: end; margin-bottom: 14px; }
.inline-form.three { grid-template-columns: 1.2fr 1.2fr .6fr auto; }
.password-form { padding: 16px; display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr) auto; align-items: end; }
@media (max-width: 820px) { .inline-form, .inline-form.three, .password-form { grid-template-columns: 1fr; } }
.credentials { padding: 16px; display: grid; gap: 8px; margin-bottom: 14px; border-color: var(--accent); justify-items: start; }
.credentials .mono { font-size: 15px; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; user-select: all; }
.small { font-size: 12px; }
.packages { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 26px; }
.package { padding: 20px; display: grid; gap: 4px; justify-items: start; }
.package .credits-count { font-size: 34px; font-weight: 800; line-height: 1; }
.package .price { font-size: 20px; font-weight: 700; margin-top: 10px; }
.package .btn { margin-top: 12px; width: 100%; }
td .chip { margin-left: 6px; }

/* logo spot editor */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(960px, 100%); max-height: 100%; overflow: auto; padding: 16px; display: grid; gap: 12px; }
.modal .title { display: flex; align-items: center; gap: 8px; }
.modal .title strong { flex: 1; }
.modal .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.spot-stage { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); touch-action: none; user-select: none; }
.spot-room { width: 100%; height: 100%; object-fit: fill; display: block; }
.spot-logo { position: absolute; cursor: move; outline: 1px dashed rgba(255,122,26,.9); outline-offset: 2px; touch-action: none; }
.spot-logo img { width: 100%; height: 100%; display: block; pointer-events: none; }
.spot-resize { position: absolute; right: -9px; bottom: -9px; width: 16px; height: 16px; border-radius: 3px; background: var(--accent); border: 2px solid #fff; cursor: nwse-resize; box-shadow: 0 1px 4px rgba(0,0,0,.5); }

/* ---------- listing (AD Manager) ---------- */
.listing-form { padding: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid textarea { resize: vertical; font: inherit; line-height: 1.45; }
label.field.missing { color: var(--warn); }
label.field.missing .input { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
label.field.check { display: flex; align-items: center; gap: 8px; align-self: end; padding-bottom: 10px; color: var(--text); font-size: 14px; }
label.field .hint { font-size: 12px; color: var(--muted); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.form-actions .grow { flex: 1; }
.listing-stage { padding: 16px 18px; }
.listing-stage p { margin: 0 0 12px; }
.stage-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
h1 .chip { vertical-align: middle; font-size: 13px; }
.form-grid label.field { align-content: start; }
.form-grid input.input, .form-grid select.input { height: 40px; box-sizing: border-box; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.md-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.md-head .grow { flex: 1; }
.listing-stage .error { margin: 0 0 12px; color: var(--warn); }
.warn-text { color: var(--warn); margin: 0 0 12px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form .input { width: 220px; max-width: 100%; }
p.small { font-size: 12px; margin: 10px 0 0; }
.spinner.small { width: 12px; height: 12px; border-width: 2px; display: inline-block; vertical-align: -2px; }
