/* ============================================
   CLIENT PERFORMANCE DASHBOARD
   Design system + responsive layout
   ============================================ */

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
  --color-accent: #2563eb;
  --color-accent-light: #eff6ff;
  --color-success: #059669;
  --color-warning: #d97706;
  --color-views: #2563eb;
  --color-likes: #dc2626;
  --color-comments: #7c3aed;
  --color-shares: #059669;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---- Dark Mode ---- */

[data-theme="dark"] {
  --color-bg: #0f1117;
  --color-surface: #1a1d27;
  --color-text: #e5e7eb;
  --color-text-secondary: #9ca3af;
  --color-border: #2d3140;
  --color-accent-light: #1e293b;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
}

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

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */

.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ---- Header ---- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

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

.header-left .subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.header-right .last-updated {
  font-weight: 500;
}

/* ---- Writer client switcher ---- */

.client-switcher {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
}

.client-switcher:hover {
  border-color: var(--color-accent);
}

/* ---- Theme Toggle ---- */

.theme-toggle {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text);
  transition: background 0.15s ease, border-color 0.15s ease;
  line-height: 1;
}

.theme-toggle:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.refresh-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0 0 0 6px;
  vertical-align: middle;
  transition: color 0.15s ease;
  line-height: 1;
}

.refresh-btn:hover {
  color: var(--color-accent);
}

.refresh-btn.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ---- Summary Cards ---- */

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.card-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.card-detail {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 6px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Analytics Dropdown ---- */

.analytics-dropdown {
  margin-bottom: 24px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.analytics-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.15s ease;
}

.analytics-toggle::-webkit-details-marker { display: none; }

.analytics-toggle:hover {
  background: var(--color-accent-light);
}

.analytics-toggle-icon {
  font-size: 14px;
  transition: transform 0.2s ease;
  color: var(--color-text-secondary);
}

.analytics-dropdown[open] .analytics-toggle-icon {
  transform: rotate(90deg);
}

.analytics-toggle-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-secondary);
  margin-left: auto;
}

.analytics-dropdown[open] .analytics-toggle-hint {
  display: none;
}

.analytics-content {
  padding: 8px 24px 24px;
  border-top: 1px solid var(--color-border);
}

/* ---- Charts ---- */

/* ---- Monthly Summary Cards ---- */

.monthly-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.monthly-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.monthly-card-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.monthly-card-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.monthly-card-sub {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

/* ---- State Of Account Report ---- */

.report-emv-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  padding: 24px;
  margin-bottom: 24px;
  text-align: center;
}

.emv-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.emv-value {
  font-size: 48px;
  font-weight: 800;
  color: var(--color-success, #16a34a);
  line-height: 1.1;
  margin-bottom: 4px;
}

.emv-formula {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.emv-slider-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.emv-slider-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.emv-slider {
  width: 200px;
  accent-color: var(--color-success, #16a34a);
  cursor: pointer;
}

.emv-slider-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  min-width: 32px;
}

.report-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  padding: 24px;
  margin-bottom: 24px;
}

.report-box-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.report-box-sub {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 16px;
}

.report-paragraph {
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text);
  margin: 0;
}

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

.report-comparison-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
}

.report-comparison-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}

.report-comparison-table tbody tr:last-child td {
  border-bottom: none;
}

.report-metric-label {
  font-weight: 500;
  color: var(--color-text);
}

.report-metric-value {
  font-weight: 700;
  color: var(--color-text);
}

.report-insights {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.report-insights-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.report-insight {
  font-size: 13px;
  line-height: 1.5;
  padding: 6px 0;
  color: var(--color-text);
}

.report-insight .insight-label {
  font-weight: 600;
}

.report-insight .insight-change {
  font-weight: 600;
}

.hook-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hook-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

.hook-pill-count {
  font-weight: 700;
  font-size: 14px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.charts-grid-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-container {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}

.chart-container.full-width {
  grid-column: 1 / -1;
}

.chart-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--color-text);
}

.chart-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title-row .chart-title {
  margin-bottom: 0;
}

.chart-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.chart-toggle .period-btn {
  padding: 4px 10px;
  font-size: 11px;
}

.chart-wrapper {
  position: relative;
  width: 100%;
}

/* ---- Category Tags ---- */

.category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  overflow: visible;
}

.cat-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.4;
}

.cat-none {
  color: var(--color-text-secondary);
  font-size: 12px;
}

