:root {
  --bg:        #080d16;
  --sidebar:   #0b1120;
  --surface:   #111827;
  --surface2:  #1a2235;
  --border:    rgba(255,255,255,0.07);
  --accent:    #00c9a7;
  --accent2:   #06b6d4;
  --danger:    #ef4444;
  --text:      #f0f4f8;
  --muted:     #64748b;
  --muted2:    #94a3b8;
  --radius:    10px;
  --radius-lg: 14px;
  --sidebar-w: 250px;
}

/* ── Light mode ───────────────────────────────────────── */
body.light {
  --bg:        #f0f4f8;
  --sidebar:   #ffffff;
  --surface:   #ffffff;
  --surface2:  #f1f5f9;
  --border:    rgba(0,0,0,0.09);
  --accent:    #00a888;
  --accent2:   #0891b2;
  --danger:    #ef4444;
  --text:      #0f172a;
  --muted:     #94a3b8;
  --muted2:    #475569;
}

body.light .hero {
  background: linear-gradient(135deg, #e0f2fe 0%, #bfdbfe 50%, #dbeafe 100%);
}
body.light .hero::before {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0,168,136,0.1) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(8,145,178,0.08) 0%, transparent 50%);
}
body.light .hero h1 { color: #0f172a; }
body.light .hero p  { color: #475569; }

body.light .logo-icon { color: #fff; }
body.light .btn-primary { color: #fff; }
body.light .view-btn.active { color: #fff; }
body.light .page-btn.active { color: #fff; }
body.light .card-buy { color: #fff; }
body.light .vendor-card-avatar { color: #fff; }
body.light .cat-tile:hover { background: rgba(0,168,136,0.08); }
body.light .nav-item.active { background: rgba(0,168,136,0.1); }
body.light .products-page-full { background: #ffffff; }
body.light .compare-page-full  { background: #ffffff; }
body.light .product-card { border-color: #cbd5e1; }
body.light .product-card:hover { border-color: var(--accent); }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  min-height: 100vh;
  overflow: hidden;
}

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

/* ── App shell ────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s, min-width 0.2s;
  overflow: hidden;
  z-index: 10;
}

.sidebar.collapsed {
  width: 56px;
  min-width: 56px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
  color: #000;
}

.logo-text {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 6px 8px 4px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}

.nav-item svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(0,201,167,0.12); color: var(--accent); }

.sidebar-categories { padding: 0 8px; }

.sidebar-cat-select {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.sidebar-cat-select:hover,
.sidebar-cat-select:focus { border-color: var(--accent); }
.collapsed .sidebar-cat-select { display: none; }

.cat-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted2);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}
.cat-nav-item:hover { background: var(--surface2); color: var(--text); }
.cat-nav-item.active { color: var(--accent); }
.cat-nav-item .cat-count { font-size: 10px; color: var(--muted); }

.nav-skeleton {
  height: 28px;
  background: var(--surface2);
  border-radius: 6px;
  margin-bottom: 4px;
  animation: pulse 1.5s ease-in-out infinite;
}

/* ── Settings trigger button ──────────────────────────── */
.settings-trigger-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s;
  white-space: nowrap;
}
.settings-trigger-btn:hover { color: var(--text); }
.settings-trigger-btn svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }
.sidebar.collapsed .settings-trigger-btn .collapse-text { display: none; }

/* ── Settings popover ─────────────────────────────────── */
.settings-popover {
  display: none;
  position: absolute;
  bottom: 96px;
  left: 12px;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  z-index: 200;
}
.settings-popover.open { display: block; }
.sidebar.collapsed .settings-popover { left: 70px; bottom: 80px; }

.settings-popover-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.setting-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}

.theme-pills {
  display: flex;
  gap: 4px;
}
.theme-pill {
  flex: 1;
  padding: 5px 0;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  cursor: pointer;
}
.setting-label {
  font-size: 11px;
  color: var(--muted2);
}

.setting-data-btns {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.setting-btn {
  flex: 1;
  padding: 5px 0;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted2);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.setting-btn:hover         { border-color: var(--accent); color: var(--accent); }
.setting-btn-danger:hover  { border-color: #ef4444;       color: #ef4444; }

.collapse-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px;
  border-top: 1px solid var(--border);
  background: none;
  border-left: none; border-right: none; border-bottom: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s;
  white-space: nowrap;
}
.collapse-btn:hover { color: var(--text); }
.collapse-btn svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; transition: transform 0.2s; }
.sidebar.collapsed .collapse-btn svg { transform: rotate(180deg); }
.sidebar.collapsed .collapse-text { display: none; }

/* ── Main wrap ────────────────────────────────────────── */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-wrap {
  flex: 1;
  max-width: 500px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
}

.search-icon { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
}
.search-input::placeholder { color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.back-dashboard-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.back-dashboard-btn:hover { border-color: var(--accent); color: var(--accent); }

#topbar-filter-slot {
  display: flex;
  align-items: center;
}
#topbar-filter-slot .cat-filter-panel {
  top: calc(100% + 8px);
  z-index: 200;
}

.icon-btn {
  width: 34px;
  height: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted2);
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* ── Page content ─────────────────────────────────────── */
#page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Dashboard ────────────────────────────────────────── */
.dashboard { padding-bottom: 40px; }

.hero {
  position: relative;
  background: linear-gradient(135deg, #0a1628 0%, #0d2040 50%, #071a30 100%);
  padding: 48px 36px 52px;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0,201,167,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(6,182,212,0.06) 0%, transparent 50%);
}

.hero-content { position: relative; z-index: 1; }

.hero h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.hero p {
  font-size: 15px;
  color: var(--muted2);
  margin-bottom: 24px;
  max-width: 480px;
  line-height: 1.5;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 13px;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }

/* Metric cards */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  padding: 24px 28px 0;
}

/* ── Category shortcut cards ──────────────────────────── */
.category-shortcuts {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  padding: 20px 28px 0;
}

.cat-shortcut-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  user-select: none;
}
.cat-shortcut-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,201,167,0.15);
}
.cat-shortcut-card:active { transform: translateY(0); }

.cat-shortcut-icon {
  font-size: 28px;
  line-height: 1;
}

.cat-shortcut-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.02em;
}

body.light .cat-shortcut-card { background: #ffffff; }

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s;
}
.metric-card:hover { border-color: rgba(0,201,167,0.3); }

.metric-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 4px;
}

