:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --taobao: #f97316;
  --jd: #e11d48;
  --success: #059669;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .04);
  --radius: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1400px; margin: 0 auto; padding: 0 24px; }
a { color: var(--primary); text-decoration: none; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #4f46e5); color: #fff; font-size: 20px; font-weight: 700;
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .5px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--success); background: #ecfdf5; padding: 5px 12px; border-radius: 999px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.link-btn { font-size: 13px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin: 20px 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.muted { color: var(--muted); font-size: 12px; margin: 4px 0 0; }

.filter-panel { margin-top: 24px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.field select, .field input, .keyword-box input {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field select:focus, .field input:focus, .keyword-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); background: #fff; }
.filter-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.keyword-box { flex: 1; max-width: 520px; }
.filter-actions { display: flex; gap: 10px; }

.btn { height: 38px; padding: 0 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; transition: all .15s; }
.btn:hover { border-color: #cbd5e1; background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.small { height: 30px; padding: 0 12px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { border: none; background: transparent; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 25px; font-weight: 680; margin: 6px 0 3px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11px; color: #94a3b8; }

.chart { width: 100%; }
.main-chart { height: 360px; }
.sub-chart { height: 280px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.two-col .panel { margin: 0 0 20px; }
.legend-note { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.swatch.taobao { background: var(--taobao); }
.swatch.jd { background: var(--jd); }

.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th { text-align: left; padding: 9px 10px; background: var(--surface-2); color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.data-table tr:hover td { background: #fafcff; }
.data-table .empty { text-align: center; color: var(--muted); padding: 30px 0; }
.data-table.compact td, .data-table.compact th { padding: 7px 9px; }
.title-cell { max-width: 360px; }
.title-cell a { color: var(--text); }
.title-cell a:hover { color: var(--primary); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.platform-tag { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; white-space: nowrap; }
.platform-tag.taobao { background: #fff7ed; color: #c2410c; }
.platform-tag.jd { background: #fff1f2; color: #be123c; }
.status-tag { font-size: 11px; color: var(--muted); white-space: nowrap; }
.snapshot-link { color: var(--primary); font-size: 12px; white-space: nowrap; cursor: pointer; background: none; border: none; padding: 0; font-family: inherit; }
.snapshot-link:hover { text-decoration: underline; }
.page-control { display: flex; align-items: center; gap: 10px; }

.crawl-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; }
.crawl-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-content: start; }
.crawl-log { background: #0f172a; color: #a5f3d0; border-radius: 8px; padding: 14px; font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; min-height: 150px; max-height: 240px; overflow: auto; }
.sub-title { font-size: 13px; margin: 22px 0 10px; }

.prose { color: #475569; font-size: 13px; }
.prose p { margin: 0 0 12px; }
.prose code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.footer { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; padding-top: 6px; padding-bottom: 30px; }

.drawer-mask { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; width: min(760px, 92vw); height: 100vh; background: var(--surface); box-shadow: -8px 0 40px rgba(15,23,42,.15); z-index: 41; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { padding: 18px 20px; overflow: auto; flex: 1; }
.snapshot-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.snapshot-card .row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.snapshot-card a { font-size: 12px; word-break: break-all; }
.snapshot-card code { font-size: 11px; color: var(--muted); }
[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .crawl-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .filter-grid, .kpi-grid { grid-template-columns: 1fr 1fr; }
  .topbar-right .badge { display: none; }
  .filter-footer { flex-direction: column; align-items: stretch; }
  .keyword-box { max-width: none; }
  .footer { flex-direction: column; gap: 6px; }
}
