/* Influencer Environment Explorer — TikTok-style SaaS layout */

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

:root {
  --ie-sidebar-w: 220px;
  --ie-topbar-h: 52px;
  --ie-bg: #f5f6fa;
  --ie-sidebar-bg: #ffffff;
  --ie-sidebar-text: #5c6370;
  --ie-sidebar-active: #fe2c55;
  --ie-sidebar-hover: #f4f4f8;
  --ie-accent: #fe2c55;
  --ie-accent-soft: #fff1f3;
  --ie-green: #16a34a;
  --ie-green-soft: #dcfce7;
  --ie-amber: #d97706;
  --ie-amber-soft: #fef3c7;
  --ie-red: #dc2626;
  --ie-red-soft: #fee2e2;
  --ie-border: #e8eaef;
  --ie-text: #1e293b;
  --ie-text-mid: #64748b;
  --ie-text-dim: #94a3b8;
  --ie-card-bg: #fff;
  --ie-radius: 10px;
  --ie-radius-sm: 6px;
  --ie-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
  --ie-shadow-hover: 0 4px 12px rgba(0,0,0,0.07);
  --ie-transition: 0.2s ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--ie-bg);
  color: var(--ie-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ── */
.ie-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--ie-topbar-h);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ie-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}
.ie-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ie-topbar-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--ie-text);
  letter-spacing: -0.02em;
}
.ie-topbar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--ie-accent-soft);
  color: var(--ie-accent);
  padding: 3px 10px;
  border-radius: 4px;
  font-weight: 600;
}
.ie-topbar-back {
  font-size: 13px;
  color: var(--ie-accent);
  text-decoration: none;
  font-weight: 500;
  transition: opacity var(--ie-transition);
}
.ie-topbar-back:hover { opacity: 0.7; }

/* ── Layout ── */
.ie-layout {
  display: flex;
  margin-top: var(--ie-topbar-h);
  min-height: calc(100vh - var(--ie-topbar-h));
}

/* ── Sidebar ── */
.ie-sidebar {
  position: fixed;
  top: var(--ie-topbar-h);
  left: 0;
  bottom: 0;
  width: var(--ie-sidebar-w);
  background: var(--ie-sidebar-bg);
  border-right: 1px solid var(--ie-border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
}
.ie-nav {
  list-style: none;
  padding: 12px 10px;
}
.ie-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: var(--ie-sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--ie-transition);
  border-radius: 7px;
  margin-bottom: 2px;
}
.ie-nav-item:hover {
  background: var(--ie-sidebar-hover);
  color: var(--ie-text);
}
.ie-nav-item.active {
  background: var(--ie-accent-soft);
  color: var(--ie-sidebar-active);
  font-weight: 600;
}
.ie-nav-item.active svg { stroke: var(--ie-sidebar-active); }
.ie-sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--ie-border);
}
.ie-data-label {
  font-size: 11px;
  color: var(--ie-text-dim);
}

/* ── Content area ── */
.ie-content {
  margin-left: var(--ie-sidebar-w);
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
}

/* ── Loading ── */
@keyframes ie-spin {
  to { transform: rotate(360deg); }
}
.ie-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 300px;
  color: var(--ie-text-dim);
  font-size: 14px;
}
.ie-loading::before {
  content: '';
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--ie-border);
  border-top-color: var(--ie-accent);
  border-radius: 50%;
  animation: ie-spin 0.7s linear infinite;
}

/* ── Section titles ── */
.ie-section-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--ie-text);
  letter-spacing: -0.02em;
}
.ie-section-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--ie-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ie-border);
}