.cat-leadMagnet { background: #fef3c7; color: #92400e; }
.cat-brandJack { background: #dbeafe; color: #1e40af; }
.cat-contrarian { background: #fee2e2; color: #991b1b; }
.cat-questionHook { background: #f3f4f6; color: #374151; }
.cat-caseStudy { background: #d1fae5; color: #065f46; }
.cat-personal { background: #fed7aa; color: #7c2d12; }
.cat-mediaBuying { background: #e0e7ff; color: #4338ca; }
.cat-exitValuation { background: #ccfbf1; color: #0f766e; }
.cat-creative { background: #fae8ff; color: #a21caf; }
.cat-retentionLtv { background: #ffedd5; color: #ea580c; }
.cat-aiContent { background: #cffafe; color: #0e7490; }
.cat-graphsCharts { background: #fef9c3; color: #ca8a04; }
.cat-companyMilestone { background: #e0f2fe; color: #0369a1; }
.cat-productStory { background: #f3e8ff; color: #7e22ce; }
.cat-recruitment { background: #fef3c7; color: #b45309; }
.cat-fundraising { background: #d1fae5; color: #059669; }
.cat-product { background: #f3e8ff; color: #7e22ce; }
.cat-team { background: #dbeafe; color: #1d4ed8; }
.cat-sales { background: #fce7f3; color: #be185d; }
.cat-seo { background: #cffafe; color: #0e7490; }
.cat-competitorAttack { background: #fef2f2; color: #dc2626; }
.cat-youtube { background: #fee2e2; color: #cc0000; }
.cat-googleAds { background: #e8f0fe; color: #4285f4; }
.cat-incrementality { background: #cffafe; color: #0891b2; }
.cat-pmax { background: #ede9fe; color: #7c3aed; }
.cat-demandGen { background: #ffedd5; color: #c2410c; }
.cat-searchCampaign { background: #dbeafe; color: #1d4ed8; }
.cat-audit { background: #fef9c3; color: #a16207; }
.cat-technical { background: #f1f5f9; color: #475569; }
.cat-more {
  background: var(--color-border);
  color: var(--color-text-secondary);
  cursor: help;
}

[data-theme="dark"] .cat-leadMagnet { background: #78350f; color: #fef3c7; }
[data-theme="dark"] .cat-brandJack { background: #1e3a5f; color: #bfdbfe; }
[data-theme="dark"] .cat-contrarian { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .cat-questionHook { background: #374151; color: #d1d5db; }
[data-theme="dark"] .cat-caseStudy { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .cat-personal { background: #7c2d12; color: #fed7aa; }
[data-theme="dark"] .cat-mediaBuying { background: #312e81; color: #c7d2fe; }
[data-theme="dark"] .cat-exitValuation { background: #134e4a; color: #99f6e4; }
[data-theme="dark"] .cat-creative { background: #701a75; color: #f5d0fe; }
[data-theme="dark"] .cat-retentionLtv { background: #7c2d12; color: #fed7aa; }
[data-theme="dark"] .cat-aiContent { background: #164e63; color: #a5f3fc; }
[data-theme="dark"] .cat-graphsCharts { background: #713f12; color: #fef08a; }
[data-theme="dark"] .cat-companyMilestone { background: #0c4a6e; color: #bae6fd; }
[data-theme="dark"] .cat-productStory { background: #581c87; color: #e9d5ff; }
[data-theme="dark"] .cat-recruitment { background: #78350f; color: #fef3c7; }
[data-theme="dark"] .cat-fundraising { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .cat-product { background: #581c87; color: #e9d5ff; }
[data-theme="dark"] .cat-team { background: #1e3a8a; color: #bfdbfe; }
[data-theme="dark"] .cat-sales { background: #831843; color: #fce7f3; }
[data-theme="dark"] .cat-seo { background: #164e63; color: #a5f3fc; }
[data-theme="dark"] .cat-competitorAttack { background: #7f1d1d; color: #fecaca; }
[data-theme="dark"] .cat-youtube { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .cat-googleAds { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .cat-incrementality { background: #164e63; color: #a5f3fc; }
[data-theme="dark"] .cat-pmax { background: #4c1d95; color: #c4b5fd; }
[data-theme="dark"] .cat-demandGen { background: #7c2d12; color: #fed7aa; }
[data-theme="dark"] .cat-searchCampaign { background: #1e3a8a; color: #bfdbfe; }
[data-theme="dark"] .cat-audit { background: #713f12; color: #fef08a; }
[data-theme="dark"] .cat-technical { background: #334155; color: #cbd5e1; }
[data-theme="dark"] .cat-more { background: #374151; color: #9ca3af; }

/* Category edit button */
.cat-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: var(--color-text-muted, #9ca3af);
  opacity: 0;
  padding: 0 2px;
  transition: opacity 0.15s;
}

.category-tags:hover .cat-edit-btn {
  opacity: 1;
}

.cat-edit-btn:hover {
  color: var(--color-accent);
}

/* Category editor row */
.cat-editor-row td {
  padding: 0 !important;
  border-bottom: 1px solid var(--color-border);
}

.cat-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  background: var(--color-bg);
  flex-wrap: wrap;
}

.cat-editor-label {
  font-size: 11px;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.cat-toggle {
  background: none;
  border: 2px solid var(--color-border);
  border-radius: 14px;
  padding: 0;
  cursor: pointer;
  opacity: 0.4;
  transition: all 0.15s;
}

.cat-toggle:hover {
  opacity: 0.7;
}

.cat-toggle.active {
  opacity: 1;
  border-color: var(--color-accent);
}

.cat-toggle.saving {
  opacity: 0.5;
  pointer-events: none;
}

/* ---- Table Toolbar ---- */

.table-toolbar {
  padding: 12px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-search {
  flex: 1;
  min-width: 160px;
  display: flex;
  gap: 8px;
}

.toolbar-search input {
  flex: 1;
  min-width: 0;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.toolbar-search input:focus {
  border-color: var(--color-accent);
}

.toolbar-search input::placeholder {
  color: var(--color-text-secondary);
}

.toolbar-period {
  display: flex;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.period-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  transition: all 0.15s ease;
  border-right: 1px solid var(--color-border);
}

.period-btn:last-child {
  border-right: none;
}

.period-btn:hover {
  color: var(--color-text);
  background: var(--color-accent-light);
}

.period-btn.active {
  background: var(--color-accent);
  color: white;
}

.top-per-month-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  border-radius: 6px;
  transition: all 0.15s ease;
}

.top-per-month-btn:hover {
  color: var(--color-text);
  background: var(--color-accent-light);
}

.top-per-month-btn.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.toolbar-daterange {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 6px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.toolbar-daterange label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-daterange input[type="date"] {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.toolbar-daterange input[type="date"]:focus {
  border-color: var(--color-accent);
}

.toolbar-views select {
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.toolbar-views select:focus {
  border-color: var(--color-accent);
}

.toolbar-categories {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-group-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  min-width: 64px;
}

.filter-tag {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  transition: all 0.15s ease;
  font-family: var(--font-sans);
}

.filter-tag:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.filter-tag.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.filter-tag-uncategorized {
  border-style: dashed;
}

/* ---- Repeat Detection ---- */

.repeat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s ease;
}

.repeat-badge:hover,
.repeat-badge.active {
  background: #1e40af;
  color: white;
}

[data-theme="dark"] .repeat-badge {
  background: #1e3a5f;
  color: #93c5fd;
  border-color: #2563eb;
}

[data-theme="dark"] .repeat-badge:hover,
[data-theme="dark"] .repeat-badge.active {
  background: #2563eb;
  color: white;
}

.repeat-row td {
  padding: 0 !important;
  border-bottom: 1px solid var(--color-border);
}

.repeat-detail {
  padding: 12px 24px 16px;
  background: var(--color-accent-light);
}

.repeat-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.repeat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.repeat-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: 12px;
}

.repeat-item .repeat-date .comp-slug-row {
  margin-top: 4px;
}

.repeat-item.repeat-current {
  border-color: #d97706;
  background: #fffbeb;
}

.repeat-item.repeat-best {
  border-color: #059669;
  background: #ecfdf5;
}

.repeat-item.repeat-worst {
  border-color: #dc2626;
  background: #fef2f2;
}

[data-theme="dark"] .repeat-item.repeat-current {
  border-color: #d97706;
  background: #451a03;
}

[data-theme="dark"] .repeat-item.repeat-best {
  border-color: #059669;
  background: #064e3b;
}

[data-theme="dark"] .repeat-item.repeat-worst {
  border-color: #dc2626;
  background: #7f1d1d;
}

.repeat-date {
  font-weight: 500;
  color: var(--color-text-secondary);
  min-width: 90px;
  line-height: 1.4;
}

.repeat-days-ago {
  font-size: 10px;
  font-weight: 400;
  color: var(--color-text-muted, #9ca3af);
}

.repeat-hook {
  flex: 1;
  overflow: hidden;
  white-space: pre-line;
  color: var(--color-text);
  line-height: 1.4;
}

.repeat-hook.clickable-hook {
  cursor: pointer;
  transition: color 0.15s;
}

.repeat-hook.clickable-hook:hover {
  color: var(--color-accent);
}

.repeat-hook.clickable-hook.expanded {
  color: var(--color-accent);
}

.repeat-fullpost {
  padding: 12px 16px;
  margin: 0 0 6px 92px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.repeat-fullpost .fullpost-content {
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-text);
  white-space: pre-line;
}

.repeat-fullpost .fullpost-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--color-accent);
  text-decoration: none;
}

.repeat-fullpost .fullpost-link:hover {
  text-decoration: underline;
}

.repeat-metric {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-secondary);
  min-width: 70px;
  text-align: right;
}

/* ---- Post Table ---- */

.table-container {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
}

.table-header h2 { font-size: 15px; font-weight: 600; }
.table-header .post-count { font-size: 13px; color: var(--color-text-secondary); }
.table-header .notion-link { font-size: 12px; color: var(--color-accent); text-decoration: none; font-weight: 500; opacity: 0.8; transition: opacity 0.15s; }
.table-header .notion-link:hover { opacity: 1; text-decoration: underline; }
.notify-btn { padding: 4px 10px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; cursor: pointer; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); transition: opacity 0.15s; white-space: nowrap; }
.notify-btn:hover:not(:disabled) { opacity: 0.7; }
.notify-btn:disabled { cursor: default; opacity: 0.6; }
.notify-btn--sent { background: #ecfdf5; border-color: #059669; color: #059669; }
.notify-btn--error { background: #fef2f2; border-color: #dc2626; color: #dc2626; }

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

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

/* Column sizing */
th.col-date, td.col-date          { white-space: nowrap; }
th.col-hook, td.col-hook          { min-width: 300px; }
th.col-num, td.col-num            { white-space: nowrap; }
th.col-repeats, td.col-repeats    { white-space: nowrap; }
th.col-rework, td.col-rework      { white-space: nowrap; text-align: center; }
th.col-notes, td.col-notes        { white-space: nowrap; }

.rework-badge {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  background: #10b981;
  color: white;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  border: none;
  padding: 0;
}
.rework-badge.copied {
  background: #2563eb;
}
[data-theme="dark"] .rework-badge {
  background: #059669;
}
[data-theme="dark"] .rework-badge.copied {
  background: #3b82f6;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

/* Column resize handle */
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 1;
}

.col-resize-handle:hover,
.col-resize-handle.active {
  background: var(--color-accent);
  opacity: 0.4;
}

body.col-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.col-resizing * {
  cursor: col-resize !important;
}

thead th.sortable {
  cursor: pointer;
  transition: color 0.15s;
}

thead th.sortable:hover { color: var(--color-accent); }
thead th.sorted-asc  { color: var(--color-accent); }
thead th.sorted-desc { color: var(--color-accent); }
thead th.sorted-asc::after  { content: ' \2191'; }
thead th.sorted-desc::after { content: ' \2193'; }

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-accent-light); }

/* Date cell */
td.col-date {
  vertical-align: middle;
}

.date-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.recent-pill {
  display: block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 9px;
  background: var(--color-accent-light, #dbeafe);
  color: var(--color-accent, #3b82f6);
  margin-top: 2px;
}

.post-link-icon {
  color: var(--color-text-muted, #9ca3af);
  text-decoration: none;
  font-size: 12px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.post-link-icon:hover {
  opacity: 1;
  color: var(--color-accent);
}

/* Hook cell */
.hook-text {
  white-space: pre-line;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text);
  transition: color 0.15s ease;
}
.hook-text:hover { color: var(--color-accent); }
.hook-text.expanded { color: var(--color-accent); }

/* Numeric cells */
.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Notes cell */
.notes-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted, #9ca3af);
  cursor: pointer;
  padding: 3px 6px;
  font-size: 11px;
  transition: all 0.15s;
}

.notes-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.notes-btn.has-note {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.notes-row td {
  padding: 0 !important;
  border-bottom: 1px solid var(--color-border);
}

.notes-editor {
  padding: 12px 24px 16px;
  background: var(--color-bg);
}

.notes-editor textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
}

.notes-editor textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.notes-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.notes-actions button {
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

.notes-actions button.save-note {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

/* Full Post Expansion */
.fullpost-row td {
  padding: 0 !important;
  border-bottom: 1px solid var(--color-border);
}

.fullpost-detail {
  padding: 16px 24px 20px;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

.fullpost-content {
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-text);
  max-width: 640px;
  white-space: pre-line;
  word-wrap: break-word;
}

.fullpost-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}
.fullpost-link:hover { text-decoration: underline; }

/* ---- Loading & Error States ---- */

.loading-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.loading-state .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

.loading-state p {
  font-size: 15px;
  color: var(--color-text-secondary);
}

.error-state h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.error-state p {
  font-size: 14px;
  color: var(--color-text-secondary);
}

/* ---- Section Spacing ---- */

.section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .charts-grid-3col {
    grid-template-columns: 1fr;
  }

  .monthly-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .emv-slider {
    width: 140px;
  }

  .repeat-item {
    flex-wrap: wrap;
  }
}

@media (max-width: 600px) {
  .dashboard {
    padding: 16px 12px 40px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .header-right {
    text-align: left;
  }

  .summary-cards {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .card {
    padding: 14px 16px;
  }

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

  .chart-container {
    padding: 16px;
  }

  .table-toolbar {
    padding: 10px 16px;
  }

  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-search {
    min-width: unset;
  }

  .emv-value {
    font-size: 36px;
  }

  .emv-slider-row {
    flex-wrap: wrap;
  }

  .report-comparison-table {
    font-size: 12px;
  }

  .report-comparison-table thead th,
  .report-comparison-table tbody td {
    padding: 6px 8px;
  }
}

/* ---- Print ---- */

@media print {
  body { background: white; }
  .dashboard { max-width: none; padding: 0; }
  .card, .chart-container, .table-container {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }
  .theme-toggle { display: none; }
}

/* ---- Tab Navigation ---- */

.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
  border-bottom: 2px solid var(--color-border);
}

.tab-item {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--font-sans);
}

.tab-item:hover {
  color: var(--color-text);
}

.tab-item.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* Notification pills on tabs */
.tab-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  background: #dc2626;
  color: white;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---- Interview Table ---- */

.interview-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.interview-table th,
.interview-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  font-size: 13px;
}

.interview-table th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.interview-table th.col-drag,
.interview-table td.col-drag { width: 32px; min-width: 32px; max-width: 32px; padding: 12px 4px; text-align: center; }

.drag-handle {
  cursor: grab;
  color: var(--color-text-secondary);
  opacity: 0.3;
  font-size: 14px;
  user-select: none;
  transition: opacity 0.15s;
}
.drag-handle:hover { opacity: 0.8; }
.drag-handle:active { cursor: grabbing; }

tr.dragging { opacity: 0.4; }
tr.drag-over-above { box-shadow: inset 0 2px 0 0 var(--color-accent); }
tr.drag-over-below { box-shadow: inset 0 -2px 0 0 var(--color-accent); }

.interview-table th.col-idea { width: 200px; }
.interview-table th.col-questions { width: 380px; min-width: 280px; }
.interview-table th.col-answer { width: auto; }
.interview-table th.col-status { width: 140px; }
.interview-table th.col-actions { width: 60px; }

/* Sortable interview headers */
th.iv-sortable { cursor: pointer; user-select: none; }
th.iv-sortable:hover { color: var(--color-accent); }
th.iv-sortable::after { content: ''; margin-left: 4px; }
th.iv-sortable.sorted-asc::after { content: ' \25B2'; font-size: 9px; }
th.iv-sortable.sorted-desc::after { content: ' \25BC'; font-size: 9px; }

/* Interview filter select */
/* Interview toolbar row layout */
.interview-table ~ .table-toolbar,
.table-container:has(.interview-table) .table-toolbar {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.interview-filter-select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 8px);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
.interview-filter-select:focus { border-color: var(--color-accent); }

/* Delete button */
.delete-interview-btn {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.4;
  transition: opacity 0.15s, color 0.15s;
}
.delete-interview-btn:hover {
  opacity: 1;
  color: #dc2626;
}
td.col-actions {
  text-align: center;
  vertical-align: middle;
}

.interview-table td.col-idea {
  font-weight: 500;
}

.iv-image-link {
  display: block;
  margin: 0 0 12px;
  text-decoration: none;
}

.iv-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border, #e2e2e2);
  border-radius: 6px;
  background: #fff;
}

.iv-image-caption {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--color-text-muted, #888);
}

.iv-image-link:hover .iv-image {
  border-color: var(--color-accent, #888);
}

.question-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.question-list li {
  position: relative;
  padding-left: 14px;
  padding-right: 20px;
  margin-bottom: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text);
}

.delete-question-btn {
  position: absolute;
  right: 0;
  top: 0;
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.question-list li:hover .delete-question-btn {
  opacity: 0.5;
}
.delete-question-btn:hover {
  opacity: 1 !important;
  color: #dc2626;
}

.question-list li:last-child {
  margin-bottom: 0;
}

.question-list li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--color-text-secondary);
}

.status-select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 8px);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}

.status-select:focus {
  border-color: var(--color-accent);
}

.status-select.status-not-answered {
  border-left: 3px solid var(--color-text-secondary);
}

.status-select.status-answered {
  border-left: 3px solid #d97706;
}

.status-select.status-ingested {
  border-left: 3px solid #2563eb;
}

.status-select.status-na-icp {
  border-left: 3px solid #dc2626;
}

.status-select.status-written {
  border-left: 3px solid #059669;
}

/* ---- Answer Textarea ---- */

.answer-textarea {
  width: 100%;
  min-height: 150px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 8px);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.5;
  resize: none;
  overflow: hidden;
  outline: none;
  transition: border-color 0.15s;
}

.answer-textarea:focus {
  border-color: var(--color-accent);
}

.answer-textarea::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.6;
}

/* ---- Question Editing ---- */

.question-list li .q-text {
  cursor: default;
}

.question-list li .q-text.q-editable {
  cursor: pointer;
}

.question-list li .q-text.q-editable:hover {
  color: var(--color-accent);
}

.q-link {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--color-accent) 40%, transparent);
  cursor: pointer;
}

.q-link:hover {
  text-decoration-color: var(--color-accent);
}

.q-link-post {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
  padding: 1px 4px;
  border-radius: 3px;
}

.question-list li:has(.question-edit-input) {
  padding-left: 0;
}

.question-list li:has(.question-edit-input)::before {
  display: none;
}

.question-edit-input {
  display: block;
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--color-accent);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.5;
  box-sizing: border-box;
  resize: vertical;
  outline: none;
}

/* ---- Interview Guidance Banner ---- */

.interview-guidance {
  padding: 16px 20px;
  margin-bottom: 16px;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm, 8px);
  background: var(--color-accent-light);
  color: var(--color-text);
  font-size: 13px;
  line-height: 1.6;
}

.interview-guidance p + p {
  margin-top: 10px;
}

.interview-guidance ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.interview-guidance li {
  margin-top: 2px;
}

/* ---- Add Interview Form ---- */

.add-interview-form {
  padding: 16px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 8px);
  background: var(--color-surface);
  margin-bottom: 12px;
}

.add-interview-fields {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.add-interview-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.add-interview-field--questions {
  flex: 2;
}

.add-interview-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
}

.add-interview-field input {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 8px);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 12px;
  outline: none;
}

.add-interview-field input:focus {
  border-color: var(--color-accent);
}

.add-interview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.add-iv-save {
  background: var(--color-accent) !important;
  color: #fff !important;
  border-color: var(--color-accent) !important;
}

/* ---- Content Table ---- */

.content-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.content-table th,
.content-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  font-size: 13px;
}

.content-table th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.content-table tbody tr:hover {
  background: var(--color-accent-light);
}

.content-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

[data-theme="dark"] .content-status-badge {
  background: transparent !important;
}

/* ---- Empty State ---- */

.empty-state {
  padding: 64px 24px;
  text-align: center;
}

.empty-state p {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.empty-hint code {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* ---- Ads Dashboard ---- */

.ads-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.ads-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ads-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.ads-stat-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.ads-stat-context {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.ads-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ads-filter-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.ads-filter-input {
  width: 100px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  font-family: inherit;
}

.ads-filter-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

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

.ads-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.ads-table th.col-num {
  text-align: right;
}

.ads-table th.sorted-desc::after {
  content: ' \u25BC';
  font-size: 10px;
}

.ads-table th.sorted-asc::after {
  content: ' \u25B2';
  font-size: 10px;
}

.ads-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.ads-table td.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ads-table tbody tr:hover {
  background: var(--color-hover);
}

/* ---- Ads: Preset Buttons ---- */

.ads-preset-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ads-preset-btn {
  padding: 6px 16px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.ads-preset-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.ads-preset-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

/* ---- Ads: Expand / Drill-Down ---- */

.ads-expand-col {
  width: 30px !important;
  min-width: 30px;
  max-width: 30px;
}

.ads-expand-cell {
  text-align: center;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 10px;
  padding: 10px 4px !important;
  user-select: none;
}

.ads-company-row,
.ads-campaign-row {
  cursor: pointer;
}

.ads-company-row:hover .ads-expand-cell,
.ads-campaign-row:hover .ads-expand-cell {
  color: var(--color-accent);
}

.ads-row-expanded {
  background: var(--color-accent-light);
}

.ads-row-expanded:hover {
  background: var(--color-accent-light) !important;
}

.ads-drill-row {
  background: var(--color-bg);
}

.ads-drill-row:hover {
  background: var(--color-bg) !important;
}

.ads-drill-container {
  padding: 8px 16px 12px 40px;
}

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

.ads-drill-table th {
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.ads-drill-table th.col-num {
  text-align: right;
}

.ads-drill-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.ads-drill-table td.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ads-drill-table tbody tr:hover {
  background: var(--color-surface);
}

.ads-drill-table tbody tr:last-child td {
  border-bottom: none;
}

/* ---- Ads: Accordion Tables ---- */

.ads-accordion {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-top: 16px;
}

.ads-accordion-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.15s ease;
}

.ads-accordion-toggle::-webkit-details-marker { display: none; }

.ads-accordion-toggle:hover {
  background: var(--color-accent-light);
}

.ads-accordion-icon {
  font-size: 14px;
  transition: transform 0.2s ease;
  color: var(--color-text-secondary);
}

.ads-accordion[open] .ads-accordion-icon {
  transform: rotate(90deg);
}

.ads-accordion-content {
  border-top: 1px solid var(--color-border);
}

.ads-accordion-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--color-border);
}

/* ---- Ads: Status Badge ---- */

.ads-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ads-status-badge.badge-active {
  background: #d1fae5;
  color: #065f46;
}

.ads-status-badge.badge-paused {
  background: #f3f4f6;
  color: #6b7280;
}

[data-theme="dark"] .ads-status-badge.badge-active {
  background: #064e3b;
  color: #a7f3d0;
}

[data-theme="dark"] .ads-status-badge.badge-paused {
  background: #374151;
  color: #9ca3af;
}

/* ============================================
   COMPETITORS TAB
   ============================================ */

.comp-section {
  margin-bottom: 16px;
}

.comp-empty {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 24px;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.comp-empty code {
  background: var(--color-accent-light);
  color: var(--color-accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* Profiles card */

.comp-profiles-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px 20px;
}

.comp-profiles-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.comp-profiles-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.comp-count {
  color: var(--color-text-secondary);
  font-weight: 400;
  font-size: 0.85rem;
}

.comp-scrape-all {
  background: var(--color-accent);
  color: white;
  border: 0;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.comp-scrape-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.comp-scrape-status {
  color: var(--color-text-secondary);
  font-size: 0.8rem;
}

.comp-scrape-status--error {
  color: #dc2626;
}

.comp-scrape-all:hover:not(:disabled) {
  filter: brightness(1.05);
}

.comp-scrape-all:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.comp-profiles-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comp-profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}

.comp-profile-row:last-child {
  border-bottom: 0;
}

.comp-profile-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.comp-profile-handle {
  color: var(--color-accent);
  font-weight: 500;
  text-decoration: none;
  font-size: 0.9rem;
}

.comp-profile-meta {
  color: var(--color-text-secondary);
  font-size: 0.8rem;
}

.comp-run-badge {
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 500;
}

.comp-run-failed {
  background: #fee2e2;
  color: #991b1b;
}

[data-theme="dark"] .comp-run-badge {
  background: #422006;
  color: #fbbf24;
}

[data-theme="dark"] .comp-run-failed {
  background: #450a0a;
  color: #fca5a5;
}

/* Toolbar */

.comp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 14px;
}

.comp-cat-toggle,
.comp-view-toggle,
.comp-filter-toggle {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}

.comp-cat-btn,
.comp-view-btn,
.comp-filter-btn {
  background: transparent;
  color: var(--color-text-secondary);
  border: 0;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.comp-cat-btn.active,
.comp-view-btn.active,
.comp-filter-btn.active {
  background: var(--color-accent);
  color: white;
}

.comp-cat-btn {
  font-weight: 600;
}

.comp-cat-badge {
  background: var(--color-accent-light);
  color: var(--color-accent);
  padding: 1px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Slug pill + copy button shown on saved posts */
.comp-slug-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.comp-slug {
  background: var(--color-accent-light);
  color: var(--color-accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.comp-copy-btn {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 120ms ease;
}

.comp-copy-btn:hover {
  background: var(--color-accent-light);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.comp-copy-btn.copied {
  background: #d1fae5;
  color: #065f46;
  border-color: #10b981;
}

[data-theme="dark"] .comp-copy-btn.copied {
  background: #064e3b;
  color: #a7f3d0;
}

.comp-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.comp-search {
  flex: 1;
  min-width: 200px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}

.comp-search:focus {
  border-color: var(--color-accent);
}

.comp-period {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}

.comp-period-btn {
  background: transparent;
  color: var(--color-text-secondary);
  border: 0;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  border-right: 1px solid var(--color-border);
}

.comp-period-btn:last-child { border-right: 0; }

.comp-period-btn.active {
  background: var(--color-accent);
  color: white;
}

.comp-outliers {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text);
  font-size: 0.85rem;
  cursor: pointer;
}

.comp-sort,
.comp-creator {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

.comp-creator {
  max-width: 200px;
}

/* Table */

.comp-table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.comp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}

.comp-table thead {
  background: var(--color-accent-light);
}

.comp-table th.comp-sortable { cursor: pointer; }
.comp-table th.comp-sortable:hover { color: var(--color-accent); }
.comp-table th[data-sorted] { color: var(--color-accent); }
.comp-sort-arrow {
  margin-left: 4px;
  font-size: 0.7em;
  vertical-align: middle;
}

.comp-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: relative;
  user-select: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.comp-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comp-cell-hook {
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

.comp-table tbody tr:hover {
  background: var(--color-accent-light);
}

.comp-cell-date { white-space: nowrap; color: var(--color-text-secondary); }
.comp-cell-handle a { color: var(--color-accent); text-decoration: none; }
.comp-cell-hook a { color: var(--color-text); text-decoration: none; }
.comp-cell-hook a:hover { color: var(--color-accent); }

/* Expandable hook */
.comp-hook-toggle {
  cursor: pointer;
  color: var(--color-text);
  display: block;
}
.comp-hook-toggle:hover { color: var(--color-accent); }
.comp-hook-toggle::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  color: var(--color-text-secondary);
  transition: transform 120ms ease;
}
.comp-hook-toggle.expanded::before { transform: rotate(90deg); }

.comp-detail-row > td {
  background: var(--color-accent-light);
  padding: 0 12px 14px 12px !important;
}
.comp-detail-row:hover > td { background: var(--color-accent-light); }
.comp-detail {
  padding-left: 18px;
}
.comp-detail-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  color: var(--color-text);
  font-size: 0.88rem;
}
.comp-detail-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--color-accent);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
}
.comp-detail-link:hover { text-decoration: underline; }
.comp-cell-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.comp-cell-score { font-weight: 600; }
.comp-cell-actions { white-space: nowrap; text-align: right; }

.comp-outlier-badge {
  display: inline-block;
  margin-left: 4px;
  color: #f59e0b;
  font-size: 0.9em;
}

/* Tick / cross buttons */

.comp-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  margin-left: 4px;
  transition: all 120ms ease;
}

.comp-btn-tick:hover {
  background: #d1fae5;
  border-color: #10b981;
  color: #065f46;
}

.comp-btn-cross:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

[data-theme="dark"] .comp-btn-tick:hover {
  background: #064e3b;
  color: #a7f3d0;
}

[data-theme="dark"] .comp-btn-cross:hover {
  background: #450a0a;
  color: #fca5a5;
}

/* Grid */

.comp-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 1100px) {
  .comp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .comp-grid { grid-template-columns: minmax(0, 1fr); }
}

.comp-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.comp-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.comp-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.comp-card-score {
  font-weight: 600;
  color: var(--color-text);
}

.comp-card-actions {
  display: flex;
  gap: 4px;
}

.comp-card-meta {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.comp-card-meta a {
  color: var(--color-accent);
  text-decoration: none;
}

.comp-card-media {
  position: relative;
  flex-shrink: 0;
  margin-top: auto;
  border-radius: 6px;
  overflow: hidden;
  background: var(--color-bg, #f4f4f5);
  border: 1px solid var(--color-border);
}

.comp-card-media img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
}

.comp-media-count {
  position: absolute;
  bottom: 6px;
  right: 6px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
}

.comp-card-body {
  font-size: 0.85rem;
  color: var(--color-text);
  white-space: pre-wrap;
  line-height: 1.45;
  max-height: 380px;
  overflow-y: auto;
}

/* ---- Lead Magnet Roadmap ---- */

.magnet-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  background: var(--color-bg);
  margin-bottom: 12px;
}

.magnet-card:last-child { margin-bottom: 0; }

.magnet-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.magnet-body { flex: 1; min-width: 0; }

.magnet-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.magnet-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.magnet-format {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.magnet-summary {
  font-size: 13px;
  color: var(--color-text);
}

.magnet-note {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.magnet-made-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.magnet-made-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.magnet-made-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.magnet-made-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

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

.magnet-made-item a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}

.magnet-made-item a:hover { text-decoration: underline; }

.magnet-made-note {
  display: block;
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* ---- Post media column (thumbnail + hover preview) ---- */

th.col-media, td.col-media {
  width: 56px;
  min-width: 48px;
}

.media-cell {
  position: relative;
  width: 40px;
  height: 40px;
  cursor: zoom-in;
}

.media-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  display: block;
  background: var(--color-bg);
}

.media-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  pointer-events: none;
}

.media-count {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--color-text);
  color: var(--color-surface);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 8px;
  pointer-events: none;
}

#media-preview {
  position: fixed;
  display: none;
  z-index: 3000;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  pointer-events: none;
  max-height: 80vh;
  overflow: hidden;
}

#media-preview img,
#media-preview video {
  display: block;
  max-width: 420px;
  max-height: 62vh;
  border-radius: var(--radius-sm);
}

#media-preview img + img {
  margin-top: 6px;
}

.media-preview-more {
  font-size: 11px;
  color: var(--color-text-secondary);
  text-align: center;
  padding: 4px 0 2px;
}

.comp-card-media { cursor: zoom-in; }

/* ---- Media download buttons ---- */

.media-dl {
  position: absolute;
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.media-dl:hover { background: rgba(0, 0, 0, 0.9); }

.media-cell .media-dl { top: -5px; right: -5px; }
.media-cell:hover .media-dl { display: flex; }

.comp-media-dl {
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  font-size: 13px;
}

.comp-card-media:hover .comp-media-dl { display: flex; }
