/* ==== ISAUTO WebApp — dark + red ==== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: #0d0e10;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  overscroll-behavior-y: none;
  padding-bottom: 88px;
}
:root {
  --bg: #0d0e10;
  --card: #1a1c20;
  --card-2: #22252a;
  --border: #2a2d33;
  --muted: #8a8e96;
  --muted-2: #6b6f76;
  --red: #C40E1C;
  --red-dark: #9A0B16;
  --red-bg: rgba(196, 14, 28, 0.14);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; outline: none; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.row { display: flex; align-items: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); }

/* ==== App container ==== */
#app { max-width: 480px; margin: 0 auto; min-height: 100%; padding: 0 16px 16px; }

/* ==== Header ==== */
.app-header {
  display: flex; align-items: center;
  padding: 14px 0 10px;
  position: sticky; top: 0; background: var(--bg);
  z-index: 10;
}
.app-header .logo { height: 30px; }
.app-header .icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%; background: var(--card);
  display: grid; place-items: center;
  margin-left: auto;
}
.icon-btn svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 2; fill: none; }
.back-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,.55); backdrop-filter: blur(10px);
  display: grid; place-items: center;
  position: absolute; top: 14px; left: 16px; z-index: 5;
}
.back-btn svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 2.5; fill: none; }

/* ==== Hero ==== */
.hero {
  position: relative;
  border-radius: 18px; overflow: hidden;
  background: linear-gradient(135deg, #1f2126 0%, #0d0e10 100%);
  padding: 22px 18px;
  margin-bottom: 16px;
  min-height: 240px;
  display: flex; flex-direction: column;
}
.hero h1 { font-size: 22px; font-weight: 800; line-height: 1.18; max-width: 60%; }
.hero p { color: var(--muted); margin-top: 8px; font-size: 13px; max-width: 60%; }
.hero-img {
  position: absolute;
  right: -10px; bottom: 6px; width: 65%;
  pointer-events: none;
}
.hero .btn {
  align-self: flex-start;
  margin-top: auto;
}

/* ==== Buttons ==== */
.btn {
  background: var(--red); color: #fff;
  font-weight: 600; font-size: 15px;
  padding: 13px 22px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .1s, background .15s;
  width: auto;
}
.btn:active { transform: scale(.97); }
.btn:hover { background: var(--red-dark); }
.btn.full { width: 100%; }
.btn.ghost { background: var(--card); color: #fff; }
.btn.ghost:hover { background: var(--card-2); }
.btn.icon-only { width: 50px; height: 50px; padding: 0; border-radius: 14px; flex-shrink: 0; }

/* ==== Stat tiles ==== */
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.stat-tile {
  background: var(--card); border-radius: 16px;
  padding: 14px 12px; text-align: left;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-tile .ic { width: 32px; height: 32px; border-radius: 10px; background: var(--red-bg); display: grid; place-items: center; margin-bottom: 6px; }
.stat-tile .ic svg { width: 16px; height: 16px; stroke: var(--red); stroke-width: 2; fill: none; }
.stat-tile .name { font-size: 13px; color: #fff; font-weight: 600; }
.stat-tile .value { font-size: 13px; color: var(--muted); }

/* ==== Section headers ==== */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 6px 0 12px;
}
.section-head h2 { font-size: 17px; font-weight: 700; }
.section-head a { color: var(--red); font-size: 13px; font-weight: 600; }

/* ==== Car grid / cards ==== */
.car-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.car-grid.one-col { grid-template-columns: 1fr; }
.car-card {
  background: var(--card); border-radius: 16px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.car-card .photo {
  position: relative;
  aspect-ratio: 4/3; background: #11131600;
  overflow: hidden;
}
.car-card .photo img { width: 100%; height: 100%; object-fit: cover; }
.car-card .photo .fav {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,.55);
  display: grid; place-items: center;
}
.car-card .photo .fav svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 2; fill: none; }
.car-card .photo .fav.active svg { fill: var(--red); stroke: var(--red); }
.car-card .body { padding: 10px 12px 12px; }
.car-card .title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.car-card .meta { color: var(--muted); font-size: 11.5px; margin-bottom: 8px; }
.car-card .price { font-size: 15px; font-weight: 800; color: #fff; }

/* ==== Detail page ==== */
.detail { padding-bottom: 16px; }
.gallery {
  position: relative;
  border-radius: 18px; overflow: hidden;
  background: #11131666;
}
.gallery .main-photo {
  aspect-ratio: 4/3; background: var(--card);
}
.gallery .main-photo img { width: 100%; height: 100%; object-fit: cover; }
.gallery .top-actions { position: absolute; top: 14px; right: 16px; display: flex; gap: 8px; z-index: 4; }
.gallery .top-actions .icon-btn { background: rgba(0,0,0,.55); }
.gallery .thumbs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; padding: 12px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.4));
  position: absolute; left: 0; right: 0; bottom: 0;
}
.gallery .thumbs .th {
  aspect-ratio: 1.4/1; border-radius: 10px;
  background: var(--card); overflow: hidden;
  position: relative;
}
.gallery .thumbs .th img { width: 100%; height: 100%; object-fit: cover; }
.gallery .thumbs .th.more {
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700;
  background: rgba(0,0,0,.55);
}

