/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0a0e17;
  --panel: #111827;
  --border: #1e293b;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #3b82f6;
  --accent-glow: rgba(59,130,246,.25);
  --red: #ef4444;
  --gold: #f59e0b;
  --orange: #f97316;
  --purple: #a855f7;
  --green: #22c55e;
}
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 13px; overflow: hidden; }
input, select, button { font-family: inherit; font-size: inherit; color: var(--text); }
input, select { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
button { background: var(--accent); border: none; border-radius: 4px; padding: 6px 14px; cursor: pointer; font-weight: 600; }
button:hover { opacity: .9; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Layout ────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-columns: 300px 1fr 340px;
  grid-template-rows: 1fr 200px;
  height: 100vh;
  gap: 1px;
  background: var(--border);
}
#user-panel { grid-row: 1 / 3; background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
#graph-panel { grid-row: 1; background: var(--bg); position: relative; }
#inspector-panel { grid-row: 1 / 3; background: var(--panel); overflow-y: auto; }
#timeline-panel { grid-column: 2; grid-row: 2; background: var(--panel); overflow: hidden; position: relative; }

/* ── User Panel ────────────────────────────────────────── */
.panel-header { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-dim); }
.panel-header .count { background: var(--accent); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 10px; }

#search-box { padding: 8px 12px; border-bottom: 1px solid var(--border); }
#search-box input { width: 100%; }
#auth-box {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.auth-row input {
  min-width: 0;
  font-size: 11px;
}
.auth-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.auth-actions button {
  font-size: 10px;
  padding: 4px 8px;
}
button.secondary {
  background: var(--bg);
  border: 1px solid var(--border);
}
#auth-status {
  margin-left: auto;
  font-size: 10px;
  color: var(--green);
  letter-spacing: .2px;
}
#auth-status.error {
  color: var(--red);
}
#relation-tabs { padding: 8px 12px; border-bottom: 1px solid var(--border); display: flex; gap: 6px; }
.relation-tab {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
}
.relation-tab.active {
  background: rgba(59,130,246,.16);
  border-color: var(--accent);
  color: var(--text);
}