.metric-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.metric-sub {
  font-size: 11px;
  color: var(--muted2);
}

/* Dashboard body: deals + right panel */
.dashboard-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  padding: 28px 28px 0;
  align-items: start;
}

/* Today's Best Deals */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.section-title .trend-icon { color: var(--accent); font-size: 16px; }

.view-all-link {
  font-size: 12px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.view-all-link:hover { text-decoration: underline; }

.deals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.deal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 0;
  display: block;
  transition: border-color 0.15s, transform 0.1s;
  cursor: pointer;
}
.deal-card:hover { border-color: rgba(0,201,167,0.35); transform: translateY(-1px); }

.deal-card-img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface2);
  flex-shrink: 0;
}
.deal-card-img-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--surface2);
  flex-shrink: 0;
}
.deal-card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.deal-card-title-row > div { min-width: 0; }
.deal-card-body {
  padding: 14px;
}

.deal-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.deal-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.deal-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.save-badge {
  flex-shrink: 0;
  background: rgba(0,201,167,0.15);
  color: var(--accent);
  border: 1px solid rgba(0,201,167,0.3);
  border-radius: 20px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

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

.deal-price-left { display: flex; flex-direction: column; gap: 2px; }

.deal-best-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
}
.deal-best-price .arrow { font-size: 12px; }

