:root {
  --bg: #0e1117;
  --surface: #161b22;
  --surface2: #1c2333;
  --border: #30363d;
  --text: #e6edf3;
  --text2: #8b949e;
  --accent: #58a6ff;
  --accent2: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --green: #3fb950;
  --blue: #58a6ff;
  --purple: #bc8cff;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

.top-bar .project-label {
  font-size: 13px;
  color: var(--text2);
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 24px;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.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; }

.container { padding: 20px 24px; }

/* Domain nav -- Linear-style pill selector */
.domain-nav {
  display: flex;
  gap: 6px;
  padding: 12px 0 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.domain-pill {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.domain-pill:hover {
  color: var(--text);
  border-color: var(--text2);
}

.domain-pill.active {
  background: rgba(88,166,255,0.12);
  color: var(--accent);
  border-color: rgba(88,166,255,0.35);
}

.domain-pill .pill-count {
  font-size: 10px;
  opacity: 0.6;
  margin-left: 4px;
}

/* Tables */
.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 20px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  background: var(--surface2);
  color: var(--text2);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.data-table td {
  padding: 6px 12px;
  border-bottom: 1px solid rgba(48,54,61,0.5);
  color: var(--text);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tr:hover td { background: rgba(88,166,255,0.04); }

.section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(88,166,255,0.15);
  color: var(--accent);
}

/* HEATMAP */
.map-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  height: calc(100vh - 120px);
}

.map-panel {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.map-panel-title {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  position: sticky;
  top: 0;
  z-index: 5;
}

.heatmap-container {
  padding: 8px;
  overflow: auto;
}

.heatmap {
  border-collapse: collapse;
  font-size: 10px;
}

.heatmap th {
  padding: 3px 4px;
  color: var(--text2);
  font-weight: 500;
  text-align: center;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 4;
}

.heatmap th.row-header {
  text-align: left;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 5;
  padding-left: 8px;
  font-size: 10px;
}

.heatmap th.col-header {
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  min-height: 100px;
  max-width: 42px;
  font-size: 10px;
  line-height: 1.25;
  padding: 6px 2px;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  text-align: justify;
  white-space: normal;
}

.heatmap td.cell {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: 1px solid rgba(30,30,30,0.6);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
}

.heatmap td.cell:hover {
  transform: scale(1.6);
  z-index: 10;
  box-shadow: 0 0 8px rgba(0,0,0,0.6);
}

.heatmap td.cell.selected {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* Side panel */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 12px;
}

.metric-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  position: relative;
}

.metric-card .metric-label {
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 4px;
  cursor: help;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.metric-card .metric-label .info-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--text2);
  font-size: 8px;
  line-height: 12px;
  text-align: center;
  opacity: 0.5;
  flex-shrink: 0;
}

.metric-card .metric-value {
  font-size: 22px;
  font-weight: 700;
}

.metric-card .metric-sub {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.zone-summary {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.zone-summary h4 {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.zone-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(48,54,61,0.3);
}

.zone-item:last-child { border-bottom: none; }

.zone-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.selection-info {
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
  color: var(--text2);
}

.selection-info strong { color: var(--text); }

.btn-clear {
  background: rgba(88,166,255,0.1);
  color: var(--accent);
  border: 1px solid rgba(88,166,255,0.3);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  margin-left: 8px;
}

.btn-clear:hover { background: rgba(88,166,255,0.2); }

.legend-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 10px;
  color: var(--text2);
}

.legend-gradient {
  width: 200px;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(to right, #d73027, #fc8d59, #fee08b, #91cf60, #1a9850, #2166ac);
}

/* Metric Tooltip */
.metric-tooltip {
  position: fixed;
  pointer-events: none;
  background: #1a1f2e;
  border: 1px solid rgba(88,166,255,0.25);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 11px;
  line-height: 1.6;
  max-width: 320px;
  z-index: 1000;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  display: none;
  color: var(--text);
}

.metric-tooltip .mt-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 6px;
}

.metric-tooltip .mt-desc {
  color: var(--text2);
  margin-bottom: 6px;
}

.metric-tooltip .mt-formula {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 10px;
  color: var(--accent2);
  background: rgba(63,185,80,0.08);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.metric-tooltip .mt-use {
  font-style: italic;
  color: var(--text2);
  font-size: 10px;
}

/* Tooltip */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: #1e2530;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.5;
  max-width: 360px;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: none;
}

.tooltip .tt-title { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.tooltip .tt-score { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; }
.tooltip .tt-label { color: var(--text2); }

.color-positive { color: var(--green); }
.color-negative { color: var(--red); }
.color-neutral { color: var(--orange); }

/* Sub-select tabs */
.sub-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.sub-tab-btn {
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.12s;
}

.sub-tab-btn:hover {
  color: var(--text);
  border-color: var(--text2);
}

.sub-tab-btn.active {
  background: rgba(88,166,255,0.15);
  color: var(--accent);
  border-color: rgba(88,166,255,0.3);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }

/* ============ GTM TESTS ============ */
.gtm-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.gtm-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 10px; transition: border-color 0.2s; }
.gtm-card:hover { border-color: rgba(88,166,255,0.3); }
.gtm-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.gtm-status { padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #fff; }
.gtm-status.draft { background: #6e7681; }
.gtm-status.ready { background: #1a9850; }
.gtm-status.running { background: #2166ac; }
.gtm-status.completed { background: #58a6ff; }
.gtm-status.validated { background: #64dc96; }
.gtm-status.rejected { background: #d73027; }
.gtm-priority { padding: 2px 6px; border-radius: 3px; font-size: 9px; font-weight: 600; text-transform: uppercase; }
.gtm-priority.high { background: rgba(255,160,80,0.15); color: #ffa050; }
.gtm-priority.medium { background: rgba(88,166,255,0.12); color: #58a6ff; }
.gtm-priority.low { background: rgba(139,148,158,0.15); color: #8b949e; }
.gtm-hypothesis { font-size: 13px; color: var(--text); line-height: 1.4; margin-bottom: 6px; font-weight: 500; }
.gtm-campaign { font-size: 11px; color: var(--accent); margin-bottom: 4px; }
.gtm-platform { font-size: 10px; color: var(--text2); margin-bottom: 8px; }
.gtm-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.gtm-metric { background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05); border-radius: 4px; padding: 6px 8px; text-align: center; }
.gtm-metric .metric-val { font-size: 16px; font-weight: 700; color: var(--accent2); }
.gtm-metric .metric-actual { font-size: 14px; font-weight: 700; color: #64dc96; }
.gtm-metric .metric-label { font-size: 9px; color: var(--text2); margin-top: 2px; }
.gtm-link { font-size: 10px; color: var(--text2); opacity: 0.7; }
.gtm-budget { font-size: 10px; color: var(--text2); margin-top: 4px; }
.gtm-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.gtm-summary-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; text-align: center; }
.gtm-summary-card .summary-val { font-size: 24px; font-weight: 800; color: var(--accent2); }
.gtm-summary-card .summary-label { font-size: 10px; color: var(--text2); margin-top: 2px; }

/* ============ C1 DRIVERS ============ */
.churn-header { margin-bottom: 8px; }
.churn-header h3 { color: var(--accent); font-size: 18px; margin-bottom: 4px; }
.churn-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.churn-segment h4 { font-size: 16px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.churn-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; margin-bottom: 12px; transition: border-color 0.2s; }
.churn-card:hover { border-color: rgba(80,160,255,0.3); }
.churn-risk { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.churn-risk .risk-bar-track { flex: 1; max-width: 200px; height: 8px; background: #1c2333; border-radius: 4px; overflow: hidden; }
.risk-bar { height: 100%; border-radius: 4px; transition: width 0.3s; }
.risk-val { font-size: 12px; color: var(--accent2); font-weight: 700; min-width: 40px; }
.churn-driver { font-size: 14px; color: var(--text); line-height: 1.5; margin-bottom: 6px; font-weight: 500; }
.churn-meta { font-size: 12px; color: var(--text2); margin-bottom: 6px; display: flex; align-items: center; }
.churn-need { color: var(--accent); font-weight: 500; }
.churn-evidence { font-size: 11px; color: var(--text2); opacity: 0.8; line-height: 1.4; padding-top: 6px; border-top: 1px solid var(--border); }

/* ============ KANO ============ */
.kano-matrix { overflow-x: auto; }
.kano-matrix .heatmap th.col-header {
  writing-mode: vertical-lr; transform: rotate(180deg);
  max-width: 42px; font-size: 10px; text-align: left; word-break: break-word;
  padding: 4px 2px; white-space: normal; line-height: 1.2;
}

/* ============ SWOT-5 FACTORS ============ */
.retention-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.retention-segment h4 { font-size: 16px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.retention-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; margin-bottom: 12px; transition: border-color 0.2s; }
.retention-card:hover { border-color: rgba(80,160,255,0.3); }
.ret-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ret-dim { padding: 3px 10px; border-radius: 6px; color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; white-space: nowrap; }
.ret-factor { font-size: 14px; color: var(--text); font-weight: 500; line-height: 1.4; }
.ret-bars { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.ret-bar-row { display: flex; align-items: center; gap: 10px; }
.ret-bar-label { font-size: 11px; color: var(--text2); min-width: 44px; font-weight: 600; }
.ret-bar { flex: 1; height: 7px; background: #1c2333; border-radius: 4px; overflow: hidden; }
.ret-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.ret-bar-val { font-size: 11px; color: var(--accent2); min-width: 36px; text-align: right; font-weight: 600; }
.ret-mechanic { font-size: 12px; color: var(--green); line-height: 1.4; margin-bottom: 8px; padding: 8px 12px; background: rgba(63,185,80,0.06); border-radius: 6px; border-left: 3px solid var(--green); }
.ret-mechanic strong { color: var(--accent2); }
.ret-evidence { font-size: 11px; color: var(--text2); opacity: 0.8; line-height: 1.4; padding-top: 8px; border-top: 1px solid var(--border); }

/* ============ GTM BUNDLES ============ */
.gtm-summary-bundles { grid-template-columns: repeat(2, 1fr) !important; max-width: 520px; }
.gtm-bundle-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; transition: border-color 0.2s; overflow: hidden; position: relative; padding: 0; }
.gtm-bundle-card:hover { border-color: rgba(88,166,255,0.3); }
.bundle-inner { padding: 18px 20px; position: relative; z-index: 1; }
.bundle-inner-locked { filter: blur(3px) saturate(0.85); opacity: 0.72; pointer-events: none; user-select: none; transform: translateZ(0); }
.bundle-lock-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(14,17,23,0.58); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 10; cursor: pointer; pointer-events: auto; padding: 20px; text-align: center; }
.lock-icon { font-size: 28px; margin-bottom: 6px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35)); }
.lock-tier { font-size: 13px; font-weight: 600; color: #e6b422; margin-bottom: 4px; }
.lock-text { color: var(--text2); font-size: 12px; line-height: 1.45; max-width: 280px; margin-bottom: 12px; }
.bundle-unlock-btn { border: none; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-family: inherit; transition: background 0.15s, transform 0.1s; }
.bundle-unlock-btn:hover { background: #79b8ff; }
.bundle-unlock-btn:active { transform: scale(0.98); }
.bundle-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.bundle-seg { font-size: 13px; font-weight: 600; color: var(--accent); }
.bundle-chan { font-size: 11px; color: var(--text2); padding: 2px 8px; background: rgba(255,255,255,0.04); border-radius: 4px; }
.bundle-roi { margin-left: auto; font-size: 12px; font-weight: 700; color: #64dcb4; background: rgba(100,220,180,0.1); padding: 2px 10px; border-radius: 4px; cursor: help; }
.bundle-needs, .bundle-features, .bundle-vp, .bundle-sales { font-size: 12px; color: var(--text); line-height: 1.5; margin-bottom: 6px; }
.bundle-needs strong, .bundle-features strong, .bundle-vp strong, .bundle-sales strong { color: var(--text2); font-weight: 500; }
.bundle-pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.bundle-pill { font-size: 11px; padding: 4px 10px; border-radius: 999px; line-height: 1.3; max-width: 100%; }
.bundle-pill-need { background: rgba(88,166,255,0.12); border: 1px solid rgba(88,166,255,0.28); color: #79b8ff; }
.bundle-pill-feat { background: rgba(63,185,80,0.1); border: 1px solid rgba(63,185,80,0.25); color: #56d364; }
.bundle-pill-more { background: rgba(255,255,255,0.06); border: 1px solid var(--border); color: var(--text2); }
.bundle-metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 12px 0; padding: 10px; background: rgba(255,255,255,0.02); border-radius: 8px; }
.bm { text-align: center; cursor: help; }
.bm-tip:hover .bm-label { color: var(--accent); }
.bm-label { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text2); margin-bottom: 4px; }
.bm-base { font-size: 11px; color: var(--text2); }
.bm-arrow { font-size: 10px; color: var(--text2); margin: 0 2px; }
.bm-adj { font-size: 12px; font-weight: 600; color: #64dcb4; }
.bundle-overlap { font-size: 11px; color: var(--text2); margin-top: 6px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.05); line-height: 1.45; }
.bundle-overlap .bundle-rat { color: var(--text); }
.gtm-bundle-header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
@media (max-width: 640px) { .bundle-metrics { grid-template-columns: repeat(3, 1fr); } }


/* ============ GTM BUNDLE UI LABELS ============ */
.bundle-num { font-size: 11px; font-weight: 700; color: var(--text2); background: rgba(255,255,255,0.06); border: 1px solid var(--border); padding: 2px 8px; border-radius: 4px; }
.bundle-section-label { font-size: 10px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.6px; margin: 10px 0 4px; }
.bundle-metrics-header { font-size: 10px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin: 12px 0 4px; }
.bundle-metrics-header .bm-hint { font-weight: 400; opacity: 0.6; text-transform: none; letter-spacing: 0; }
.bundle-rationale { font-size: 11px; color: var(--text); line-height: 1.45; margin-top: 4px; padding: 8px 12px; background: rgba(88,166,255,0.04); border-radius: 6px; border-left: 3px solid rgba(88,166,255,0.2); }

@media (max-width: 1200px) {
  .map-layout { grid-template-columns: 1fr; }
  .gtm-summary { grid-template-columns: repeat(2, 1fr); }
}
