/* ─── Analytics Dashboard ───────────────────────────────── */
.analytics-wrap {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
  width: 100%;
  flex: 1;
  box-sizing: border-box;
}

.analytics-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 50px;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 10px;
}

.ana-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 1200px) { .ana-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1800px) { .ana-grid { grid-template-columns: repeat(3, 1fr); } }

/* 3-column grid used by Pipeline/Contactos/Follow-ups and Top KOLs/Top ER/Activity rows.
   Scales: 2 cols default → 3 cols ≥1800px → 1 col on tablet. */
.ana-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (min-width: 1800px) { .ana-grid-3 { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 1024px) { .ana-grid-3 { grid-template-columns: 1fr; } }

.ana-card {
  background: var(--card-bg, var(--bg1));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  animation: fadeIn .2s ease;
}
.ana-card-title {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text3);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ana-card-title span { color: var(--accent); font-size: 10px; }

/* KPI Row */
.ana-kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
@media (max-width: 900px) { .ana-kpi-row { grid-template-columns: repeat(3, 1fr); } }
.ana-kpi {
  background: var(--card-bg, var(--bg1));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 10px;
  text-align: center;
  transition: var(--transition);
}
.ana-kpi:hover { border-color: var(--accent); }
.ana-kpi.glow-accent { border-color: rgba(240,180,41,.3); box-shadow: 0 0 12px rgba(240,180,41,.08); }
.ana-kpi-v {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 4px;
}
.ana-kpi-l {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.ana-kpi-sub {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  margin-top: 2px;
  opacity: .6;
}

/* Chart container */
.chart-container {
  position: relative;
  height: 200px;
}

/* Pipeline funnel */
.funnel-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}
.funnel-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text2);
  width: 100px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.funnel-bar-wrap {
  flex: 1;
  background: var(--bg3);
  border-radius: var(--radius);
  height: 16px;
  overflow: hidden;
}
.funnel-bar {
  height: 100%;
  border-radius: var(--radius);
  transition: width .5s ease;
  display: flex;
  align-items: center;
  padding-left: 6px;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--text);
  font-weight: 500;
}
.funnel-count {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

/* Contact bars */
.contact-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
.contact-icon { width: 18px; text-align: center; font-size: 11px; flex-shrink: 0; }
.contact-lbl { font-family: var(--mono); font-size: 8px; color: var(--text2); width: 55px; flex-shrink: 0; }
.contact-bar-wrap { flex: 1; background: var(--bg3); border-radius: var(--radius); height: 10px; overflow: hidden; }
.contact-bar { height: 100%; border-radius: var(--radius); transition: width .5s ease; }
.contact-pct { font-family: var(--mono); font-size: 8px; color: var(--text2); width: 55px; text-align: right; flex-shrink: 0; }

/* Top KOLs list */
.ana-top-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}
.ana-top-item:hover { background: var(--bg3); }
.ana-rank {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}
.chav.mini { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; overflow: hidden; }
.ana-top-name { font-size: 10px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ana-top-sub { font-family: var(--mono); font-size: 8px; color: var(--text3); }
.ana-top-metric { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent); text-align: right; flex-shrink: 0; }
.ana-top-metric span { display: block; font-size: 9px; color: var(--text3); font-weight: 400; }

/* ─── Follow-ups queue ─────────────────────────────────── */
.fu-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: var(--transition);
}
.fu-row:hover { background: var(--bg3); border-color: var(--line2); }
.fu-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: var(--text); font-weight: 500; }
.fu-days {
  font-family: var(--mono); font-size: 9px; padding: 2px 6px;
  border-radius: 8px; flex-shrink: 0; white-space: nowrap;
}
.fu-days.warn { background: rgba(240,180,41,.1); color: var(--accent); }
.fu-days.stale { background: rgba(239,68,68,.1); color: #ef4444; }
.fu-actions { display: flex; gap: 4px; flex-shrink: 0; }
.fu-btn {
  font-family: var(--mono); font-size: 8px; padding: 3px 7px;
  border-radius: 4px; border: 1px solid var(--line2);
  background: transparent; color: var(--text2); cursor: pointer;
  transition: var(--transition);
}
.fu-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--accent); }
.fu-btn.primary { background: rgba(240,180,41,.08); border-color: rgba(240,180,41,.3); color: var(--accent); }
.fu-btn.primary:hover { background: rgba(240,180,41,.18); }
.fu-empty {
  font-family: var(--mono); font-size: 9px; color: var(--text3);
  padding: 24px 12px; text-align: center; opacity: .6;
}

