:root {
  --bg: #06060b;
  --surface: rgba(18, 18, 28, 0.8);
  --surface-solid: #12121c;
  --surface2: rgba(26, 26, 40, 0.9);
  --surface3: #22223a;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);
  --text: #f0f0f8;
  --text2: #7878a0;
  --text3: #4a4a6a;
  --accent: #fe2c55;
  --accent-glow: rgba(254,44,85,0.3);
  --cyan: #25f4ee;
  --cyan-glow: rgba(37,244,238,0.2);
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #f87171;
  --purple: #a78bfa;
  --pink: #f472b6;
  --orange: #fb923c;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Ambient background */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 20% 50%, rgba(254,44,85,0.04) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(37,244,238,0.03) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 80%, rgba(167,139,250,0.03) 0%, transparent 50%);
  z-index: -1;
  animation: ambientDrift 30s ease-in-out infinite alternate;
}
@keyframes ambientDrift {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-3%, 2%) rotate(3deg); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text3); border-radius: 3px; }

/* ── NAV ── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 64px;
  background: rgba(6,6,11,0.85);
  backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
  color: var(--text2);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}
.nav-links a:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-links a.active { color: var(--text); background: rgba(255,255,255,0.07); }
.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}
.nav-right { display: flex; align-items: center; gap: 1rem; }
.auto-refresh-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text2);
  cursor: pointer;
}
.auto-refresh-toggle input { accent-color: var(--accent); }

/* ── MAIN ── */
main { max-width: 1440px; margin: 0 auto; padding: 2rem; }
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; font-weight: 600; margin-bottom: 0.75rem; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }

