:root {
  --bg: #14151f;
  --sidebar-bg: #1a1b28;
  --panel: #1f2130;
  --border: #2f3042;
  --text: #ececf1;
  --muted: #8b8b9c;
  --accent: #9b8afb;
  --accent-bg: rgba(155, 138, 251, 0.14);
  --accent-text: #b7a8ff;
  --good: #4ade80;
  --warn: #eab308;
  --bad: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  display: flex;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* --- Sidebar --- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
}
.sidebar .brand-link { display: block; padding: 0 10px 20px; }
.sidebar .brand { font-size: 16px; font-weight: 600; }
.sidebar .brand-sub { font-size: 11px; color: var(--accent); letter-spacing: 0.08em; margin-top: 2px; }
.sidebar .section-label { font-size: 10.5px; color: #6b6b7d; letter-spacing: 0.08em; margin: 18px 10px 6px; text-transform: uppercase; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--muted); position: relative; margin-bottom: 2px;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.sidebar nav a.active { background: rgba(255,255,255,0.05); color: var(--text); }
.sidebar nav a.active::after {
  content: ""; position: absolute; right: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.sidebar nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar .sub-nav { display: flex; flex-direction: column; margin: 0 0 2px 30px; }
.sidebar .sub-nav a {
  padding: 5px 10px; font-size: 12.5px; color: var(--muted); border-radius: 6px; margin-bottom: 0;
}
.sidebar .sub-nav a:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.sidebar .sub-nav a.active { color: var(--accent-text); background: none; }
.sidebar .footer { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--border); }
.sidebar .footer .label { font-size: 10.5px; color: #6b6b7d; }
.sidebar .footer .value { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* --- Main --- */
.main { flex: 1; padding: 28px 32px; min-width: 0; }
h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; margin: 28px 0 12px; color: var(--text); font-weight: 600; }
.subtitle { color: var(--muted); margin: 4px 0 22px; font-size: 13.5px; }

/* --- Stat tiles --- */
.stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; min-width: 160px; }
.stat .value { font-size: 26px; font-weight: 600; }
.stat .label { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; margin-top: 4px; text-transform: uppercase; }

/* --- Cards / panels --- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* --- Content Engine creative cards --- */
.creative-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.creative-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.creative-card img { width: 100%; aspect-ratio: 4/5; object-fit: cover; display: block; background: rgba(255,255,255,0.04); }
.creative-card .body { padding: 14px; }
.creative-card .idea-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.creative-card .score-row { display: flex; align-items: baseline; gap: 8px; margin: 8px 0; }
.creative-card .score-row .overall { font-size: 22px; font-weight: 700; }
.creative-card .caption { font-size: 12px; color: var(--muted); margin: 8px 0; }
.creative-card .actions { display: flex; gap: 8px; margin-top: 10px; }
.creative-card .actions form { flex: 1; }
.creative-card .actions button { width: 100%; }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
td a { color: var(--text); }
td a:hover { color: var(--accent-text); }

/* --- Badges / scores --- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-generic { background: rgba(255,255,255,0.06); color: var(--text); }
.badge-competitor { background: rgba(239,68,68,0.14); color: var(--bad); }
.badge-brand { background: rgba(239,68,68,0.14); color: var(--bad); }
.badge-feature { background: rgba(74,222,128,0.14); color: var(--good); }
.badge-status-completed { background: rgba(74,222,128,0.14); color: var(--good); }
.badge-status-pending { background: rgba(234,179,8,0.14); color: var(--warn); }
.badge-status-processing { background: rgba(234,179,8,0.14); color: var(--warn); }
.badge-status-failed { background: rgba(239,68,68,0.14); color: var(--bad); }

.score { font-weight: 700; }
.score-high { color: var(--good); }
.score-mid { color: var(--warn); }
.score-low { color: var(--bad); }

/* --- Filters / forms --- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 20px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.filters label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.filters input, .filters select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 7px;
  padding: 7px 9px; font-size: 13px;
}
.filters input:focus, .filters select:focus { outline: none; border-color: var(--accent); }
.filters select[multiple] { min-width: 140px; height: 64px; }

button, .btn {
  background: var(--accent); color: #16121f; border: none; border-radius: 7px;
  padding: 8px 15px; font-weight: 600; cursor: pointer; font-size: 13px; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button.secondary, .btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }

.pagination { display: flex; gap: 8px; margin-top: 16px; align-items: center; color: var(--muted); font-size: 13px; }
.pagination a { color: var(--text); padding: 5px 11px; border: 1px solid var(--border); border-radius: 7px; }
.pagination a:hover { border-color: var(--accent); }

/* --- Detail page --- */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 9px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.reasoning { color: var(--text); line-height: 1.6; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
.source-label { color: var(--good); }
.ai-label { color: var(--accent-text); }

.empty { color: var(--muted); font-style: italic; padding: 32px 20px; text-align: center; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
#enrich-log, #import-log { margin-top: 16px; font-size: 13px; }
#enrich-log .line, #import-log .line { padding: 5px 0; border-bottom: 1px solid var(--border); color: var(--muted); }

/* --- Growth Dashboard --- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h1 { margin: 0; }
.topbar .controls { display: flex; gap: 10px; }
.topbar .pill {
  font-size: 12.5px; color: var(--muted); background: transparent; border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px;
}
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 20px; }
.label-purple { font-size: 11px; color: var(--accent); letter-spacing: 0.08em; font-weight: 600; text-transform: uppercase; }
.label-gray { font-size: 11.5px; color: var(--muted); letter-spacing: 0.04em; margin-top: 4px; }
.label-gray.inline-note { display: inline-block; margin-top: 0; margin-left: 8px; }
.big-value { font-size: 42px; font-weight: 600; margin: 10px 0 12px; }
.big-value.placeholder-value { color: var(--muted); }
.badge.neutral { background: rgba(255,255,255,0.06); color: var(--muted); }
h2.section-title { font-size: 15.5px; font-weight: 600; margin: 26px 0 12px; }
.funnel-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 4px; }
.funnel-stat { background: var(--panel); border: 1px solid var(--border); border-top: 2px solid var(--stage); border-radius: 8px; padding: 14px 16px; }
.funnel-stat .value { font-size: 20px; font-weight: 600; margin-top: 6px; }
.card-title { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; font-weight: 600; margin-bottom: 14px; text-transform: uppercase; }
.top-opp { font-size: 13.5px; color: var(--muted); margin-top: 12px; }
.top-opp strong { color: var(--text); }
.card-link { display: inline-block; margin-top: 14px; font-size: 12.5px; color: var(--accent-text); }
.card-link:hover { text-decoration: underline; }
.status-note { font-size: 12.5px; color: #6b6b7d; margin-top: 14px; }
.empty-state { padding: 60px 20px; text-align: center; color: #6b6b7d; }
.empty-state .big { font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.label-gray strong { color: var(--text); font-weight: 600; }
.placeholder-value { color: var(--muted) !important; }

/* --- Generation categories --- */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; margin-bottom: 4px; }
.category-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.category-card .value { font-size: 22px; font-weight: 600; margin: 6px 0 10px; }
.mini-bar { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.mini-bar-fill { height: 100%; background: var(--accent); }

/* --- Vertical funnel stack --- */
.funnel-stack { display: flex; flex-direction: column; }
.funnel-stage {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--stage);
  border-radius: 10px; padding: 18px 22px;
}
.funnel-stage .value { font-size: 30px; font-weight: 600; margin: 4px 0; }
.funnel-conversion { text-align: right; }
.funnel-conversion .value { font-size: 20px; font-weight: 600; color: var(--accent-text); }
.funnel-arrow { text-align: center; color: var(--muted); padding: 6px 0; font-size: 14px; }

/* --- Buttons --- */
button:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; filter: none; }
.status-note.err { color: var(--bad); }

/* --- Intent badges --- */
.intent-badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: var(--accent-bg); color: var(--accent-text);
}