/* ─── Activity feed ─────────────────────────────────────── */
.act-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 6px;
  border-left: 2px solid transparent;
  transition: var(--transition);
  cursor: pointer;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.act-row:hover { background: var(--bg3); border-left-color: var(--accent); }
.act-icon {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; flex-shrink: 0; margin-top: 1px;
}
.act-body { flex: 1; min-width: 0; }
.act-title {
  font-size: 10px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.act-title b { font-weight: 600; color: var(--text); }
.act-meta {
  font-family: var(--mono); font-size: 8px; color: var(--text3);
  margin-top: 1px;
}
.act-time {
  font-family: var(--mono); font-size: 8px; color: var(--text3);
  flex-shrink: 0; white-space: nowrap; margin-top: 2px;
}

/* ─── Insights tab ─────────────────────────────────────── */
.ins-title-list { display: flex; flex-direction: column; gap: 2px; max-height: 520px; overflow-y: auto; }
.ins-title-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 6px;
  border-radius: var(--radius); cursor: pointer; transition: var(--transition);
  border-left: 2px solid transparent;
}
.ins-title-row:hover { background: var(--bg3); border-left-color: var(--accent); }
.ins-thumb { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; flex-shrink: 0; background: var(--bg3); }
.ins-thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--text3); }
.ins-title-body { flex: 1; min-width: 0; }
.ins-title-text {
  font-size: 11px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.ins-title-meta { font-family: var(--mono); font-size: 8px; color: var(--text3); }
.ins-er {
  font-family: var(--mono); font-size: 14px; font-weight: 600;
  text-align: right; flex-shrink: 0; min-width: 50px;
}
.ins-er span { display: block; font-size: 9px; color: var(--text3); font-weight: 400; letter-spacing: .1em; }

/* Hashtags */
.ins-hash-list { display: flex; flex-direction: column; gap: 4px; max-height: 440px; overflow-y: auto; }
.ins-hash-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.ins-hash-tag {
  font-family: var(--mono); font-size: 10px; color: var(--accent);
  font-weight: 600; width: 120px; flex-shrink: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ins-hash-bar-wrap { flex: 1; background: var(--bg3); border-radius: var(--radius); height: 10px; overflow: hidden; min-width: 40px; }
.ins-hash-bar { height: 100%; background: rgba(240,180,41,.5); border-radius: var(--radius); transition: width .5s ease; }
.ins-ngram-bar { height: 100%; background: rgba(168,85,247,.5); border-radius: var(--radius); transition: width .5s ease; }
.ins-daybar-bar { height: 100%; background: rgba(34,197,94,.5); border-radius: var(--radius); transition: width .5s ease; }
.ins-hash-stats { display: flex; gap: 8px; flex-shrink: 0; font-family: var(--mono); font-size: 8px; }
.ins-hash-count { color: var(--text2); min-width: 28px; text-align: right; }
.ins-hash-er { min-width: 50px; text-align: right; }

/* N-grams */
.ins-ngram-list { display: flex; flex-direction: column; gap: 4px; max-height: 440px; overflow-y: auto; }
.ins-ngram-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.ins-ngram-phrase {
  font-size: 10px; color: var(--text); width: 140px; flex-shrink: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-style: italic;
}

/* Emojis */
.ins-emoji-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 8px; max-height: 440px; overflow-y: auto;
}
.ins-emoji-chip {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--radius); transition: var(--transition);
}
.ins-emoji-chip:hover { border-color: var(--accent); }
.ins-emoji-glyph { font-size: 22px; line-height: 1; }
.ins-emoji-stats { text-align: center; }
.ins-emoji-count { font-family: var(--mono); font-size: 9px; color: var(--text2); font-weight: 600; }
.ins-emoji-er { font-family: var(--mono); font-size: 8px; color: var(--green); }

/* Heatmap */
.ins-heat { display: flex; flex-direction: column; gap: 2px; overflow-x: auto; }
.ins-heat-row { display: grid; grid-template-columns: 32px repeat(24, 1fr); gap: 2px; align-items: center; }
.ins-heat-label { font-family: var(--mono); font-size: 8px; color: var(--text3); text-align: right; padding-right: 4px; }
.ins-heat-cell {
  aspect-ratio: 1; border-radius: 2px; background: var(--bg3);
  min-height: 14px; transition: transform .15s;
}
.ins-heat-cell:hover { transform: scale(1.3); border: 1px solid var(--accent); }
.ins-heat-hours .ins-heat-hour {
  font-family: var(--mono); font-size: 9px; color: var(--text3); text-align: center;
}

