  :root {
    --navy: #00232f;
    --cream: #f1f0ea;
    --teal: #78d6c6;
    --sage: #a8c864;
    --amber: #c8a96e;
    --text: #1a1a1a;
    --text-muted: #666;
    --card-bg: #fff;
    --border: #e2e2e2;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --up: #2e8b57;
    --down: #c0392b;
    --flat: #888;
    --health-strong: #2e8b57;
    --health-ok: #c8a96e;
    --health-weak: #c0392b;
    --health-new: #6ba3d6;
  }
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body { font-family: var(--font); background: var(--cream); color: var(--text); line-height: 1.5; }

  .header { background: linear-gradient(135deg, var(--navy) 0%, #003a4f 100%); color: var(--cream); padding: 36px 40px 32px; position: relative; overflow: hidden; }
  .header::after { content: ''; position: absolute; top: 0; right: 0; width: 300px; height: 100%; background: radial-gradient(circle at 80% 50%, rgba(120,214,198,0.08) 0%, transparent 70%); pointer-events: none; }
  .header-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; position: relative; z-index: 1; }
  .header-left { flex: 1; }
  .header h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--teal); margin-bottom: 6px; }
  .header .title-main { font-size: 1.7rem; font-weight: 300; line-height: 1.3; }
  .header .title-main strong { font-weight: 600; }
  .header-right { text-align: right; }
  .header .subtitle { font-size: 0.78rem; opacity: 0.5; }
  .header .period { font-size: 0.78rem; opacity: 0.45; margin-top: 4px; }

  .container { max-width: 1200px; margin: 0 auto; padding: 32px 24px 64px; }

  /* Tabs */
  .tab-bar { display: flex; gap: 4px; margin-bottom: 28px; border-bottom: 2px solid var(--border); overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { padding: 10px 16px; font-size: 0.78rem; font-weight: 600; cursor: pointer; border: none; background: none; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; white-space: nowrap; flex-shrink: 0; }
  .tab:hover { color: var(--text); }
  .tab.active { color: var(--navy); border-bottom-color: var(--teal); }
  .tab-content { display: none; }
  .tab-content.active { display: block; }

  /* Sub-tabs for Analytics */
  .sub-tab-bar { display: flex; gap: 2px; margin-bottom: 20px; }
  .sub-tab { padding: 6px 12px; font-size: 0.72rem; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--card-bg); color: var(--text-muted); border-radius: 6px; transition: all 0.15s; white-space: nowrap; }
  .sub-tab:hover { color: var(--text); }
  .sub-tab.active { color: var(--card-bg); background: var(--navy); border-color: var(--navy); }
  .sub-content { display: none; }
  .sub-content.active { display: block; }
  .set-content { display: none; }
  .set-content.active { display: block; }

  /* Empty state */
  .empty-state { text-align: center; padding: 120px 40px; color: var(--text-muted); }
  .empty-state h2 { font-size: 1.3rem; margin-bottom: 16px; color: var(--text); }
  .empty-state code { display: inline-block; background: var(--navy); color: var(--teal); padding: 8px 16px; border-radius: 6px; font-size: 0.85rem; margin: 12px 0; }
  .empty-state ol { text-align: left; display: inline-block; margin-top: 20px; font-size: 0.85rem; line-height: 2; }

  /* KPI cards */
  .kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
  .kpi { background: var(--card-bg); border-radius: 10px; padding: 18px; border: 1px solid var(--border); }
  .kpi .label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); margin-bottom: 4px; }
  .kpi .value { font-size: 1.6rem; font-weight: 700; color: var(--navy); }
  .kpi .change { font-size: 0.72rem; margin-top: 3px; font-weight: 600; }
  .kpi .change.up { color: var(--up); }
  .kpi .change.down { color: var(--down); }
  .kpi .change.flat { color: var(--flat); }
  .kpi .unit { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

  /* Section */
  .section { margin-bottom: 28px; }
  .section h2 { font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; color: var(--navy); }
  .section .section-sub { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; margin-left: 8px; }
  .card { background: var(--card-bg); border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }

  /* Chart */
  .chart-container { padding: 20px; overflow-x: auto; }
  .chart { display: flex; align-items: flex-end; gap: 2px; height: 140px; min-width: 400px; }
  .chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
  .chart-bar { width: 100%; max-width: 22px; background: var(--teal); border-radius: 3px 3px 0 0; min-height: 2px; cursor: default; position: relative; }
  .chart-bar:hover { opacity: 0.75; }
  .chart-bar .tooltip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--navy); color: var(--cream); padding: 4px 8px; border-radius: 4px; font-size: 0.7rem; white-space: nowrap; z-index: 10; }
  .chart-bar:hover .tooltip { display: block; }
  .chart-label { font-size: 0.5rem; color: var(--text-muted); margin-top: 4px; writing-mode: vertical-rl; transform: rotate(180deg); max-height: 44px; overflow: hidden; }

  /* Tables */
  .table-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
  th { text-align: left; padding: 9px 14px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); border-bottom: 1px solid var(--border); background: rgba(0,0,0,0.02); }
  th.num, td.num { text-align: right; }
  td { padding: 7px 14px; border-bottom: 1px solid rgba(0,0,0,0.04); }
  tr:last-child td { border-bottom: none; }
  .page-path { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--navy); font-weight: 500; }
  .bar-cell { display: flex; align-items: center; gap: 6px; }
  .mini-bar { height: 5px; background: var(--teal); border-radius: 3px; flex-shrink: 0; }
  .bar-val { font-weight: 600; font-size: 0.78rem; white-space: nowrap; }

  /* Two/three column */
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
  @media (max-width: 900px) { .three-col { grid-template-columns: 1fr; } }
  @media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } .header { padding: 24px 20px; } .container { padding: 20px 16px 48px; } }

  /* Donut */
  .donut-wrap { padding: 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
  .donut-svg { width: 110px; height: 110px; flex-shrink: 0; }
  .donut-legend { font-size: 0.78rem; line-height: 1.9; }
  .donut-legend .swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

  /* Event cards */
  .event-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
  .event-card { background: var(--card-bg); border-radius: 8px; padding: 14px 16px; border: 1px solid var(--border); }
  .event-card .ev-name { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
  .event-card .ev-val { font-size: 1.3rem; font-weight: 700; color: var(--navy); }
  .event-card .ev-change { font-size: 0.7rem; font-weight: 600; margin-top: 2px; }

  /* Source trend table */
  .trend-cell { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
  .trend-arrow { font-size: 0.7rem; }

  /* Page type tags */
  .page-tag { font-size: 0.6rem; font-weight: 700; padding: 2px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.06em; margin-left: 6px; }
  .page-tag.guide { background: rgba(168,200,100,0.15); color: #6a8020; }
  .page-tag.article { background: rgba(200,169,110,0.15); color: #8a6e30; }
  .page-tag.offering { background: rgba(120,214,198,0.15); color: #2a7a6a; }

  /* Sortable table headers */
  th.sortable { cursor: pointer; user-select: none; position: relative; }
  th.sortable:hover { color: var(--navy); }
  th.sortable::after { content: '\2195'; font-size: 0.55rem; margin-left: 4px; opacity: 0.35; }
  th.sortable.sort-asc::after { content: '\25B2'; opacity: 0.7; }
  th.sortable.sort-desc::after { content: '\25BC'; opacity: 0.7; }

  /* Audience Health */
  .overlap-viz { display: flex; align-items: center; gap: 40px; padding: 28px; flex-wrap: wrap; }
  .overlap-circles { position: relative; width: 260px; height: 160px; flex-shrink: 0; }
  .overlap-circle { position: absolute; width: 140px; height: 140px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-direction: column; font-weight: 700; font-size: 1.1rem; color: var(--card-bg); }
  .overlap-circle.kit { background: rgba(120,214,198,0.75); left: 0; top: 10px; }
  .overlap-circle.substack { background: rgba(168,200,100,0.75); left: 120px; top: 10px; }
  .overlap-count { position: absolute; left: 90px; top: 50px; width: 80px; height: 60px; display: flex; align-items: center; justify-content: center; flex-direction: column; font-size: 1.3rem; font-weight: 700; color: var(--navy); z-index: 2; }
  .overlap-count .ov-label { font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
  .overlap-stats { font-size: 0.85rem; line-height: 2; }
  .overlap-stats strong { color: var(--navy); }

  .edition-perf-table { font-size: 0.75rem; }
  .edition-perf-table th { font-size: 0.6rem; white-space: nowrap; }
  .edition-perf-table td { padding: 6px 10px; vertical-align: middle; }
  .edition-perf-table .ed-title { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--navy); }
  .platform-date { font-size: 0.6rem; color: var(--text-muted); display: block; }

  .growth-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  @media (max-width: 768px) { .growth-charts { grid-template-columns: 1fr; } }
  .growth-chart { padding: 20px; }
  .growth-bars { display: flex; align-items: flex-end; gap: 3px; height: 100px; }
  .growth-bar { flex: 1; background: var(--teal); border-radius: 2px 2px 0 0; min-height: 2px; position: relative; cursor: default; }
  .growth-bar.substack { background: var(--sage); }
  .growth-bar:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--navy); color: var(--cream); padding: 3px 6px; border-radius: 3px; font-size: 0.65rem; white-space: nowrap; z-index: 10; }

  .tag-search { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.82rem; margin-bottom: 12px; font-family: var(--font); }
  .tag-table td select { font-size: 0.75rem; padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--card-bg); }
  .tag-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.65rem; font-weight: 600; }
  .tag-badge.client { background: rgba(120,214,198,0.15); color: #2a7a6a; }
  .tag-badge.former { background: rgba(200,169,110,0.15); color: #8a6e30; }
  .tag-badge.prospect { background: rgba(168,200,100,0.15); color: #4a6e20; }
  .tag-badge.peer { background: rgba(107,163,214,0.15); color: #3a6a9a; }

  .refresh-note { text-align: center; font-size: 0.72rem; color: var(--text-muted); margin-top: 28px; }
  .refresh-note code { background: rgba(0,0,0,0.06); padding: 2px 6px; border-radius: 3px; font-size: 0.7rem; }

  .engage-bar { height: 4px; border-radius: 2px; background: #e8e8e4; position: relative; width: 60px; display: inline-block; vertical-align: middle; }
  .engage-fill { height: 100%; border-radius: 2px; position: absolute; left: 0; top: 0; }

  /* Publish markers on chart */
  .chart-bar.published { background: var(--sage); }
  .chart-bar.published .tooltip { background: #4a6e20; }
  .pub-marker { width: 7px; height: 7px; background: var(--sage); border-radius: 50%; margin-bottom: 2px; flex-shrink: 0; }

  /* Impact table */
  .impact-row { display: grid; grid-template-columns: 1fr 80px 80px 80px; gap: 8px; padding: 10px 14px; border-bottom: 1px solid rgba(0,0,0,0.04); font-size: 0.8rem; align-items: center; }
  .impact-row:last-child { border-bottom: none; }
  .impact-header { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); background: rgba(0,0,0,0.02); border-bottom: 1px solid var(--border); }
  .impact-title { font-weight: 500; color: var(--navy); }
  .impact-date { font-size: 0.7rem; color: var(--text-muted); }
  .impact-val { text-align: right; font-weight: 600; }

  /* Intelligence cards */
  .insight-card { background: var(--card-bg); border-radius: 10px; border: 1px solid var(--border); padding: 20px; margin-bottom: 14px; }
  .insight-card .insight-type { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; padding: 3px 8px; border-radius: 3px; display: inline-block; margin-bottom: 8px; }
  .insight-card .insight-type.opportunity { background: rgba(168,200,100,0.15); color: #4a6e20; }
  .insight-card .insight-type.watch { background: rgba(200,169,110,0.15); color: #8a6e30; }
  .insight-card .insight-type.win { background: rgba(120,214,198,0.15); color: #2a7a6a; }
  .insight-card .insight-type.action { background: rgba(192,57,43,0.1); color: #a02020; }
  .insight-card .insight-type.decay { background: rgba(192,57,43,0.1); color: #a02020; }
  .insight-card .insight-type.strong { background: rgba(46,139,87,0.12); color: #1a6b3a; }
  .insight-card h3 { font-size: 0.95rem; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
  .insight-card p { font-size: 0.82rem; color: var(--text); line-height: 1.6; }
  .insight-card .insight-data { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; }

  /* Health score badge */
  .health-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.05em; }
  .health-badge.strong { background: rgba(46,139,87,0.12); color: var(--health-strong); }
  .health-badge.ok { background: rgba(200,169,110,0.15); color: #8a6e30; }
  .health-badge.weak { background: rgba(192,57,43,0.1); color: var(--health-weak); }
  .health-badge.new { background: rgba(107,163,214,0.15); color: #3a6a9a; }
  .health-badge.no-data { background: rgba(0,0,0,0.05); color: var(--flat); }

  /* Experiment tracker */
  .exp-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 16px; }
  .exp-form input, .exp-form select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.82rem; font-family: var(--font); }
  .exp-form button { padding: 8px 16px; background: var(--navy); color: var(--cream); border: none; border-radius: 6px; font-size: 0.78rem; font-weight: 600; cursor: pointer; }
  .exp-form button:hover { opacity: 0.85; }
  .exp-status { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.65rem; font-weight: 700; }
  .exp-status.running { background: rgba(107,163,214,0.15); color: #3a6a9a; }
  .exp-status.concluded { background: rgba(46,139,87,0.12); color: var(--health-strong); }
  .exp-status.abandoned { background: rgba(0,0,0,0.05); color: var(--flat); }
  @media (max-width: 768px) { .exp-form { grid-template-columns: 1fr; } }

  /* Action list */
  .action-list { list-style: none; }
  .action-list li { padding: 12px 16px; border-bottom: 1px solid rgba(0,0,0,0.04); font-size: 0.85rem; display: flex; gap: 10px; align-items: flex-start; }
  .action-list li:last-child { border-bottom: none; }
  .action-num { width: 24px; height: 24px; border-radius: 50%; background: var(--navy); color: var(--cream); font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .action-text { flex: 1; }
  .action-text strong { color: var(--navy); }
  .action-text .action-why { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

  /* Content card grid */
  .content-card { background: var(--card-bg); border-radius: 10px; border: 1px solid var(--border); padding: 16px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
  .content-card .cc-title { font-weight: 600; color: var(--navy); font-size: 0.88rem; }
  .content-card .cc-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
  .content-card .cc-stats { display: flex; gap: 12px; font-size: 0.75rem; margin-top: 6px; }
  .content-card .cc-stat { display: flex; flex-direction: column; align-items: center; }
  .content-card .cc-stat-val { font-weight: 700; color: var(--navy); }
  .content-card .cc-stat-label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; }
  @media (max-width: 768px) { .content-card { grid-template-columns: 1fr; } }

  /* Brief summary card */
  .brief-card { background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border); padding: 24px; margin-bottom: 20px; }
  .brief-card h3 { font-size: 1rem; font-weight: 700; color: var(--navy); margin-bottom: 12px; }
  .brief-card.highlight { border-left: 4px solid var(--teal); }
