:root {
  --bg: #0f172a;
  --bg-elevated: #17203a;
  --card: #1c2540;
  --border: #2a3556;
  --text: #e8ecf7;
  --text-dim: #9aa4c2;
  --accent: #4f8cff;
  --accent-2: #22c55e;
  --danger: #f4574f;
  --warn: #f5a524;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: calc(64px + var(--safe-bottom));
  min-height: 100vh;
}

#app {
  padding: calc(14px + var(--safe-top)) 14px 24px;
  max-width: 640px;
  margin: 0 auto;
}

h1, h2, h3 { margin: 0 0 4px; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
p { margin: 0 0 8px; color: var(--text-dim); font-size: 14px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { opacity: 0.8; }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.field input, .field select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
}
.row { display: flex; gap: 10px; }
.row > .field { flex: 1; }

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex: none;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.chip.active { background: var(--accent); color: white; border-color: var(--accent); }

.sort-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.sort-row select {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  flex: 1;
}

.car-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  display: flex;
  cursor: pointer;
}
.car-card img {
  width: 110px;
  height: 100%;
  min-height: 100px;
  object-fit: cover;
  background: var(--bg-elevated);
  flex: none;
}
.car-card .no-image {
  width: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-size: 24px;
  flex: none;
}
.car-card-body { padding: 12px; flex: 1; min-width: 0; }
.car-card-title { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.car-card-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.car-card-price { font-size: 18px; font-weight: 800; color: var(--accent-2); }
.car-card-meta { display: flex; gap: 10px; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; margin-top: 4px; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}
.badge.sold { background: rgba(244,87,79,0.18); color: var(--danger); }
.badge.drop { background: rgba(34,197,94,0.18); color: var(--accent-2); }
.badge.rise { background: rgba(245,165,36,0.18); color: var(--warn); }

.fav-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}
.stat {
  background: var(--bg-elevated);
  border-radius: 10px;
  padding: 10px 12px;
}
.stat .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.stat .value { font-size: 17px; font-weight: 700; margin-top: 2px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; }

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: var(--safe-bottom);
  z-index: 50;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 9px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.tab.active { color: var(--accent); }
.tab-icon { font-size: 19px; }

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  padding: 6px 0;
  margin-bottom: 8px;
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: calc(74px + var(--safe-bottom));
  left: 14px;
  right: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 700;
  margin: 18px 0 8px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.notice {
  background: rgba(79,140,255,0.1);
  border: 1px solid rgba(79,140,255,0.3);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