.detail .head { padding: 16px 0 8px; }
.detail .head h1 { font-size: 22px; font-weight: 800; }
.detail .head .price { font-size: 22px; font-weight: 800; }
.detail .summary { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.detail .badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.badge {
  background: var(--card); border-radius: 10px;
  padding: 8px 12px; font-size: 12.5px; color: #fff;
  display: inline-flex; align-items: center; gap: 6px;
}
.badge svg { width: 13px; height: 13px; stroke: var(--muted); stroke-width: 2; fill: none; }

.specs-card {
  background: var(--card); border-radius: 16px;
  padding: 4px 16px;
  margin-bottom: 14px;
}
.specs-card h3 { font-size: 16px; font-weight: 700; padding: 14px 0 4px; }
.specs-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--border);
  font-size: 14px;
}
.specs-row:first-of-type { border-top: 1px solid var(--border); }
.specs-card h3 + .specs-row { border-top: 1px solid var(--border); }
.specs-row .k { color: var(--muted); }
.specs-row .v { color: #fff; font-weight: 500; text-align: right; }
.specs-card .show-all { color: var(--red); font-weight: 600; padding: 12px 0 16px; font-size: 14px; }

.detail .actions {
  position: sticky; bottom: 88px; z-index: 6;
  display: flex; gap: 10px; padding-top: 6px;
}
.detail .actions .btn { flex: 1; }

/* ==== Add listing form ==== */
.form-section {
  background: var(--card); border-radius: 16px;
  padding: 4px 16px; margin-bottom: 14px;
}
.form-section h3 { font-size: 16px; font-weight: 700; padding: 14px 0 4px; }
.form-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  cursor: pointer;
  gap: 12px;
}
.form-row:first-of-type, .form-section h3 + .form-row { border-top: 1px solid var(--border); }
.form-row .k { color: #fff; font-size: 14px; flex: 1; }
.form-row .v { color: var(--muted); font-size: 14px; text-align: right; }
.form-row .v.set { color: #fff; }
.form-row svg.chev { width: 14px; height: 14px; stroke: var(--muted); stroke-width: 2.5; fill: none; flex-shrink: 0; }
.form-row input.inline {
  background: transparent; border: none; text-align: right; color: #fff;
  flex: 1; min-width: 0;
}
.form-row input.inline::placeholder { color: var(--muted); }
.form-row textarea.inline {
  background: transparent; border: none; color: #fff;
  flex: 1; min-height: 60px; resize: vertical; padding: 0;
}

/* photo upload */
.photo-upload {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 10px 0 4px;
}
.photo-cell {
  aspect-ratio: 1; border-radius: 12px; background: var(--card-2);
  display: grid; place-items: center;
  position: relative;
  border: 1px dashed var(--border);
  overflow: hidden;
}
.photo-cell.has-img { border: none; background: var(--card-2); }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.photo-cell .ic { color: var(--red); font-size: 20px; }
.photo-cell .label { position: absolute; bottom: 6px; font-size: 10px; color: var(--muted); text-align: center; left: 0; right: 0; }
.photo-cell .rm {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.7); display: grid; place-items: center;
  font-size: 14px; line-height: 1;
}
.photo-counter { color: var(--muted); font-size: 13px; padding: 14px 0 6px; display: flex; justify-content: space-between; }
.photo-counter .lbl { color: #fff; font-size: 16px; font-weight: 700; }

/* ==== Filters ==== */
.filter-section { margin-bottom: 18px; }
.filter-section .h { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: #fff; }
.range-inputs { display: flex; gap: 10px; margin-bottom: 12px; }
.range-inputs input {
  flex: 1; background: var(--card); border-radius: 10px;
  padding: 12px 14px; color: #fff; font-size: 14px;
}
.range-inputs input::placeholder { color: var(--muted); }

.range-slider { position: relative; height: 28px; margin: 6px 6px 0; }
.range-slider .track { position: absolute; left: 0; right: 0; top: 12px; height: 4px; background: var(--card-2); border-radius: 2px; }
.range-slider .fill { position: absolute; top: 12px; height: 4px; background: var(--red); border-radius: 2px; }
.range-slider .thumb {
  position: absolute; top: 4px; width: 20px; height: 20px;
  background: var(--red); border-radius: 50%;
  transform: translateX(-10px); cursor: grab;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--card); border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px; color: #fff;
  border: 1px solid transparent;
}
.chip.active { border-color: var(--red); color: var(--red); background: var(--red-bg); }

select.dropdown {
  width: 100%; background: var(--card); border-radius: 12px;
  padding: 14px 16px; color: #fff; font-size: 14px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath stroke='%238a8e96' stroke-width='2' fill='none' d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 14px;
}
.filter-bottom {
  position: sticky; bottom: 88px; padding-top: 12px; background: var(--bg);
}

/* ==== Bottom Nav ==== */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(72px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  display: flex; align-items: center; justify-content: space-around;
  z-index: 50;
  border-top: 1px solid var(--border);
}
.bottom-nav .nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); padding: 10px 0; font-size: 11px;
}
.bottom-nav .nav-item.active { color: #fff; }
.bottom-nav .nav-item svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; fill: none; }
.bottom-nav .fab {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--red);
  display: grid; place-items: center;
  margin-top: -22px;
  box-shadow: 0 6px 20px rgba(196,14,28,.4);
}
.bottom-nav .fab svg { width: 24px; height: 24px; stroke: #fff; stroke-width: 2.5; fill: none; }

/* ==== Modal ==== */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: grid; align-items: end; justify-content: stretch;
  z-index: 100;
  animation: fadeIn .15s ease;
}
.modal-sheet {
  background: var(--bg); width: 100%; max-width: 480px; margin: 0 auto;
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(20px + var(--safe-bottom));
  max-height: 80vh; overflow: auto;
  animation: slideUp .2s ease;
}
.modal-sheet h3 { font-size: 18px; font-weight: 700; padding: 6px 0 14px; text-align: center; }
.modal-sheet .opt {
  padding: 14px 4px; font-size: 15px; color: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-sheet .opt.active { color: var(--red); font-weight: 600; }
.modal-sheet .opt:last-child { border-bottom: none; }
.modal-sheet .number-input {
  width: 100%; background: var(--card);
  border-radius: 12px; padding: 14px 16px;
  font-size: 16px; margin: 6px 0 12px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ==== Toast ==== */
.toast {
  position: fixed; left: 50%; top: 26px; transform: translateX(-50%);
  background: var(--card); color: #fff;
  padding: 12px 20px; border-radius: 12px;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  z-index: 200; max-width: 90%;
  animation: toastIn .25s ease;
}
.toast.error { background: var(--red); }
@keyframes toastIn { from { transform: translate(-50%, -10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ==== Empty / loading ==== */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .ic { font-size: 40px; margin-bottom: 12px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--card-2); border-top-color: var(--red);
  animation: spin .9s linear infinite;
  margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==== Photo viewer ==== */
.lightbox {
  position: fixed; inset: 0; background: #000; z-index: 200;
  display: flex; flex-direction: column;
}
.lightbox .top { padding: 14px; display: flex; justify-content: space-between; color: #fff; font-size: 13px; }
.lightbox .stage {
  flex: 1; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.lightbox .stage img { max-width: 100%; max-height: 100%; }
.lightbox .strip {
  display: flex; gap: 6px; padding: 10px; overflow-x: auto;
}
.lightbox .strip .th {
  width: 64px; height: 50px; border-radius: 8px; overflow: hidden;
  flex-shrink: 0; opacity: .5;
}
.lightbox .strip .th.active { opacity: 1; outline: 2px solid var(--red); }
.lightbox .strip .th img { width: 100%; height: 100%; object-fit: cover; }
