:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #1f6feb;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --orange: #ffa657;

  --sidebar-w: 220px;
  --header-h: 52px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}
header h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}
header .badge {
  font-size: 11px;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}
header .crawl-time {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

/* Layout */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
nav {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 12px 0;
}
nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
  transition: all 0.12s;
  white-space: nowrap;
  overflow: hidden;
}
nav a:hover { color: var(--text); background: var(--surface2); }
nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(88,166,255,0.08);
  font-weight: 500;
}
nav .nav-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 14px 16px 4px;
}

/* Main content */
main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Section heading */
.module-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}
.module-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.12s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent-dim); border-color: var(--accent); color: #fff; }

input.search-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  width: 280px;
  outline: none;
}
input.search-box:focus { border-color: var(--accent); }

/* Signal cards */
.signal-list { display: flex; flex-direction: column; gap: 10px; }

.signal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  transition: border-color 0.12s;
}
.signal-card:hover { border-color: var(--accent-dim); }

.signal-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.signal-headline {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.4;
}
.signal-headline a { color: inherit; text-decoration: none; }
.signal-headline a:hover { color: var(--accent); }
.signal-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.signal-summary {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

/* Chips / Tags */
.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  line-height: 1.6;
}
.chip-axis-mobile_ap    { background: rgba(63,185,80,0.15); color: var(--green); }
.chip-axis-hpc_datacenter { background: rgba(88,166,255,0.15); color: var(--accent); }
.chip-axis-custom_soc   { background: rgba(188,140,255,0.15); color: var(--purple); }
.chip-axis-foundry      { background: rgba(255,166,87,0.15); color: var(--orange); }
.chip-axis-packaging    { background: rgba(248,81,73,0.15); color: var(--red); }
.chip-cat-news      { background: var(--surface2); color: var(--text-muted); }
.chip-cat-process   { background: rgba(255,166,87,0.15); color: var(--orange); }
.chip-cat-packaging { background: rgba(210,153,34,0.15); color: var(--yellow); }
.chip-cat-price     { background: rgba(248,81,73,0.15); color: var(--red); }
.chip-cat-hiring    { background: rgba(188,140,255,0.15); color: var(--purple); }
.chip-tag { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 32px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
th { color: var(--text-muted); font-weight: 500; font-size: 12px; background: var(--surface); }
tr:hover td { background: var(--surface2); }

/* Bar */
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.bar-label { width: 140px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.3s; }
.bar-count { width: 32px; text-align: right; color: var(--text-muted); font-size: 12px; }

/* Matrix */
.matrix-table th:first-child { width: 120px; }
.matrix-cell-yes { color: var(--green); font-weight: 600; }
.matrix-cell-no  { color: var(--border); }

/* Channel list */
.channel-list { display: flex; flex-direction: column; gap: 8px; }
.channel-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.channel-status { font-size: 12px; font-weight: 500; }
.channel-status.ok    { color: var(--green); }
.channel-status.warn  { color: var(--yellow); }

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty h3 { font-size: 16px; margin-bottom: 8px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Today stat card drill-down ───────────────────────────────────────── */
.stat-card-clickable {
  cursor: pointer;
  transition: border-color 0.12s, transform 0.1s, background 0.12s;
  user-select: none;
}
.stat-card-clickable:hover {
  border-color: var(--accent-dim);
  transform: translateY(-1px);
}
.stat-card-clickable.active {
  border-color: var(--accent);
  background: rgba(88,166,255,0.08);
}
.stat-card-clickable.active .stat-value { color: var(--green); }

/* ── Ecosystem graph ──────────────────────────────────────────────────── */
.eco-graph {
  position: relative;
  margin-bottom: 4px;
}
.eco-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 0;
}
.eco-columns {
  display: flex;
  gap: 10px;
  position: relative;
  z-index: 1;
}
.eco-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.eco-axis-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  text-align: center;
  background: var(--surface2);
  margin-bottom: 4px;
}
.eco-node {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}
.eco-node:hover { border-color: var(--accent-dim); }
.eco-node.active {
  border-color: var(--accent);
  background: rgba(88,166,255,0.10);
}
.eco-node.highlighted {
  border-color: var(--green);
  background: rgba(63,185,80,0.07);
}
.eco-node.eco-node-empty { opacity: 0.45; }
.eco-node-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eco-node-count {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 8px;
}

/* Responsive */
@media (max-width: 700px) {
  nav { width: 48px; }
  nav a span.nav-label { display: none; }
  main { padding: 16px; }
  .eco-columns { gap: 5px; }
  .eco-node { padding: 5px 6px; font-size: 10px; }
}
