:root {
  --accent: #fe2c55;
  --accent2: #f5a623;
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: #eceef2;
  --text: #1f2329;
  --muted: #8a919c;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif; color: var(--text); background: var(--bg); }

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

/* 左侧 */
.sidebar {
  width: 240px; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.group-tree { flex: 1; overflow-y: auto; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.logo { padding: 18px 20px; font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.logo .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.nav-item { padding: 12px 20px; cursor: pointer; color: var(--muted); font-weight: 500; }
.nav-item:hover, .nav-item.active { color: var(--accent); background: #fff0f3; }
.group-tree { margin-top: 8px; flex: 1; }
.group-node {
  border-left: 2px solid transparent;
}
.group-title { display: flex; align-items: center; gap: 6px; padding: 10px 20px; cursor: pointer; font-weight: 600; }
.group-title:hover { background: #fafbfc; }
.group-title .caret { transition: transform .15s; font-size: 11px; color: var(--muted); }
.group-title.open .caret { transform: rotate(90deg); }
.group-actions { margin-left: auto; display: flex; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.g-act { padding: 2px 4px; border-radius: 4px; }
.g-act:hover { background: #f0f1f4; color: var(--accent); }
.shop-item { padding: 8px 20px 8px 44px; cursor: pointer; color: var(--text); font-size: 14px; }
.shop-item:hover { background: #fafbfc; }
.shop-item.active { color: var(--accent); background: #fff0f3; }
.shop-item .seller { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* 主区 */
.main { flex: 1; overflow-y: auto; padding: 24px 28px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 20px; }
.rank-group-select { padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text); cursor: pointer; }
.btn { border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px; background: var(--accent); color: #fff; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.stop { background: #fff; color: #dc2626; border: 1px solid #dc2626; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; border: 1px solid var(--border); }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }


.shop-header { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.shop-title-row { display: flex; align-items: center; gap: 14px; }
.shop-avatar { width: 52px; height: 52px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; }
.shop-title-row h2 { margin: 0; font-size: 22px; }
.shop-title-row .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.shop-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 18px; }
.stat-box { background: #fafbfc; border-radius: 10px; padding: 14px; text-align: center; }
.stat-box .v { font-size: 20px; font-weight: 700; }
.stat-box .k { font-size: 12px; color: var(--muted); margin-top: 4px; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 18px; padding: 16px; }
.panel h3 { margin: 4px 0 12px; font-size: 16px; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab { padding: 7px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; background: #f0f1f4; color: var(--muted); }
.tab.active { background: var(--accent); color: #fff; }

#trendChart { width: 100%; height: 300px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent); }
th.sorted { color: var(--accent); }
th.sorted.asc::after { content: " ▲"; font-size: 10px; }
th.sorted.desc::after { content: " ▼"; font-size: 10px; }
td.num { text-align: right; }
th.num { text-align: right; }
tr.row-link { cursor: pointer; }
tr.row-link:hover { background: #fafbfc; }
.rank { display: inline-block; min-width: 22px; text-align: center; }
.rank.top { color: var(--accent); font-weight: 700; }
.p-title { color: var(--text); }
.p-link { color: var(--accent); font-size: 12px; margin-left: 6px; }
.curve-link { color: var(--accent); font-size: 12px; margin-left: 6px; cursor: pointer; border-bottom: 1px dashed var(--accent); }
.shop-chip { display: inline-block; padding: 2px 10px; border-radius: 20px; background: #fff0f3; color: var(--accent); font-size: 13px; cursor: pointer; }
.shop-chip:hover { background: #ffe0e6; }
.badge-fail { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: #dc2626; color: #fff; font-size: 11px; font-weight: 600; }
.collect-fail { color: #dc2626; font-size: 12px; font-weight: 600; }
.thumb-wrap { display: inline-block; }
.thumb { display: block; width: 46px; height: 46px; object-fit: cover; border-radius: 6px; background: #f0f1f4; cursor: zoom-in; transition: transform .15s ease; }
.thumb.thumb-none { display: flex; align-items: center; justify-content: center; font-size: 11px; color: #8a919c; }
.thumb-wrap:hover .thumb:not(.thumb-none) { transform: scale(3.6); box-shadow: 0 8px 22px rgba(0,0,0,.3); position: relative; z-index: 60; }
.collect-banner { margin-bottom: 16px; padding: 11px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.collect-banner.running { background: #eef3ff; color: #2563eb; }
.collect-banner.done { background: #e8f7ef; color: #16a34a; }
.collect-banner.done-warn { background: #fdecec; color: #dc2626; }
.collect-banner.hidden { display: none; }
.curve-popover { position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 10px; width: 340px; }
.curve-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 12px; }
#curveTitle { flex: 1; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#curveOpen { color: var(--accent); text-decoration: none; }
.curve-chart { width: 320px; height: 200px; }
.up { color: #16a34a; } .down { color: #dc2626; }
.mv-approx { opacity: .75; margin-right: 1px; color: #b08968; }
.approx-note { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 420px; max-width: 92vw; }
.modal h3 { margin: 0 0 16px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.modal input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.hidden { display: none !important; }
body:not(.is-admin) .admin-only { display: none !important; }
body.is-admin .guest-login { display: none !important; }
.auth-status {
  padding: 0 16px 10px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-help { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.admin-log-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 370px;
  max-width: calc(100vw - 36px);
  background: rgba(25, 29, 37, .96);
  color: #e7eaf0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
  z-index: 45;
  overflow: hidden;
}
.admin-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,.06);
}
.admin-log-toggle {
  border: 0;
  background: transparent;
  color: #d9dee8;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.admin-log-stop {
  border: 1px solid rgba(255,120,120,.4);
  border-radius: 5px;
  background: rgba(255,80,80,.12);
  color: #ffb7b7;
  cursor: pointer;
  font-size: 11px;
  margin-right: 6px;
  padding: 2px 6px;
}
.admin-log-stop:disabled { opacity: .35; cursor: default; }
.admin-log-summary {
  padding: 6px 10px;
  color: #aeb7c6;
  font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.admin-log-lines {
  height: 126px;
  padding: 7px 10px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 11px/1.45 Consolas, monospace;
  color: #c8d0dc;
}
.admin-log-panel.minimized .admin-log-summary,
.admin-log-panel.minimized .admin-log-lines { display: none; }
.group-chip { margin-top: 3px; color: var(--muted); font-size: 11px; }
#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #333; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; font-size: 14px; }
.empty { color: var(--muted); text-align: center; padding: 40px; }