/* --- Generic Keywords word cloud --- */
.word-cloud { display: flex; flex-wrap: wrap; gap: 10px; }
.word-chip {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.04);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; font-size: 13.5px;
}
.word-chip strong { color: var(--text); font-weight: 600; }
.word-chip span { color: var(--muted); font-size: 12px; }

/* --- Feature Opps clusters --- */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 4px; }
.feature-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.feature-card-title { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; color: var(--accent-text); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.feature-card-roadmap { opacity: 0.7; }
.feature-card-roadmap .feature-card-title { color: var(--muted); }
.feature-kw-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.feature-kw-list li a { font-size: 13.5px; color: var(--text); }
.feature-kw-list li a:hover { color: var(--accent-text); }

/* --- Country Analysis heatmap --- */
.table-scroll { overflow-x: auto; }
table.heatmap { width: 100%; border-collapse: collapse; background: transparent; border: none; }
table.heatmap th { text-align: left; padding: 8px 14px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
table.heatmap td { padding: 8px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.heatmap tr:last-child td { border-bottom: none; }
table.heatmap td:first-child { font-weight: 600; color: var(--text); }
.heat-cell { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.heat-bar { width: 26px; height: 8px; border-radius: 4px; background: var(--border); }
.heat-cell.heat-high .heat-bar { background: var(--accent); }
.heat-cell.heat-medium .heat-bar { background: var(--accent); opacity: 0.6; }
.heat-cell.heat-low .heat-bar { background: var(--accent); opacity: 0.3; }
.heat-cell.heat-none { color: #5a5a68; }
.heat-cell.heat-none .heat-bar { display: none; }

/* --- Keyword Data delete button --- */
.delete-keyword-btn {
  background: transparent; border: none; color: var(--muted); font-size: 16px; line-height: 1;
  cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.delete-keyword-btn:hover { color: var(--bad); background: rgba(239,68,68,0.1); }

/* --- Import Data upload cards --- */
.upload-card { text-align: center; padding: 32px 24px; }
.upload-card.disabled-card { opacity: 0.6; }
.upload-icon {
  width: 44px; height: 44px; margin: 0 auto 14px; border-radius: 10px; background: var(--accent-bg);
  color: var(--accent-text); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
}
.upload-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.upload-card .label-gray { margin: 0 0 18px; }
.upload-actions { display: flex; gap: 10px; justify-content: center; }
.csv-example {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; color: var(--muted);
  overflow-x: auto; white-space: pre;
}

/* --- Growth Objectives --- */
.objective-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.objective-card { position: relative; }
.objective-card.objective-active { border-color: var(--accent); }
.objective-meta { display: flex; gap: 20px; margin-top: 14px; flex-wrap: wrap; }
.objective-activate-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.objective-activate-form input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 7px;
  padding: 6px 9px; font-size: 12.5px; flex: 1 1 120px; min-width: 0;
}
.objective-activate-form button { flex-shrink: 0; }

.progress-track { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); }

.objective-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--accent-bg); border: 1px solid rgba(155,138,251,0.3); border-radius: 10px;
  padding: 10px 16px; margin-bottom: 20px;
}
.objective-banner .label-gray { margin-top: 0; color: var(--text); }

/* --- Role toggle --- */
.role-toggle { display: flex; align-items: center; gap: 8px; }
.role-toggle-link { font-size: 11px; color: var(--accent-text); }
.role-toggle-link:hover { text-decoration: underline; }

/* --- Tabs --- */
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-pill { background: transparent; border: none; color: var(--muted); font-size: 13px; font-weight: 500; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-family: inherit; }
.tab-pill:hover { color: var(--text); }
.tab-pill.active { background: var(--accent-bg); color: var(--accent-text); font-weight: 600; }
.big-line { font-size: 19px; font-weight: 600; margin: 4px 0 10px; }
.big-line a { color: var(--text); }
.big-line a:hover { color: var(--accent-text); }

/* --- User Behavior funnel rows --- */
.behavior-row { display: grid; grid-template-columns: 160px 1fr 60px; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.behavior-row:last-child { border-bottom: none; }
.behavior-label { font-size: 13.5px; color: var(--text); }
.behavior-bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.behavior-bar-fill { height: 100%; background: var(--accent); }
.behavior-value { font-size: 13.5px; font-weight: 600; text-align: right; color: var(--muted); }
