/* ============================================================
   Elinom Analytics — analytics.css
   Modern dark-glass premium analytics dashboard
   ============================================================ */

:root {
  --an-bg: #0a0d1a;
  --an-surface: #0f1325;
  --an-card: #141929;
  --an-card-hover: #1a2035;
  --an-border: rgba(99, 102, 241, 0.18);
  --an-border-light: rgba(148, 163, 184, 0.12);
  --an-text: #e2e8f0;
  --an-text-muted: #94a3b8;
  --an-text-dim: #64748b;
  --an-indigo: #6366f1;
  --an-violet: #8b5cf6;
  --an-cyan: #06b6d4;
  --an-emerald: #10b981;
  --an-amber: #f59e0b;
  --an-rose: #f43f5e;
  --an-sky: #38bdf8;
  --an-pink: #f472b6;
  --an-radius: 16px;
  --an-radius-sm: 10px;
  --an-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --an-shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--an-bg);
  color: var(--an-text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--an-bg); }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.35); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.6); }

/* ── Layout ────────────────────────────────────────────── */
.an-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.an-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(10, 13, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--an-border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.an-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.an-header-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.an-header-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
  padding: 2px;
}

.an-header-logo [data-erp-brand-fallback] {
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  flex-shrink: 0;
}

.an-header-title {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(90deg, #38bdf8, #6366f1, #f472b6);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.an-header-subtitle {
  font-size: 0.65rem;
  color: var(--an-text-muted);
  font-weight: 400;
  margin-top: -3px;
}

.an-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.an-badge-live {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #34d399;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.an-badge-live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  animation: an-pulse 2s infinite;
}

.an-btn-refresh {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Poppins', sans-serif;
}

.an-btn-refresh:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  color: #fff;
  transform: translateY(-1px);
}

.an-btn-refresh.spinning i {
  animation: an-spin 0.6s linear infinite;
}

.an-date-display {
  font-size: 0.72rem;
  color: var(--an-text-muted);
  white-space: nowrap;
}

/* ── Period Tabs ──────────────────────────────────────── */
.an-period-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem 0;
}

.an-period-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--an-text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-right: 0.25rem;
}

.an-period-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--an-border-light);
  color: var(--an-text-muted);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Poppins', sans-serif;
}

.an-period-btn:hover,
.an-period-btn.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

/* ── Module Selector ──────────────────────────────────────── */
.an-module-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--an-border-light);
  flex-wrap: wrap;
  background: rgba(10,13,26,0.5);
}

.an-module-bar-label {
  font-size: 0.63rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--an-text-dim);
  white-space: nowrap;
  margin-right: 0.15rem;
}

.an-mod-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--an-border-light);
  color: var(--an-text-dim);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.63rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.18s;
  font-family: 'Poppins', sans-serif;
  white-space: nowrap;
}

.an-mod-btn:hover {
  color: var(--an-text);
  border-color: var(--an-border);
  background: rgba(255,255,255,0.07);
}

.an-mod-btn.active {
  background: rgba(99,102,241,0.15);
  border-color: rgba(99,102,241,0.4);
  color: #e0e7ff;
}

.an-mod-btn i { font-size: 0.58rem; }

.an-mod-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.an-mod-action-btn {
  background: none;
  border: 1px solid var(--an-border-light);
  color: var(--an-text-dim);
  border-radius: 6px;
  padding: 2px 9px;
  font-size: 0.61rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  transition: all 0.18s;
}

.an-mod-action-btn:hover {
  color: var(--an-text);
  border-color: var(--an-border);
}

