:root {
  --red:    #e44;
  --amber:  #f5a623;
  --blue:   #2196f3;
  --purple: #9c27b0;
  --green:  #4caf50;
  --gray:   #666;
  --border: #e0e0e0;
  --bg:     #f9f9f9;
  --card-bg:#fff;
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: #222;
  min-height: 100vh;
}

/* Top bar */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}
.logo { font-size: 22px; font-weight: 800; color: var(--red); text-decoration: none; }
.topbar-nav { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.topbar-nav a, .btn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  color: #222;
}
.btn-primary { background: var(--red); color: #fff; border-color: var(--red); }

/* Status bar */
.status-bar {
  text-align: center;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  display: none;
}
.status-connecting { background: #fff8e1; color: var(--amber); }
.status-fetching   { background: #e3f2fd; color: var(--blue); }
.status-ranking    { background: #f3e5f5; color: var(--purple); }
.status-saving     { background: #e8f5e9; color: var(--green); }
.status-emailing   { background: #e8f5e9; color: var(--green); }
.status-publishing { background: #e8f5e9; color: var(--green); }
.status-complete   { background: #e8f5e9; color: var(--green); }
.status-error      { background: #ffebee; color: var(--red); }

/* Layout */
.layout { display: flex; align-items: flex-start; max-width: 1400px; margin: 0 auto; }
.sidebar-toggle { display: none; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 16px;
  position: sticky;
  top: 53px;
  max-height: calc(100vh - 53px);
  overflow-y: auto;
}
.sidebar-section { margin-bottom: 24px; }
.sidebar-section h3 { font-size: 13px; text-transform: uppercase; color: var(--gray); margin-bottom: 10px; letter-spacing: .03em; }

.date-list { display: flex; flex-direction: column; gap: 2px; }
.date-month-label { font-size: 11px; font-weight: 700; color: var(--gray); margin: 10px 0 4px; text-transform: uppercase; }
.date-month-label:first-child { margin-top: 0; }
.date-link {
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: #222;
  text-decoration: none;
}
.date-link:hover { background: #f5f5f5; }
.date-link.active { background: var(--red); color: #fff; font-weight: 600; }

.chips-col { flex-direction: column; align-items: flex-start; padding: 0; }
.chips-col .chip { width: 100%; text-align: left; }

.main-content { flex: 1; min-width: 0; }

@media (max-width: 900px) {
  .sidebar-toggle { display: inline-block; }
  .layout { flex-direction: column; }
  .sidebar {
    position: static;
    max-height: none;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: none;
  }
  .sidebar.open { display: block; }
}

/* Controls */
.controls {
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.search-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.view-toggle { display: flex; gap: 4px; }
.view-btn {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
  font-size: 16px;
}
.view-btn.active { background: var(--red); color: #fff; border-color: var(--red); }

/* Category chips */
.chips-row {
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: #fff;
  transition: all .15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--red); color: var(--red); }
.chip.active { background: var(--red); color: #fff; border-color: var(--red); }
.chip-hot { border-color: var(--amber); color: var(--amber); }
.chip-hot.active { background: var(--amber); color: #fff; }

/* Price range */
.price-row {
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
input[type=range] { flex: 1; max-width: 200px; }

/* Results meta */
.results-meta {
  padding: 10px 20px;
  font-size: 13px;
  color: var(--gray);
}
.results-meta strong { color: #222; }
.hot-count { color: var(--red); font-weight: 600; }

/* Main content */
main { padding: 0 20px 40px; max-width: 1400px; margin: 0 auto; }

/* Grid */
.deals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

/* Deal card */
.deal-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .2s;
}
.deal-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.deal-card.deal-hot { border-color: var(--amber); }

.card-image {
  position: relative;
  background: #f5f5f5;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-image img { max-width: 100%; max-height: 100%; object-fit: contain; }

.badge {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
}
.badge-hot { top: 8px; left: 8px; background: var(--red); color: #fff; }
.badge-rank { top: 8px; right: 8px; background: rgba(0,0,0,.55); color: #fff; }
.badge-disc { background: #fff3cd; color: #856404; border-radius: 4px; }

.card-body { padding: 12px; }
.card-source { font-size: 11px; color: var(--gray); text-transform: uppercase; margin-bottom: 4px; }
.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-category {
  display: inline-block;
  font-size: 11px;
  color: var(--gray);
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 8px;
}
.card-prices {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.price-sale { font-size: 18px; font-weight: 700; color: var(--red); }
.price-orig { font-size: 13px; color: var(--gray); text-decoration: line-through; }

.score-bar-wrap { margin-bottom: 10px; }
.score-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--gray); margin-bottom: 3px; }
.score-bar { background: #eee; border-radius: 4px; height: 5px; overflow: hidden; }
.score-fill { background: var(--green); height: 100%; transition: width .4s; }

.btn-cta {
  display: block;
  text-align: center;
  background: var(--red);
  color: #fff;
  padding: 9px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.btn-cta:hover { background: #c33; }

/* List row */
.deal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
}
.deal-row img { width: 60px; height: 60px; object-fit: contain; flex-shrink: 0; }
.deal-row-info { flex: 1; min-width: 0; }
.deal-row-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-row-meta { font-size: 12px; color: var(--gray); margin-top: 2px; }
.deal-row-prices { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.page-btn {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
  font-size: 13px;
}
.page-btn.active { background: var(--red); color: #fff; border-color: var(--red); }
.page-btn:disabled { opacity: .5; cursor: default; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray);
}
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }

/* Subscribe footer */
.subscribe-footer {
  background: var(--red);
  color: #fff;
  text-align: center;
  padding: 40px 20px;
  margin-top: 40px;
}
.subscribe-footer h2 { font-size: 22px; margin-bottom: 12px; }
.subscribe-form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.subscribe-form input {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  min-width: 220px;
}
.subscribe-form button {
  padding: 10px 20px;
  background: #222;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

@media (max-width: 600px) {
  .controls { padding: 12px; }
  main { padding: 0 12px 40px; }
  .chips-row { padding: 8px 12px; }
  .deals-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}
