:root {
  --bg: #0d0d11;
  --surface: #16161d;
  --surface-2: #1e1e27;
  --border: #2a2a38;
  --text: #e8e8f0;
  --text-muted: #6b6b82;
  --text-faint: #3d3d52;
  --accent: #6366f1;
  --accent-glow: rgba(99,102,241,0.15);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.1);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.1);
  --orange: #f97316;
  --crowding-bg: rgba(239,68,68,0.12);
  --crowding-text: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
}

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

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

.layout {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

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

.brand-tagline {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }

.daily-task-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 12px 4px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(99,102,241,0.08));
  border: 1px solid rgba(99,102,241,0.35);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: #a5b4fc;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.daily-task-btn:hover { background: linear-gradient(135deg, rgba(99,102,241,0.35), rgba(99,102,241,0.15)); border-color: rgba(99,102,241,0.6); }

.scrape-btn {
  margin: 0 12px 8px;
  padding: 9px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.scrape-btn:hover { opacity: 0.85; }
.scrape-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Main ────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.page-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  text-transform: uppercase;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text);
}

.stats-bar {
  margin-top: 10px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.stat-pill .ok { color: var(--green); font-weight: 700; }

.section-label-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.section-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.count-badge {
  margin-left: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.product-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
  align-content: start;
}

/* ── Product Card ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}

.card:hover { border-color: #3a3a4e; }

.card-img-wrap {
  position: relative;
  width: 100%;
  min-height: 160px;
  background: var(--surface-2);
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-shrink: 0;
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-img-wrap .no-img {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  font-size: 40px;
  color: var(--text-faint);
}

.badge-source-check {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.72);
  color: #a5b4fc;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 9px;
  border-radius: 4px;
  border: 1px solid rgba(165,180,252,0.25);
}

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

.crowding-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 3px;
  width: fit-content;
}

.crowding-badge.high {
  background: var(--crowding-bg);
  color: var(--crowding-text);
}

.crowding-badge.low {
  background: var(--green-bg);
  color: var(--green);
}

.crowding-badge::before {
  content: '●';
  font-size: 6px;
}

.card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.metric-sublabel {
  font-size: 8.5px;
  color: var(--text-faint);
  margin-top: -1px;
}

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

.sat-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.sat-label { font-size: 9px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-muted); }
.sat-sublabel { font-size: 8.5px; color: var(--text-faint); }
.sat-value { font-size: 16px; font-weight: 700; color: var(--text); }

.sat-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ext-id {
  font-size: 10px;
  font-family: monospace;
  color: var(--text-faint);
}

.seen-at {
  font-size: 10px;
  color: var(--text-faint);
}

.source-link {
  font-size: 10px;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.source-link:hover { text-decoration: underline; }

.card-actions {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  gap: 8px;
}

.btn-approve, .btn-reject {
  flex: 1;
  padding: 7px 0;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-approve { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.25); }
.btn-reject  { background: var(--red-bg);   color: var(--red);   border: 1px solid rgba(239,68,68,0.25); }
.btn-approve:hover { opacity: 0.8; }
.btn-reject:hover  { opacity: 0.8; }

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

.loading {
  grid-column: 1/-1;
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Scraping overlay */
.scraping-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text);
  display: none;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 100;
}
.scraping-toast.show { display: flex; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Hermes-specific ─────────────────────────────────────────────────────── */

.card-hermes { border-color: rgba(99,102,241,0.3); }
.card-hermes:hover { border-color: rgba(99,102,241,0.6); }

/* Score badge — top-left corner of image */
.score-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}
.score-strong { background: rgba(34,197,94,0.85);  color: #fff; }
.score-mid    { background: rgba(234,179,8,0.85);   color: #1a1a00; }
.score-weak   { background: rgba(239,68,68,0.75);   color: #fff; }

/* Hermes pill — top-right, below source-check if present */
.hermes-pill {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(99,102,241,0.85);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

/* Decision label */
.decision-label {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  width: fit-content;
  letter-spacing: 0.3px;
}
.decision-approve { background: var(--green-bg); color: var(--green); }
.decision-test    { background: rgba(234,179,8,0.12); color: #fbbf24; }
.decision-queue   { background: rgba(99,102,241,0.12); color: #818cf8; }
.decision-reject  { background: var(--red-bg); color: var(--red); }

/* Category tag */
.card-category {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: -4px;
}

/* Problem solved */
.problem-solved {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  line-height: 1.4;
}

/* SEK price emphasis */
.metric-value.sek { color: #a5b4fc; }
.profit-strong { color: var(--green) !important; }
.profit-ok     { color: #fbbf24 !important; }
.profit-weak   { color: var(--red) !important; }

/* Seasonality row */
.season-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.season-icon { font-size: 13px; }
.season-text { color: var(--text-muted); font-weight: 600; }
.launch-window {
  color: var(--text-faint);
  font-size: 10px;
  margin-left: 2px;
}

/* Amazon risk */
.amazon-risk {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 3px;
  width: fit-content;
  letter-spacing: 0.5px;
}
.risk-low    { background: var(--green-bg); color: var(--green); }
.risk-medium { background: rgba(234,179,8,0.1); color: #fbbf24; }
.risk-high   { background: var(--red-bg); color: var(--red); }

/* Ad angle */
.ad-angle {
  font-size: 12px;
  color: #a5b4fc;
  font-style: italic;
  line-height: 1.4;
}

/* Hooks */
.hooks-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hook-item {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 8px;
  background: rgba(255,255,255,0.02);
  border-left: 2px solid var(--accent);
  border-radius: 0 3px 3px 0;
  line-height: 1.4;
}

/* Decision reason */
.decision-reason {
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
  line-height: 1.4;
}

/* Stats — Hermes highlight */
.hermes-stat { color: #818cf8; font-weight: 600; }

/* ── Hamburger button ───────────────────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}

.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

.sidebar-backdrop.show { display: block; }

/* ── Mobile responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
  }

  .sidebar.open { transform: translateX(0); }

  .main {
    width: 100%;
    min-width: 0;
  }

  .page-header {
    padding: 62px 16px 14px;
  }

  h1 { font-size: 18px; }

  .stat-pill {
    font-size: 11px;
    padding: 4px 10px;
    line-height: 1.5;
    display: inline;
  }

  .section-label-bar {
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .section-hint {
    display: none;
  }

  .product-grid {
    padding: 12px;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Settings panel mobile fixes */
  #settingsPanel {
    padding: 0 16px 20px;
    max-width: 100% !important;
  }

  #settingsPanel > div {
    overflow: hidden;
  }

  #settingsPanel div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .scraping-toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    font-size: 12px;
  }

  .card-footer {
    flex-wrap: wrap;
  }

  .empty-state {
    padding: 40px 16px;
  }

  .empty-state h3 { font-size: 16px; }
  .empty-state p { font-size: 13px; }
}

@media (max-width: 420px) {
  .page-header { padding: 58px 12px 12px; }
  .section-label-bar { padding: 8px 12px; }
  .product-grid { padding: 10px; gap: 10px; }
  h1 { font-size: 16px; }
  .section-label { font-size: 9px; }
  .stat-pill { font-size: 10px; padding: 3px 8px; }
  .metrics-grid { gap: 6px; }
  .metric-value { font-size: 14px; }
  .card-body { padding: 12px; gap: 8px; }
}