/* ── Load Progress Bar ─────────────────────────────────── */
.an-load-bar-wrap {
  padding: 0.45rem 1.5rem;
  background: rgba(10,13,26,0.6);
  border-bottom: 1px solid var(--an-border-light);
  position: sticky;
  top: 60px;
  z-index: 150;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.an-load-bar-inner {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.an-load-bar-track {
  height: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 4px;
  overflow: hidden;
}

.an-load-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6, #f472b6);
  background-size: 200% 100%;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  animation: an-bar-shimmer 1.6s linear infinite;
}

@keyframes an-bar-shimmer {
  0%   { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

.an-load-bar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.an-load-bar-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--an-text-muted);
  letter-spacing: 0.04em;
}

.an-load-bar-eta {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--an-text-dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Main Content ──────────────────────────────────────── */
.an-content {
  flex: 1;
  padding: 1.25rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
/* Full-bleed chart sections — break out of an-content side padding */
.an-charts-section {
  margin-left: -1.5rem;
  margin-right: -1.5rem;
}

.an-charts-section .an-section-title {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.an-charts-section .an-charts-row {
  gap: 0.75rem;
}
/* ── Section Headers ──────────────────────────────────── */
.an-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--an-text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 0.75rem;
}

.an-section-title i {
  font-size: 0.8rem;
}

/* ── KPI Cards Grid ────────────────────────────────────── */
.an-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.an-kpi-card {
  background: var(--an-card);
  border: 1px solid var(--an-border-light);
  border-radius: var(--an-radius);
  padding: 0.7rem 0.9rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
  user-select: none;
}

.an-kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--an-radius) var(--an-radius) 0 0;
}

.an-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--an-shadow-glow);
  border-color: var(--an-border);
}

.an-kpi-card.an-hidden { display: none; }

