/* ============================================================
   Planner 5D Marketing Intel — Light Brand Theme
   Clean, professional SaaS aesthetic matching planner5d.com
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* Planner 5D brand */
  --p5d: #1a9c42;
  --p5d-light: #22c55e;
  --p5d-dim: rgba(26, 156, 66, 0.08);
  --p5d-glow: rgba(26, 156, 66, 0.15);
  --p5d-dark: #148535;

  /* Competitors */
  --homestyler: #3b82f6;
  --homestyler-dim: rgba(59, 130, 246, 0.08);
  --roomsketcher: #f97316;
  --roomsketcher-dim: rgba(249, 115, 22, 0.08);

  /* Surfaces */
  --bg: #f8faf9;
  --bg-alt: #f0f4f2;
  --surface: #ffffff;
  --surface-hover: #f5f8f6;
  --border: #e2e8e4;
  --border-light: #eef2ef;

  /* Text */
  --text: #1a2e23;
  --text-secondary: #4a6355;
  --text-muted: #8a9e92;

  /* Status */
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.08);
  --amber: #d97706;
  --amber-dim: rgba(217, 119, 6, 0.08);

  /* Typography */
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'IBM Plex Mono', 'SF Mono', monospace;

  /* Spacing & shape */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --transition: 200ms ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 72px;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-title {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-logo { height: 28px; width: auto; }

.site-title-text {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.site-title-text span {
  color: var(--text-muted);
  font-weight: 400;
}

/* Nav */
.site-nav {
  display: flex;
  gap: 4px;
  margin-left: 32px;
}

.nav-link {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 20px;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover { background: var(--p5d-dim); color: var(--p5d); }
.nav-link.active { background: var(--p5d); color: white; }

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

.site-sync {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.admin-controls { display: flex; gap: 8px; align-items: center; }
.admin-controls.hidden { display: none; }

.btn-fetch {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: white;
  background: var(--p5d);
  border: none;
  border-radius: var(--radius-xs);
  padding: 7px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), transform var(--transition);
}

.btn-fetch:hover { background: var(--p5d-dark); }
.btn-fetch:active { transform: scale(0.97); }
.btn-fetch .spinner {
  display: none; width: 12px; height: 12px;
  border: 1.5px solid rgba(255,255,255,0.3); border-top-color: white;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.btn-fetch.loading .spinner { display: inline-block; }
.btn-fetch.loading .icon-refresh { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Main Layout: Two-Column Split ── */
.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Panel Headers ── */
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.panel-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.panel-icon.ig { background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); color: white; }
.panel-icon.reddit { background: #ff4500; color: white; border-radius: 50%; }

.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.panel-link {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--p5d);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity var(--transition);
}

.panel-link:hover { opacity: 0.7; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.card-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Scorecard (3-col comparison) ── */
.scorecard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.score-item {
  text-align: center;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border-light);
}

.score-item.winner {
  border-color: var(--p5d);
  background: var(--p5d-dim);
}

.score-account {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.score-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.score-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
}

.score-value .unit {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.score-value .star {
  color: var(--p5d);
  font-size: 14px;
}

.score-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.score-note {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-xs);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.score-note strong { color: var(--p5d); font-weight: 600; }

/* ── Content Mix ── */
.mix-account {
  margin-bottom: 14px;
}

.mix-account:last-child { margin-bottom: 0; }

.mix-account-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mix-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.mix-type {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  width: 60px;
  text-align: right;
}

.mix-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--bg-alt);
  border-radius: 3px;
  overflow: hidden;
}

.mix-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.mix-pct {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  width: 32px;
}

/* ── Top Posts ── */
.top-post {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border-light);
  margin-bottom: 8px;
  transition: border-color var(--transition);
}

.top-post:last-child { margin-bottom: 0; }
.top-post:hover { border-color: var(--border); }

.top-post-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.post-type-badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--p5d-dim);
  color: var(--p5d);
}

.post-type-badge.carousel { background: var(--homestyler-dim); color: var(--homestyler); }
.post-type-badge.static { background: var(--roomsketcher-dim); color: var(--roomsketcher); }

.top-post-caption {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.top-post-stats {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
}

/* ── Heatmap ── */
.heatmap-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.heatmap-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  width: 86px;
  text-align: right;
  flex-shrink: 0;
}

