/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #222633;
  --border: #2a2e3d;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --meta-color: #1877f2;
  --google-color: #ea4335;
  --stripe-color: #635bff;
  --hubspot-color: #ff7a59;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.dashboard {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

/* === Tabs === */
.tab-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-family: var(--font);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* === Header === */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-left: 12px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.filter-group select,
.table-controls select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  appearance: auto;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.date-range input[type="date"] {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.preset-btns { display: flex; gap: 4px; }
.preset-btn {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted) !important;
  font-size: 12px !important;
  padding: 5px 10px !important;
  font-weight: 400 !important;
}
.preset-btn:hover { border-color: var(--accent) !important; color: var(--accent-light) !important; background: var(--bg-card) !important; }
.preset-btn.preset-active {
  background: rgba(99,102,241,0.15) !important;
  border-color: var(--accent) !important;
  color: var(--accent-light) !important;
  font-weight: 600 !important;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
}

.btn:hover { background: var(--accent-light); }
.btn-sm { padding: 6px 12px; }

/* === Upload Bar === */
.upload-bar { margin-bottom: 24px; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
  color: var(--text);
}

.upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.uploaded-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.file-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.file-tag.meta { background: rgba(24, 119, 242, 0.15); color: var(--meta-color); }
.file-tag.google { background: rgba(234, 67, 53, 0.15); color: var(--google-color); }
.file-tag.analytics { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.file-tag.hubspot { background: rgba(255, 122, 89, 0.15); color: var(--hubspot-color); }
.file-tag.stripe { background: rgba(99, 91, 255, 0.15); color: var(--stripe-color); }
.file-tag.analytics { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.file-tag.dealsheet { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.file-tag.opti { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.file-tag.manual { background: rgba(245, 158, 11, 0.15); color: var(--orange); }

.file-tag .remove-file {
  cursor: pointer;
  opacity: 0.6;
  font-size: 14px;
}
.file-tag .remove-file:hover { opacity: 1; }

/* === KPI Cards === */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: background 0.2s;
}

.kpi-card:hover { background: var(--bg-card-hover); }

.kpi-card.accent {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}

.kpi-card.accent-green {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.08);
}

/* API Refresh Button */
.btn-api {
  background: rgba(99, 102, 241, 0.2) !important;
  border: 1px solid var(--accent) !important;
  color: var(--accent) !important;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-api:hover { background: rgba(99, 102, 241, 0.4) !important; }
.btn-api.loading { opacity: 0.6; pointer-events: none; }

.btn-funnel-link {
  background: rgba(34, 197, 94, 0.15) !important;
  border: 1px solid var(--green) !important;
  color: var(--green) !important;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-funnel-link:hover { background: rgba(34, 197, 94, 0.3) !important; }

.btn-conv-link {
  background: rgba(245,158,11,0.15) !important;
  border: 1px solid var(--orange) !important;
  color: var(--orange) !important;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-conv-link:hover { background: rgba(245,158,11,0.3) !important; }

/* API Status Bar */
.api-status {
  display: flex;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.api-status-item { display: flex; align-items: center; gap: 4px; }
.api-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.api-dot.on { background: var(--green); }
.api-dot.off { background: var(--text-muted); }

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* === Platform KPI Sections === */
.platform-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.platform-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

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

.platform-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.platform-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.meta-icon { background: var(--meta-color); }
.google-icon { background: var(--google-color); }

.meta-section { border-left: 3px solid var(--meta-color); }
.google-section { border-left: 3px solid var(--google-color); }

.platform-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
}

.mini-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.mini-value {
  font-size: 18px;
  font-weight: 700;
}

/* === GA Mini Funnel === */
.ga-funnel {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.gaf-stage { display: flex; align-items: center; }

.gaf-inner {
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 10px 18px;
  text-align: center;
  min-width: 100px;
}

.gaf-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.gaf-count {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.gaf-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 6px;
  gap: 3px;
}

.gaf-chevron { font-size: 1.1rem; color: var(--text-muted); line-height: 1; }

.gaf-pill {
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  white-space: nowrap;
}

.gaf-green { color: #22c55e; background: rgba(34,197,94,0.12);  border: 1px solid rgba(34,197,94,0.25); }
.gaf-amber { color: #f59e0b; background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.25); }
.gaf-red   { color: #ef4444; background: rgba(239,68,68,0.12);  border: 1px solid rgba(239,68,68,0.25); }
.gaf-muted { color: var(--text-muted); background: rgba(255,255,255,0.05); border: 1px solid var(--border); }

/* === Chart Cards === */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

.funnel-container { height: 320px; }

/* === Funnel HTML === */
.funnel-section-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px 28px;
  margin-bottom: 20px;
}

.funnel-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}
.funnel-section-header h2 { font-size: 1.05rem; font-weight: 600; color: var(--text-primary); margin: 0; }
.funnel-section-sub { font-size: 0.75rem; color: var(--text-muted); margin: 0; }

.funnel-html-stages {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 4px;
}

.fs-stage {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 130px;
  position: relative;
}

.fs-inner {
  flex: 1;
  background: var(--bg-dark);
  border-radius: 10px;
  padding: 20px 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 190px;
  justify-content: space-between;
  position: relative;
  border-top: 3px solid transparent;
  transition: transform 0.15s;
}

.fs-inner:hover { transform: translateY(-2px); }

.fs-stage-highlight .fs-inner {
  background: rgba(34, 197, 94, 0.06);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.2);
}

.fs-top { display: flex; flex-direction: column; align-items: center; gap: 5px; }

.fs-icon { font-size: 1.4rem; line-height: 1; }

.fs-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.fs-source {
  font-size: 0.63rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
  padding: 1px 5px;
}

.fs-mid { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px 0; }

.fs-count {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.fs-count-empty {
  color: var(--text-muted);
  font-size: 1.4rem;
  font-weight: 400;
}

.fs-bottom { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 36px; justify-content: flex-end; }

.fs-cost-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.fs-cost-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fs-cost-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: #22c55e;
}

/* Arrow connector between stages */
.fs-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  gap: 5px;
  flex-shrink: 0;
  width: 60px;
  z-index: 1;
}

.fs-arrow-line {
  width: 100%;
  height: 2px;
  background: var(--border);
  position: relative;
}

.fs-arrow-line::after {
  content: '';
  position: absolute;
  right: -5px;
  top: -4px;
  border-left: 6px solid var(--border);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.fs-conv-pill {
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 3px 7px;
  white-space: nowrap;
  line-height: 1;
}

.fs-conv-green  { color: #22c55e; background: rgba(34,197,94,0.12);  border: 1px solid rgba(34,197,94,0.25); }
.fs-conv-amber  { color: #f59e0b; background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.25); }
.fs-conv-red    { color: #ef4444; background: rgba(239,68,68,0.12);  border: 1px solid rgba(239,68,68,0.25); }
.fs-conv-muted  { color: var(--text-muted); background: rgba(255,255,255,0.05); border: 1px solid var(--border); }

.fs-drop {
  font-size: 0.6rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: center;
  max-width: 58px;
  word-break: break-word;
  white-space: normal;
}

.funnel-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 50px 20px;
}

.fs-scope-badge {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 500;
  color: #f59e0b;
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 4px;
  padding: 1px 5px;
  margin-top: 4px;
  white-space: nowrap;
}

.location-unfiltered-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  color: #f59e0b;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 4px;
  padding: 2px 8px;
  margin-left: 8px;
  vertical-align: middle;
}

/* === Funnel Fork (parallel paths) === */
.fs-fork {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.fs-fork-branch {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  min-width: 120px;
  max-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fs-fork-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fs-fork-foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.fs-arrow-split {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 60px;
  flex-shrink: 0;
}

.fs-split-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* === Funnel Spend Header === */
.fs-spend-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(66,133,244,0.08));
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 12px;
  padding: 14px 28px;
  margin-bottom: 16px;
  width: 100%;
}
.fs-spend-total {
  text-align: center;
  flex: 1;
}
.fs-spend-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.fs-spend-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}
.fs-spend-cpm {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.fs-spend-platform {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 120px;
  justify-content: center;
}
.fs-spend-platform strong {
  color: var(--text-primary);
  font-weight: 700;
}
.fs-spend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* === HubSpot CRM Tab === */
.hs-tab-header { margin-bottom: 20px; }
.hs-tab-header h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.hs-tab-sub { color: var(--text-muted); font-size: 0.85rem; }

/* Pipeline flow */
.hs-pipeline-flow {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 20px;
  overflow-x: auto;
}
.hs-ps-bucket {
  flex: 1;
  min-width: 160px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 3px solid;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hs-ps-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.hs-ps-icon { font-size: 1.2rem; margin-top: 2px; }
.hs-ps-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-primary); }
.hs-ps-def { font-size: 0.7rem; color: var(--text-muted); margin-top: 1px; }
.hs-ps-count { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; color: #fff; line-height: 1; margin: 4px 0; }
.hs-ps-stale-bar { height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden; }
.hs-ps-stale-fill { height: 100%; border-radius: 2px; transition: width 0.4s ease; }
.hs-ps-stale-row { font-size: 0.72rem; }
.hs-ps-stale-num { font-weight: 600; }
.hs-ps-walkin { font-size: 0.72rem; color: var(--text-muted); padding: 4px 0; border-top: 1px solid rgba(255,255,255,0.06); }
.hs-ps-action { font-size: 0.72rem; color: var(--text-muted); border-top: 1px solid rgba(255,255,255,0.06); padding-top: 8px; margin-top: auto; font-style: italic; }

.hs-ps-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
  gap: 3px;
}
.hs-ps-arrow-line { font-size: 1.2rem; color: var(--text-muted); }
.hs-ps-arrow-pct { font-size: 0.7rem; font-weight: 700; color: #818cf8; white-space: nowrap; }
.hs-ps-arrow-label { font-size: 0.6rem; color: var(--text-muted); white-space: nowrap; }

/* Stale action cards */
.hs-action-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.hs-action-card {
  flex: 1;
  min-width: 220px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-left: 4px solid;
  border-radius: 8px;
  padding: 14px 16px;
}
.hs-action-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.hs-action-pct { font-size: 0.75rem; color: var(--text-muted); }
.hs-action-cta { font-size: 0.8rem; color: var(--text-primary); margin-bottom: 6px; }
.hs-action-oldest { font-size: 0.72rem; color: var(--text-muted); }

/* Stale tabs */
.hs-stale-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.hs-stale-tab {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}
.hs-stale-tab:hover { border-color: rgba(129,140,248,0.4); color: var(--text-primary); }
.hs-stale-tab.active { background: rgba(129,140,248,0.15); border-color: rgba(129,140,248,0.5); color: #818cf8; font-weight: 600; }
.hs-tab-count {
  display: inline-block;
  background: rgba(239,68,68,0.2);
  color: #ef4444;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 4px;
}

.kpi-card-danger { border-color: rgba(239,68,68,0.4) !important; }
.kpi-card-danger .kpi-value { color: #ef4444; }
.kpi-card-danger .kpi-label { color: #ef4444; }

.hs-stale-thresholds { display: flex; gap: 8px; flex-wrap: wrap; }
.hs-threshold-badge {
  font-size: 0.72rem;
  color: #f59e0b;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 4px;
  padding: 2px 8px;
}

.hs-cohort-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.cohort-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 6px;
}
.cohort-green { color: #22c55e; background: rgba(34,197,94,0.12); }
.cohort-amber { color: #f59e0b; background: rgba(245,158,11,0.12); }
.cohort-red   { color: #ef4444; background: rgba(239,68,68,0.12); }

.stage-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 8px;
}

.stale-days { font-weight: 700; }
.stale-warn .stale-days  { color: #f59e0b; }
.stale-urgent .stale-days { color: #ef4444; }
tr.stale-warn  { background: rgba(245,158,11,0.04); }
tr.stale-urgent { background: rgba(239,68,68,0.05); }

.stale-email { color: var(--text-muted); font-size: 0.8rem; }

.hs-link {
  color: #ff7a59;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
}
.hs-link:hover { text-decoration: underline; }

/* === Tables === */
.table-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.table-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.table-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.table-header-bar h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0;
}

.table-controls {
  display: flex;
  gap: 8px;
}

.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tr:hover td { background: rgba(255, 255, 255, 0.02); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 12px !important;
  font-style: italic;
}

/* Drill-down table styles */
.col-expand {
  width: 28px;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
}

.row-campaign { cursor: default; }
.row-campaign.clickable { cursor: pointer; }
.row-campaign.clickable:hover td { background: rgba(99, 102, 241, 0.06); }

.row-adset {
  background: rgba(255, 255, 255, 0.015);
}
.row-adset.clickable { cursor: pointer; }
.row-adset.clickable:hover td { background: rgba(99, 102, 241, 0.06); }
.row-adset td { font-size: 12px; }

.row-ad {
  background: rgba(255, 255, 255, 0.03);
}
.row-ad td {
  font-size: 12px;
  color: var(--text-muted);
}

.indent-1 { padding-left: 28px !important; }
.indent-2 { padding-left: 48px !important; }

.platform-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tag-meta {
  background: rgba(24, 119, 242, 0.15);
  color: var(--meta-color);
}

.tag-google {
  background: rgba(234, 67, 53, 0.15);
  color: var(--google-color);
}

/* === MoM Section === */
.mom-section {
  margin-bottom: 24px;
}

.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.section-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.mom-table {
  width: 100%;
  border-collapse: collapse;
}

.mom-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.mom-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid rgba(42, 46, 61, 0.5);
  color: var(--text);
}

.mom-table tr:last-child td {
  border-bottom: none;
}

.mom-table .metric-name {
  font-weight: 600;
  color: var(--text);
}

.mom-change {
  font-weight: 700;
  font-size: 13px;
}

.mom-change.positive { color: var(--green); }
.mom-change.negative { color: var(--red); }
.mom-change.neutral { color: var(--text-muted); }

/* For metrics where down is good (CPA, etc) */
.mom-change.positive-inv { color: var(--red); }
.mom-change.negative-inv { color: var(--green); }

.insights-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 16px;
}

.insights-panel h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.insights-panel ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.insights-panel li {
  padding: 12px 16px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.insight-highlight {
  font-weight: 700;
  color: var(--accent-light);
}

.insight-good { border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.06); }
.insight-bad { border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.06); }
.insight-neutral { border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.06); }

/* === Notes Section === */
.notes-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.notes-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-item {
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.note-date {
  font-size: 11px;
  color: var(--orange);
  font-weight: 600;
  margin-bottom: 4px;
}

/* === Monthly Report Tab === */
.monthly-header { margin-bottom: 24px; }
.monthly-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.text-muted { color: var(--text-muted); font-size: 13px; }

.monthly-report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.monthly-report-table th {
  text-align: right;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.monthly-report-table th:first-child { text-align: left; }
.monthly-report-table td {
  text-align: right;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(42, 46, 61, 0.5);
}
.monthly-report-table td:first-child {
  text-align: left;
  font-weight: 600;
}
.monthly-report-table tr.total-row td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  color: var(--accent-light);
}
.monthly-report-table tr.subtotal-row td {
  font-weight: 600;
  color: var(--text);
}
.monthly-report-table tr.indent td:first-child {
  padding-left: 28px;
  font-weight: 400;
  color: var(--text-muted);
  font-style: italic;
}
.mom-change { font-size: 11px; font-weight: 600; }
.mom-change.up { color: var(--red); }
.mom-change.down { color: var(--green); }
.mom-change.neutral { color: var(--text-muted); }

/* === Revenue Tab === */
.revenue-loading-overlay {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.revenue-loading-overlay .spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--stripe-color);
  border-radius: 50%;
  animation: rev-spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes rev-spin {
  to { transform: rotate(360deg); }
}

/* === Web Funnel === */
.wf-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px 20px;
  margin-bottom: 16px;
}
.wf-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 20px;
}
.wf-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.wf-header-sub { font-size: 12px; color: var(--text-muted); }
.wf-stages {
  display: flex;
  align-items: flex-start;
  gap: 0;
  flex-wrap: wrap;
}
.wf-stage {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 8px;
}
.wf-stage:first-child { padding-left: 0; }
.wf-arrow {
  display: flex;
  align-items: center;
  padding-top: 14px;
  color: #334155;
  font-size: 18px;
  flex-shrink: 0;
}
.wf-stage-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.wf-stage-count {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
}
.wf-stage-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,0.05);
  border-radius: 2px;
  overflow: hidden;
  margin: 2px 0;
}
.wf-stage-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s;
}
.wf-stage-conv {
  font-size: 11px;
  min-height: 16px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.wf-drop {
  font-size: 10px;
  color: #ef4444;
}
.wf-stage-note {
  font-size: 10px;
  color: #475569;
  font-style: italic;
}
.wf-tour-note {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.wf-gaps {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 16px;
}
.wf-gaps-ok { color: #22c55e; font-size: 13px; }
.wf-gaps-title {
  font-size: 12px;
  font-weight: 600;
  color: #f59e0b;
  margin-bottom: 10px;
}
.wf-gap-row {
  font-size: 12px;
  color: var(--text-muted);
  padding: 5px 10px;
  border-left: 3px solid;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.02);
  border-radius: 0 4px 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wf-gap-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* === AIDA Chart Header === */
.aida-header { margin-bottom: 12px; }
.aida-header h3 { margin-bottom: 6px; }
.aida-cpa-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 20px;
}
.aida-stat {
  font-size: 12px;
  color: var(--text-muted);
}
.aida-stat em { font-style: normal; color: #64748b; }
.aida-stat.highlight { color: #f59e0b; font-weight: 600; }
.aida-stat.highlight em { color: #f59e0b; opacity: 0.8; }
.aida-stat-sep { color: #334155; font-size: 12px; }

/* === HubSpot Velocity Row === */
.hs-velocity-row {
  display: flex;
  gap: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}
.hs-vel-section {
  flex: 1;
  padding: 16px 20px;
}
.hs-vel-divider {
  width: 1px;
  background: var(--border);
  margin: 12px 0;
}
.hs-vel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.hs-vel-metrics, .hs-vel-rates {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hs-vel-metric, .hs-vel-rate {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 60px;
}
.hs-vel-num {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}
.hs-vel-label, .hs-vel-rate-label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}
.hs-vel-delta {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
}
.hs-vel-delta.up { color: #22c55e; background: rgba(34,197,94,0.1); }
.hs-vel-delta.down { color: #ef4444; background: rgba(239,68,68,0.1); }
.hs-vel-delta.neutral { color: var(--text-muted); }
.hs-vel-arrow, .hs-vel-rate-arrow {
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0 4px;
}
.hs-vel-rate-num {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}
.hs-vel-rate-num.high { color: #22c55e; }
.hs-vel-rate-num.mid  { color: #f59e0b; }
.hs-vel-rate-num.low  { color: #ef4444; }

/* === HubSpot Priority Actions === */
.hs-priority-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}
.hs-priority-header {
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.hs-priority-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.hs-priority-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.hs-priority-empty {
  padding: 16px 20px;
  color: #22c55e;
  font-size: 13px;
}
.hs-pa-group {
  border-bottom: 1px solid var(--border);
  padding: 12px 20px 16px;
}
.hs-pa-group:last-child { border-bottom: none; }
.hs-pa-group-label {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 3px;
}
.hs-pa-group-label.hot    { color: #f59e0b; }
.hs-pa-group-label.urgent { color: #ef4444; }
.hs-pa-group-label.warn   { color: #f97316; }
.hs-pa-group-label.cust   { color: #635bff; }
.hs-pa-group-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-style: italic;
}
.hs-pa-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.hs-pa-table tr { border-bottom: 1px solid rgba(255,255,255,0.04); }
.hs-pa-table tr:last-child { border-bottom: none; }
.hs-pa-table td { padding: 5px 8px; }
.hs-pa-table td:first-child { color: var(--text); font-size: 12px; min-width: 120px; }
.hs-pa-email { color: var(--text-muted); min-width: 160px; }
.hs-pa-loc   { color: var(--text-muted); }
.hs-pa-days  { color: var(--text-muted); white-space: nowrap; }
.hs-pa-action { color: #94a3b8; font-style: italic; font-size: 11px; }
.hs-pa-row.hot td:first-child    { color: #f59e0b; }
.hs-pa-row.urgent td:first-child { color: #ef4444; }
.hs-pa-row.warn td:first-child   { color: #f97316; }
.hs-pa-row.cust td:first-child   { color: #818cf8; }

/* === Meta Adset Expand === */
.meta-adset-expandable:hover { background: rgba(99,102,241,0.06); }
.adset-toggle {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.15s ease;
  user-select: none;
}
.meta-ad-expand-row td { padding: 0 !important; border-top: none !important; }
.meta-ad-subtable {
  width: 100%;
  border-collapse: collapse;
  background: rgba(0,0,0,0.2);
}
.meta-ad-subtable thead tr { background: rgba(99,102,241,0.08); }
.meta-ad-subtable th {
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: right;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.meta-ad-subtable th:first-child { text-align: left; }
.meta-ad-subrow td {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.meta-ad-subrow:last-child td { border-bottom: none; }
.meta-ad-subrow:hover { background: rgba(255,255,255,0.03); }

/* === Responsive === */
@media (max-width: 1100px) {
  .platform-kpis { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
  .header { flex-direction: column; align-items: flex-start; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .dashboard { padding: 12px; }
  .kpi-row { grid-template-columns: 1fr; }
  .upload-zone { flex-direction: column; }
  .header-controls { flex-direction: column; align-items: flex-start; }
}
