* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --accent: #3b82f6;
  --accent-glow: #60a5fa;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #334155;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 20px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.header-left h1 {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-glow), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 13px;
  color: var(--text-dim);
  -webkit-text-fill-color: var(--text-dim);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right button {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.header-right button:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.header-right button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.last-update {
  font-size: 12px;
  color: var(--text-dim);
}

/* Filters */
.filters {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.filter-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-dim);
}

.tag:hover { border-color: var(--accent); color: var(--text); }
.tag.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

#keywordSearch {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text);
  font-size: 14px;
  width: 220px;
  outline: none;
  transition: border 0.2s;
}

#keywordSearch:focus { border-color: var(--accent); }

/* Stats bar */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.stat-num { font-size: 28px; font-weight: 700; color: var(--accent-glow); }
.stat-label { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* Table */
#trendsTable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
}

#trendsTable th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

#trendsTable td {
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 14px;
}

#trendsTable tr td:first-child { border-radius: 8px 0 0 8px; }
#trendsTable tr td:last-child { border-radius: 0 8px 8px 0; }
#trendsTable tr:hover td { background: var(--bg-hover); }

.col-rank { width: 50px; }
.col-source { width: 90px; }
.col-heat { width: 160px; }
.col-cat { width: 100px; }
.col-action { width: 80px; text-align: center; }

.source-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.source-baidu { background: #1e3a5f; color: #60a5fa; }
.source-weibo { background: #5f1e3a; color: #f472b6; }
.source-zhihu { background: #1e5f3a; color: #4ade80; }
.source-google { background: #3a3a1e; color: #fbbf24; }
.source-amazon { background: #3a1e1e; color: #fb7185; }
.source-github { background: #1e1e2e; color: #a78bfa; }
.source-hackernews { background: #1e2e1e; color: #fb923c; }
.source-douyin { background: #1a1a2e; color: #ee5a6f; }
.source-xiaohongshu { background: #2e1a1a; color: #fe2c55; }

.keyword-cell {
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  display: inline-block;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.keyword-cell:hover { color: var(--accent-glow); }

.heat-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.heat-fill {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-glow));
  transition: width 0.5s ease;
  min-width: 4px;
}

.heat-text { font-size: 13px; font-weight: 600; min-width: 30px; }

.heat-high { color: var(--danger); }
.heat-mid { color: var(--warning); }
.heat-low { color: var(--text-dim); }

.opp-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.opp-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59,130,246,0.1);
}

.opp-btn.marked {
  border-style: solid;
  background: rgba(34,197,94,0.1);
  color: var(--success);
  border-color: var(--success);
}

/* Loading */
.loading-row {
  text-align: center;
  padding: 60px !important;
  color: var(--text-dim);
  font-size: 15px;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding: 16px;
  color: var(--text-dim);
  font-size: 14px;
}

.pagination button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.pagination button:hover { background: var(--accent); border-color: var(--accent); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 30px;
  max-width: 460px;
  width: 90%;
  border: 1px solid var(--border);
  position: relative;
}

.close {
  position: absolute;
  top: 12px; right: 18px;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-dim);
}

.close:hover { color: var(--text); }

.opp-keyword {
  font-size: 18px;
  font-weight: 600;
  margin: 16px 0;
  color: var(--accent-glow);
}

.opp-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.opp-options button {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}

.opp-options button:hover { border-color: var(--accent); background: rgba(59,130,246,0.1); }

.opp-custom {
  display: flex;
  gap: 8px;
}

.opp-custom input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.opp-custom input:focus { border-color: var(--accent); }

.opp-custom button {
  padding: 10px 20px;
  background: var(--accent);
  border: none;
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

/* Heatmap view */
#heatmapView {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
}

.chart-container {
  height: 400px;
  margin-bottom: 24px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.summary-card {
  background: var(--bg);
  border-radius: 8px;
  padding: 16px;
  border: 1px solid var(--border);
}

.summary-card .sc-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.summary-card .sc-item {
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-card .sc-item:hover { color: var(--text); }

/* Responsive */
@media (max-width: 768px) {
  header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .filters { flex-direction: column; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .col-cat { display: none; }
  .keyword-cell { max-width: 200px; }
}

/* ====== Nav ====== */
.nav {
  background: #1e293b;
  border-bottom: 1px solid #334155;
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #f1f5f9;
}
.nav-logo { font-size: 22px; }
.nav-title {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  color: #94a3b8;
  font-size: 14px;
  transition: all 0.2s;
}
.nav-link:hover { color: #f1f5f9; background: #334155; }
.nav-link.active { color: #60a5fa; background: rgba(59,130,246,0.1); }

/* Hero */
/* Breadcrumb */
.breadcrumb {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px 0;
}
.breadcrumb ol {
  list-style: none;
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}
.breadcrumb ol li + li::before {
  content: "›";
  margin-right: 8px;
  color: #475569;
}
.breadcrumb a {
  color: #94a3b8;
  text-decoration: none;
}
.breadcrumb a:hover {
  color: #60a5fa;
}
.breadcrumb ol li:last-child a {
  color: #60a5fa;
  pointer-events: none;
}

.hero {
  text-align: center;
  padding: 80px 24px 60px;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}
.hero h1 { font-size: 42px; font-weight: 800; margin-bottom: 16px; }
.hero h1 .highlight {
  background: linear-gradient(135deg, #60a5fa, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub { font-size: 17px; color: #94a3b8; max-width: 500px; margin: 0 auto 32px; line-height: 1.6; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
  padding: 12px 28px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s;
  display: inline-block;
}
.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; transform: translateY(-1px); }
.btn-secondary { background: #334155; color: #f1f5f9; border: 1px solid #475569; }
.btn-secondary:hover { background: #475569; }

/* Mini Stats */
.mini-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 800px;
  margin: -30px auto 40px;
  padding: 0 24px;
}
.stat-card-mini {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.stat-card-mini .stat-num { font-size: 24px; font-weight: 700; color: #60a5fa; display: block; }
.stat-card-mini .stat-label { font-size: 13px; color: #94a3b8; }

/* Features */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 900px;
  margin: 0 auto 40px;
  padding: 0 24px;
}
.feature-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 28px 24px;
  text-align: center;
}
.feature-icon { font-size: 36px; margin-bottom: 12px; }
.feature-card h3 { font-size: 17px; margin-bottom: 10px; }
.feature-card p { font-size: 13px; color: #94a3b8; line-height: 1.6; margin-bottom: 14px; }
.feature-link {
  color: #60a5fa;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.feature-link:hover { text-decoration: underline; }

/* Hot Preview */
.hot-preview {
  max-width: 700px;
  margin: 0 auto 40px;
  padding: 0 24px;
}
.hot-preview h2 { font-size: 20px; margin-bottom: 16px; }
.hot-grid { display: flex; flex-direction: column; gap: 8px; }
.hot-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px 16px;
  text-decoration: none;
  transition: all 0.2s;
}
.hot-card:hover { border-color: #3b82f6; background: #1e3a5f; }
.hot-source {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #334155;
  color: #94a3b8;
  white-space: nowrap;
  flex-shrink: 0;
}
.hot-word { flex: 1; font-size: 14px; color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hot-heat { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #94a3b8; white-space: nowrap; flex-shrink: 0; }
.heat-fill-sm { width: 40px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.loading-hint { text-align: center; color: #94a3b8; padding: 20px; }
.hot-more { text-align: center; margin-top: 20px; }

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid #334155;
  color: #64748b;
  font-size: 13px;
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #334155;
}
.page-header h1 { font-size: 22px; }
.page-header .subtitle { font-size: 13px; color: #94a3b8; }
