/* Pinterest Ad Central v5.0 */
:root {
  --primary:      #E60023;
  --primary-light: rgba(230,0,35,.1);
  --bg:           #F0F2F5;
  --sidebar-bg:   #FFFFFF;
  --card-bg:      #FFFFFF;
  --text:         #1E293B;
  --text-muted:   #64748B;
  --border:       #E2E8F0;
  --shadow:       0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.1), 0 12px 32px rgba(0,0,0,.08);
  --transition:   all .2s ease;
  --radius:       14px;
}

body.dark-mode {
  --bg:         #0B0E14;
  --sidebar-bg: #111520;
  --card-bg:    #161b27;
  --text:       #F1F5F9;
  --text-muted: #7C8DB0;
  --border:     #222d40;
  --shadow:     0 2px 8px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  --shadow-hover: 0 4px 16px rgba(0,0,0,.4), 0 16px 40px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  transition: background .3s, color .3s;
}

/* ── SIDEBAR ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 232px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: fixed;
  top: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 28px;
  padding: 0 6px;
  color: var(--text);
}
.logo i { color: var(--primary); font-size: 26px; }
.logo strong { color: var(--primary); }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 9px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  transition: var(--transition);
  font-size: 14px;
}
.side-nav a i { width: 16px; text-align: center; }
.side-nav a:hover { background: var(--primary-light); color: var(--primary); }
.side-nav a.active { background: var(--primary); color: #fff; font-weight: 600; }

.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin: 20px 0 6px 12px;
}

.side-nav-action {
  text-decoration: none;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  transition: var(--transition);
}
.side-nav-action i { width: 16px; text-align: center; }
.side-nav-action:hover { background: var(--primary-light); color: var(--primary); }

.sidebar-spacer { flex: 1; }

.theme-switch, .logout-btn {
  padding: 9px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}
.theme-switch i, .logout-btn i { width: 16px; text-align: center; }
.theme-switch:hover { background: var(--primary-light); color: var(--primary); }
.logout-btn:hover { color: #dc2626; }
.logout-btn { margin-top: 2px; }

/* ── MAIN ─────────────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: 232px;
  padding: 20px 28px 32px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-bar {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  transition: var(--transition);
}
.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.search-bar i { color: var(--text-muted); font-size: 13px; }
.search-bar input {
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  width: 100%;
}
.search-bar input::placeholder { color: var(--text-muted); }

.header-actions { display: flex; align-items: center; gap: 6px; }

.btn-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--card-bg);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 13px;
}
.btn-icon:hover, .btn-icon.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-danger-outline {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  background: var(--card-bg);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}
.btn-danger-outline:hover { border-color: #dc2626; color: #dc2626; background: rgba(220,38,38,.06); }

/* ── STATS ────────────────────────────────────────────────────────────────── */
.top-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }

.stat-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.stat-box:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }

.stat-label { font-size: 10px; font-weight: 700; color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); margin-top: 4px; display: block; }
.stat-icon  { font-size: 24px; color: var(--border); opacity: .8; }

/* ── FILTERS ──────────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filters-bar select, .filters-bar input[type="date"] {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 11px;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}
.filters-bar select:focus, .filters-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.btn-clear-filters {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  padding: 7px 12px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-clear-filters:hover { border-color: #dc2626; color: #dc2626; background: rgba(220,38,38,.04); }

/* ── GRID ─────────────────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(250px,1fr)); gap: 18px; }
.loading-pulse {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* ── CARDS ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); border-color: rgba(230,0,35,.2); }

.card-media {
  position: relative;
  aspect-ratio: 4/5;
  overflow: hidden;
  background: #0d1117;
  flex-shrink: 0;
}
.card-media video, .card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media video { cursor: pointer; }

.badge-video, .badge-seen {
  position: absolute;
  top: 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  color: #fff;
  z-index: 2;
  letter-spacing: .02em;
}
.badge-video { left: 8px; background: rgba(230,0,35,.9); backdrop-filter: blur(4px); }
.badge-seen  { right: 8px; background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }

.card-info { padding: 13px 14px 14px; display: flex; flex-direction: column; gap: 0; flex: 1; }

.card-category {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  border-radius: 5px;
  padding: 2px 7px;
  margin-bottom: 7px;
  letter-spacing: .05em;
  text-transform: uppercase;
  align-self: flex-start;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tags */
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tag {
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: default;
}
.tag-remove { cursor: pointer; font-size: 9px; opacity: .5; }
.tag-remove:hover { opacity: 1; }
.tag-input-row { margin-bottom: 8px; }
.tag-input {
  border: 1px dashed var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  padding: 3px 10px;
  outline: none;
  width: 80px;
  transition: var(--transition);
}
.tag-input:focus { border-color: var(--primary); width: 120px; }