.deal-now-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.deal-worst-price {
  font-size: 11px;
  color: var(--muted);
  text-decoration: line-through;
}

.deal-vendor {
  font-size: 11px;
  color: var(--muted2);
}

/* Sparkline SVG */
.sparkline-wrap { flex-shrink: 0; }
.sparkline { display: block; }

/* ── Right panel ──────────────────────────────────────── */
.right-panel { display: flex; flex-direction: column; gap: 20px; }

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

/* Category dropdown */
.cat-dropdown {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.cat-dropdown:hover, .cat-dropdown:focus { border-color: var(--accent); }

/* Category tiles (legacy) */
.cat-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cat-tile {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.cat-tile:hover { border-color: rgba(0,201,167,0.35); background: rgba(0,201,167,0.05); }

.cat-tile-name { font-size: 12px; font-weight: 600; color: var(--text); }
.cat-tile-count { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* Vendor status list */
.vendor-status-list { display: flex; flex-direction: column; gap: 10px; }

.vendor-status-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius);
  padding: 4px 6px;
  margin: 0 -6px;
  transition: background 0.15s;
}
.vendor-status-item:hover { background: var(--surface2); }
}

.vendor-avatar {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: #000;
  flex-shrink: 0;
}

.vendor-status-info { flex: 1; min-width: 0; }
.vendor-status-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vendor-status-meta { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.vendor-status-stars { font-size: 11px; line-height: 1; }
.vendor-status-time { font-size: 10px; color: var(--muted); }

.vendor-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── Products page ────────────────────────────────────── */
.products-page-full {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 16px 20px;
}

.compare-page-full {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 16px 20px;
}

/* ── Filter bar ───────────────────────────────────────── */
.products-filterbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.filterbar-left  { display: flex; align-items: center; gap: 10px; }
.filterbar-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.filter-dropdown {
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.filter-dropdown:hover, .filter-dropdown:focus { border-color: var(--accent); }

.filterbar-stock {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted2);
  cursor: pointer;
  white-space: nowrap;
}
.filterbar-stock input { accent-color: var(--accent); }

/* Category custom dropdown */
.cat-filter-wrap { position: relative; }
.cat-filter-btn  { white-space: nowrap; min-width: 140px; text-align: left; }

.cat-filter-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 240px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 100;
  padding: 6px 0;
}
.cat-filter-panel.open { display: block; }

.cat-filter-row {
  display: flex;
  align-items: center;
}
.cat-filter-option {
  flex: 1;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s;
}
.cat-filter-option:hover  { background: var(--surface2); }
.cat-filter-option.active { color: var(--accent); }

.cat-filter-brand {
  padding: 5px 14px 5px 28px;
  font-size: 11px;
  color: var(--muted2);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  transition: background 0.1s;
}
.cat-filter-brand:hover  { background: var(--surface2); }
.cat-filter-brand.active { color: var(--accent); font-weight: 700; }

.products-main { flex: 1; overflow-y: auto; padding: 16px 20px; }

.filter-section { margin-bottom: 20px; }

.filter-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.1s;
}
.filter-item:hover { background: var(--surface2); }
.filter-item input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; flex-shrink: 0; }
.filter-item label { cursor: pointer; flex: 1; font-size: 12px; }
.filter-item .f-count { color: var(--muted); font-size: 11px; }

/* Filter panel — expandable brand groups */
.filter-cat-row { display: flex; align-items: center; }
.pf-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.pf-toggle:hover { color: var(--accent); }

.filter-brand-group {
  display: none;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  margin-left: 10px;
  margin-bottom: 2px;
}
.filter-brand-group.open { display: block; }

.filter-brand-item label { font-size: 11px; color: var(--muted2); }

