/* ============================================================
 * 舆情监测 SPA — Elegant 浅色主题
 * 蓝色为唯一强调色，大面积白色/浅灰底，精致克制
 * ============================================================ */

:root {
  /* ── 表面 ── */
  --bg: #f8f9fb;
  --bg2: #ffffff;
  --card: #ffffff;
  --card-hover: #f1f5f9;
  --border: #e2e8f0;

  /* ── 文字 ── */
  --text: #111827;
  --muted: #6b7280;

  /* ── 品牌色 ── */
  --brand: #3b82f6;

  /* ── 语义色（全部基于蓝，风险分级保留） ── */
  --red: #dc2626;
  --orange: #ea580c;
  --yellow: #ca8a04;
  --blue: #3b82f6;
  --green: #16a34a;
  --purple: #7c3aed;
  --wuxi: #7c3aed;

  /* ── 形状 ── */
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.07);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Topbar ── */
#topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px 0;
  box-shadow: 0 1px 0 var(--border);
}

.logo {
  font-size: 18px; font-weight: 600; color: var(--text);
  display: inline-block; letter-spacing: -0.01em;
}
.logo span { color: var(--muted); font-weight: 400; font-size: 13px; }

.topbar-right {
  float: right; display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--muted);
}

.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.reload-btn {
  cursor: pointer; font-size: 17px; color: var(--muted);
  transition: color .2s;
}
.reload-btn:hover { color: var(--brand); }

/* ── Nav ── */
.nav-links {
  display: flex; gap: 0; margin-top: 14px;
}

.nav-item {
  display: inline-block;
  padding: 9px 18px 11px;
  font-size: 13.5px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: all .15s;
  cursor: pointer;
  font-weight: 450;
}
.nav-item:hover {
  color: var(--text);
  text-decoration: none;
  background: rgba(59,130,246,.04);
}
.nav-item.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 550;
}

/* ── Main ── */
#main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

/* ── Card ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, background .2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card h3 {
  font-size: 13.5px; font-weight: 550; color: var(--text);
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.card.full-width { grid-column: 1 / -1; }

.dot {
  display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: var(--brand);
}

/* ── KPI ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: center;
  border-top: 3px solid var(--border);
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.kpi:hover { box-shadow: var(--shadow-md); }
.kpi.v-total { border-top-color: var(--brand); }
.kpi.v-event { border-top-color: var(--orange); }
.kpi.v-high { border-top-color: var(--red); }
.kpi.v-pool { border-top-color: var(--orange); }
.kpi.v-local { border-top-color: var(--wuxi); }
.kpi.v-scan { border-top-color: var(--green); }

.kpi-val {
  font-size: 26px; font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Charts Grid ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 22px;
}
.chart-wrap { height: 220px; }

/* ── Filter Bar ── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.filter-group {
  display: flex; align-items: center; gap: 6px;
}
.filter-group label {
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.filter-select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.filter-select:focus { border-color: var(--brand); }

.filter-input {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px;
  font-size: 13px; width: 160px;
  outline: none;
  transition: border-color .15s;
}
.filter-input:focus { border-color: var(--brand); }

.filter-result {
  margin-left: auto;
  font-size: 12px; color: var(--muted);
}

/* ── Event List ── */
.event-list { display: flex; flex-direction: column; gap: 8px; }

.event-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 18px;
  cursor: pointer;
  transition: all .15s;
  border-left: 3px solid var(--border);
}
.event-item:hover {
  background: var(--card-hover);
  transform: translateX(2px);
  box-shadow: var(--shadow-md);
}
.event-item.risk-红色 { border-left-color: var(--red); }
.event-item.risk-橙色 { border-left-color: var(--orange); }
.event-item.risk-黄色 { border-left-color: var(--yellow); }
.event-item.risk-蓝色 { border-left-color: var(--blue); }

.ev-title {
  font-size: 14px; font-weight: 500;
  margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  line-height: 1.5;
}
.ev-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 12px; color: var(--muted);
  align-items: center;
}
.ev-reasons {
  font-size: 12px; color: var(--muted);
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid var(--border);
}

