:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #141415;
  --muted: #68686f;
  --subtle: #9a9aa2;
  --border: rgba(0, 0, 0, 0.075);
  --border-hover: rgba(0, 0, 0, 0.16);
  --accent: #141415;
  --green: #136f3e;
  --green-bg: #eaf6ef;
  --amber: #8f5310;
  --amber-bg: #fdf4e7;
  --radius: 8px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select,
input {
  font: inherit;
  color: inherit;
  outline: none;
}

button:focus-visible,
a:focus-visible,
select:focus-visible {
  box-shadow: 0 0 0 2px rgba(20, 20, 21, 0.14);
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1260px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.03em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 4px 2px;
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text);
  display: inline-block;
}

.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--subtle);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 33px;
  padding: 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f3f3f5;
  font-size: 13px;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-box input:hover {
  background: #efeff2;
}

.search-box input:focus {
  border-color: rgba(0, 0, 0, 0.24);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

.search-shortcut {
  position: absolute;
  right: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 17px;
  pointer-events: none;
  background: var(--surface);
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
}

.nav-tab {
  background: transparent;
  border: none;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-tab:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.nav-tab.active {
  color: var(--text);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.06);
}

.badge {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--muted);
}

/* Controls Bar */
.controls-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.controls-inner {
  max-width: 1260px;
  margin: 0 auto;
  padding: 7px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.categories-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.categories-strip::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  border: 1px solid transparent;
  background: #f2f2f4;
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

.cat-pill:hover {
  background: #e8e8ec;
  color: var(--text);
}

.cat-pill.active {
  background: var(--text);
  color: var(--surface);
  font-weight: 500;
}

.filters-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-group select {
  height: 28px;
  padding: 0 22px 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.filter-group select:hover {
  border-color: var(--border-hover);
  background-color: #fafafa;
}

.ghost-btn {
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.ghost-btn:hover {
  border-color: var(--border-hover);
  background: #f5f5f7;
  color: var(--text);
}

.view-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-text {
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
}

.layout-toggle {
  display: inline-flex;
  background: #f2f2f4;
  padding: 2px;
  border-radius: var(--radius-sm);
  gap: 2px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.icon-btn:hover {
  color: var(--text);
}

.icon-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Main Content */
.main-container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 14px 16px 32px;
}

.hidden {
  display: none !important;
}

/* Grid View */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.deal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.deal-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.045);
  transform: translateY(-1px);
}

.card-thumb-wrap {
  height: 144px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  background: #ffffff;
  position: relative;
}

.card-thumb {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.deal-card:hover .card-thumb {
  transform: scale(1.02);
}

.fav-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(244, 244, 246, 0.85);
  color: var(--subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12.5px;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}

.fav-btn:hover {
  background: #eaeaecef;
  color: var(--text);
}

.fav-btn.active {
  color: #d99b00;
  background: #fff8e1;
}

.card-body {
  padding: 10px 11px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10.5px;
  color: var(--muted);
}

.meta-cat {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  font-size: 10px;
  color: var(--subtle);
}

.cond-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #f2f2f4;
  color: var(--muted);
  white-space: nowrap;
}

.cond-tag.refurbished,
.cond-tag.openbox {
  background: var(--amber-bg);
  color: var(--amber);
}

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

.card-footer {
  margin-top: auto;
  padding-top: 5px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.price-block {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: wrap;
}

.sale-price {
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
}

.list-price {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--subtle);
  text-decoration: line-through;
}

.discount-pill {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-bg);
  padding: 1px 5px;
  border-radius: 4px;
}

.ext-link {
  font-size: 11px;
  color: var(--subtle);
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
  transition: color 0.12s ease, background 0.12s ease;
}

.ext-link:hover {
  background: #f2f2f4;
  color: var(--text);
}

/* Compact List View */
.results-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-row {
  display: grid;
  grid-template-columns: 44px 105px 1fr auto auto 28px;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.list-row:last-child {
  border-bottom: none;
}

.list-row:hover {
  background-color: #f8f8fa;
}

.list-thumb {
  width: 38px;
  height: 38px;
  object-fit: contain;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  padding: 2px;
}

.list-title-col {
  min-width: 0;
}

.list-title {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-fav-col {
  position: static;
}

/* Saved Searches */
.panel-header {
  margin-bottom: 12px;
}

.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.panel-header p {
  font-size: 12.5px;
  color: var(--muted);
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.saved-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 0.12s ease;
}

.saved-item:hover {
  border-color: var(--border-hover);
}

.saved-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  cursor: pointer;
  flex: 1;
}

.saved-query {
  font-weight: 600;
  font-family: var(--mono);
  font-size: 13px;
}

.saved-actions {
  display: flex;
  gap: 6px;
}

.EmptyState {
  padding: 44px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Pagination */
.pagination-bar {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.page-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: #fafafa;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-indicator {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

/* Detail Drawer / Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}

.detail-sheet {
  width: min(540px, 100vw);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
}

.detail-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.meta-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.close-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.close-btn:hover {
  background: #f2f2f4;
  border-color: var(--border-hover);
}

.detail-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-hero-img {
  width: 100%;
  max-height: 230px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

.detail-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

.detail-full-title {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

.detail-sale-price {
  font-size: 19px;
}

.detail-review-meta {
  margin-top: 2px;
}

.detail-cta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.primary-cta {
  background: var(--text);
  color: var(--surface);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: opacity 0.12s ease;
}

.primary-cta:hover {
  opacity: 0.88;
}

.detail-section {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  font-size: 12.5px;
  line-height: 1.55;
}

.detail-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.detail-section ul {
  padding-left: 18px;
}

.variants-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.variant-chip {
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
}

@media (max-width: 720px) {
  .topbar-inner {
    flex-wrap: wrap;
  }
  .search-box {
    order: 3;
    flex-basis: 100%;
  }
  .list-row {
    grid-template-columns: 38px 1fr auto;
  }
  .list-cat-col,
  .list-cond-col,
  .list-fav-col {
    display: none;
  }
}