/* ── Panel Mode Tabs ───────────────────────────────────── */
#panel-mode-tabs { display: flex; border-bottom: 1px solid var(--border); }
.panel-mode-tab {
  flex: 1;
  background: var(--panel);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 8px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  cursor: pointer;
}
.panel-mode-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: rgba(59,130,246,.08);
}
#reports-mode { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#hashtags-mode { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#hashtag-search-box {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 6px;
}
#hashtag-search-box input { flex: 1; min-width: 0; }
#hashtag-search-box button { font-size: 11px; padding: 6px 12px; }
#hashtag-list { max-height: 150px; overflow-y: auto; }
.hashtag-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; font-size: 12px; transition: background .15s;
}
.hashtag-item:hover { background: rgba(59,130,246,.08); }
.hashtag-item.active { background: rgba(59,130,246,.12); border-left: 3px solid var(--accent); }
.hashtag-item .hashtag-name { flex: 1; font-weight: 600; color: var(--accent); }
.hashtag-item .hashtag-count { font-size: 10px; color: var(--text-dim); }
.hashtag-item .hashtag-remove {
  font-size: 14px; color: var(--text-dim); cursor: pointer;
  background: none; border: none; padding: 0 4px; line-height: 1;
}
.hashtag-item .hashtag-remove:hover { color: var(--red); }
#hashtag-posts { flex: 1; overflow-y: auto; }
.hashtag-post-card {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.hashtag-post-card:hover { background: rgba(59,130,246,.08); }
.hashtag-post-card .post-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hashtag-post-card .post-card-header img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.hashtag-post-card .post-card-user { font-size: 11px; font-weight: 600; }
.hashtag-post-card .post-card-date { font-size: 10px; color: var(--text-dim); margin-left: auto; }
.hashtag-post-card .post-card-caption { font-size: 11px; color: var(--text-dim); line-height: 1.4; max-height: 42px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.hashtag-post-card .post-card-stats { display: flex; gap: 10px; font-size: 10px; color: var(--text-dim); margin-top: 4px; }
.hashtag-post-card .post-card-thumb { width: 100%; border-radius: 6px; margin-top: 6px; max-height: 160px; object-fit: cover; border: 1px solid var(--border); }
.hashtag-empty { display: flex; align-items: center; justify-content: center; height: 80px; color: var(--text-dim); font-size: 11px; text-align: center; padding: 12px; }
.sentiment-badge { font-size: 9px; font-weight: 700; padding: 1px 5px; border: 1px solid; border-radius: 3px; letter-spacing: .3px; flex-shrink: 0; }
.topic-tag { font-size: 9px; padding: 1px 5px; border-radius: 3px; background: rgba(59,130,246,.15); color: var(--accent); border: 1px solid rgba(59,130,246,.3); white-space: nowrap; }
.post-card-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
#topic-overview { padding: 0; }
.topic-overview-inner { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.topic-overview-inner h5 { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); margin-bottom: 6px; }
.topic-bar-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 10px; }
.topic-bar-label { width: 80px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.topic-bar-track { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.topic-bar-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width .3s; }
.topic-bar-count { width: 28px; text-align: right; color: var(--text-dim); flex-shrink: 0; }
#top-posters { max-height: 180px; overflow-y: auto; }
.top-poster {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s; font-size: 11px;
}
.top-poster:hover { background: rgba(59,130,246,.08); }
.top-poster img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.top-poster .poster-info { flex: 1; min-width: 0; }
.top-poster .poster-name { font-weight: 600; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-poster .poster-meta { font-size: 10px; color: var(--text-dim); display: flex; gap: 6px; }
.top-poster .poster-post-count { font-size: 10px; font-weight: 700; color: var(--accent); flex-shrink: 0; }

#filters { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.filter-row { display: flex; align-items: center; gap: 6px; }
.filter-row label { font-size: 11px; color: var(--text-dim); min-width: 55px; text-transform: uppercase; letter-spacing: .5px; }
.filter-row input[type="number"] { width: 70px; }
.filter-row select { flex: 1; min-width: 0; }
.filter-row input[type="checkbox"] { accent-color: var(--accent); }
#sort-row select { flex: 1; }

#user-list { flex: 1; overflow-y: auto; }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.user-card:hover { background: rgba(59,130,246,.08); }
.user-card.loaded { background: rgba(59,130,246,.12); border-left: 3px solid var(--accent); }
.user-card.selected { background: rgba(59,130,246,.18); }
.user-card img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); flex-shrink: 0; }
.user-card.loaded img { border-color: var(--accent); }
.user-card .info { flex: 1; min-width: 0; }
.user-card .name { font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .username { color: var(--text-dim); font-size: 11px; }
.user-card .stats { display: flex; gap: 8px; font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.user-card .badges { display: flex; gap: 4px; margin-top: 2px; }
.badge { font-size: 9px; padding: 1px 5px; border-radius: 3px; font-weight: 600; }
.badge-verified { background: var(--gold); color: #000; }
.badge-pro { background: var(--purple); color: #fff; }

/* ── Graph ─────────────────────────────────────────────── */
#sigma-container { width: 100%; height: 100%; }
#graph-overlay {
  position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px;
  pointer-events: none; z-index: 10;
}
#graph-overlay .stat-badge {
  pointer-events: auto;
  background: rgba(17,24,39,.85); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; font-size: 11px; backdrop-filter: blur(8px);
}
#graph-legend {
  position: absolute; bottom: 10px; left: 10px; z-index: 10;
  background: rgba(17,24,39,.85); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 12px; font-size: 10px; backdrop-filter: blur(8px);
}
#graph-legend .legend-item { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
#graph-legend .legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ── Inspector ─────────────────────────────────────────── */
#inspector-panel { padding: 0; }
#inspector-content { padding: 14px; }
.inspector-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-dim); font-size: 12px; text-align: center; padding: 20px; }
#inspector-close { position: absolute; top: 8px; right: 10px; background: none; border: 1px solid var(--border); border-radius: 4px; color: var(--text-dim); font-size: 16px; width: 24px; height: 24px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; transition: color .15s, border-color .15s; }
#inspector-close:hover { color: var(--text); border-color: var(--text-dim); }
#inspector-content { position: relative; }
.inspector-header-centered { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 14px 14px 0; }
.inspector-avatar { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; border: 3px solid var(--accent); margin-bottom: 10px; }
.inspector-name { font-size: 16px; font-weight: 700; }
.inspector-username { color: var(--text-dim); font-size: 12px; margin-bottom: 4px; text-decoration: none; }
.inspector-username:hover { color: var(--accent); }
.inspector-ig-link { font-size: 10px; color: var(--accent); text-decoration: none; margin-bottom: 10px; }
.inspector-ig-link:hover { text-decoration: underline; }
.inspector-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.inspector-stat { background: var(--bg); border-radius: 6px; padding: 8px; text-align: center; }
.inspector-stat .val { font-size: 16px; font-weight: 700; color: var(--accent); }
.inspector-stat .lbl { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.inspector-section { margin-top: 14px; }
.inspector-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 8px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }

