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

:root {
  --bg: #f4f5f7;
  --surface: #fff;
  --border: #ddd;
  --text: #1a1a1a;
  --text-muted: #666;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --row-hover: #f0f4ff;
  --header-bg: #1e293b;
  --header-text: #f1f5f9;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.4; }

/* Header */
header { background: var(--header-bg); color: var(--header-text); padding: 10px 20px; }
.header-inner { display: flex; align-items: center; gap: 16px; max-width: 1800px; margin: 0 auto; }
.logo { font-size: 18px; font-weight: 700; white-space: nowrap; color: var(--header-text); text-decoration: none; }
.subtitle { font-size: 12px; color: #94a3b8; }
.status { font-size: 11px; margin-left: auto; padding: 3px 8px; border-radius: 4px; }
.status.loading { background: #fef3c7; color: #92400e; }
.status.ready { background: var(--green-bg); color: var(--green); }
.status.error { background: var(--red-bg); color: var(--red); }

/* Tabs */
nav#tabs { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 20px; display: flex; gap: 0; max-width: 1800px; margin: 0 auto; }
.tab { background: none; border: none; padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.15s; }
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Views */
.view { display: none; max-width: 1800px; margin: 0 auto; padding: 12px 20px; }
.view.active { display: block; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input[type="text"] {
  font-size: 12px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--text);
}
.filters input[type="text"] { width: 220px; }
.stats { margin-left: auto; font-size: 11px; color: var(--text-muted); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
thead { position: sticky; top: 0; z-index: 2; }
th {
  background: #f8fafc; border-bottom: 2px solid var(--border);
  padding: 6px 8px; text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px;
  white-space: nowrap; user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--accent); }
th.sort-asc::after { content: ' ▲'; font-size: 9px; }
th.sort-desc::after { content: ' ▼'; font-size: 9px; }
th.num { text-align: right; }
td { padding: 4px 8px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; font-size: 12px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: var(--row-hover); }

/* Cell types */
.cell-img { width: 40px; height: 40px; object-fit: cover; border-radius: 3px; cursor: pointer; }
td.td-title { max-width: 340px; }
.product-link { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; color: var(--accent); text-decoration: none; cursor: pointer; }
.product-link:hover { text-decoration: underline; }
.price { font-weight: 600; color: var(--green); }
.price-was { text-decoration: line-through; color: var(--text-muted); font-size: 11px; }
.discount-badge { background: var(--red-bg); color: var(--red); padding: 1px 5px; border-radius: 3px; font-size: 10px; font-weight: 600; }
.store-link { color: var(--accent); text-decoration: none; }
.store-link:hover { text-decoration: underline; }
.trust-badge { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 600; }
.trust-yes { background: var(--green-bg); color: var(--green); }
.trust-no { background: #f1f5f9; color: var(--text-muted); }
.tag { display: inline-block; padding: 1px 5px; border-radius: 3px; font-size: 10px; margin: 1px; }
.tag-choice { background: #ede9fe; color: #7c3aed; }
.tag-welcome { background: #fef3c7; color: #92400e; }
.tag-box { background: #e0f2fe; color: #0369a1; }
.tag-free-ship { background: var(--green-bg); color: var(--green); }
.tag-brand { background: #dbeafe; color: #1d4ed8; }
.tag-minifig { background: #fce7f3; color: #be185d; }
.tag-variants { background: #f3e8ff; color: #7c3aed; cursor: help; }

/* Rating */
.rating-bar { display: inline-flex; gap: 1px; }
.rating-pip { width: 8px; height: 8px; border-radius: 2px; background: #e2e8f0; }
.rating-pip.filled { background: #facc15; }
.rating-num { font-weight: 600; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 10px; }
.pagination button {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); cursor: pointer; font-size: 12px;
}
.pagination button.active { background: var(--accent); color: white; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* Category grid */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; cursor: pointer; transition: box-shadow 0.15s;
}
.cat-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.cat-card h3 { font-size: 15px; text-transform: capitalize; margin-bottom: 6px; }
.cat-card .cat-stats { font-size: 12px; color: var(--text-muted); }
.cat-card .cat-stats span { display: block; margin-top: 2px; }
.cat-card .cat-price { font-size: 13px; color: var(--green); font-weight: 600; margin-top: 6px; }
.cat-thumb-row { display: flex; gap: 4px; margin-top: 8px; overflow: hidden; }
.cat-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }

/* Store detail header */
.store-header { padding: 16px 0; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.store-header h2 { font-size: 20px; margin-bottom: 6px; }
.store-header .store-meta { font-size: 13px; color: var(--text-muted); }
.store-header .store-meta span { margin-right: 16px; }
.store-header .store-meta a { color: var(--accent); }
.back-link { font-size: 12px; color: var(--accent); text-decoration: none; margin-bottom: 8px; display: inline-block; }
.back-link:hover { text-decoration: underline; }

/* Product detail */
.product-detail { max-width: 900px; }
.product-detail h2 { font-size: 18px; margin-bottom: 12px; }
.product-detail-img { max-width: 300px; border-radius: 6px; margin-bottom: 12px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 13px; margin-bottom: 16px; }
.detail-grid dt { color: var(--text-muted); font-weight: 500; }
.brand-match-box { padding: 12px; background: #eff6ff; border-radius: 8px; border: 1px solid #bfdbfe; margin-bottom: 16px; }
.brand-match-box h3 { font-size: 14px; margin-bottom: 8px; color: #1d4ed8; }
.competitors-section { margin-top: 16px; }
.competitors-section h3 { font-size: 14px; margin-bottom: 8px; }
.competitors-section tr.current-seller { background: #eff6ff; font-weight: 600; }
.competitors-section tr.current-seller td:first-child { border-left: 3px solid var(--accent); }

/* Spinner */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #e2e8f0; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }

/* Variants */
.variants-section { margin-top: 16px; }
.variants-section h3 { font-size: 14px; margin-bottom: 8px; }
.variant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.variant-card {
  border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-size: 12px;
  display: flex; gap: 8px; align-items: center;
}
.variant-card img { width: 40px; height: 40px; object-fit: cover; border-radius: 3px; }
.variant-name { font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.variant-price { color: var(--green); font-weight: 600; }
.current-seller td { background: #eff6ff; }

@media (max-width: 768px) {
  .filters { flex-direction: column; }
  .header-inner { flex-wrap: wrap; }
  nav#tabs { overflow-x: auto; }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
