/* ===== Ads Winner Hunter — Modern Light/Dark Dashboard CSS ===== */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-text: #4338ca;

  --emerald: #059669;
  --emerald-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --rose: #e11d48;
  --rose-soft: #fff1f2;
  --blue: #2563eb;
  --blue-soft: #eff6ff;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.16);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1a2234;
  --surface-hover: #1f2a40;
  --border: #243045;
  --border-strong: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-soft: #64748b;

  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-soft: rgba(99, 102, 241, 0.16);
  --primary-text: #a5b4fc;

  --emerald: #34d399;
  --emerald-soft: rgba(16, 185, 129, 0.15);
  --amber: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --rose: #fb7185;
  --rose-soft: rgba(244, 63, 94, 0.15);
  --blue: #60a5fa;
  --blue-soft: rgba(59, 130, 246, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 5px;
}

/* ===== Layout ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform 0.22s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: grid;
  place-items: center;
  font-size: 19px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.nav {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: all 0.15s ease;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 600;
}
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
}
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-strong);
}
.status-dot.running {
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.22);
  animation: pulse 1.6s infinite;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.mini-status {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 12px;
}
.mini-status-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.mini-status-title { font-size: 12px; font-weight: 600; }
.mini-status-desc { font-size: 11px; color: var(--text-muted); }

.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.page-title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }

.topbar-search {
  flex: 1;
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  height: 38px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.topbar-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.topbar-search input {
  border: none;
  background: transparent;
  color: var(--text);
  width: 100%;
  outline: none;
  font-size: 13px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.content {
  padding: 22px 24px 40px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

.view { display: none; flex-direction: column; gap: 20px; }
.view.active { display: flex; }

/* ===== Cards & Typography ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card-title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.card-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--text-muted); }

/* ===== Buttons & Inputs ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
.btn-soft { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-soft:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-emerald { background: var(--emerald); color: #fff; }
.btn-emerald:hover:not(:disabled) { filter: brightness(1.06); }
.btn-danger { background: var(--rose); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.07); }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-hover); }

.input, .select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input:disabled { opacity: 0.65; cursor: not-allowed; }
.input-sm, .select-sm { padding: 5px 9px; font-size: 12.5px; width: auto; }

.input-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0 11px;
}
.input-with-icon:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input-with-icon input {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 0;
  width: 100%;
  outline: none;
  font-size: 13.5px;
}

/* ===== Pills & Badges ===== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.pill-indigo { background: var(--primary-soft); color: var(--primary-text); }
.pill-emerald { background: var(--emerald-soft); color: var(--emerald); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-rose { background: var(--rose-soft); color: var(--rose); }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-muted { background: var(--surface-hover); color: var(--text-muted); }

/* ===== Dashboard KPIs ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
}
.kpi-value { font-size: 27px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.kpi-foot { margin-top: 6px; font-size: 12px; color: var(--text-muted); }

.bg-indigo { background: var(--primary-soft); color: var(--primary-text); }
.bg-emerald { background: var(--emerald-soft); color: var(--emerald); }
.bg-amber { background: var(--amber-soft); color: var(--amber); }
.bg-blue { background: var(--blue-soft); color: var(--blue); }
.bg-rose { background: var(--rose-soft); color: var(--rose); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
}

/* Score bars */
.score-bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 60px 1fr 56px; align-items: center; gap: 12px; }
.bar-label { font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.bar-track { height: 11px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; border-radius: 99px; transition: width 0.45s ease; }
.bar-count { text-align: right; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }

.media-summary {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Top pages */
.top-pages-list { display: flex; flex-direction: column; gap: 8px; }
.page-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.15s;
}
.page-row:hover { border-color: var(--primary); background: var(--surface-hover); }
.page-row-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-row-meta { font-size: 11.5px; color: var(--text-muted); }
.page-row-badges { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ===== Ads Explorer ===== */
.filter-card { padding: 16px 18px; }
.tabs-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 13px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.tab-btn:hover { background: var(--surface-hover); color: var(--text); }
.tab-btn.active { background: var(--primary-soft); color: var(--primary-text); border-color: rgba(79, 70, 229, 0.22); }
.tab-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(100, 116, 139, 0.15);
}
.tab-btn.active .tab-count { background: var(--primary); color: #fff; }

.filters-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.filters-row .select { width: auto; min-width: 155px; }
.filters-row .filter-num { width: 130px; }
.flex-2 { flex: 1; min-width: 220px; }

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  width: 34px;
  height: 30px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}
.seg-btn.active { background: var(--surface); color: var(--primary-text); box-shadow: var(--shadow-sm); }

.active-filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: 12px;
  font-weight: 600;
}
.filter-chip button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 800;
  padding: 0 2px;
}