/* ── KPI strip ── */
.ie-kpi-strip {
  display: flex;
  background: var(--ie-card-bg);
  border: 1px solid var(--ie-border);
  border-radius: var(--ie-radius);
  box-shadow: var(--ie-shadow);
  margin-bottom: 24px;
  overflow: hidden;
}
.ie-kpi {
  flex: 1;
  padding: 16px 20px;
  border-right: 1px solid var(--ie-border);
  min-width: 0;
}
.ie-kpi:last-child { border-right: none; }
.ie-kpi-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--ie-text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.ie-kpi-val.ie-kpi-alert { color: var(--ie-red); }
.ie-kpi-label {
  font-size: 10px;
  color: var(--ie-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.ie-kpi-sub {
  font-size: 11px;
  color: var(--ie-text-dim);
  margin-top: 1px;
}

/* ── Metric cards ── */
.ie-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.ie-metric-card {
  background: var(--ie-card-bg);
  border: 1px solid var(--ie-border);
  border-radius: var(--ie-radius);
  padding: 14px 16px;
  box-shadow: var(--ie-shadow);
}
.ie-metric-label {
  font-size: 10px;
  color: var(--ie-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.ie-metric-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--ie-text);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.ie-metric-delta {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}
.ie-metric-delta.up { color: var(--ie-green); }
.ie-metric-delta.down { color: var(--ie-red); }

/* ── Tables ── */
.ie-table-wrap {
  background: var(--ie-card-bg);
  border: 1px solid var(--ie-border);
  border-radius: var(--ie-radius);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--ie-shadow);
}
.ie-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ie-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ie-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbfc;
  border-bottom: 1px solid var(--ie-border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
  transition: color var(--ie-transition);
}
.ie-table th:hover { color: var(--ie-accent); }
.ie-table th .sort-arrow { font-size: 10px; margin-left: 3px; opacity: 0.4; }
.ie-table th .sort-arrow.active { opacity: 1; color: var(--ie-accent); }
.ie-table td {
  padding: 9px 14px;
  border-bottom: 1px solid #f0f1f3;
  color: var(--ie-text);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ie-table tr:nth-child(even) td { background: #fafbfc; }
.ie-table tr:last-child td { border-bottom: none; }
.ie-table tr:hover td { background: var(--ie-accent-soft); }

/* ── Pagination ── */
.ie-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--ie-text-dim);
  border-top: 1px solid var(--ie-border);
  background: #fafbfc;
}
.ie-pagination button {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--ie-border);
  border-radius: var(--ie-radius-sm);
  background: #fff;
  color: var(--ie-text-mid);
  cursor: pointer;
  transition: all var(--ie-transition);
}
.ie-pagination button:hover:not(:disabled) {
  border-color: var(--ie-accent);
  color: var(--ie-accent);
}
.ie-pagination button:disabled { opacity: 0.4; cursor: default; }

/* ── Badges ── */
.ie-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.ie-badge-good { background: var(--ie-green-soft); color: var(--ie-green); }
.ie-badge-warn { background: var(--ie-amber-soft); color: var(--ie-amber); }
.ie-badge-bad { background: var(--ie-red-soft); color: var(--ie-red); }
.ie-badge-neutral { background: #f1f5f9; color: var(--ie-text-mid); }
.ie-badge-accent { background: var(--ie-accent-soft); color: var(--ie-accent); }

/* ── Filter bar ── */
.ie-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.ie-filter-input {
  padding: 7px 12px;
  font-size: 13px;
  height: 36px;
  border: 1px solid var(--ie-border);
  border-radius: var(--ie-radius-sm);
  outline: none;
  width: 260px;
  background: var(--ie-card-bg);
  transition: border-color var(--ie-transition), box-shadow var(--ie-transition);
}
.ie-filter-input:focus {
  border-color: var(--ie-accent);
  box-shadow: 0 0 0 3px rgba(254,44,85,0.10);
}
.ie-filter-select {
  padding: 7px 10px;
  font-size: 13px;
  height: 36px;
  border: 1px solid var(--ie-border);
  border-radius: var(--ie-radius-sm);
  background: var(--ie-card-bg);
  color: var(--ie-text);
  outline: none;
  transition: border-color var(--ie-transition), box-shadow var(--ie-transition);
}
.ie-filter-select:focus {
  border-color: var(--ie-accent);
  box-shadow: 0 0 0 3px rgba(254,44,85,0.10);
}

/* ── Pills/tabs ── */
.ie-pills {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--ie-border);
  padding-bottom: 0;
}
.ie-pill {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ie-text-mid);
  cursor: pointer;
  transition: all var(--ie-transition);
  margin-bottom: -1px;
}
.ie-pill:hover { color: var(--ie-text); }
.ie-pill.active {
  color: var(--ie-accent);
  border-bottom-color: var(--ie-accent);
  font-weight: 600;
}