/* Card footer — two rows to prevent overflow */
.card-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.card-advertiser {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.card-advertiser i { flex-shrink: 0; }
.card-advertiser span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.card-btns a, .card-btns button {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  flex-shrink: 0;
}
.card-btns a:hover, .card-btns button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.btn-fav:hover, .btn-fav.active {
  background: rgba(245,158,11,.1) !important;
  border-color: #f59e0b !important;
  color: #f59e0b !important;
}
.btn-ai {
  border-color: rgba(99,102,241,.35) !important;
  color: #6366f1 !important;
}
.btn-ai:hover { background: rgba(99,102,241,.1) !important; }
.btn-del:hover { border-color: #dc2626 !important; color: #dc2626 !important; background: rgba(220,38,38,.06) !important; }

.card-seen-info { font-size: 11px; color: var(--text-muted); margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.card-price { font-size: 12px; color: #10b981; font-weight: 600; margin-top: 4px; }
.card-lp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #6366f1;
  text-decoration: none;
  margin-top: 6px;
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 6px;
  padding: 2px 8px;
  align-self: flex-start;
  transition: var(--transition);
}
.card-lp-badge:hover { background: rgba(99,102,241,.08); }

/* ── LIST VIEW ────────────────────────────────────────────────────────────── */
.list-view { grid-template-columns: 1fr; gap: 6px; }
.list-view .card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
}
.card-media-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  background: #0d1117;
  flex-shrink: 0;
}
.card-media-thumb video, .card-media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-list-info { min-width: 0; }
.card-list-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-list-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.card-list-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }

.btn-icon-sm {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}
.btn-icon-sm:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ── PAGINATION ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 0;
}
.pagination button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--card-bg);
  color: var(--text);
  transition: var(--transition);
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button:disabled { opacity: .3; cursor: not-allowed; }
#pageInfo { font-size: 13px; color: var(--text-muted); }