.heatmap-cells { display: flex; gap: 2px; flex: 1; overflow: hidden; }

.heatmap-cell {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.heatmap-cell:hover { outline: 1px solid var(--text-muted); }

.heatmap-cell-0 { background: var(--bg-alt); }
.heatmap-cell-1 { background: rgba(26, 156, 66, 0.15); }
.heatmap-cell-2 { background: rgba(26, 156, 66, 0.35); }
.heatmap-cell-3 { background: rgba(26, 156, 66, 0.6); }

/* ── Reddit Signal Overview ── */
.signal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.signal-stat {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border-light);
  text-align: center;
}

.signal-number {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.signal-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.mention-bar {
  grid-column: 1 / -1;
  display: flex;
  gap: 16px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.mention-item {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.mention-item strong {
  font-family: var(--mono);
  font-weight: 600;
}

/* ── Reddit Thread Cards ── */
.thread-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border-light);
  margin-bottom: 8px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.thread-card:last-child { margin-bottom: 0; }
.thread-card:hover { border-color: var(--border); box-shadow: var(--shadow-sm); }

.thread-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.intent-badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--p5d-dim);
  color: var(--p5d);
}

.subreddit-badge {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 2px 8px;
}

.thread-score {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.thread-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 8px;
}

.thread-title a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}

.thread-title a:hover { color: var(--p5d); }

.thread-mentions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.mention-pill {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid;
}

.mention-pill.planner5d { color: var(--p5d); border-color: rgba(26, 156, 66, 0.3); background: var(--p5d-dim); }
.mention-pill.homestyler { color: var(--homestyler); border-color: rgba(59, 130, 246, 0.3); background: var(--homestyler-dim); }
.mention-pill.roomsketcher { color: var(--roomsketcher); border-color: rgba(249, 115, 22, 0.3); background: var(--roomsketcher-dim); }
.mention-pill.not-mentioned { color: var(--red); border-color: rgba(220, 38, 38, 0.3); background: var(--red-dim); }

.thread-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
}

/* ── Subreddit Breakdown ── */
.sub-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.sub-row:last-child { margin-bottom: 0; }

.sub-name {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-secondary);
  width: 120px;
  text-align: right;
  flex-shrink: 0;
}

.sub-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--bg-alt);
  border-radius: 4px;
  overflow: hidden;
}

.sub-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: #ff4500;
  opacity: 0.7;
}

.sub-members {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  width: 40px;
}

/* ── Content Gaps ── */
.gap-row {
  display: grid;
  grid-template-columns: 1fr 1fr 56px;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
}

.gap-row:last-child { border-bottom: none; }

.gap-bar-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gap-topic {
  font-size: 12px;
  color: var(--text);
  min-width: 80px;
}

.gap-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--bg-alt);
  border-radius: 3px;
  overflow: hidden;
}

.gap-bar-fill { height: 100%; border-radius: 3px; }

.gap-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  width: 20px;
  text-align: right;
}

.gap-status {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-align: center;
}

.gap-status.match { color: var(--p5d); }
.gap-status.low { color: var(--amber); }
.gap-status.gap { color: var(--red); }

.gap-header {
  display: grid;
  grid-template-columns: 1fr 1fr 56px;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.gap-header span {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.gap-summary {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  background: var(--red-dim);
  font-size: 12px;
  color: var(--text-secondary);
}

.gap-summary strong { color: var(--red); font-weight: 600; }

/* ── Fetch Log ── */
.fetch-log-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px;
}

.fetch-log {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  max-height: 200px;
  overflow-y: auto;
}

.fetch-log.visible { display: block; }

.fetch-log pre {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.fetch-log .log-error { color: var(--red); }

/* ── View All link ── */
.card-footer-link {
  display: block;
  text-align: center;
  padding: 10px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--p5d);
  text-decoration: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-xs);
  transition: background var(--transition), border-color var(--transition);
}

.card-footer-link:hover {
  background: var(--p5d-dim);
  border-color: var(--p5d);
}