/* ── Expandable row detail ── */
.ie-row-detail {
  display: none;
  padding: 12px 14px;
  background: #f8f9fb;
  border-bottom: 1px solid var(--ie-border);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ie-text-mid);
}
.ie-row-detail.open { display: table-row; }
.ie-row-detail td { white-space: normal; max-width: none; }
.ie-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 24px;
}
.ie-detail-grid dt { font-weight: 600; color: var(--ie-text); }
.ie-detail-grid dd { margin: 0; color: var(--ie-text-mid); }

/* ── Competitor cards ── */
.ie-comp-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.ie-comp-card {
  background: var(--ie-card-bg);
  border: 1px solid var(--ie-border);
  border-radius: var(--ie-radius);
  padding: 16px;
  box-shadow: var(--ie-shadow);
}
.ie-comp-card.ours {
  border-color: var(--ie-accent);
  background: linear-gradient(135deg, var(--ie-accent-soft), #fff);
}
.ie-comp-domain {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--ie-text);
}
.ie-comp-stat {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 13px;
}
.ie-comp-stat span:first-child { color: var(--ie-text-mid); }
.ie-comp-stat span:last-child { font-weight: 600; }

/* ── Feed cards ── */
.ie-feed-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.ie-feed-card {
  background: var(--ie-card-bg);
  border: 1px solid var(--ie-border);
  border-radius: var(--ie-radius);
  padding: 16px;
  box-shadow: var(--ie-shadow);
  transition: box-shadow var(--ie-transition);
}
.ie-feed-card:hover { box-shadow: var(--ie-shadow-hover); }
.ie-feed-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.ie-feed-creator {
  font-weight: 700;
  font-size: 13px;
  color: var(--ie-text);
}
.ie-feed-caption {
  font-size: 13px;
  color: var(--ie-text-mid);
  line-height: 1.5;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ie-feed-stats {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--ie-text-dim);
}
.ie-feed-stats span { font-weight: 600; color: var(--ie-text); }

/* ── Hook distribution bars ── */
.ie-hook-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}
.ie-hook-label {
  min-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ie-text);
}
.ie-hook-track {
  flex: 1;
  height: 16px;
  background: #eef0f4;
  border-radius: 3px;
  overflow: hidden;
}
.ie-hook-fill {
  height: 100%;
  background: var(--ie-accent);
  border-radius: 3px;
  min-width: 2px;
}
.ie-hook-count {
  min-width: 44px;
  text-align: right;
  font-weight: 600;
  font-size: 12px;
  color: var(--ie-text-mid);
}

/* ── Tool list ── */
.ie-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.ie-tool-card {
  background: var(--ie-card-bg);
  border: 1px solid var(--ie-border);
  border-radius: var(--ie-radius-sm);
  padding: 12px 16px;
  box-shadow: var(--ie-shadow);
}
.ie-tool-name {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--ie-accent);
  margin-bottom: 4px;
}
.ie-tool-desc {
  font-size: 12px;
  color: var(--ie-text-mid);
  line-height: 1.5;
}
.ie-tool-type {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 6px;
}
.ie-tool-type.read { background: #dbeafe; color: #2563eb; }
.ie-tool-type.write { background: #fce7f3; color: #db2777; }

/* ── Issue count badges inline ── */
.ie-issue-count {
  display: inline-block;
  font-weight: 600;
  background: var(--ie-red-soft);
  color: var(--ie-red);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
}
.ie-issue-count.warn {
  background: var(--ie-amber-soft);
  color: var(--ie-amber);
}
.ie-issue-count.ok {
  background: var(--ie-green-soft);
  color: var(--ie-green);
}