/* ── ANALYTICS ────────────────────────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 24px; }
.chart-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.chart-box h3 { font-size: 13px; font-weight: 700; margin: 0 0 16px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.chart-box-wide { grid-column: 1/-1; }

/* ── MODALS ───────────────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal.open { display: flex; }

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 28px 24px;
  width: 100%;
  max-width: 520px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.modal-wide { max-width: 680px; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--text); border-color: var(--text-muted); }

.modal-content h2 { margin: 0 0 4px; font-size: 17px; }
.modal-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

#notesText {
  width: 100%;
  min-height: 130px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 12px;
  outline: none;
  resize: vertical;
  margin-bottom: 14px;
  transition: var(--transition);
}
#notesText:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 24px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover { opacity: .88; }

/* ── AI MODAL ─────────────────────────────────────────────────────────────── */
.ai-copy-box { margin-bottom: 14px; }
.ai-copy-box label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.ai-field {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
.ai-headline { font-size: 17px; font-weight: 700; }
.ai-cta { font-weight: 700; color: var(--primary); }
.ai-copy-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai-bullets {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.ai-bullets li { padding: 4px 0; font-size: 13px; display: flex; align-items: flex-start; gap: 8px; }
.ai-bullets li i { color: #10b981; margin-top: 2px; flex-shrink: 0; }
.ai-design { align-items: center; }
.kw-badge {
  display: inline-block;
  background: rgba(99,102,241,.1);
  color: #6366f1;
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11px;
  margin: 2px;
}
.ai-lp-box {
  background: rgba(99,102,241,.05);
  border: 1px solid rgba(99,102,241,.18);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 16px;
}
.ai-lp-box label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #6366f1;
  margin-bottom: 6px;
  margin-top: 10px;
}
.ai-lp-box label:first-child { margin-top: 0; }
.ai-lp-row { display: flex; align-items: center; gap: 8px; }
.ai-lp-url { font-size: 12px; font-family: monospace; color: var(--text); word-break: break-all; flex: 1; }
.btn-copy, .btn-open {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid rgba(99,102,241,.3);
  background: transparent;
  color: #6366f1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  text-decoration: none;
  flex-shrink: 0;
  transition: var(--transition);
}
.btn-copy:hover, .btn-open:hover { background: rgba(99,102,241,.1); }
.ai-utm-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; font-style: italic; }
.ai-error {
  background: rgba(220,38,38,.08);
  border: 1px solid rgba(220,38,38,.25);
  border-radius: 8px;
  color: #ef4444;
  padding: 12px;
  font-size: 14px;
}

/* ── PERSONA BOX ──────────────────────────────────────────────────────────── */
.ai-persona-box { border: 1px solid rgba(99,102,241,.2); border-radius: 10px; background: rgba(99,102,241,.04); padding: 12px; }
.ai-persona-field { background: transparent; border: none; padding: 0; }
.persona-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.persona-item { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.persona-item--full { grid-column: 1 / -1; }
.persona-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.kw-dor    { background: rgba(239,68,68,.1);  color: #ef4444; }
.kw-desejo { background: rgba(16,185,129,.1); color: #10b981; }

.ai-product-image-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.ai-start-panel {
  display: none;
  margin: 18px 0 6px;
  padding: 18px;
  border: 1px solid rgba(99,102,241,.22);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(99,102,241,.07), rgba(99,102,241,.02));
}
.ai-start-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}
.ai-start-head > div { min-width: 0; }
.ai-start-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--primary);
  margin-bottom: 6px;
}
.ai-start-subtitle {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ai-start-subtitle strong { color: var(--text); font-weight: 700; }
.ai-start-head .btn-primary {
  white-space: nowrap;
  flex-shrink: 0;
  align-self: stretch;
  padding: 10px 18px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  min-height: 44px;
}
@media (max-width: 640px) {
  .ai-start-head { grid-template-columns: 1fr; }
  .ai-start-head .btn-primary { width: 100%; justify-content: center; }
}

.lp-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: stretch;
}
.lp-template-card {
  display: flex;
  flex-direction: column;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--card-bg);
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s, border-color .18s, box-shadow .18s;
  outline: none;
}
.lp-template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0,0,0,.16);
}
.lp-template-card:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230,0,35,.18);
}
.lp-template-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(230,0,35,.12), 0 14px 30px rgba(0,0,0,.2);
}

.lp-template-thumb {
  position: relative;
  height: 96px;
  display: block;
  padding: 10px 12px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}
.lp-template-mode {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  background: rgba(15,23,42,.55);
  color: #fff;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  backdrop-filter: blur(6px);
}
.lp-template-badge {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 2;
  background: var(--primary);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 4px 9px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(230,0,35,.32);
}

.lp-template-body {
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
}
.lp-template-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
}
.lp-template-description {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}
.lp-template-notes {
  margin-top: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(99,102,241,.06);
  border: 1px solid rgba(99,102,241,.12);
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1.45;
}

/* ── LP HISTORY TABLE ─────────────────────────────────────────────────────── */
.section-header { padding: 0 0 20px; }
.section-header h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.section-subtitle { font-size: .85rem; color: var(--text-muted); margin: 0; }