/* ── BUTTONS ── */
.btn {
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  backdrop-filter: blur(10px);
}
.btn:hover { border-color: var(--border-hover); background: var(--surface3); transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #e0234a);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 4px 20px var(--accent-glow); transform: translateY(-1px); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(255,255,255,0.05); border-color: transparent; }
.btn-icon { padding: 0.4rem; border-radius: 8px; font-size: 1rem; line-height: 1; }
.btn-group { display: flex; gap: 0.35rem; }

/* ── HERO STATS ── */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.hero-stat {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.hero-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}
.hero-stat:nth-child(1)::before { background: linear-gradient(90deg, var(--accent), transparent); }
.hero-stat:nth-child(2)::before { background: linear-gradient(90deg, var(--cyan), transparent); }
.hero-stat:nth-child(3)::before { background: linear-gradient(90deg, var(--green), transparent); }
.hero-stat:nth-child(4)::before { background: linear-gradient(90deg, var(--purple), transparent); }
.hero-stat .label { font-size: 0.78rem; color: var(--text2); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.hero-stat .value { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; margin-top: 0.25rem; }
.hero-stat .delta { font-size: 0.78rem; font-weight: 600; margin-top: 0.25rem; display: inline-flex; align-items: center; gap: 0.25rem; padding: 2px 6px; border-radius: 6px; }
.delta-up { color: var(--green); background: rgba(74,222,128,0.1); }
.delta-down { color: var(--red); background: rgba(248,113,113,0.1); }
.delta-neutral { color: var(--text2); background: rgba(120,120,160,0.1); }

/* ── STAT CARDS ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; }
.stat-card .name { font-size: 1.05rem; font-weight: 600; }
.stat-card .rank {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.rank-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #000; }
.rank-2 { background: rgba(192,192,192,0.2); color: #ccc; }
.rank-3 { background: rgba(205,127,50,0.2); color: #cd7f32; }
.status { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.status-active { background: rgba(74,222,128,0.12); color: var(--green); }
.status-paused { background: rgba(251,191,36,0.12); color: var(--yellow); }
.status-archived { background: rgba(136,136,160,0.12); color: var(--text2); }
.stat-card .metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.stat-card .metric .label { font-size: 0.7rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .metric .value { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.color-accent { color: var(--accent); }
.color-cyan { color: var(--cyan); }
.color-green { color: var(--green); }
.color-purple { color: var(--purple); }
.color-yellow { color: var(--yellow); }
.stat-card .sparkline-row { margin-top: 1rem; height: 40px; }
.stat-card .score-bar {
  margin-top: 1rem;
  height: 4px;
  background: rgba(255,255,255,0.05);
  border-radius: 2px;
  overflow: hidden;
}
.stat-card .score-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 1s ease;
}

/* ── CHARTS ── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.chart-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.chart-box {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.chart-box .chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.chart-box .chart-title { font-size: 0.88rem; font-weight: 600; }
.chart-box .chart-subtitle { font-size: 0.75rem; color: var(--text2); }
@media (max-width: 1100px) { .chart-grid { grid-template-columns: 1fr; } .chart-grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 768px) { .hero-stats { grid-template-columns: 1fr 1fr; } }
@media (max-width: 500px) { .hero-stats { grid-template-columns: 1fr; } }

/* ── TABLES ── */
.table-wrap {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th { padding: 0.75rem 1rem; text-align: left; color: var(--text2); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; background: rgba(255,255,255,0.02); border-bottom: 1px solid var(--border); }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody tr:last-child td { border-bottom: none; }
td .primary { font-weight: 600; }
td .secondary { font-size: 0.78rem; color: var(--text2); }
.table-empty { text-align: center; padding: 3rem; color: var(--text2); }

/* ── FILTERS ── */
.filters { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap; align-items: center; }
.filters select, .filters input[type="text"], .filters input[type="search"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  backdrop-filter: blur(10px);
  transition: var(--transition);
}
.filters select:focus, .filters input:focus { border-color: var(--accent); outline: none; }

/* ── MODAL ── */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.75); backdrop-filter: blur(8px); z-index: 200; align-items: center; justify-content: center; }
.modal.show { display: flex; animation: modalIn 0.25s ease; }
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 550px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: modalSlide 0.25s ease;
}
@keyframes modalSlide { from { transform: translateY(16px) scale(0.97); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal-wide { max-width: 960px; }
.modal-close { position: absolute; top: 1rem; right: 1.5rem; font-size: 1.3rem; cursor: pointer; color: var(--text2); transition: var(--transition); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.modal-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.modal label { display: block; margin-top: 1rem; margin-bottom: 0.3rem; font-size: 0.78rem; color: var(--text2); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.modal input, .modal textarea, .modal select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  transition: var(--transition);
}
.modal input:focus, .modal textarea:focus, .modal select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }
.modal textarea { resize: vertical; }
.modal button[type="submit"] { margin-top: 1.5rem; width: 100%; }
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }

/* ── SECTION ── */
.section {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* ── TAGS ── */
.tag {
  display: inline-block;
  background: rgba(255,255,255,0.05);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-right: 4px;
  border: 1px solid var(--border);
}
.tag-strategy {
  background: rgba(254,44,85,0.1);
  border-color: rgba(254,44,85,0.2);
  color: var(--accent);
}

/* ── MISC ── */
.empty { text-align: center; padding: 3rem; color: var(--text2); }
a { color: var(--cyan); text-decoration: none; transition: var(--transition); }
a:hover { color: #5ff8f3; }

.note-item { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.note-item:last-child { border-bottom: none; }
.note-date { font-size: 0.72rem; color: var(--text3); }

.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 2px 8px; border-radius: 6px; font-size: 0.72rem; font-weight: 600; }
.badge-views { background: rgba(254,44,85,0.1); color: var(--accent); }
.badge-engagement { background: rgba(37,244,238,0.1); color: var(--cyan); }

/* Toast */
.toast-container { position: fixed; bottom: 2rem; right: 2rem; z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(8px); } }

/* Insights */
.insight-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  border-left: 3px solid var(--cyan);
}
.insight-card .insight-title { font-size: 0.78rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.35rem; }
.insight-card .insight-value { font-size: 1.1rem; font-weight: 700; }
.insight-card .insight-detail { font-size: 0.8rem; color: var(--text2); margin-top: 0.25rem; }
.insight-card.accent-border { border-left-color: var(--accent); }
.insight-card.green-border { border-left-color: var(--green); }
.insight-card.purple-border { border-left-color: var(--purple); }
.insight-card.yellow-border { border-left-color: var(--yellow); }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; }
.spinner { width: 24px; height: 24px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Export btn */
.export-group { margin-left: auto; display: flex; gap: 0.5rem; }