/* Accent colours per card */
.an-kpi-card.accent-indigo::before { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.an-kpi-card.accent-emerald::before { background: linear-gradient(90deg, #10b981, #34d399); }
.an-kpi-card.accent-amber::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.an-kpi-card.accent-rose::before { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.an-kpi-card.accent-cyan::before { background: linear-gradient(90deg, #06b6d4, #38bdf8); }
.an-kpi-card.accent-violet::before { background: linear-gradient(90deg, #8b5cf6, #c084fc); }
.an-kpi-card.accent-sky::before { background: linear-gradient(90deg, #38bdf8, #7dd3fc); }
.an-kpi-card.accent-pink::before { background: linear-gradient(90deg, #f472b6, #f9a8d4); }
.an-kpi-card.accent-teal::before { background: linear-gradient(90deg, #14b8a6, #2dd4bf); }
.an-kpi-card.accent-orange::before { background: linear-gradient(90deg, #f97316, #fb923c); }

.an-kpi-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  margin-bottom: 0.45rem;
}

.an-kpi-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--an-text-muted);
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.an-kpi-value {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  color: var(--an-text);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.an-kpi-value.loading {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: an-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
  width: 65px;
  height: 20px;
  display: inline-block;
  color: transparent;
}

.an-kpi-change {
  font-size: 0.65rem;
  font-weight: 600;
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 3px;
}

.an-kpi-change.up { color: #34d399; }
.an-kpi-change.down { color: #fb7185; }
.an-kpi-change.neutral { color: var(--an-text-muted); }

.an-kpi-glow {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  bottom: -20px;
  right: -10px;
  opacity: 0.06;
  filter: blur(20px);
}

/* ── Charts Grid ───────────────────────────────────────── */
.an-charts-row {
  display: grid;
  gap: 1rem;
}

.an-charts-row.col-2 { grid-template-columns: repeat(2, 1fr); }
.an-charts-row.col-3 { grid-template-columns: repeat(3, 1fr); }
.an-charts-row.col-4 { grid-template-columns: repeat(4, 1fr); }
.an-charts-row.an-charts-row-wide-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.an-chart-span-2 {
  grid-column: span 2;
}

.an-chart-card {
  background: var(--an-card);
  border: 1px solid var(--an-border-light);
  border-radius: var(--an-radius);
  padding: 1.5rem 1.6rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s;
}

.an-chart-card:hover {
  border-color: var(--an-border);
}

.an-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.an-chart-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--an-text);
  display: flex;
  align-items: center;
  gap: 7px;
}

.an-chart-title i {
  font-size: 0.8rem;
  opacity: 0.7;
}

.an-chart-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
  white-space: nowrap;
}

.an-chart-legend {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.an-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--an-text-muted);
}

.an-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.an-chart-canvas-wrap {
  position: relative;
  width: 100%;
}

.an-chart-skeleton {
  width: 100%;
  height: 300px;
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%;
  animation: an-shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}

/* ── Module Health Grid ────────────────────────────────── */
.an-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.an-health-card {
  background: var(--an-card);
  border: 1px solid var(--an-border-light);
  border-radius: var(--an-radius-sm);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.an-health-card:hover {
  background: var(--an-card-hover);
  border-color: var(--an-border);
}

.an-health-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.an-health-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--an-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.an-health-count {
  font-size: 0.65rem;
  color: var(--an-text-muted);
  margin-top: 1px;
}

.an-health-status {
  margin-left: auto;
  flex-shrink: 0;
}

.an-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.an-dot.active { background: #34d399; animation: an-pulse 2s infinite; }
.an-dot.loading { background: #fbbf24; animation: an-pulse 2s infinite; }
.an-dot.idle { background: var(--an-text-dim); }
.an-dot.error { background: #fb7185; }

/* ── Insights Panel ────────────────────────────────────── */
.an-insights {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.an-insight-item {
  background: var(--an-card);
  border: 1px solid var(--an-border-light);
  border-radius: var(--an-radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: border-color 0.2s;
}

.an-insight-item:hover {
  border-color: var(--an-border);
}

.an-insight-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.an-insight-body {
  flex: 1;
}

.an-insight-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--an-text);
  margin-bottom: 2px;
}

.an-insight-desc {
  font-size: 0.7rem;
  color: var(--an-text-muted);
  line-height: 1.5;
}

.an-insight-tag {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 8px;
  margin-top: 4px;
  display: inline-block;
}

.an-insight-tag.financial { background: rgba(16,185,129,0.15); color: #34d399; }
.an-insight-tag.growth { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.an-insight-tag.risk { background: rgba(244,63,94,0.15); color: #fb7185; }
.an-insight-tag.ops { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* ── GA4 Intelligence Section ────────────────────────── */
.an-ga4-section {
  background: linear-gradient(160deg, rgba(99,102,241,0.07) 0%, rgba(16,185,129,0.05) 60%, rgba(6,182,212,0.04) 100%);
  border: 1px solid rgba(99,102,241,0.18);
  border-radius: var(--an-radius);
  padding: 1.2rem 1.4rem;
  display: grid;
  gap: 1rem;
}

/* connector header row */
.an-ga4-connector-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
}
.an-ga4-connector-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.an-ga4-logo-wrap {
  width: 2.4rem; height: 2.4rem;
  border-radius: 10px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 6px rgba(0,0,0,0.18);
}
.an-ga4-title {
  font-size: 0.9rem; font-weight: 800; color: var(--an-text);
}
.an-ga4-subtitle {
  font-size: 0.68rem; color: var(--an-text-muted); margin-top: 2px;
}
.an-ga4-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 999px; font-size: 0.68rem; font-weight: 700;
  background: rgba(245,158,11,0.15); color: #f59e0b; border: 1px solid rgba(245,158,11,0.25);
}
.an-ga4-pill.connected {
  background: rgba(16,185,129,0.15); color: #10b981; border-color: rgba(16,185,129,0.25);
}
.an-ga4-connector-meta {
  display: flex; flex-wrap: wrap; gap: 1rem;
  font-size: 0.68rem; color: var(--an-text-muted);
}

/* 5-metric strip */
.an-ga4-metrics-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.7rem;
}
@media (max-width: 700px) {
  .an-ga4-metrics-strip { grid-template-columns: repeat(3, 1fr); }
}
.an-ga4-metric-tile {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(99,102,241,0.14);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  text-align: center;
}
.an-ga4-metric-val {
  font-size: 1.4rem; font-weight: 800; color: var(--an-text); line-height: 1;
}
.an-ga4-metric-lbl {
  font-size: 0.62rem; color: var(--an-text-muted); font-weight: 500; margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* intelligence grid */
.an-ga4-intel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.9rem;
}
@media (max-width: 900px) {
  .an-ga4-intel-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .an-ga4-intel-grid { grid-template-columns: 1fr; }
}
.an-ga4-intel-card {
  background: rgba(15,23,42,0.4);
  border: 1px solid rgba(99,102,241,0.12);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.8rem;
}
.an-ga4-intel-card-title {
  font-size: 0.72rem; font-weight: 700; color: var(--an-text-muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  display: flex; align-items: center; gap: 6px;
}
.an-ga4-intel-card-title i { color: #6366f1; }

/* traffic sources */
.an-ga4-sources-wrap {
  display: flex; align-items: center; gap: 1rem;
}
.an-ga4-sources-chart-wrap {
  flex-shrink: 0; width: 100px; height: 100px;
}
.an-ga4-sources-legend {
  display: grid; gap: 0.3rem; flex: 1;
}
.an-ga4-source-row {
  display: flex; align-items: center; gap: 0.4rem; font-size: 0.68rem;
}
.an-ga4-source-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.an-ga4-source-label { color: var(--an-text-muted); flex: 1; }
.an-ga4-source-pct { font-weight: 700; color: var(--an-text); }

/* conversion funnel */
.an-ga4-funnel { display: grid; gap: 0.5rem; }
.an-ga4-funnel-step {}
.an-ga4-funnel-bar-wrap {
  height: 6px; border-radius: 999px;
  background: rgba(255,255,255,0.06); margin-bottom: 4px; overflow: hidden;
}
.an-ga4-funnel-bar {
  height: 100%; border-radius: 999px;
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}
.an-ga4-funnel-row {
  display: flex; justify-content: space-between; align-items: center;
}
.an-ga4-funnel-label { font-size: 0.68rem; color: var(--an-text-muted); }
.an-ga4-funnel-val { font-size: 0.72rem; font-weight: 700; color: var(--an-text); }

/* top pages */
.an-ga4-pages { display: grid; gap: 0.4rem; }
.an-ga4-page-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.an-ga4-page-row:last-child { border-bottom: none; }
.an-ga4-page-path {
  font-size: 0.68rem; color: var(--an-text-muted); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.an-ga4-page-views {
  font-size: 0.7rem; font-weight: 700; color: var(--an-text); white-space: nowrap;
}
.an-ga4-page-bar-wrap {
  width: 50px; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,0.06); overflow: hidden;
}
.an-ga4-page-bar { height: 100%; border-radius: 999px; background: #6366f1; }

/* setup CTA */
.an-ga4-setup-cta {
  display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap;
  background: rgba(99,102,241,0.06);
  border: 1px dashed rgba(99,102,241,0.25);
  border-radius: 12px; padding: 1rem 1.2rem;
  font-size: 0.72rem; color: var(--an-text-muted);
}
.an-ga4-setup-cta strong {
  display: block; color: var(--an-text); font-size: 0.8rem; margin-bottom: 3px;
}
.an-ga4-setup-steps {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem;
}
.an-ga4-setup-step {
  display: flex; align-items: center; gap: 6px;
  background: rgba(99,102,241,0.1); border-radius: 999px;
  padding: 3px 10px; font-size: 0.65rem; color: var(--an-text-muted);
}
.an-ga4-step-num {
  width: 16px; height: 16px; border-radius: 50%;
  background: #6366f1; color: #fff; font-size: 0.6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.an-ga4-setup-cta code {
  background: rgba(99,102,241,0.15); color: #a5b4fc; padding: 1px 5px; border-radius: 4px;
}

  background: rgba(99,102,241,0.15); color: #a5b4fc; padding: 1px 5px; border-radius: 4px;
}

/* KPI source attribution row */
.an-kpi-source-row {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px;
}
.an-kpi-src-tag {
  font-size: 0.58rem; font-weight: 700;
  padding: 2px 6px; border-radius: 999px;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.65);
}

/* ═══════════════════════════════════════════════════════════
   CONNECTOR SECTIONS — shared (Metabase + Grafana)
═══════════════════════════════════════════════════════════ */
.an-connector-section {
  background: var(--an-card);
  border: 1px solid var(--an-border-light);
  border-radius: var(--an-radius);
  padding: 1.25rem 1.4rem;
  display: grid;
  gap: 1rem;
  margin-bottom: 0; /* spacing handled by an-content gap */
}

/* shared connector logo circle */
.an-connector-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem; flex-shrink: 0;
}
.an-metabase-logo {
  background: linear-gradient(135deg, #509ee3, #2d86c6);
  box-shadow: 0 0 14px rgba(80,158,227,0.4);
}
.an-grafana-logo {
  background: linear-gradient(135deg, #f46800, #e05200);
  box-shadow: 0 0 14px rgba(244,104,0,0.4);
}

/* inline connector badge */
.an-connector-badge {
  display: inline-flex; align-items: center;
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: 999px; margin-left: 8px;
  vertical-align: middle;
}
.an-badge-metabase {
  background: rgba(80,158,227,0.18); color: #509ee3;
  border: 1px solid rgba(80,158,227,0.3);
}
.an-badge-grafana {
  background: rgba(244,104,0,0.18); color: #f46800;
  border: 1px solid rgba(244,104,0,0.3);
}

/* KPI strip shared */
.an-connector-kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem;
}
.an-grafana-strip { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 800px) {
  .an-connector-kpi-strip,
  .an-grafana-strip { grid-template-columns: repeat(3, 1fr); }
}
.an-connector-kpi-tile {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(80,158,227,0.12);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  text-align: center;
}
.an-grafana-tile { border-color: rgba(244,104,0,0.12); }
.an-connector-kpi-val {
  font-size: 1.3rem; font-weight: 800; color: var(--an-text); line-height: 1;
}
.an-connector-kpi-lbl {
  font-size: 0.6rem; color: var(--an-text-muted); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px;
  display: flex; align-items: center; justify-content: center; gap: 3px;
}

/* ── Embed frame ──────────────────────────────────────── */
.an-embed-frame-wrap {
  display: flex; flex-direction: column;
  border: 1px solid var(--an-border-light);
  border-radius: 12px; overflow: hidden;
}
.an-embed-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.9rem;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--an-border-light);
  gap: 0.6rem;
}
.an-grafana-toolbar { background: rgba(244,104,0,0.04); border-color: rgba(244,104,0,0.12); }
.an-embed-label {
  font-size: 0.7rem; font-weight: 700; color: var(--an-text-muted);
  display: flex; align-items: center; gap: 6px;
}
.an-embed-hint {
  font-size: 0.65rem; color: var(--an-text-dim); white-space: nowrap;
}
.an-embed-actions {
  display: flex; align-items: center; gap: 0.4rem;
}
.an-embed-btn {
  background: rgba(255,255,255,0.06); border: 1px solid var(--an-border-light);
  color: var(--an-text-muted); border-radius: 7px;
  width: 28px; height: 28px; font-size: 0.7rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.an-embed-btn:hover { background: rgba(255,255,255,0.12); color: var(--an-text); }
.an-embed-iframe {
  width: 100%; height: 560px; display: block;
  background: #0f1325;
}
.an-grafana-iframe { height: 600px; }

/* ── Grafana tabs ─────────────────────────────────────── */
.an-grafana-tabs {
  display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap;
}
.an-grafana-tab {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 8px; font-size: 0.72rem; font-weight: 600;
  background: rgba(255,255,255,0.05); border: 1px solid var(--an-border-light);
  color: var(--an-text-muted); cursor: pointer; transition: all 0.15s;
}
.an-grafana-tab:hover { background: rgba(244,104,0,0.12); color: #f46800; border-color: rgba(244,104,0,0.25); }
.an-grafana-tab.active { background: rgba(244,104,0,0.18); color: #f46800; border-color: rgba(244,104,0,0.35); }
.an-grafana-tab-spacer { flex: 1; }
.an-grafana-live-dot {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.62rem; font-weight: 800; color: #10b981; letter-spacing: 0.06em;
}
.an-grafana-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: #10b981;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16,185,129,0.6);
  animation: an-pulse 1.4s infinite;
}
@keyframes an-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.6); }
  70%  { box-shadow: 0 0 0 7px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
.an-grafana-refresh-badge {
  font-size: 0.62rem; font-weight: 700; color: #f46800;
  background: rgba(244,104,0,0.12); border-radius: 6px;
  padding: 2px 7px;
}

/* ── Code block inside setup CTA ─────────────────────── */
.an-connector-code-block {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; overflow: hidden;
}
.an-connector-code-title {
  background: rgba(255,255,255,0.06);
  padding: 0.35rem 0.8rem;
  font-size: 0.65rem; font-weight: 700; color: var(--an-text-muted);
  display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.an-connector-pre {
  margin: 0; padding: 0.75rem 0.9rem;
  background: rgba(0,0,0,0.35);
  font-size: 0.65rem; color: #94a3b8;
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  line-height: 1.7; overflow-x: auto; white-space: pre;
}

/* Metabase CTA border accent */
.an-metabase-cta { border-color: rgba(80,158,227,0.25); background: rgba(80,158,227,0.05); }
.an-grafana-cta  { border-color: rgba(244,104,0,0.25);  background: rgba(244,104,0,0.05);  }

/* ── Toast ─────────────────────────────────────────────── */
.an-toast-wrap {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.an-toast {
  background: var(--an-card);
  border: 1px solid var(--an-border);
  border-radius: var(--an-radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--an-text);
  box-shadow: var(--an-shadow);
  animation: an-slide-up 0.3s ease;
  pointer-events: auto;
  max-width: 320px;
}

/* ── KPI Detail Modal ───────────────────────────────────── */
.an-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: an-modal-overlay-in 0.2s ease;
}

.an-modal {
  background: var(--an-surface);
  border: 1px solid var(--an-border);
  border-radius: 20px;
  width: min(580px, 92vw);
  max-height: 88vh;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.65);
  animation: an-modal-in 0.25s cubic-bezier(0.34,1.4,0.64,1);
}

.an-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem 0.85rem;
  border-bottom: 1px solid var(--an-border-light);
}

.an-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.an-modal-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.an-modal-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--an-text);
  line-height: 1.2;
}

.an-modal-sub {
  font-size: 0.65rem;
  color: var(--an-text-muted);
  margin-top: 2px;
}

.an-modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--an-border-light);
  color: var(--an-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.an-modal-close:hover {
  background: rgba(244,63,94,0.15);
  border-color: rgba(244,63,94,0.35);
  color: #fb7185;
}

.an-modal-kpi-row {
  padding: 0.85rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--an-border-light);
}

.an-modal-kpi-value {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--an-text);
  letter-spacing: -1px;
  line-height: 1;
}

.an-modal-kpi-change {
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.an-modal-kpi-change.up      { color: #34d399; }
.an-modal-kpi-change.down    { color: #fb7185; }
.an-modal-kpi-change.neutral { color: var(--an-text-muted); }

.an-modal-chart-wrap {
  padding: 1rem 1.4rem 1.4rem;
  height: 270px;
  position: relative;
}

@keyframes an-modal-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes an-modal-in {
  from { opacity: 0; transform: scale(0.9) translateY(24px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Animations ────────────────────────────────────────── */
@keyframes an-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes an-spin {
  to { transform: rotate(360deg); }
}

@keyframes an-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes an-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes an-count-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1200px) {
  .an-charts-row.col-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1100px) {
  .an-kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .an-charts-row.col-2 { grid-template-columns: 1fr; }
  .an-charts-row.col-3 { grid-template-columns: repeat(3, 1fr); }
  .an-charts-row.col-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .an-header { padding: 0 1rem; }
  .an-content { padding: 1rem; }
  .an-charts-section { margin-left: -1rem; margin-right: -1rem; }
  .an-charts-section .an-section-title { padding-left: 1rem; padding-right: 1rem; }
  .an-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .an-charts-row.an-charts-row-wide-2 { grid-template-columns: 1fr; }
  .an-chart-span-2 { grid-column: auto; }
  .an-charts-row.col-3 { grid-template-columns: repeat(2, 1fr); }
  .an-charts-row.col-4 { grid-template-columns: 1fr; }
  .an-health-grid { grid-template-columns: repeat(2, 1fr); }
  .an-date-display { display: none; }
}

@media (max-width: 480px) {
  .an-kpi-grid { grid-template-columns: 1fr 1fr; }
  .an-kpi-value { font-size: 1.3rem; }
}