/* Day bars */
.ins-daybar-list { display: flex; flex-direction: column; gap: 6px; }
.ins-daybar-row { display: flex; align-items: center; gap: 8px; }
.ins-daybar-label { font-family: var(--mono); font-size: 9px; color: var(--text2); width: 32px; flex-shrink: 0; }
.ins-daybar-val { font-family: var(--mono); font-size: 9px; color: var(--green); min-width: 42px; text-align: right; flex-shrink: 0; }

/* Trending */
.ins-trend-list { display: flex; flex-direction: column; gap: 3px; max-height: 240px; overflow-y: auto; }
.ins-trend-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  border-radius: var(--radius); background: var(--bg2); border: 1px solid var(--line);
}
.ins-trend-word { flex: 1; font-size: 10px; font-weight: 500; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-trend-mult { font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--green); flex-shrink: 0; min-width: 40px; }
.ins-trend-counts { font-family: var(--mono); font-size: 8px; color: var(--text3); flex-shrink: 0; }

/* Filter bar */
.ins-filter-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--bg1); border: 1px solid var(--line);
  border-radius: var(--radius-lg); margin-bottom: 2px; flex-wrap: wrap;
}
.ins-filter-label { font-family: var(--mono); font-size: 9px; color: var(--text3); text-transform: uppercase; letter-spacing: .1em; }
.ins-filter-select {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--radius);
  color: var(--text); padding: 5px 10px; font-size: 10px; font-family: var(--mono);
  cursor: pointer; min-width: 140px;
}
.ins-filter-select:hover { border-color: var(--accent); }
.ins-filter-btn {
  background: rgba(240,180,41,.08); border: 1px solid rgba(240,180,41,.3);
  color: var(--accent); border-radius: var(--radius); padding: 5px 12px;
  font-size: 10px; font-family: var(--mono); cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}
.ins-filter-btn:hover { background: rgba(240,180,41,.15); }

/* Niche keyword filter — composite control (toggle + edit) */
.ins-niche-box {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--line2); border-radius: var(--radius);
  background: var(--bg2); overflow: hidden;
}
.ins-niche-box.on { border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.05); }
.ins-niche-box.off { border-color: var(--line2); background: var(--bg2); opacity: .7; }
.ins-niche-toggle, .ins-niche-edit {
  background: transparent; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 10px;
  padding: 5px 10px; display: inline-flex; align-items: center; gap: 5px;
  color: var(--text2); transition: background .15s;
}
.ins-niche-box.on .ins-niche-toggle { color: var(--green); font-weight: 600; }
.ins-niche-toggle:hover { background: rgba(255,255,255,.03); }
.ins-niche-edit {
  border-left: 1px solid var(--line);
  color: var(--text3);
}
.ins-niche-edit:hover { background: rgba(255,255,255,.03); color: var(--accent); }
.ins-niche-preview { font-size: 9px; }
.ins-niche-pencil { font-size: 10px; opacity: .7; }

.ins-filter-match {
  font-family: var(--mono); font-size: 9px; color: var(--text3);
  white-space: nowrap; padding: 0 4px;
}

/* Copy-all buttons in card titles */
.ins-copy-btn {
  background: transparent; border: 1px solid var(--line2); color: var(--text3);
  border-radius: 4px; padding: 2px 7px; font-size: 11px; cursor: pointer;
  transition: var(--transition); line-height: 1;
}
.ins-copy-btn:hover { background: var(--bg3); color: var(--accent); border-color: var(--accent); }

/* AI title generator */
.ins-gen-card { border-color: rgba(168,85,247,.25); background: linear-gradient(180deg, rgba(168,85,247,.03) 0%, var(--bg1) 100%); }
.ins-gen-btn {
  background: rgba(168,85,247,.1); border: 1px solid rgba(168,85,247,.4);
  color: var(--purple, #a855f7); border-radius: var(--radius); padding: 5px 14px;
  font-size: 10px; font-family: var(--mono); font-weight: 600;
  cursor: pointer; transition: var(--transition); display: inline-flex; align-items: center;
}
.ins-gen-btn:hover:not(:disabled) { background: rgba(168,85,247,.2); }
.ins-gen-btn:disabled { opacity: .6; cursor: not-allowed; }
.ins-gen-list { display: flex; flex-direction: column; gap: 4px; }
.ins-gen-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--line);
}
.ins-gen-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 6px;
  border-radius: var(--radius); border-left: 2px solid transparent;
  transition: var(--transition);
}
.ins-gen-row:hover { background: var(--bg3); border-left-color: var(--purple, #a855f7); }
.ins-gen-body { flex: 1; min-width: 0; }
.ins-gen-title {
  font-size: 12px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 2px;
}
.ins-gen-meta { font-family: var(--mono); font-size: 8px; color: var(--text3); }