/* Overview Stats */
/* Concept Info */
.concept-info { padding: 14px; border-bottom: 1px solid var(--border); }
.concept-info-name { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.concept-info-desc { font-size: 10px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.4; }
.concept-info-row { margin-bottom: 6px; }
.concept-info-label { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 4px; }
.concept-info-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.concept-filter-tag { cursor: pointer; transition: background .15s, border-color .15s; }
.concept-filter-tag:hover { background: rgba(59,130,246,.25); border-color: rgba(59,130,246,.5); }
.concept-filter-tag.active { background: rgba(59,130,246,.35); border-color: var(--accent); color: #fff; }
.concept-filter-clear { font-size: 9px; margin-top: 8px; padding: 3px 10px; background: none; color: var(--text-dim); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.concept-filter-clear:hover { color: var(--text); border-color: var(--text-dim); }

.overview-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px; }
.overview-stat { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 8px; text-align: center; }
.overview-stat .val { font-size: 18px; font-weight: 700; color: var(--accent); }
.overview-stat .lbl { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }

/* Top Users */
.top-user-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.top-user-row:last-child { border-bottom: none; }
.top-user-rank { font-size: 10px; color: var(--text-dim); width: 16px; text-align: right; flex-shrink: 0; }
.top-user-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.top-user-avatar-placeholder { width: 24px; height: 24px; border-radius: 50%; background: var(--surface); flex-shrink: 0; }
.top-user-info { flex: 1; min-width: 0; }
.top-user-name { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-user-bar-bg { height: 3px; background: var(--border); border-radius: 2px; margin-top: 3px; }
.top-user-bar { height: 100%; background: var(--accent); border-radius: 2px; }
.top-user-meta { display: flex; gap: 6px; font-size: 9px; color: var(--text-dim); margin-top: 2px; }
.top-user-stats { text-align: right; flex-shrink: 0; }
.top-user-count { font-size: 11px; font-weight: 700; color: var(--accent); }
.top-user-likes { display: block; font-size: 9px; color: var(--text-dim); }

.risk-card { border: 1px solid var(--border); border-radius: 6px; padding: 8px; background: rgba(10,14,23,.75); }
.risk-card.monitor { border-color: rgba(34,197,94,.5); }
.risk-card.review { border-color: rgba(245,158,11,.7); }
.risk-card.priority { border-color: rgba(239,68,68,.8); }
.risk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.risk-level { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.risk-score { font-size: 12px; font-weight: 700; color: var(--text); }
.risk-breakdown { display: flex; gap: 8px; font-size: 10px; color: var(--text-dim); margin-bottom: 6px; }
.risk-signals { font-size: 10px; color: var(--text-dim); line-height: 1.4; }
.bot-meter { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bot-meter-fill { height: 100%; border-radius: 4px; transition: width .5s; }
.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.post-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  border-radius: 4px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
}
.post-thumb:hover { border-color: var(--accent); }
.overlap-list { list-style: none; }
.overlap-list li { padding: 4px 0; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.overlap-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.overlap-warning { background: rgba(239,68,68,.15); border: 1px solid var(--red); border-radius: 6px; padding: 8px; margin-top: 8px; font-size: 11px; color: var(--red); font-weight: 600; }

/* ── Timeline ──────────────────────────────────────────── */
#timeline-canvas { width: 100%; height: 100%; }
#timeline-panel .panel-header { position: absolute; top: 0; left: 0; right: 0; z-index: 5; background: rgba(17,24,39,.9); backdrop-filter: blur(8px); }
#timeline-content { padding-top: 32px; height: 100%; overflow-x: auto; overflow-y: hidden; position: relative; }
.timeline-intel-summary { display: flex; gap: 6px; padding: 8px 12px 2px; flex-wrap: wrap; }
.intel-chip { font-size: 10px; color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; background: rgba(10,14,23,.7); }
.timeline-claims { margin: 4px 12px 8px; border: 1px solid var(--border); border-radius: 6px; padding: 8px; background: rgba(10,14,23,.55); }
.timeline-claims h5 { font-size: 10px; letter-spacing: .7px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px; }
.claim-row { border-top: 1px solid var(--border); padding: 6px 0; }
.claim-row:first-of-type { border-top: none; padding-top: 0; }
.claim-text { font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.claim-meta { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.timeline-view-tabs { display: flex; gap: 4px; margin-left: 8px; }
.timeline-view-tab {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  padding: 3px 8px;
}
.timeline-view-tab.active {
  background: rgba(59,130,246,.16);
  border-color: var(--accent);
  color: var(--text);
}
.timeline-row { display: flex; align-items: center; height: 36px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.timeline-label { width: 100px; font-size: 10px; color: var(--text-dim); flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-track { flex: 1; position: relative; height: 100%; }
.timeline-dot {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 10px; height: 10px; border-radius: 50%; cursor: pointer;
  transition: transform .15s;
}
.timeline-dot:hover { transform: translate(-50%, -50%) scale(1.8); z-index: 5; }
.timeline-dot.similar-caption {
  box-shadow: 0 0 0 2px rgba(245,158,11,.95), 0 0 10px rgba(245,158,11,.55);
}
.timeline-dot.coordination { box-shadow: 0 0 0 2px rgba(245,158,11,.85), 0 0 8px 3px var(--red); }
.timeline-dot.risk-review { outline: 2px solid rgba(245,158,11,.95); outline-offset: 1px; }
.timeline-dot.risk-priority { outline: 2px solid rgba(239,68,68,.95); outline-offset: 1px; box-shadow: 0 0 10px rgba(239,68,68,.5); }
.timeline-axis { height: 24px; padding: 0 12px; display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.timeline-axis-track { flex: 1; margin-left: 100px; position: relative; height: 100%; display: flex; align-items: center; }
.timeline-tick { position: absolute; font-size: 9px; color: var(--text-dim); transform: translateX(-50%); }
.coord-bracket {
  position: absolute; border: 2px solid var(--red); border-radius: 4px;
  pointer-events: none; opacity: .6; z-index: 4;
  background: rgba(239,68,68,.08);
}

/* ── Loading ───────────────────────────────────────────── */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10,14,23,.8); z-index: 20; font-size: 12px; gap: 8px;
}

/* ── Tooltip ───────────────────────────────────────────── */
.tooltip {
  position: fixed; z-index: 100; background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 12px; font-size: 11px; pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.5); max-width: 250px;
}
