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

:root {
  --yellow: #FFE600;
  --orange: #FF7733;
  --blue: #3483FA;
  --blue-dark: #2968c8;
  --green: #00A650;
  --text: #1a1a2e;
  --text-muted: #666;
  --bg: #f5f5f8;
  --surface: #fff;
  --border: #e8e8f0;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-hover: 0 6px 24px rgba(0,0,0,.14);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
.header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,.3);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 500;
  color: #fff;
}
.logo strong { color: var(--yellow); }
.header-meta { display: flex; align-items: center; gap: 12px; }
.badge {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  color: #ccc;
}
.badge strong { color: var(--yellow); }

/* ── Buttons ── */
.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:active { transform: scale(.97); }

.btn-sm {
  background: rgba(255,255,255,.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background .2s;
}
.btn-sm:hover { background: rgba(255,255,255,.2); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--blue);
  color: var(--blue);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
  margin-top: 8px;
  width: 100%;
}
.btn-outline:hover { background: var(--blue); color: #fff; }

/* ── Main ── */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* ── Search bar ── */
.search-bar-wrap {
  margin-bottom: 24px;
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  box-shadow: var(--shadow);
  transition: border-color .2s;
}
.search-bar:focus-within { border-color: var(--blue); }
.search-icon { color: var(--text-muted); flex-shrink: 0; }
.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: transparent;
}
.search-bar select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.tab {
  background: none;
  border: none;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* ── Filters ── */
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.filters label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.filters select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.filters .btn-sm {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.filters .btn-sm:hover { background: var(--blue-dark); }

/* ── Panels ── */
.panel { display: none; }
.panel.active { display: block; }

.section-header { margin-bottom: 20px; }
.section-header h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.hint { font-size: 13px; color: var(--text-muted); }

/* ── States ── */
.loading-state, .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 300px;
  color: var(--text-muted);
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Trend groups ── */
.trend-group { margin-bottom: 32px; }
.trend-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.trend-label h3 { font-size: 16px; font-weight: 600; }
.trend-tag {
  background: linear-gradient(135deg, var(--orange), #ff5500);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── Product Grid ── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

/* ── Product Card ── */
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.product-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.product-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  padding: 12px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}

.product-body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 6px; }

.product-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.product-price .cents { font-size: 13px; font-weight: 500; }

.product-installments {
  font-size: 12px;
  color: var(--green);
  font-weight: 500;
}

.product-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.badge-shipping {
  background: #e8f5e9;
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}
.badge-condition {
  background: #e3f0ff;
  color: var(--blue);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
}
.badge-sold {
  background: #fff3e0;
  color: #e65100;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
}

.product-footer { padding: 10px 12px; border-top: 1px solid var(--border); }
.btn-affiliate {
  width: 100%;
  background: linear-gradient(135deg, var(--yellow) 0%, #ffd000 100%);
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  font-family: inherit;
}
.btn-affiliate:hover { opacity: .9; }
.btn-affiliate:active { transform: scale(.97); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(16px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.modal-product-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
}
.link-box {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.link-box input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--bg);
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1a1a2e;
  color: #fff;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  transition: transform .3s ease;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Search results ── */
#searchMeta { font-size: 13px; color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .main { padding: 16px; }
  .search-bar { flex-wrap: wrap; }
  .search-bar select { width: 100%; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .header-inner { flex-wrap: wrap; height: auto; padding: 12px 0; }
  .tab { padding: 10px 14px; font-size: 13px; }
}
