:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --red: #dc2626;
  --green: #059669;
  --amber: #d97706;
  --purple: #7c3aed;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.65;
}

/* ---- top bar ---- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 28px; }
.brand h1 { font-size: 18px; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--text-3); }
#nav { display: flex; gap: 4px; flex: 1; }
.nav-btn {
  border: none; background: transparent; padding: 7px 14px; border-radius: 8px;
  font-size: 14px; color: var(--text-2); cursor: pointer; transition: all .15s;
}
.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.meta-info { font-size: 12px; color: var(--text-3); }

main { max-width: 1200px; margin: 0 auto; padding: 24px; min-height: calc(100vh - 130px); }
.footer { max-width: 1200px; margin: 0 auto; padding: 16px 24px; color: var(--text-3); font-size: 12px; border-top: 1px solid var(--border); }

/* ---- generic ---- */
.section-title { font-size: 16px; font-weight: 700; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--bg); color: var(--text-2); border: 1px solid var(--border); }
.tag.blue { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.red { background: #fef2f2; color: var(--red); border-color: transparent; }
.tag.green { background: #ecfdf5; color: var(--green); border-color: transparent; }
.tag.amber { background: #fffbeb; color: var(--amber); border-color: transparent; }
.tag.purple { background: #f5f3ff; color: var(--purple); border-color: transparent; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- overview ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat-card { padding: 16px; }
.stat-card .num { font-size: 26px; font-weight: 700; }
.stat-card .label { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 900px) { .overview-grid { grid-template-columns: 1fr; } }
.panel { padding: 16px 20px; }
.panel h3 { font-size: 14px; margin-bottom: 10px; color: var(--text-2); font-weight: 600; }

/* ---- competitor cards ---- */
.comp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.comp-card { padding: 18px 20px; cursor: pointer; transition: box-shadow .15s, transform .15s; position: relative; }
.comp-card:hover { box-shadow: 0 4px 12px rgba(16,24,40,.12); transform: translateY(-2px); }
.comp-card .head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.comp-card h3 { font-size: 16px; }
.comp-card .company { font-size: 12px; color: var(--text-2); }
.comp-card .positioning { font-size: 13px; color: var(--text-2); margin: 6px 0 10px; min-height: 40px; }
.comp-card .one-liner { font-size: 13px; color: var(--text); font-weight: 500; border-left: 3px solid var(--accent); padding-left: 8px; margin: 8px 0; }
.comp-metrics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.metric-chip { font-size: 11px; background: var(--bg); border-radius: 6px; padding: 3px 8px; color: var(--text-2); }
.metric-chip b { color: var(--text); }
.comp-footer { display: flex; justify-content: space-between; margin-top: 12px; font-size: 12px; color: var(--text-3); }
.ref-badge { position: absolute; top: 14px; right: 14px; }

.category-block { margin-bottom: 28px; }
.category-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.category-header h2 { font-size: 15px; }

/* ---- detail modal ---- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; }
.modal.hidden { display: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); }
.modal-body { position: relative; background: var(--surface); border-radius: 12px; max-width: 860px; width: 100%; max-height: calc(100vh - 80px); overflow-y: auto; padding: 28px 32px; }
.modal-close { position: absolute; top: 14px; right: 14px; border: none; background: var(--bg); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 14px; }
.detail-header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.detail-header h2 { font-size: 20px; }
.detail-sub { color: var(--text-2); font-size: 13px; margin-bottom: 16px; }
.detail-section { margin-top: 20px; }
.detail-section h4 { font-size: 14px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.detail-section ul { padding-left: 20px; }
.detail-section li { margin: 4px 0; color: var(--text-2); }
.detail-section li b { color: var(--text); }
.metrics-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.metrics-table th, .metrics-table td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.metrics-table th { color: var(--text-3); font-weight: 500; font-size: 12px; }
.metrics-table td b { font-size: 14px; }

/* ---- timeline ---- */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 14px; }
.timeline-item::before { content: ""; position: absolute; left: -19px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.timeline-item .t-date { font-size: 12px; color: var(--text-3); }
.timeline-item .t-event { font-size: 13px; }
.timeline-item .t-src { font-size: 11px; color: var(--text-3); }

/* ---- compare ---- */
.compare-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.compare-controls select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.compare-table th, .compare-table td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; vertical-align: top; }
.compare-table thead th { background: var(--bg); font-size: 13px; position: sticky; top: 60px; }
.compare-table td:first-child { background: var(--bg); font-weight: 600; width: 110px; white-space: nowrap; }
.compare-wrap { overflow-x: auto; }

/* ---- reports ---- */
.report-filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-btn { border: 1px solid var(--border); background: var(--surface); padding: 5px 14px; border-radius: 20px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.report-list { display: flex; flex-direction: column; gap: 10px; }
.report-item { padding: 16px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; transition: box-shadow .15s; }
.report-item:hover { box-shadow: 0 4px 12px rgba(16,24,40,.12); }
.report-item .r-title { font-weight: 600; font-size: 14px; }
.report-item .r-excerpt { font-size: 12px; color: var(--text-2); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* markdown rendering inside modal */
.md-body h1 { font-size: 18px; margin: 18px 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.md-body h2 { font-size: 16px; margin: 18px 0 8px; }
.md-body h3 { font-size: 14px; margin: 14px 0 6px; }
.md-body p, .md-body li { font-size: 13.5px; color: var(--text-2); }
.md-body strong { color: var(--text); }
.md-body table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 10px 0; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md-body th { background: var(--bg); }
.md-body blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-2); margin: 10px 0; }
.md-body code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---- about ---- */
.about-body { padding: 24px 28px; max-width: 860px; }
.about-body h3 { margin: 16px 0 8px; }
.about-body p, .about-body li { color: var(--text-2); font-size: 13.5px; }
.about-body ul, .about-body ol { padding-left: 20px; }
.about-body pre { background: #1f2329; color: #d8e0ea; padding: 14px 16px; border-radius: 8px; font-size: 12px; overflow-x: auto; margin: 8px 0; }
