/* AmazonBSRTracker — static web report styles. Self-contained, no external deps. */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #1c1f23;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eef3ff;
  --up: #1a8a3a;
  --down: #d23a2e;
  --new: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 64px; }

/* Header */
.topbar {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.topbar h1 { font-size: 22px; margin: 0; }
.topbar .meta { color: var(--muted); font-size: 13px; }
.crumb { margin-bottom: 12px; font-size: 13px; }
.crumb a::before { content: "‹ "; }

.badge-brand {
  background: var(--accent-soft); color: var(--accent);
  padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
}

/* Category cards (index) */
.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.cat-card {
  display: block; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; box-shadow: var(--shadow);
  color: inherit;
}
.cat-card:hover { border-color: var(--accent); text-decoration: none; }
.cat-card .card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.cat-card .name { font-size: 16px; font-weight: 600; }

/* Marketplace badge + index filter */
.site-badge { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .3px; padding: 1px 7px; border-radius: 6px; background: #11203b; color: #fff; vertical-align: middle; }
.site-filter { display: inline-flex; gap: 2px; background: #eceef1; border-radius: 8px; padding: 3px; margin-bottom: 16px; flex-wrap: wrap; }
.site-chip { border: 0; background: transparent; padding: 5px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--muted); }
.site-chip.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.cat-card .sub { color: var(--muted); font-size: 12px; }
.cat-card .count { font-size: 26px; font-weight: 700; margin-top: 8px; }
.cat-card .count small { font-size: 13px; font-weight: 400; color: var(--muted); }

/* Table */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); overflow: hidden;
}
table { border-collapse: collapse; width: 100%; }
thead th {
  position: sticky; top: 0; background: #fbfbfc; z-index: 1;
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: pointer; user-select: none;
}
thead th.num { text-align: right; }
thead th:hover { color: var(--text); }
thead th .arrow { color: var(--accent); margin-left: 4px; font-size: 10px; }
tbody td { padding: 8px 12px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
tbody tr:hover { background: #f9fafb; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.title-cell { max-width: 420px; }
.title-cell a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-zh { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-title-zh { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.thumb {
  width: 34px; height: 34px; object-fit: contain; border-radius: 4px;
  background: #f0f1f3; display: block;
}
.muted { color: var(--muted); }
.sub2 { font-size: 11px; color: var(--muted); }

/* Status pill */
.pill { font-size: 11px; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.pill.new { background: #e7efff; color: var(--new); }
.pill.rising { background: #e4f6ea; color: var(--up); }
.pill.falling { background: #fde9e7; color: var(--down); }
.pill.stable { background: #eef0f2; color: var(--muted); }
.pill.dropped { background: #f1f1f1; color: #999; }
.delta-up { color: var(--up); }
.delta-down { color: var(--down); }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.footnote { margin-top: 24px; color: var(--muted); font-size: 12px; }

/* Tabs */
.tabs { display: inline-flex; background: #eceef1; border-radius: 8px; padding: 3px; margin-bottom: 16px; gap: 2px; }
.tab { border: 0; background: transparent; padding: 6px 16px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

/* Pulse grid */
.pulse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.pulse-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }
.pulse-t { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pulse-v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Dashboard cards */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; align-items: start; }
.dash-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.dash-card-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dash-title { font-weight: 600; font-size: 14px; }
.dash-card-b { padding: 14px 16px; }
.cap { font-size: 11px; color: var(--muted); margin: 8px 0 6px; }
.dash-card-b > .cap:first-child { margin-top: 0; }

/* Mini stats row */
.stat-row { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 6px; }
.mini-stat .mini-l { font-size: 11px; color: var(--muted); }
.mini-stat .mini-v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-label { width: 130px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.bar-label.hl { font-weight: 700; color: var(--accent); }
.bar-track { flex: 1; height: 8px; background: #eceef1; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: rgba(37,99,235,.55); border-radius: 999px; }
.bar-fill.green { background: rgba(26,138,58,.55); }
.bar-fill.hl { background: var(--accent); }
.bar-val { width: 90px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }

/* Mini product rows */
.mini-rows { display: flex; flex-direction: column; }
.mini-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; border-top: 1px solid #f2f3f5; }
.mini-row:first-child { border-top: 0; }
.mini-rank { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; width: 38px; }
.mini-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-rv { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }

/* Product page */
.hero { display: flex; gap: 20px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.hero-img { width: 150px; height: 150px; object-fit: contain; border-radius: 8px; background: #f0f1f3; flex: none; }
.hero-meta { flex: 1; min-width: 0; }
.hero-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.hero-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.hero-sub .pill { vertical-align: middle; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.info-cell .info-l { font-size: 11px; color: var(--muted); }
.info-cell .info-v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.desc { font-size: 13px; color: #333; white-space: pre-wrap; margin: 10px 0 0; }
.chip-block { margin-top: 10px; }
.chip-h { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: #eef0f2; }
.chip.good { background: #e4f6ea; color: var(--up); }
.chip.bad { background: #fde9e7; color: var(--down); }
.chip.badge { background: var(--accent-soft); color: var(--accent); }
.blist { margin-top: 10px; }
.blist ul { margin: 4px 0 0; padding-left: 18px; }
.blist li { font-size: 13px; margin: 2px 0; }
.dash-card-b table { width: 100%; }
.dash-card-b thead th { position: static; }

/* Charts */
.range-bar { display: inline-flex; gap: 2px; background: #eceef1; border-radius: 7px; padding: 3px; margin-bottom: 12px; }
.range-btn { border: 0; background: transparent; padding: 4px 12px; border-radius: 5px; font-size: 12px; cursor: pointer; color: var(--muted); }
.range-btn.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.chart-box { }
.chart-t { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chart-wrap { width: 100%; }
.chart { width: 100%; height: 170px; display: block; }
.chart-line { fill: none; stroke-width: 1.8; }
.chart-area { opacity: .10; stroke: none; }
.chart-bar { opacity: .85; }
.chart-grid-line, .chart-grid { stroke: #e9ebee; stroke-width: 1; }
.chart-axis { fill: #9aa0a6; font-size: 9px; }
.chart-empty { fill: #b0b4b9; font-size: 12px; }

/* Dark-horse table */
.dh-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; border-top: 1px solid #f2f3f5; }
.dh-row.dh-head { border-top: 0; color: var(--muted); font-size: 11px; }
.dh-brand { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dh-brand.hl { font-weight: 700; color: var(--accent); }
.dh-num { width: 64px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }

/* Brand comparison table (index page) */
.bc-wrap { overflow-x: auto; }
.bc-table { border-collapse: collapse; width: 100%; }
.bc-table th, .bc-table td { padding: 7px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.bc-table thead th { text-align: right; vertical-align: bottom; }
.bc-table thead th:first-child { text-align: left; }
.bc-table .bc-brand { font-weight: 700; color: var(--text); }
.bc-table .bc-site { font-size: 11px; color: var(--muted); font-weight: 400; }
.bc-table .bc-metric { text-align: left; color: var(--muted); font-size: 13px; }
.bc-table td.bc-best { font-weight: 700; color: var(--accent); }
.bc-table tbody tr:hover { background: #f9fafb; }
