:root {
  --bg: #FAF8F0;
  --bg-card: #ffffff;
  --bg-hover: #F2F0E8;
  --border: #E5E3DB;
  --text: #1C1A1A;
  --text-muted: #7A7872;
  --accent: #69D43A;
  --accent-hover: #5BC132;
  --accent-light: rgba(105, 212, 58, 0.12);
  --green: #69D43A;
  --yellow: #E5A820;
  --red: #E54040;
  --blue: #3B82F6;
  --radius: 10px;
  --font: 'Inter', -apple-system, system-ui, sans-serif;
  --shadow: 0 1px 3px rgba(28, 26, 26, 0.06), 0 1px 2px rgba(28, 26, 26, 0.04);
  --shadow-md: 0 4px 12px rgba(28, 26, 26, 0.08);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse at center, black 50%, transparent 90%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 50%, transparent 90%);
  pointer-events: none;
  z-index: 0;
}

/* ══════════ TOPBAR ══════════ */
.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0 2rem;
  height: 60px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(28, 26, 26, 0.04);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

.topbar__brand-logo {
  height: 45px;
}

.topbar__brand-suffix {
  font-size: 1.05rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  border-left: 1px solid var(--border);
  padding-left: 0.6rem;
}

.topbar__tabs {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab.active { color: #ffffff; background: var(--text); }

/* ══════════ TAB DROPDOWN ══════════ */
.tab-dropdown {
  position: relative;
}
.tab-dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
}
.tab-dropdown:hover .tab-dropdown__menu {
  display: block;
}
.tab-dropdown__item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 0.55rem 1rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.tab-dropdown__item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.tab-dropdown__item.active {
  color: var(--text);
  font-weight: 600;
}

/* ══════════ SUBTABS ══════════ */
.subtabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}
.subtab {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.subtab:hover { color: var(--text); background: var(--bg-hover); }
.subtab.active { color: #ffffff; background: var(--text); border-color: var(--text); }

.subtab-content { display: none; }
.subtab-content.active { display: block; }

/* ══════════ TAG FILTERS ══════════ */
.tag-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}
.tag-filter {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}
.tag-filter:hover { color: var(--text); border-color: var(--text-muted); }
.tag-filter.active { color: #ffffff; background: var(--text); border-color: var(--text); }

/* ══════════ EMPTY STATE ══════════ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ══════════ CREATIVES ══════════ */
.creative-batch {
  margin-bottom: 2.5rem;
}
.creative-batch__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.creative-batch__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.creative-batch__count {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.creative-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.creative-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
.creative-card:hover { box-shadow: var(--shadow-md); }
.creative-card img, .creative-card video {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.creative-card__info {
  padding: 0.5rem 0.75rem;
}
.creative-card__name {
  font-size: 0.72rem;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.creative-card__type {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ══════════ PIPELINE ══════════ */
.pipeline-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.pipeline-toolbar .subtabs {
  margin-bottom: 0;
}
.pipeline-toolbar__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.pipeline-date-select {
  min-width: 140px;
}
.pipeline-zoom {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.pipeline-zoom__btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.pipeline-zoom__btn:last-child { width: auto; padding: 0 0.6rem; font-size: 0.75rem; }
.pipeline-zoom__btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.pipeline-zoom__level {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
}

.pipeline-viewport {
  overflow: auto;
  width: 100%;
  max-height: calc(100vh - 180px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 2rem;
}
.pipeline-canvas {
  transform-origin: top center;
  transition: transform 0.2s ease;
  min-width: max-content;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pipeline-flow {
  margin-bottom: 4rem;
}

/* Campaign columns layout */
.pipeline-campaigns-row {
  display: flex;
  justify-content: center;
  gap: 3.5rem;
  flex-wrap: nowrap;
}
.pipeline-campaign-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pipeline-node--subcampaign {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  min-width: 240px;
  max-width: 340px;
}

/* Campaign root node */
.pipeline-root {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 0;
}
.pipeline-node {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
}
.pipeline-node--campaign {
  border-color: var(--text);
  padding: 1.25rem 2rem;
  min-width: 380px;
}
.pipeline-node__platform {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.pipeline-node__platform img {
  height: 14px;
  vertical-align: middle;
  margin-right: 4px;
}
.pipeline-date-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pipeline-node__label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

/* Campaign list inside node */
.pipeline-campaigns {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.pipeline-campaign-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
}
.pipeline-campaign-row__name {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.pipeline-campaign-row__stats {
  display: flex;
  gap: 0.6rem;
  color: var(--text-muted);
  font-size: 0.68rem;
  white-space: nowrap;
}
.pipeline-campaign-row__stats strong {
  color: var(--text);
}

/* Aggregated stats bar */
.pipeline-stats-bar {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}
.pipeline-stat {
  text-align: center;
}
.pipeline-stat__value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.pipeline-stat__label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

/* Connector lines */
.pipeline-connector {
  width: 2px;
  height: 32px;
  background: var(--border);
  margin: 0 auto;
}
.pipeline-connector--branch {
  height: 24px;
}

/* Angles row */
.pipeline-angles {
  display: flex;
  justify-content: center;
  gap: 3.5rem;
  position: relative;
}
.pipeline-angles::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 2px;
  background: var(--border);
}

.pipeline-angle {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 200px;
  max-width: 260px;
}
.pipeline-node--angle {
  width: 100%;
  border-left: 4px solid var(--border);
}

/* Creatives block under angle */
.pipeline-creatives-block {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.pipeline-creative-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 6px 8px;
  box-shadow: var(--shadow);
}
.pipeline-creative-rank {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
}
.pipeline-creative-thumb {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.pipeline-creative-stats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.pipeline-creative-stats strong {
  font-weight: 700;
}
.pipeline-creative-stats .stat-good { color: #2DA30E; }
.pipeline-creative-stats .stat-warn { color: var(--yellow); }

/* Ad cards list under campaign */
.pipeline-ads-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 280px;
  margin: 0 auto;
}
.pipeline-ad-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
}
.pipeline-ad-card__rank {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  float: right;
}
.pipeline-ad-card__name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pipeline-ad-card__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 0.65rem;
  color: var(--text-muted);
}
.pipeline-ad-card__stats strong {
  font-weight: 700;
}
.pipeline-ad-card__stats .stat-good { color: #2DA30E; }
.pipeline-ad-card__stats .stat-warn { color: var(--yellow); }

/* Clickable nodes */
.pipeline-clickable {
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.pipeline-clickable:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

/* Form/LP node */
.pipeline-node--form {
  border-color: var(--accent);
  background: var(--accent-light);
  overflow: hidden;
}
.pipeline-node--form .pipeline-node__label {
  font-size: 0.82rem;
  font-weight: 600;
}
.pipeline-node--form .pipeline-node__platform {
  color: #3D8C1F;
}

/* Form preview iframe */
.pipeline-form-preview {
  width: 100%;
  height: 120px;
  overflow: hidden;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: #fff;
  border: 1px solid var(--border);
}
.pipeline-form-preview iframe {
  width: 400%;
  height: 400%;
  transform: scale(0.25);
  transform-origin: top left;
  border: none;
  pointer-events: none;
}

/* Instant Form Facebook node */
.pipeline-node--instant-form {
  background: var(--bg-card);
  border: 2px solid #1877F2;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.pipeline-node--instant-form .pipeline-node__platform {
  color: #1877F2;
}
.pipeline-node--instant-form .pipeline-node__platform img {
  height: 12px;
}
.pipeline-instant-form-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.4rem;
}
.pipeline-instant-form-row__name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pipeline-instant-form-row__stats {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}
.pipeline-instant-form-row__stats strong {
  font-weight: 700;
}
.pipeline-instant-form-row__stats .stat-good { color: #2DA30E; }
.pipeline-instant-form-row__stats .stat-warn { color: var(--yellow); }

/* Horizontal line connecting angles */
.pipeline-hline {
  position: relative;
  height: 2px;
  background: var(--border);
  margin: 0 auto;
}

/* Funnel rows — same stage items on same horizontal line */
.pipeline-funnel-row {
  display: flex;
  justify-content: center;
  gap: 3rem;
}
.pipeline-funnel-cell {
  min-width: 200px;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ══════════ CONTENT ══════════ */
.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.section-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

/* ══════════ OVERVIEW HEADER ══════════ */
.overview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.motivation {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 0;
  font-weight: 700;
}
.motivation .accent {
  color: #40B818;
  font-weight: 700;
}

/* ══════════ KPI CARDS ══════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-card__label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.kpi-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

/* ══════════ TABLE ══════════ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table thead { background: var(--bg-hover); }
.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text);
}
.data-table tbody tr:hover { background: rgba(105, 212, 58, 0.04); }

/* ══════════ BADGES ══════════ */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge--green { background: rgba(105, 212, 58, 0.12); color: #3D8C1F; }
.badge--yellow { background: rgba(229, 168, 32, 0.12); color: #9A7210; }
.badge--red { background: rgba(229, 64, 64, 0.12); color: var(--red); }
.badge--blue { background: rgba(59, 130, 246, 0.1); color: var(--blue); }
.badge--gray { background: rgba(122, 120, 114, 0.1); color: var(--text-muted); }

/* ══════════ BUTTONS & INPUTS ══════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent); }

select, .search-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}
select:focus, .search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(105, 212, 58, 0.12);
}
.search-input { width: 280px; }
.search-input::placeholder { color: var(--text-muted); }

/* ══════════ LOADING ══════════ */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.loading::after {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 0.5rem;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════ EMPTY STATE ══════════ */
.empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ══════════ ANSWERS ══════════ */
.answers-cell {
  position: relative;
  cursor: default;
}
.answers-cell code {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ══════════ ANALYTICS ══════════ */

.analytics-section {
  margin-top: 1.5rem;
}
.analytics-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.scroll-bars {
  display: flex;
  gap: 1.5rem;
  align-items: flex-end;
  height: 160px;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.scroll-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  position: relative;
  justify-content: flex-end;
}
.scroll-bar__fill {
  width: 100%;
  max-width: 48px;
  background: var(--accent, #1a1a1a);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
}
.scroll-bar__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}
.scroll-bar__value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  position: absolute;
  top: -4px;
  transform: translateY(-100%);
}

.rec-card {
  transition: transform 0.15s ease;
}
.rec-card:hover {
  transform: translateX(4px);
}

#analytics-lp-select,
#analytics-period {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--bg-card);
  color: var(--text);
}
