*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #f0f2f5;
  --surface: #ffffff;
  --border:  #e4e6ea;
  --text:    #1c1e21;
  --muted:   #8a8d91;
  --accent:  #5b4fcf;
  --accent2: #2563eb;
  --olx:     #7c3aed;
  --fb:      #1877f2;
  --radius:  14px;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.header-brand { display: flex; flex-direction: column; gap: 0.15rem; }

.logo { display: flex; align-items: center; gap: 0.6rem; }

.logo-text {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline { font-size: 0.72rem; color: var(--muted); padding-left: 48px; }

.header-meta { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50%       { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

.last-updated { font-size: 0.73rem; color: var(--muted); }

/* ── Search bar ── */
.search-bar-wrap {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.search-icon { color: var(--muted); display: flex; align-items: center; flex-shrink: 0; }

#search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.92rem;
  color: var(--text);
  background: transparent;
}
#search-input::placeholder { color: var(--muted); }

.search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: var(--muted);
  color: white;
  border-radius: 50%;
  font-size: 0.6rem;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}
.search-clear:hover { background: var(--text); }

/* ── Filters ── */
.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.7rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.filter-group { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.filter-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s;
}
.filter-btn:hover:not(.active) {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(91,79,207,0.05);
}
.filter-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: white;
  box-shadow: 0 2px 10px rgba(91,79,207,0.25);
}

.source-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-olx    { background: var(--olx); }
.dot-fb     { background: var(--fb); }
.dot-sv     { background: #0077b6; }
.dot-dealer { background: #059669; }

.filter-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.price-range {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.28rem 0.75rem;
  background: white;
}
.price-range input {
  width: 72px;
  border: none;
  outline: none;
  font-size: 0.8rem;
  color: var(--text);
  background: transparent;
}
.price-range input::placeholder { color: var(--muted); }
.price-range input::-webkit-outer-spin-button,
.price-range input::-webkit-inner-spin-button { -webkit-appearance: none; }
.price-sep { color: var(--muted); font-size: 0.8rem; }

#sort-select {
  padding: 0.38rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
}
#sort-select:hover { border-color: var(--accent); }

#refresh-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s;
  flex-shrink: 0;
}
#refresh-btn:hover {
  border-color: var(--accent2);
  color: var(--accent2);
  background: rgba(37,99,235,0.05);
}
#refresh-btn svg { transition: transform 0.4s; }
#refresh-btn:hover svg { transform: rotate(180deg); }

/* ── Result bar ── */
.result-bar {
  padding: 0.5rem 2rem 0;
}
.result-count {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  padding: 0.75rem 2rem 1.5rem;
  flex: 1;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s, box-shadow 0.18s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.card-img-wrap { position: relative; }

.card-img {
  width: 100%;
  height: 185px;
  object-fit: cover;
  display: block;
  background: #e9ebee;
}
.card-img-placeholder {
  width: 100%;
  height: 185px;
  background: linear-gradient(135deg, #e9ebee, #dde0e6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: #bcc0c8;
}
.card-img-fallback { display: none; }

.badge-new {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #22c55e;
  color: white;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-body {
  padding: 0.85rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.card-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-price { font-size: 1rem; font-weight: 700; color: var(--accent); }
.card-location {
  font-size: 0.73rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.card-footer {
  padding: 0.65rem 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}

.badge {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-olx         { background: #f0ebff; color: #7c3aed; }
.badge-facebook    { background: #e8f0fe; color: #1877f2; }
.badge-standvirtual{ background: #e0f0ff; color: #005f8c; }
.badge-dealer      { background: #ecfdf5; color: #065f46; }

.card-link {
  font-size: 0.77rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 0.28rem 0.65rem;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  transition: all 0.15s;
}
.card-link:hover { background: var(--accent); color: white; }
.card-link-dealer { color: #059669; border-color: #059669; }
.card-link-dealer:hover { background: #059669; color: white; }

.card.card-dealer { border-color: #a7f3d0; }

/* ── Spinner ── */
.spinner {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 5rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.spinner-ring {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── Star button ── */
.star-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted);
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.star-btn:hover { color: #f59e0b; background: rgba(245,158,11,0.08); }
.star-btn.starred { color: #f59e0b; }
.star-btn.loading { opacity: 0.5; pointer-events: none; }

/* ── Badge featured ── */
.badge-featured {
  background: #fef3c7;
  color: #92400e;
  font-size: 0.64rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Card featured highlight ── */
.card.featured {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px #f59e0b22;
}

/* ── Featured section ── */
.featured-section {
  margin: 0.5rem 2rem 0;
  background: linear-gradient(135deg, #fffbeb, #fef9e7);
  border: 1.5px solid #f59e0b44;
  border-radius: var(--radius);
  overflow: hidden;
}

.featured-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0.6rem;
  border-bottom: 1px solid #f59e0b33;
}

.featured-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #92400e;
  flex: 1;
}

.featured-count {
  font-size: 0.72rem;
  color: #b45309;
  background: #fde68a;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  padding: 0.75rem;
}

/* ── Feature modal ── */
.feature-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(2px);
}
.feature-modal[hidden] { display: none; }

.feature-modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: min(340px, 90vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.feature-modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}

.day-btn {
  padding: 0.5rem 0.25rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  line-height: 1.2;
}
.day-btn:hover, .day-btn.selected {
  border-color: #f59e0b;
  background: #fef3c7;
  color: #92400e;
}
.day-price {
  font-size: 0.82rem;
  font-weight: 700;
  color: #d97706;
}
.day-btn.selected .day-price { color: #92400e; }

.modal-email-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.modal-email-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.modal-email-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.modal-email-input:focus { border-color: var(--accent); }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.feature-pay {
  padding: 0.45rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.feature-pay:disabled { opacity: 0.4; cursor: not-allowed; }
.feature-pay:not(:disabled):hover { opacity: 0.88; }

.feature-cancel {
  align-self: flex-end;
  padding: 0.38rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
}
.feature-cancel:hover { border-color: var(--text); color: var(--text); }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.1rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface);
}
footer strong { color: var(--text); font-weight: 600; }

/* ── Advertise link ── */
.advertise-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 700;
  color: #065f46;
  background: #ecfdf5;
  border: 1.5px solid #a7f3d0;
  border-radius: 999px;
  padding: .28rem .75rem;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.advertise-link:hover { background: #d1fae5; border-color: #059669; }

/* ── Mobile ── */
@media (max-width: 700px) {
  header { padding: 0.85rem 1rem; }
  .tagline { display: none; }
  .search-bar-wrap { padding: 0.6rem 1rem; }
  .filters { padding: 0.6rem 1rem; }
  .filter-right { width: 100%; }
  .price-range { flex: 1; }
  .result-bar { padding: 0.4rem 1rem 0; }
  .grid { padding: 0.6rem 1rem 1rem; gap: 0.75rem; }
  .featured-section { margin: 0.5rem 1rem 0; }
  .featured-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .days-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Success / Cancel pages ─────────────────────────────────────────────── */
.result-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 4rem 2rem;
  text-align: center;
  gap: 1rem;
}
.result-icon  { font-size: 3.5rem; line-height: 1; }
.result-title { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.result-sub   { font-size: 0.9rem; color: var(--muted); max-width: 320px; }
.result-back {
  margin-top: 0.5rem;
  padding: 0.55rem 1.4rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
}
.result-back:hover { opacity: 0.88; }
