:root {
  --bg: #08080a;
  --card: #111214;
  --text: #f5f6f7;
  --muted: #91969a;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #00deec;
  --pn: #4f8cff;
  --pl: #ff5d7a;
  --ind: #3ddc97;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(900px 520px at 50% -220px, rgba(0, 222, 236, 0.10), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.04em;
  background: linear-gradient(132deg, #ffffff 0%, #b0b0b0 81%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.h1-sub {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  -webkit-text-fill-color: var(--muted);
  color: var(--muted);
}

.meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

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

.btn {
  background: #fafafa;
  color: #050506;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 9px 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 40px rgba(0, 222, 236, 0.16);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.status {
  color: var(--muted);
  font-size: 14px;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tabs {
  display: flex;
  gap: 12px;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 500;
}

.tab-btn.active {
  color: var(--text);
  border-color: rgba(122, 162, 247, 0.8);
  background: rgba(122, 162, 247, 0.18);
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.card {
  background: linear-gradient(180deg, rgba(154, 160, 180, 0.08) 0%, transparent 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: 0 40px 60px -40px rgba(122, 162, 247, 0.4);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 12px;
}

.card-header h2 {
  margin: 0;
  font-size: 18px;
}

.filters {
  display: flex;
  gap: 10px;
}

.filters input,
.filters select {
  background: rgba(18, 24, 42, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
}

.chart-wrap {
  padding: 0 28px 12px;
}

.table-wrap {
  overflow-x: auto;
  padding: 0 0 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

thead th {
  text-align: left;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 10px 28px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

thead th.num {
  text-align: right;
}

tbody td {
  padding: 12px 28px;
  border-bottom: 1px solid rgba(36, 42, 61, 0.7);
  font-size: 14px;
}

tbody tr:hover {
  background: rgba(122, 162, 247, 0.08);
}

tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.title-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.title-cell a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.title-cell a:hover {
  color: var(--accent);
}

.title-cell small {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.pn { background: rgba(79, 140, 255, 0.22); color: var(--pn); }
.badge.pl { background: rgba(255, 93, 122, 0.22); color: var(--pl); }
.badge.ind { background: rgba(61, 220, 151, 0.22); color: var(--ind); }

pre {
  margin: 0;
  padding: 20px 28px 28px;
  max-height: 520px;
  overflow: auto;
  font-size: 13px;
  color: var(--muted);
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: #1a1f35;
  color: #e6e9f5;
  border: 1px solid #3a4166;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.5;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.legend {
  display: flex;
  gap: 1.25rem;
  padding: 0 1rem 0.5rem;
  font-size: 0.8rem;
  color: #9aa0b4;
}
.legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.dot.pn { background: #4f8cff; }
.dot.pl { background: #ff5d7a; }
.dot.ind { background: #3ddc97; }

/* ---- Tokens tab ---- */
.legend-note {
  margin-left: auto;
  color: #6b7190;
  font-size: 0.72rem;
}

.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 0.6rem;
  padding: 0.75rem 1rem 1rem;
}

.token-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.7rem 0.8rem 0.85rem;
  border-radius: 10px;
  border: 1px solid #2b3150;
  background: #141829;
  color: #e6e9f5;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.token-card:hover {
  transform: translateY(-2px);
  background: #1a1f35;
}
.token-card.pn { border-left: 3px solid #4f8cff; }
.token-card.pl { border-left: 3px solid #ff5d7a; }
.token-card.ind { border-left: 3px solid #3ddc97; }
.token-card.pn:hover { border-color: #4f8cff; }
.token-card.pl:hover { border-color: #ff5d7a; }
.token-card.ind:hover { border-color: #3ddc97; }
.token-name {
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.token-meta { font-size: 0.72rem; color: #8b91b0; }
.token-net {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #b9bfe0;
}
.token-shares {
  display: flex;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: #232842;
  margin-top: 0.15rem;
}
.seg { display: block; height: 100%; }
.seg.pl { background: #ff5d7a; }
.seg.pn { background: #4f8cff; }
.seg.ind { background: #3ddc97; }
.token-empty {
  grid-column: 1 / -1;
  padding: 1.5rem 1rem;
  color: #8b91b0;
  font-size: 0.85rem;
}
.grid-footer {
  padding: 0 1rem 1rem;
  color: #8b91b0;
  font-size: 0.78rem;
}
.btn-small {
  background: #232842;
  color: #cfd4ee;
  border: 1px solid #3a4166;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}
.btn-small:hover { background: #2b3150; }

.token-panel {
  position: fixed;
  top: 72px;
  right: 0;
  width: min(440px, 92vw);
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  background: #11142a;
  border: 1px solid #2b3150;
  border-right: none;
  border-radius: 14px 0 0 14px;
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.45);
  transform: translateX(105%);
  transition: transform 0.22s ease;
  z-index: 50;
  padding: 1rem 1.1rem 1.4rem;
}
.token-panel.open { transform: translateX(0); }
.token-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.token-panel-header h2 { font-size: 1.15rem; }
.token-panel-subtitle { font-size: 0.75rem; color: #8b91b0; }
.close-btn {
  background: transparent;
  border: none;
  color: #8b91b0;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.token-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.token-metric {
  background: #161a2e;
  border: 1px solid #262b45;
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.token-metric .label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: #8b91b0; }
.token-metric .value { font-size: 1rem; font-weight: 600; }
.share-bar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #232842;
  margin-bottom: 0.4rem;
}
.share-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: #8b91b0;
  margin-bottom: 1rem;
}
.share-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.token-articles { display: flex; flex-direction: column; gap: 0.5rem; }
.token-article {
  display: block;
  padding: 0.6rem 0.7rem;
  border: 1px solid #262b45;
  border-radius: 10px;
  background: #141829;
  text-decoration: none;
  color: #e6e9f5;
}
.token-article:hover { border-color: #3a4166; background: #181d33; }
.token-article-title { display: block; font-size: 0.85rem; font-weight: 500; line-height: 1.35; margin-bottom: 0.3rem; }
.token-article-meta { display: flex; flex-wrap: wrap; gap: 0.6rem; font-size: 0.72rem; color: #8b91b0; }

.signal-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.signal-badge.strong { background: rgba(79, 140, 255, 0.18); color: #8fb3ff; border-color: rgba(79, 140, 255, 0.5); }
.signal-badge.balanced { background: rgba(61, 220, 151, 0.16); color: #7ee8b6; border-color: rgba(61, 220, 151, 0.45); }
.signal-badge.weak { background: rgba(154, 160, 180, 0.14); color: #9aa0b4; border-color: rgba(154, 160, 180, 0.35); }

.src-link {
  color: var(--accent);
  text-decoration: none;
}
.src-link:hover {
  text-decoration: underline;
}

/* Copy provenance ------------------------------------------------------ */

.copy-pill {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.copy-pill.copy-copy {
  color: #ffd08a;
  background: rgba(246, 186, 80, 0.12);
  border-color: rgba(246, 186, 80, 0.38);
}
.copy-pill.copy-source {
  color: #7ee8b6;
  background: rgba(61, 220, 151, 0.12);
  border-color: rgba(61, 220, 151, 0.38);
}
.tab-count {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  color: var(--muted);
  font-size: 10px;
  line-height: 17px;
}
.copy-other-outlet {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.copy-empty {
  padding: 32px 12px;
  text-align: center;
  color: var(--muted);
}
#copiesTable {
  min-width: 980px;
}
#copiesTable a {
  color: var(--text);
  text-decoration: none;
}
#copiesTable a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}
#copiesTable td:nth-child(4) {
  min-width: 260px;
}
.copy-hint {
  margin: 0;
  padding: 0 18px 16px;
  color: var(--muted);
  font-size: 12px;
}
.copy-pill.copy-match {
  color: #c3c7ce;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
}