.lps-table-wrap,
.campaigns-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th {
  background: var(--bg);
  padding: 10px 14px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--primary-light); }

.price-badge {
  display: inline-block;
  background: rgba(16,185,129,.12);
  color: #10b981;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
}
.stat-good { color: #10b981; font-weight: 700; }
.stat-bad  { color: #ef4444; font-weight: 700; }

/* ── CARD SHEET BADGE ─────────────────────────────────────────────────────── */
.card-sheet-badge {
  background: rgba(139,92,246,.1);
  color: #8b5cf6;
  border: 1px solid rgba(139,92,246,.25);
}
.card-sheet-badge:hover { background: rgba(139,92,246,.2); }

/* ── WINDSOR SELECT ───────────────────────────────────────────────────────── */
.windsor-select {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
}

/* ── HEALTH CARDS ─────────────────────────────────────────────────────────── */
.health-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .2s;
}
.health-card.ok    { border-color: #10b98133; }
.health-card.error { border-color: #E6002355; }
.health-card.warn  { border-color: #f59e0b55; }

.hc-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #555;
  margin-bottom: 6px;
}
.health-card.ok   .hc-dot { background: #10b981; box-shadow: 0 0 6px #10b98166; }
.health-card.error .hc-dot { background: #E60023; box-shadow: 0 0 6px #E6002366; animation: blink-dot 1.4s infinite; }
.health-card.warn  .hc-dot { background: #f59e0b; }
@keyframes blink-dot { 0%,100%{opacity:1} 50%{opacity:.3} }

.hc-name  { font-size: .78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.hc-status{ font-size: .82rem; font-weight: 600; color: var(--text); }
.hc-ms    { font-size: .72rem; color: var(--text-muted); }
.hc-detail{ font-size: .68rem; color: #ff6b6b; margin-top: 4px; word-break: break-all; line-height: 1.3; }

/* Error cards */
.error-card {
  background: var(--card-bg);
  border: 1px solid #E6002333;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 12px;
}
.error-card.resolved { opacity: .5; border-color: var(--border); }
.error-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.error-type { font-size: .75rem; font-weight: 700; text-transform: uppercase; color: #E60023; letter-spacing: .05em; }
.error-date { font-size: .75rem; color: var(--text-muted); }
.error-msg  { font-family: monospace; font-size: .82rem; color: var(--text); background: var(--bg); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; word-break: break-all; }
.error-path { font-size: .78rem; color: var(--text-muted); margin-bottom: 10px; }
.error-tip  { font-size: .82rem; color: var(--text); background: #f59e0b11; border-left: 3px solid #f59e0b; padding: 8px 12px; border-radius: 0 6px 6px 0; margin-bottom: 12px; line-height: 1.5; }
.error-actions { display: flex; gap: 8px; }
.btn-copy-error { font-size: .78rem; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--primary); color: var(--primary); background: transparent; cursor: pointer; transition: background .2s; }
.btn-copy-error:hover { background: var(--primary); color: #fff; }

/* ── COPY TOAST ───────────────────────────────────────────────────────────── */
#copyToast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary);
  color: #fff;
  padding: 10px 24px;
  border-radius: 50px;
  font-size: .88rem;
  font-weight: 700;
  z-index: 9999;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  white-space: nowrap;
}
#copyToast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── SCROLLBAR ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .top-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 14px 16px; }
  .top-stats { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .ai-copy-row { grid-template-columns: 1fr; }
  .lp-editor-body { grid-template-columns: 1fr; }
  .lp-editor-panel { border-right: none; border-bottom: 1px solid var(--border); max-height: 44vh; }
}
@media (max-width: 600px) {
  .top-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .filters-bar { gap: 6px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
}

/* ── SETTINGS MODAL ─────────────────────────────────────────────────────── */
.settings-group { margin-bottom: 20px; }
.settings-label {
  display: block; font-size: .82rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px;
}
.settings-input {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--card-bg);
  color: var(--text); font-size: .9rem; outline: none;
  transition: border-color .2s;
}
.settings-input:focus { border-color: var(--primary); }

/* ── LP EDITOR ──────────────────────────────────────────────────────────── */
.lp-editor-content {
  max-width: 98vw !important;
  width: 98vw;
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
}
.lp-editor-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.lp-editor-header h2 { font-size: 1.1rem; margin: 0; }
.lp-editor-body {
  display: grid;
  grid-template-columns: 360px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.lp-editor-panel {
  overflow-y: auto;
  padding: 20px;
  border-right: 1px solid var(--border);
  background: var(--card-bg);
}
.editor-section { margin-bottom: 24px; }
.editor-section-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--primary); margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.editor-label {
  display: block; font-size: .8rem; color: var(--text-muted);
  font-weight: 600; margin-top: 10px; margin-bottom: 4px;
}
.editor-input {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--card-bg);
  color: var(--text); font-size: .88rem; outline: none;
  transition: border-color .2s;
}
.editor-input:focus { border-color: var(--primary); }
.editor-textarea {
  width: 100%;
  min-height: 92px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: .88rem;
  line-height: 1.55;
  resize: vertical;
  outline: none;
}
.editor-textarea:focus { border-color: var(--primary); }
.editor-textarea-code {
  font-family: Consolas, 'SFMono-Regular', Monaco, monospace;
  font-size: .8rem;
  line-height: 1.6;
}
.editor-help {
  margin: 8px 0 0;
  font-size: .74rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.editor-inline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.lp-editor-preview {
  display: flex;
  flex-direction: column;
  background: #111;
  overflow: hidden;
}
.lp-preview-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--card-bg); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.preview-device-btn {
  background: none; border: 1.5px solid var(--border); color: var(--text-muted);
  border-radius: 6px; padding: 5px 10px; cursor: pointer; font-size: .85rem;
  transition: all .2s;
}
.preview-device-btn.active {
  border-color: var(--primary); color: var(--primary); background: var(--primary)15;
}
.lp-preview-frame-wrap {
  flex: 1; overflow: auto; background: #1a1a2e;
}
#lpPreviewFrame {
  width: 100%; height: 100%; min-height: 600px;
  border: none; display: block;
  transition: width .3s;
}
#lpEditorMsg { padding: 8px 24px; }
.btn-sm {
  padding: 5px 10px; font-size: .8rem; border-radius: 6px;
  border: 1.5px solid var(--border); background: none; color: var(--text);
  cursor: pointer;
}
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { color: var(--primary); border-color: var(--primary); }
.btn-secondary {
  padding: 8px 16px; border-radius: 8px; font-size: .88rem; font-weight: 600;
  border: 1.5px solid var(--border); background: none; color: var(--text);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ── FUNNEL ─────────────────────────────────────────────────────────────── */
.funnel-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 16px 0 8px;
}
.funnel-stage-wrap {
  display: flex; flex-direction: column; align-items: center; width: 100%;
}
/* Trapezoid funnel shape using clip-path */
.funnel-stage {
  position: relative; width: 100%; max-width: 520px; margin: 0 auto;
  padding: 16px 24px; text-align: center; color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  clip-path: polygon(4% 0%, 96% 0%, 100% 100%, 0% 100%);
  transition: all .3s;
}
.funnel-stage[data-stage="0"] { background: linear-gradient(135deg,#E60023,#ff4d4d); min-height:68px; clip-path: polygon(0% 0%,100% 0%,97% 100%,3% 100%); }
.funnel-stage[data-stage="1"] { background: linear-gradient(135deg,#f97316,#fb923c); min-height:64px; }
.funnel-stage[data-stage="2"] { background: linear-gradient(135deg,#7c3aed,#a855f7); min-height:60px; }
.funnel-stage[data-stage="3"] { background: linear-gradient(135deg,#16a34a,#22c55e); min-height:56px; clip-path: polygon(8% 0%,92% 0%,88% 100%,12% 100%); }
.funnel-stage-left { display:flex; align-items:center; gap:10px; }
.funnel-stage-icon { font-size: 1.5rem; flex-shrink:0; }
.funnel-stage-label { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; opacity: .95; white-space:nowrap; }
.funnel-stage-center { flex:1; }
.funnel-stage-value { font-size: 1.9rem; font-weight: 900; line-height:1; }
.funnel-stage-rate  { font-size: .72rem; opacity: .85; margin-top:2px; }
.funnel-stage-right { text-align:right; flex-shrink:0; }
.funnel-stage-pct   { font-size: 1.1rem; font-weight: 800; }
.funnel-stage-pct-label { font-size:.65rem; opacity:.8; }
/* Drop arrow between stages */
.funnel-drop-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; width: 100%; max-width: 520px; margin: 0 auto;
}
.funnel-drop-line { flex:1; height:1px; background: var(--border); }
.funnel-drop-badge {
  font-size:.73rem; font-weight:700; padding:3px 10px; border-radius:50px;
  display:flex; align-items:center; gap:4px; white-space:nowrap;
}
.funnel-drop-badge.bad  { background:#ef444420; color:#ef4444; border:1px solid #ef444430; }
.funnel-drop-badge.ok   { background:#22c55e20; color:#22c55e; border:1px solid #22c55e30; }
/* KPI summary */
.funnel-summary { margin-top: 20px; }
.funnel-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.funnel-metric {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 12px; text-align: center;
}
.funnel-metric-value { font-size: 1.7rem; font-weight: 900; color: var(--primary); }
.funnel-metric-label { font-size: .73rem; color: var(--text-muted); margin-top: 3px; font-weight:600; }
.funnel-empty { text-align:center; padding:20px; color:var(--text-muted); font-size:.85rem; margin-top:8px; }

/* ── AD DETAIL MODAL ────────────────────────────────────────────────────── */
.ad-detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start;
}
.ad-detail-player {
  width: 100%; border-radius: 14px; max-height: 340px; object-fit: cover;
  display: block; background: #000;
}
.ad-detail-product-img-wrap {
  display:flex; align-items:center; gap:10px; margin-top:10px;
}
.ad-detail-product-img {
  width:72px; height:72px; border-radius:10px; object-fit:cover;
  border:2px solid var(--border); flex-shrink:0;
}
.ad-detail-info { display:flex; flex-direction:column; gap:10px; }
.ad-detail-cat {
  display:inline-block; font-size:.72rem; font-weight:800; text-transform:uppercase;
  letter-spacing:.07em; padding:3px 10px; border-radius:50px; align-self:flex-start;
}
.ad-detail-title { font-size:1.05rem; line-height:1.4; margin:0; font-weight:700; }
.ad-detail-row { display:flex; align-items:center; gap:8px; font-size:.88rem; }
.ad-detail-row i { color:var(--primary); width:14px; flex-shrink:0; }
.ad-detail-link { color:var(--primary); word-break:break-all; font-size:.82rem; }
.ad-detail-price { color:#22c55e; font-size:1rem; }
.ad-detail-cta {
  background:var(--primary)18; color:var(--primary); font-size:.78rem; font-weight:700;
  padding:3px 10px; border-radius:50px;
}
.ad-detail-stats {
  display:flex; gap:12px; flex-wrap:wrap; margin-top:2px;
}
.ad-detail-stat {
  background:var(--card-bg); border:1px solid var(--border); border-radius:10px;
  padding:8px 12px; text-align:center; flex:1; min-width:80px;
}
.ad-detail-stat strong { display:block; font-size:1rem; font-weight:800; }
.ad-detail-stat span   { font-size:.7rem; color:var(--text-muted); }
.ad-detail-tags { display:flex; flex-wrap:wrap; gap:5px; }
.ad-detail-tag {
  background:var(--primary)18; color:var(--primary); font-size:.72rem;
  font-weight:700; padding:3px 9px; border-radius:50px;
}
.ad-detail-notes {
  background:var(--card-bg); border:1px solid var(--border); border-radius:10px;
  padding:10px 12px; font-size:.84rem; line-height:1.6; color:var(--text-muted);
}
.ad-detail-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:4px; }
.ad-detail-action-btn {
  flex:1; min-width:120px; text-align:center; justify-content:center;
  font-size:.82rem; padding:8px 12px; text-decoration:none;
}
@media(max-width:600px){
  .ad-detail-grid { grid-template-columns:1fr; }
  .funnel-metrics { grid-template-columns:1fr 1fr; }
}

/* ── BACKGROUND JOBS PANEL ──────────────────────────────────────────────────── */
.bgjobs-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  width: 340px;
  background: var(--card-bg, #1e1e2e);
  border: 1px solid var(--border, #333);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
  font-size: 13px;
  overflow: hidden;
  display: none;
}

.bgjobs-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--primary, #E60023);
  color: #fff;
  cursor: pointer;
  user-select: none;
}

.bgjobs-title {
  flex: 1;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bgjobs-count {
  background: rgba(255,255,255,.25);
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}

.bgjobs-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  opacity: .8;
}
.bgjobs-toggle:hover { opacity: 1; }

.bgjobs-body {
  max-height: 300px;
  overflow-y: auto;
  padding: 6px 0;
}

.bgjobs-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border, #2a2a3a);
  transition: background .15s;
}
.bgjobs-item:last-child { border-bottom: none; }
.bgjobs-item:hover { background: rgba(255,255,255,.03); }

.bgjobs-icon {
  font-size: 15px;
  line-height: 1.4;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.bgjobs-item--running  .bgjobs-icon { animation: bgjobs-spin 1.5s linear infinite; }
.bgjobs-item--completed .bgjobs-icon { color: #10b981; }
.bgjobs-item--error    .bgjobs-icon { color: #ef4444; }
.bgjobs-item--interrupted .bgjobs-icon { color: #f59e0b; }

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

.bgjobs-info {
  flex: 1;
  min-width: 0;
}

.bgjobs-item-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--text, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.bgjobs-log {
  font-size: 11px;
  color: var(--text-muted, #888);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bgjobs-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  align-items: center;
}

.bgjobs-action {
  background: var(--primary, #E60023);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.bgjobs-action:hover { opacity: .85; }

.bgjobs-dismiss {
  background: none;
  border: none;
  color: var(--text-muted, #888);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}
.bgjobs-dismiss:hover { color: #ef4444; }

/* ── LP Quality Banner ─────────────────────────────────────────────────── */
.ai-lp-quality {
  background: linear-gradient(135deg, rgba(99,102,241,.10), rgba(99,102,241,.04));
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: grid;
  gap: 10px;
}
.ai-lpq-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ai-lpq-pill {
  background: rgba(99,102,241,.18);
  color: #4338ca;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.ai-lpq-pill-niche {
  background: rgba(34,197,94,.16);
  color: #15803d;
}
.ai-lpq-score {
  margin-left: auto;
  font-weight: 900;
  font-size: 16px;
  color: var(--text, #111827);
}
.ai-lpq-score.lpq-good { color: #16a34a; }
.ai-lpq-score.lpq-warn { color: #d97706; }
.ai-lpq-score.lpq-bad  { color: #dc2626; }
.ai-lpq-issues {
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.5;
}
.ai-lpq-issue {
  padding: 6px 10px;
  border-radius: 8px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.ai-lpq-issue.lpq-error   { background: rgba(220,38,38,.10); color: #991b1b; border: 1px solid rgba(220,38,38,.18); }
.ai-lpq-issue.lpq-warning { background: rgba(217,119,6,.10);  color: #92400e; border: 1px solid rgba(217,119,6,.18); }
.ai-lpq-issue::before {
  content: '⚠';
  flex-shrink: 0;
  margin-top: 1px;
}
.ai-lpq-issue.lpq-error::before { content: '✕'; }