/* ── Footer ── */
.site-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(248, 250, 249, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  z-index: 50;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-stat {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.footer-stat span { color: var(--text-secondary); font-weight: 500; }
.footer-sep { color: var(--border); }

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

/* ── Full-width page layout (Instagram / Reddit pages) ── */
.page-full {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── IG Page: Account Selector Tabs ── */
.account-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.account-tab {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}

.account-tab:hover { border-color: var(--text-muted); }
.account-tab.active { background: var(--p5d); color: white; border-color: var(--p5d); }
.account-tab .tab-dot { width: 6px; height: 6px; border-radius: 50%; }
.account-tab.active .tab-dot { background: rgba(255,255,255,0.6); }

/* ── IG Page: Metrics Grid ── */
.ig-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.ig-metric-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.ig-metric-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.ig-metric-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
}

.ig-metric-value .unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.ig-metric-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── IG Page: Two-column sections ── */
.ig-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* ── IG Page: Posts table ── */
.posts-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.posts-table th {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.posts-table td {
  font-size: 13px;
  color: var(--text);
  padding: 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.posts-table tr:hover td { background: var(--surface-hover); }

.posts-table .caption-cell {
  max-width: 300px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.posts-table .mono {
  font-family: var(--mono);
  font-size: 12px;
}

.posts-table .type-badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* ── IG Page: Comparison table ── */
.comparison-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.comparison-col {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.comparison-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.comparison-col-name {
  font-size: 13px;
  font-weight: 600;
}

.comparison-col-followers {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.comparison-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
}

.comparison-row-label {
  font-size: 12px;
  color: var(--text-muted);
}

.comparison-row-value {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.comparison-row-value.best { color: var(--p5d); font-weight: 600; }

/* ── IG Profile Bar ── */
.ig-profile-bar {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

.ig-profile-info { flex: 1; min-width: 200px; }

.ig-profile-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.ig-profile-handle {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--p5d);
  margin-bottom: 6px;
}

.ig-profile-bio {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.ig-profile-stats {
  display: flex;
  gap: 24px;
  flex-shrink: 0;
}

.ig-profile-stat { text-align: center; }

.ig-profile-stat-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.ig-profile-stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Competitor Section ── */
.ig-competitor-section {
  margin-bottom: 32px;
  padding-top: 24px;
  border-top: 2px solid var(--border);
}

.ig-competitor-section:first-child { border-top: none; padding-top: 0; }

.ig-competitor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ig-competitor-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.ig-competitor-followers {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.ig-vs-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg);
  border: 1px solid var(--border-light);
}

/* ── VS Comparison Table ── */
.vs-table {
  display: flex;
  flex-direction: column;
}

.vs-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 80px;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
}

.vs-row:last-child { border-bottom: none; }

.vs-header-row {
  border-bottom: 1px solid var(--border);
}

.vs-header-row .vs-cell {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.vs-cell {
  font-size: 13px;
  color: var(--text);
}

.vs-metric-name {
  font-size: 12px;
  color: var(--text-secondary);
}

.vs-p5d, .vs-comp {
  font-family: var(--mono);
  font-size: 13px;
  text-align: center;
}

.vs-winner {
  font-weight: 600;
  color: var(--p5d);
}

.vs-verdict {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

/* ── Breadcrumbs ── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumb-link {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--p5d);
  text-decoration: none;
  transition: opacity var(--transition);
}

.breadcrumb-link:hover { opacity: 0.7; }

.breadcrumb-sep {
  font-size: 11px;
  color: var(--text-muted);
}

.breadcrumb-current {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Status Badges ── */
.status-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}

.status-done { background: rgba(26, 156, 66, 0.1); color: var(--p5d); }
.status-in-progress { background: var(--amber-dim); color: var(--amber); }
.status-pending { background: var(--bg-alt); color: var(--text-muted); }

/* ── Progress Bar ── */
.progress-bar {
  height: 4px;
  background: var(--bg-alt);
  border-radius: 2px;
  margin-bottom: 24px;
  display: flex;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--p5d);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.progress-fill.progress-ip { background: var(--amber); }

/* ── Children Grid ── */
.children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.child-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}

.child-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--p5d);
  transform: translateY(-2px);
}

.child-card .status-badge { margin-bottom: 10px; }

.child-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}

.child-card-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.child-card-hypothesis {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mini-progress {
  height: 3px;
  background: var(--bg-alt);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}

.mini-progress-fill {
  height: 100%;
  background: var(--p5d);
  border-radius: 2px;
}

/* ── Root Summary ── */
.root-summary { margin-bottom: 24px; }

.root-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.root-metric {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.root-metric-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.root-metric-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.root-metric-source {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Hypothesis / Finding cards ── */
.hypothesis-card {
  border-left: 3px solid var(--amber);
}

.hypothesis-text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  font-style: italic;
}

.method-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.finding-card {
  border-left: 3px solid var(--p5d);
  background: rgba(26, 156, 66, 0.03);
}

.finding-text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  font-weight: 500;
}

/* Pending state */
.pending-card {
  text-align: center;
  padding: 40px 24px;
  background: var(--bg-alt);
  border: 1px dashed var(--border);
}

.pending-icon { font-size: 32px; color: var(--text-muted); margin-bottom: 8px; }
.pending-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.pending-text { font-size: 13px; color: var(--text-muted); max-width: 400px; margin: 0 auto; }

/* ── Sibling Navigation ── */
.sibling-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

.sibling-link {
  font-size: 13px;
  color: var(--p5d);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity var(--transition);
}

.sibling-link:hover { opacity: 0.7; }
.sibling-next { margin-left: auto; }
.sibling-arrow { font-size: 16px; }

/* ── Placeholder page ── */
.placeholder-page {
  text-align: center;
  padding: 80px 24px;
}

.placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.placeholder-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.placeholder-text {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 400px;
  margin: 0 auto;
}

/* ════════════════════════════════════════════════════════════════
   DASHBOARD STYLES
   ════════════════════════════════════════════════════════════════ */

.dash-page { padding-bottom: 64px; }
.dash-loading { text-align: center; padding: 80px 24px; color: var(--text-muted); font-size: 16px; }
.dash-empty { text-align: center; padding: 32px; color: var(--text-muted); font-style: italic; }
.dash-error { text-align: center; padding: 32px; color: var(--red); }
.dash-more { text-align: center; padding: 16px; color: var(--text-muted); font-size: 13px; }

/* Hero */
.dash-hero { margin-bottom: 32px; padding: 32px 0; border-bottom: 2px solid var(--border); }
.dash-hero-title { font-size: 28px; font-weight: 700; color: var(--text); margin: 0 0 8px; }
.dash-hero-sub { font-size: 14px; color: var(--text-secondary); margin: 0; }
.dash-hero-overview { text-align: center; padding: 48px 0; }

/* KPI Row */
.dash-kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }
.dash-kpi { background: var(--surface); border: 1px solid var(--border-light); border-left: 4px solid var(--p5d); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.dash-kpi-value { font-family: var(--mono); font-size: 28px; font-weight: 700; color: var(--text); }
.dash-kpi-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-top: 4px; }
.dash-kpi-detail { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Insight cards */
.dash-insight { display: flex; gap: 16px; align-items: flex-start; padding: 20px; border-radius: var(--radius); margin-bottom: 24px; background: #fef3c7; border: 1px solid #f59e0b33; }
.dash-insight-warning { background: #fef3c7; border-color: #f59e0b33; }
.dash-insight-info { background: #dbeafe; border-color: #3b82f633; }
.dash-insight-opportunity { background: #dcfce7; border-color: #22c55e33; }
.dash-insight-icon { font-size: 24px; flex-shrink: 0; }
.dash-insight-text { font-size: 14px; color: var(--text); line-height: 1.5; }
.dash-insights { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }

/* Section headers */
.dash-section-header { margin: 40px 0 16px; padding-top: 24px; border-top: 1px solid var(--border-light); }
.dash-section-title { font-size: 20px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.dash-section-sub { font-size: 13px; color: var(--text-muted); margin: 0; }

/* Timeline chart */
.dash-timeline { display: flex; gap: 4px; align-items: flex-end; height: 160px; padding: 16px 0; overflow-x: auto; margin-bottom: 24px; }
.dash-timeline-bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 24px; flex: 1; }
.dash-timeline-fill { width: 100%; max-width: 20px; background: var(--p5d); border-radius: 3px 3px 0 0; opacity: 0.8; transition: opacity 0.2s; cursor: default; }
.dash-timeline-fill:hover { opacity: 1; }
.dash-timeline-label { font-family: var(--mono); font-size: 9px; color: var(--text-muted); margin-top: 6px; writing-mode: vertical-rl; text-orientation: mixed; transform: rotate(180deg); height: 24px; }
.dash-timeline-count { font-family: var(--mono); font-size: 9px; color: var(--text-secondary); margin-top: 2px; }

/* Authors */
.dash-authors { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 24px; }
.dash-author-card { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.dash-author-name { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.dash-author-count { font-family: var(--mono); font-size: 13px; color: var(--p5d); font-weight: 600; margin-bottom: 8px; }
.dash-author-subs { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.dash-author-thread { display: block; font-size: 12px; color: var(--text-secondary); text-decoration: none; padding: 4px 0; border-top: 1px solid var(--border-light); transition: color 0.2s; }
.dash-author-thread:hover { color: var(--p5d); }

/* Language bars */
.dash-lang { margin-bottom: 24px; }
.dash-lang-row { display: grid; grid-template-columns: 100px 1fr 120px; gap: 12px; align-items: center; padding: 8px 0; }
.dash-lang-label { font-size: 13px; font-weight: 600; color: var(--text); }
.dash-lang-bar { height: 24px; background: var(--bg-alt); border-radius: 4px; overflow: hidden; }
.dash-lang-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.dash-lang-count { font-family: var(--mono); font-size: 12px; color: var(--text-secondary); text-align: right; }

/* Subreddit breakdown bars */
.dash-sub-list { margin-bottom: 24px; }
.dash-sub-row { display: grid; grid-template-columns: 180px 1fr 50px 100px; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border-light); }
.dash-sub-name { font-size: 13px; font-weight: 600; color: var(--text); }
.dash-sub-bar { height: 16px; background: var(--bg-alt); border-radius: 3px; overflow: hidden; }
.dash-sub-fill { height: 100%; background: var(--p5d); border-radius: 3px; opacity: 0.7; }
.dash-sub-count { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); text-align: right; }
.dash-sub-date { font-family: var(--mono); font-size: 11px; color: var(--text-muted); text-align: right; }

/* Comments list */
.dash-comments { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.dash-comment-card { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.dash-comment-negative { border-left: 4px solid var(--red); }
.dash-comment-positive { border-left: 4px solid var(--p5d); }
.dash-comment-official { border-left: 4px solid var(--amber); background: #fef3c7; }
.dash-comment-header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.dash-comment-author { font-size: 12px; font-weight: 600; color: var(--text); }
.dash-comment-date { font-size: 11px; color: var(--text-muted); }
.dash-comment-score { font-family: var(--mono); font-size: 11px; color: var(--text-secondary); }
.dash-comment-thread { display: block; font-size: 12px; color: var(--p5d); text-decoration: none; margin-bottom: 8px; }
.dash-comment-thread:hover { text-decoration: underline; }
.dash-comment-body { font-size: 13px; color: var(--text-secondary); line-height: 1.5; font-style: italic; }

/* Sub badge */
.sub-badge { font-family: var(--mono); font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px; background: var(--p5d-dim); color: var(--p5d-dark); white-space: nowrap; }

/* Thread table */
.dash-thread-table-wrap { overflow-x: auto; margin-bottom: 24px; }
.dash-thread-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-thread-table th { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); text-align: left; padding: 8px 12px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.dash-thread-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-light); color: var(--text); vertical-align: top; }
.dash-thread-table .mono { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.dash-thread-table .thread-title { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-row-official { background: #fef3c7; }
.dash-row-has-p5d { background: rgba(26, 156, 66, 0.04); }
.evidence-link { font-family: var(--mono); font-size: 11px; color: var(--p5d); text-decoration: none; }
.evidence-link:hover { text-decoration: underline; }
.badge-official { color: var(--amber); font-size: 16px; }

/* Thread evidence page */
.dash-back { display: inline-block; font-size: 13px; color: var(--p5d); text-decoration: none; margin-bottom: 24px; }
.dash-back:hover { text-decoration: underline; }
.dash-thread-header { margin-bottom: 24px; }
.dash-thread-sub { font-family: var(--mono); font-size: 12px; color: var(--p5d); margin-bottom: 8px; }
.dash-thread-title { font-size: 22px; font-weight: 700; color: var(--text); margin: 0 0 8px; line-height: 1.3; }
.dash-thread-meta { font-size: 13px; color: var(--text-muted); }
.dash-thread-body { background: var(--bg-alt); padding: 20px; border-radius: var(--radius); font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 24px; white-space: pre-wrap; word-wrap: break-word; max-height: 400px; overflow-y: auto; }
.dash-p5d-where { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 24px; padding: 12px 16px; background: var(--p5d-dim); border-radius: var(--radius); }
.badge-where { font-family: var(--mono); font-size: 11px; padding: 3px 10px; border-radius: 10px; background: var(--p5d); color: white; }
.badge-p5d { font-family: var(--mono); font-size: 10px; padding: 2px 8px; border-radius: 10px; background: var(--p5d); color: white; margin-left: 8px; }

/* Comment tree */
.dash-comment-tree { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.dash-tree-comment { background: var(--surface); border: 1px solid var(--border-light); border-radius: 8px; padding: 12px 16px; }
.dash-tree-header { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.dash-tree-body { font-size: 13px; color: var(--text); line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.dash-highlight-p5d { border-left: 3px solid var(--p5d); background: rgba(26, 156, 66, 0.04); }
.dash-highlight-official { border-left: 3px solid var(--amber); background: #fef3c7; }

/* Nav cards (overview) */
.dash-nav-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-bottom: 40px; }
.dash-nav-card { display: block; background: var(--surface); border: 1px solid var(--border-light); border-left: 4px solid var(--p5d); border-radius: var(--radius); padding: 24px; text-decoration: none; color: inherit; box-shadow: var(--shadow-sm); transition: all 0.2s; }
.dash-nav-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-left-color: var(--p5d); }
.dash-nav-icon { font-size: 28px; margin-bottom: 12px; }
.dash-nav-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.dash-nav-desc { font-size: 13px; color: var(--text-muted); }

/* Content bridge */
.dash-bridge-chart { margin-bottom: 24px; }
.dash-bridge-row { display: grid; grid-template-columns: 160px 1fr 60px; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.dash-bridge-topic { font-size: 13px; font-weight: 600; color: var(--text); }
.dash-bridge-bars { display: flex; flex-direction: column; gap: 4px; }
.dash-bridge-bar { height: 20px; border-radius: 3px; font-family: var(--mono); font-size: 10px; color: white; display: flex; align-items: center; padding-left: 8px; min-width: 4px; }
.dash-bridge-bar.reddit { background: var(--p5d); opacity: 0.8; }
.dash-bridge-bar.ig { background: var(--homestyler); opacity: 0.7; }
.dash-bridge-gap { font-family: var(--mono); font-size: 13px; font-weight: 700; text-align: center; }
.gap-positive { color: var(--red); }
.gap-negative { color: var(--p5d); }
.gap-zero { color: var(--text-muted); }
.dash-bridge-legend { display: flex; gap: 16px; justify-content: center; margin-bottom: 24px; font-size: 12px; color: var(--text-muted); }
.legend-reddit { color: var(--p5d); }
.legend-ig { color: var(--homestyler); }

/* Recommendations */
.dash-recs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 24px; }
.dash-rec-card { background: var(--surface); border: 1px solid var(--border-light); border-left: 4px solid var(--red); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.dash-rec-topic { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.dash-rec-stat { font-family: var(--mono); font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.dash-rec-examples { font-size: 12px; }
.dash-rec-ex-label { font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.dash-rec-ex-link { display: block; color: var(--p5d); text-decoration: none; padding: 2px 0; }
.dash-rec-ex-link:hover { text-decoration: underline; }

/* Language badges */
.lang-badge { font-family: var(--mono); font-size: 10px; padding: 2px 8px; border-radius: 10px; }
.lang-english { background: var(--p5d-dim); color: var(--p5d-dark); }
.lang-portuguese { background: #ede9fe; color: #7c3aed; }
.lang-spanish { background: #fef3c7; color: #d97706; }
.lang-russian { background: #fee2e2; color: #dc2626; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .dashboard { grid-template-columns: 1fr; padding: 16px; }
  .header-inner { padding: 0 16px; }
  .site-nav { display: none; }
  .fetch-log-wrapper { padding: 0 16px; }
  .page-full { padding: 16px; }
  .ig-metrics-grid { grid-template-columns: 1fr; }
  .ig-columns { grid-template-columns: 1fr; }
  .comparison-grid { grid-template-columns: 1fr; }
}