.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Ads Grid */
.ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.ad-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  box-shadow: var(--shadow-sm);
}
.ad-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.ad-card.is-analyzed { border-top: 3px solid var(--emerald); }

.ad-thumb {
  position: relative;
  height: 168px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ad-thumb img, .ad-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ad-thumb-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #cbd5e1;
  font-size: 12px;
  padding: 16px;
  text-align: center;
}
.ad-thumb-fallback .big-emoji { font-size: 32px; opacity: 0.9; }
.ad-thumb-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
.score-badge {
  padding: 4px 10px;
  border-radius: 99px;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.28);
}
.score-super { background: linear-gradient(135deg, #7c3aed, #ec4899); }
.score-high { background: linear-gradient(135deg, #059669, #10b981); }
.score-mid { background: linear-gradient(135deg, #4f46e5, #3b82f6); }
.score-low { background: #475569; }

.media-tag {
  position: absolute;
  bottom: 9px;
  right: 10px;
  background: rgba(15, 23, 42, 0.76);
  color: #f8fafc;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.ad-body {
  padding: 14px 15px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.ad-page-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ad-page {
  font-weight: 700;
  font-size: 14px;
  flex: 1 1 100%;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}
.ad-page-badges { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.ad-delete-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--rose);
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ad-delete-btn:hover {
  background: var(--rose);
  color: #fff;
  border-color: var(--rose);
}
.ad-follow-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--primary-text);
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ad-follow-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.ad-follow-btn.is-following {
  background: color-mix(in srgb, var(--emerald) 16%, transparent);
  border-color: var(--emerald);
  color: var(--emerald);
}
.ad-follow-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ad-fav-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ad-fav-btn:hover:not(:disabled) {
  background: var(--amber);
  color: #fff;
  border-color: var(--amber);
}
.ad-fav-btn.is-favorite {
  background: color-mix(in srgb, var(--amber) 18%, transparent);
  border-color: var(--amber);
  color: var(--amber);
}
.ad-fav-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ad-seen-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ad-seen-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.ad-seen-btn.is-seen {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  border-color: var(--primary);
  color: var(--primary-text);
}
.ad-seen-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.table-actions { display: flex; align-items: center; gap: 6px; }
.ad-product {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-hook {
  font-size: 12.5px;
  background: var(--amber-soft);
  color: var(--text);
  border-left: 3px solid var(--amber);
  padding: 6px 9px;
  border-radius: 0 7px 7px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-text {
  font-size: 12.5px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-metrics {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.metric-group { display: flex; gap: 10px; align-items: center; }

/* Table view */
.ads-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.ads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ads-table th {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.ads-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ads-table tbody tr { cursor: pointer; transition: background 0.12s; }
.ads-table tbody tr:hover { background: var(--surface-hover); }
.table-snippet { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }

/* Pagination */
.pagination-bar, .pagination-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ===== Pipeline View ===== */
.pipeline-status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-left: 4px solid var(--border-strong);
}
.pipeline-status-banner.running {
  border-left-color: #10b981;
  background: linear-gradient(90deg, var(--emerald-soft), var(--surface) 45%);
}
.pipeline-banner-left { display: flex; align-items: center; gap: 14px; }
.pipeline-banner-actions { display: flex; gap: 8px; }
.banner-title { font-size: 16px; font-weight: 700; }
.banner-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.pulse-ring {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}
.pipeline-status-banner.running .pulse-ring {
  background: #10b981;
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.25);
  animation: pulse 1.5s infinite;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.preset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.preset-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
}
.preset-card h3 { margin: 0; font-size: 15px; }
.preset-card p { margin: 0 0 auto; font-size: 12.5px; color: var(--text-muted); }

.custom-run-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.check-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  cursor: pointer;
}
.check-card input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); }
.check-card strong { display: block; font-size: 13px; }
.check-card span { font-size: 11.5px; color: var(--text-muted); }

.custom-run-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.inline-field { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }

.log-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toggle-inline { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; cursor: pointer; color: var(--text-muted); }
.toggle-inline input { accent-color: var(--primary); }

.log-terminal {
  background: #0b1120;
  color: #cbd5e1;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  padding: 14px 16px;
  border-radius: 10px;
  height: 360px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.log-line { padding: 1px 0; }
.log-line.lvl-error { color: #fda4af; }
.log-line.lvl-warn { color: #fcd34d; }
.log-line.lvl-info { color: #e2e8f0; }
.log-line.lvl-debug { color: #94a3b8; }

/* ===== Targets & Settings ===== */
.targets-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.add-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.ai-gen-row { margin-bottom: 6px; }
.ai-gen-row #genKeywordsCount { max-width: 84px; }
.tags-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}
.tag-chip button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}
.tag-chip button:hover { color: var(--rose); }

.page-id-list { display: flex; flex-direction: column; gap: 8px; }
.page-id-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.page-id-code { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.page-id-actions { display: flex; align-items: center; gap: 8px; }

.followed-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.followed-page-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-wrap: wrap;
}
.followed-page-info { min-width: 0; }
.followed-page-name {
  font-weight: 700;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.followed-page-meta { font-size: 11.5px; color: var(--text-muted); }
.followed-page-meta code { font-family: var(--mono); font-size: 11px; }
.followed-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.help-text { font-size: 12px; color: var(--text-muted); }
.span-2 { grid-column: span 2; }

.card-footer-actions {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.settings-save-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.btn-row { display: flex; gap: 10px; }

/* ===== Detail Drawer ===== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 60;
  backdrop-filter: blur(2px);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(680px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 70;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-title { font-size: 17px; font-weight: 800; }
.drawer-sub { font-size: 12px; color: var(--text-muted); font-family: var(--mono); }

.drawer-body {
  padding: 18px 20px 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.detail-media {
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
  max-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.detail-media video, .detail-media img {
  max-width: 100%;
  max-height: 360px;
  display: block;
}
.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.breakdown-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}
.breakdown-box .b-val { font-size: 19px; font-weight: 800; }
.breakdown-box .b-lbl { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.ai-panel {
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-field-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 4px; }
.ai-hook-box {
  background: var(--amber-soft);
  border-left: 3px solid var(--amber);
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  font-weight: 600;
}
.script-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.script-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-text);
}
.script-card-text { font-size: 13.5px; white-space: pre-wrap; }

.body-text-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px;
  white-space: pre-wrap;
  font-size: 13.5px;
  max-height: 240px;
  overflow-y: auto;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.meta-item span { color: var(--text-muted); display: block; font-size: 11px; }
.meta-item strong { word-break: break-all; }

.empty-state {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 10px; }

/* ===== Toast ===== */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 12px 15px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  animation: slideIn 0.2s ease;
}
.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: #e11d48; }

.mobile-only { display: none; }
.sidebar-backdrop { display: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@keyframes slideIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Responsive ===== */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .preset-grid, .custom-run-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .dashboard-grid, .targets-layout, .settings-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
  }
  .main-wrap { margin-left: 0; }
  .mobile-only { display: grid; }
  .hide-sm { display: none; }
  .topbar { padding: 0 14px; }
  .content { padding: 16px 14px 32px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .breakdown-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .topbar-search { display: none; }
  .preset-grid, .custom-run-grid, .form-grid-2 { grid-template-columns: 1fr; }
}