.ev-detail {
  margin-top: 10px; padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.detail-desc {
  font-size: 13px; color: var(--text);
  line-height: 1.6; margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.detail-url {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 10px; font-size: 12px;
  color: var(--brand); text-decoration: none;
}
.detail-url:hover { text-decoration: underline; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-red { background: rgba(220,38,38,.08); color: var(--red); }
.badge-orange { background: rgba(234,88,12,.08); color: var(--orange); }
.badge-yellow { background: rgba(202,138,4,.08); color: var(--yellow); }
.badge-blue { background: rgba(59,130,246,.08); color: var(--blue); }
.badge-none { background: rgba(107,114,128,.08); color: var(--muted); }
.badge-green { background: rgba(22,163,106,.08); color: var(--green); }

.pool-tag { background: rgba(234,88,12,.06); color: var(--orange); }
.local-tag { background: rgba(124,58,237,.06); color: var(--purple); }

/* ── Platform Tags ── */
.plat { font-size: 11px; padding: 2px 7px; border-radius: 4px; font-weight: 450; }
.plat-weibo { background: rgba(220,38,38,.06); color: #dc2626; }
.plat-douyin { background: rgba(13,148,136,.06); color: #0d9488; }
.plat-toutiao { background: rgba(202,138,4,.06); color: #ca8a04; }
.plat-wechat { background: rgba(22,163,106,.06); color: #16a34a; }
.plat-xiaohongshu { background: rgba(190,24,93,.06); color: #be185d; }

/* ── Table ── */
.tbl {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  text-align: left; padding: 9px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--muted); font-weight: 550;
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tbl td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl tr:hover td { background: rgba(59,130,246,.03); }

/* ── Page Header ── */
.page-header {
  margin-bottom: 16px;
  display: flex; align-items: baseline; gap: 12px;
}
.page-header h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.page-desc { font-size: 13px; color: var(--muted); }

/* ── Stats Chips ── */
.event-stats, .lifecycle-stats {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.stat-chip {
  font-size: 13px; color: var(--muted);
  padding: 5px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.stat-chip strong { color: var(--text); font-weight: 600; }
.stat-chip.stat-red { color: var(--red); border-color: rgba(220,38,38,.2); background: rgba(220,38,38,.03); }
.stat-chip.stat-green { color: var(--green); border-color: rgba(22,163,106,.2); background: rgba(22,163,106,.03); }
.stat-chip.stat-yellow { color: var(--yellow); border-color: rgba(202,138,4,.2); background: rgba(202,138,4,.03); }
.stat-chip.stat-purple { color: var(--purple); border-color: rgba(124,58,237,.2); background: rgba(124,58,237,.03); }
.stat-chip.stat-gray { color: var(--muted); }

/* ── Lifecycle ── */
.lifecycle-filters {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}

.lifecycle-list { display: flex; flex-direction: column; gap: 12px; }

.lc-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.lc-header {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 12px; color: var(--muted);
  align-items: center; margin-bottom: 6px;
}
.lc-title { font-size: 15px; font-weight: 550; margin-bottom: 6px; }
.lc-meta {
  display: flex; flex-wrap: wrap; gap: 10px;
  font-size: 12px; color: var(--muted);
  margin-bottom: 10px;
}
.lc-eid {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  opacity: .6;
}
.lc-pool {
  font-size: 11px;
  padding: 1px 6px;
  background: rgba(107,114,128,.06);
  border-radius: 4px;
}
.lc-bottom {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* ── Trend Badge ── */
.trend-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  line-height: 1.4;
}

/* ── Heat Change ── */
.heat-change {
  font-size: 11px; font-weight: 600;
  font-family: var(--mono);
}
.heat-change.hc-up   { color: #dc2626; }
.heat-change.hc-down { color: #2563eb; }
.heat-change.hc-flat { color: #6b7280; }

/* ── Stat Divider ── */
.stat-divider {
  width: 1px; height: 20px;
  background: var(--border);
  margin: 0 4px;
  align-self: center;
}

/* ── Sparkline (mini bar chart) ── */
.sparkline {
  display: flex; align-items: flex-end; gap: 2px;
  width: 48px; height: 28px;
  flex-shrink: 0;
  padding: 2px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}
.spark-bar {
  flex: 1;
  min-width: 3px;
  background: var(--brand);
  border-radius: 1px;
  opacity: .7;
  transition: height .3s ease;
}

/* ── Timeline ── */
.tl-timeline {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
  margin-left: 4px;
  flex: 1;
}
.tl-node {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--border);
}
.tl-dot {
  width: 6px; height: 6px;
  border-radius: 50%; flex-shrink: 0;
}
.tl-time { color: var(--text); font-weight: 500; }
.tl-heat { color: var(--orange); }

/* ── Map ── */
.map-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
}
.map-events { margin-top: 16px; }

/* ── Reports ── */
.report-card {
  border-left: 3px solid var(--brand);
  transition: box-shadow .2s;
}
.report-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; cursor: pointer; user-select: none;
}
.report-header:hover { opacity: .85; }
.report-header-left { display: flex; gap: 10px; align-items: center; }
.report-toggle { color: var(--muted); transition: transform .2s; flex-shrink: 0; }
.report-date { font-size: 13px; color: var(--muted); }
.report-summary {
  font-size: 13px; line-height: 1.6;
  margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.report-body {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
  animation: fadeIn .2s ease;
}
.report-md {
  font-size: 14px; line-height: 1.75; color: var(--text);
}
.report-md h1 { font-size: 20px; margin: 16px 0 8px; font-weight: 700; }
.report-md h2 { font-size: 17px; margin: 14px 0 6px; font-weight: 600; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.report-md h3 { font-size: 15px; margin: 10px 0 4px; font-weight: 600; }
.report-md p { margin: 6px 0; }
.report-md ul, .report-md ol { margin: 6px 0; padding-left: 20px; }
.report-md li { margin: 3px 0; }
.report-md strong { color: var(--text); }
.report-md blockquote {
  margin: 8px 0; padding: 8px 12px;
  background: rgba(59,130,246,.04); border-left: 3px solid var(--brand);
  color: var(--muted); font-size: 13px;
}
.report-md code {
  background: var(--bg); padding: 1px 5px; border-radius: 3px;
  font-size: 13px; color: var(--red);
}
.report-md pre {
  background: var(--bg); padding: 12px; border-radius: 6px;
  overflow-x: auto; font-size: 13px;
}
.report-md table {
  width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px;
}
.report-md th, .report-md td {
  border: 1px solid var(--border); padding: 6px 10px; text-align: left;
}
.report-md th { background: var(--bg); font-weight: 600; }
.report-meta {
  display: flex; gap: 16px;
  font-size: 12px; color: var(--muted);
}

/* ── Loading & Empty ── */
.loading-spinner {
  width: 28px; height: 28px;
  margin: 60px auto;
  border: 2.5px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center; padding: 40px;
  color: var(--muted); font-size: 14px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .charts-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .nav-links { overflow-x: auto; }
  .nav-item { padding: 8px 12px; font-size: 13px; }
  #main { padding: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
  #topbar { padding: 12px 16px 0; }
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; align-items: stretch; }
}

/* ── Lucide 风格 SVG 图标 ── */
.icon {
  display: inline-block;
  vertical-align: -3px;
  flex-shrink: 0;
}
.nav-item .icon {
  margin-right: 5px;
  opacity: 0.7;
}
.nav-item:hover .icon,
.nav-item.active .icon {
  opacity: 1;
}
.reload-btn .icon {
  transition: transform 0.3s ease;
}
.reload-btn:hover .icon {
  transform: rotate(180deg);
}
.icon.text-green { color: #22c55e; }
.icon.text-yellow { color: #eab308; }
.icon.text-gray { color: #9ca3af; }
.tab-icon svg {
  display: block;
  margin: 0 auto;
}