/* Sidebar — expandable brand groups */
.sc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.sc-cat-label {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  padding: 5px 4px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.sc-cat-label:hover { background: var(--surface2); color: var(--accent); }
.sc-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.sc-toggle:hover { color: var(--accent); }
.sc-brand-count { font-size: 10px; color: var(--muted); font-weight: 400; }

.sc-brand-list {
  display: none;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  margin-left: 10px;
  margin-bottom: 2px;
}
.sc-brand-list.open { display: block; }

.sc-brand-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted2);
  padding: 3px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.sc-brand-item:hover { background: var(--surface2); color: var(--accent); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.toggle-row label { color: var(--text); font-size: 13px; }

.toggle { position: relative; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* Products toolbar */
.products-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.toolbar-left { display: flex; align-items: center; gap: 12px; }
.result-count { font-size: 13px; color: var(--muted); }

.clear-filters-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.clear-filters-btn:hover { background: var(--accent); color: #000; }

.sidebar-clear-btn {
  width: 100%;
  margin-top: 8px;
  padding: 5px 0;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-clear-btn:hover { background: var(--accent); color: #000; }

.view-toggle { display: flex; gap: 4px; }
.view-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted2);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}
.view-btn:hover { border-color: var(--accent); color: var(--text); }
.view-btn.active { background: var(--accent); border-color: var(--accent); color: #000; }

.sort-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

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

/* ── Favorites ───────────────────────────────────────── */
.fav-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  z-index: 2;
}
.fav-btn:hover      { color: #ef4444; border-color: #ef4444; }
.fav-btn.fav-active { color: #ef4444; border-color: #ef4444; background: #fef2f2; }
body.light .fav-btn { background: #fff; }

.favorites-page { padding: 28px; }
.fav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.fav-card { position: relative; }
.fav-card .fav-btn { position: static; margin-left: auto; }
.fav-card .deal-card-top { align-items: flex-start; }

.fav-vendor-list { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.fav-vendor-row {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted2);
  padding: 3px 6px; border-radius: 4px;
}
.fav-vendor-row.fav-best {
  background: rgba(0,201,167,0.1);
  color: var(--accent);
  font-weight: 700;
}

.product-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.1s;
}
.product-card:hover { border-color: rgba(0,201,167,0.35); transform: translateY(-2px); }

.product-card .img-wrap {
  background: var(--surface2);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.product-card .img-wrap img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 8px;
}
.product-card .img-wrap .no-img { color: var(--muted); font-size: 11px; }

.card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-brand { font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.card-name  { font-size: 12px; font-weight: 600; line-height: 1.3; }
.card-cat   { font-size: 11px; color: var(--muted); }

.card-footer {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.card-price-wrap { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.card-price { font-size: 17px; font-weight: 700; }
.card-price.best { color: var(--accent); }
.card-price-range { font-size: 13px; font-weight: 500; color: var(--muted2); }
.card-moq  { font-size: 10px; color: var(--muted); }
.card-avail { font-size: 10px; }

.card-vendor-count {
  font-size: 10px;
  color: var(--muted);
  padding: 3px 8px 5px;
  display: block;
}
.card-avail.in  { color: var(--accent); }
.card-avail.out { color: var(--danger); }

.card-vendor {
  font-size: 10px;
  color: var(--muted);
  padding: 4px 12px 8px;
}

.card-buy {
  display: block;
  text-align: center;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  padding: 7px 0;
  font-size: 11px;
  transition: opacity 0.15s;
}
.card-buy:hover { opacity: 0.85; }

.vd-cart-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.vd-cart-btn:hover { opacity: 0.85; }

/* ── Compare table ────────────────────────────────────── */
.compare-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.compare-table th {
  background: var(--surface2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.compare-table th.supplier-col { text-align: right; min-width: 130px; }
.compare-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:hover td { background: var(--surface2); }

.cmp-product { display: flex; align-items: center; gap: 10px; min-width: 200px; max-width: 280px; flex-wrap: wrap; }
.cmp-fav-btn { position: static; width: 24px; height: 24px; font-size: 12px; margin-left: auto; flex-shrink: 0; }
.cmp-thumb { width: 36px; height: 36px; object-fit: contain; background: var(--surface2); border-radius: 4px; flex-shrink: 0; }
.cmp-thumb-placeholder { width: 36px; height: 36px; background: var(--surface2); border-radius: 4px; flex-shrink: 0; }
.cmp-name { font-weight: 600; line-height: 1.3; font-size: 12px; white-space: normal; }
.cmp-meta { font-size: 10px; color: var(--muted); margin-top: 2px; }

.cmp-price-cell { text-align: right; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cmp-price-cell.best-price { color: var(--accent); }
.cmp-price-cell.best-price .price-val::after { content: ' ★'; font-size: 10px; }
.cmp-price-cell a { color: inherit; text-decoration: none; }
.cmp-price-cell a:hover { text-decoration: underline; }
.cmp-price-cell .unavail { color: var(--muted); font-size: 11px; font-weight: 400; }
.cmp-na { color: var(--border); font-size: 12px; text-align: right; }
.cmp-spread { text-align: right; font-size: 11px; color: var(--accent); white-space: nowrap; }

/* ── Vendors page ─────────────────────────────────────── */
.vendors-page { padding: 28px; }
.vendor-card { cursor: pointer; }

/* ── Compare cart button ──────────────────────────────── */
.cmp-price-cell { position: relative; }
.cmp-cart-btn {
  display: none;
  position: absolute;
  bottom: 4px; right: 4px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 4px;
  width: 20px; height: 20px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}
.cmp-price-cell:hover .cmp-cart-btn { display: flex; }

/* ── Cart badge ───────────────────────────────────────── */
.cart-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
  line-height: 14px;
}

/* ── Order List page ──────────────────────────────────── */
.order-list-page { padding: 28px; }

.ol-table-wrap { overflow-x: auto; margin-bottom: 16px; }
.ol-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ol-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
}
.ol-table tbody tr { border-bottom: 1px solid var(--border); }
.ol-table tbody td { padding: 12px; vertical-align: middle; }
.cart-row:last-child { border-bottom: none; }

.ol-product { display: flex; align-items: center; gap: 10px; }
.ol-thumb   { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--surface2); }
.ol-name    { font-size: 13px; font-weight: 600; }
.ol-meta    { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ol-vendor  { color: var(--muted2); font-size: 12px; }
.ol-price   { font-weight: 700; white-space: nowrap; }
.ol-subtotal { font-weight: 700; color: var(--accent); white-space: nowrap; }

.ol-qty-input {
  width: 56px;
  padding: 5px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  text-align: center;
}
.ol-qty-input:focus { outline: none; border-color: var(--accent); }

.ol-remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.ol-remove-btn:hover { color: #ef4444; background: rgba(239,68,68,0.08); }

.ol-totals { display: flex; justify-content: flex-end; }
.ol-total-row {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  font-size: 14px;
  color: var(--muted2);
}
.ol-total-amt {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

/* ── Vendor Apply page ────────────────────────────────── */
.vendor-apply-page {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 24px;
  min-height: 100%;
}

.vendor-apply-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  width: 100%;
  max-width: 640px;
}

.vendor-apply-header { margin-bottom: 28px; }

.vendor-apply-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.vendor-apply-sub {
  font-size: 13px;
  color: var(--muted);
}

.vendor-apply-form { display: flex; flex-direction: column; gap: 20px; }

.vaf-row { display: flex; flex-direction: column; gap: 20px; }
.vaf-row-2 { flex-direction: row; gap: 16px; }
.vaf-row-2 .vaf-field { flex: 1; min-width: 0; }

.vaf-field { display: flex; flex-direction: column; gap: 6px; }

.vaf-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.vaf-req { color: #e53e3e; }

.vaf-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}
.vaf-input:focus { border-color: var(--accent); }
.vaf-input::placeholder { color: var(--muted); }

.vaf-submit {
  align-self: flex-start;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 24px;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 4px;
}
.vaf-submit:hover { opacity: 0.85; }

.vaf-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 0;
  gap: 12px;
}

.vaf-success-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 26px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vaf-success-title {
  font-size: 20px;
  font-weight: 800;
}

.vaf-success-msg {
  font-size: 13px;
  color: var(--muted);
  max-width: 420px;
  line-height: 1.6;
}

.become-vendor-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.become-vendor-btn:hover { opacity: 0.85; }

body.light .vendor-apply-card { background: #ffffff; }

/* ── Clearance page ──────────────────────────────────── */
.clearance-page {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.clearance-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.clearance-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.clearance-sub {
  font-size: 13px;
  color: var(--muted);
  flex: 1;
}

.flash-refresh-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.flash-refresh-btn:hover { border-color: var(--accent); color: var(--accent); }

.clearance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.clearance-card { position: relative; cursor: default; }

.flash-discount-ribbon {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #e53e3e;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  z-index: 2;
}

.flash-orig-price {
  font-size: 11px;
  color: var(--muted);
  text-decoration: line-through;
}

.flash-cart-btn {
  cursor: pointer;
  border: none;
  width: 100%;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 9px 0;
  font-size: 12px;
}

body.light .clearance-page { background: #ffffff; }

/* ── Heatmap page ─────────────────────────────────────── */
.heatmap-page { padding: 28px; }

.hm-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.hm-legend-swatch {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.hm-scroll-wrap { overflow-x: auto; }

.hm-table {
  border-collapse: separate;
  border-spacing: 3px;
  min-width: 600px;
}

.hm-cat-header {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 10px 10px 0;
  white-space: nowrap;
}

.hm-vendor-header {
  text-align: center;
  padding: 0 6px 10px;
  min-width: 100px;
  white-space: nowrap;
}
.hm-vendor-header span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted2);
}

.hm-cat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  padding-right: 14px;
}

.hm-cell {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  padding: 8px 4px;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.hm-cell:hover { opacity: 0.82; }
.hm-empty {
  background: var(--surface2) !important;
  color: var(--muted) !important;
  font-weight: 400;
  cursor: default;
}

/* ── Vendor detail page ───────────────────────────────── */
.vendor-detail-page { padding: 28px; }

.vendor-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.vendor-detail-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.vendor-detail-title h2 { margin: 0; font-size: 20px; }
.vendor-detail-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.vendor-detail-stars .star { font-size: 18px; }
.vd-price-label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }

.back-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s;
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); }
.vendors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.vendor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.15s;
}
.vendor-card:hover { border-color: rgba(0,201,167,0.3); }

.vendor-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.vendor-card-avatar {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #000;
}
.vendor-card-name { font-size: 14px; font-weight: 700; }
.vendor-card-time { font-size: 11px; color: var(--muted); }

.vendor-stars { margin: -4px 0 12px; }
.star { font-size: 16px; color: var(--muted2); }
.star-filled { color: #f59e0b; }

.vendor-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vendor-stat { background: var(--surface2); border-radius: var(--radius); padding: 10px; }
.vendor-stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.vendor-stat-value { font-size: 16px; font-weight: 700; margin-top: 2px; }

/* ── Pagination ───────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
  padding-bottom: 24px;
}

.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.15s;
}
.page-btn:hover { border-color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 700; }
.page-btn:disabled { opacity: 0.35; cursor: default; }

/* ── State messages ───────────────────────────────────── */
.state-msg {
  text-align: center;
  color: var(--muted);
  padding: 80px 20px;
  font-size: 15px;
}

/* ── Toast ────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }

/* ── Animations ───────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

/* ── Page header ──────────────────────────────────────── */
.page-header {
  padding: 24px 28px 0;
  margin-bottom: 4px;
}
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header p  { font-size: 13px; color: var(--muted2); margin-top: 4px; }
