/* ════════════════════════════════════════════════════════════════
   META ADS INTELLIGENCE ENGINE — Premium UI System
   NeumaticOS SaaS v8 · Desacoplado · Themeable
════════════════════════════════════════════════════════════════ */

/* ── Design tokens propios del módulo ────────────────────────── */
#page-meta_ads {
  --mads-purple:      #7c3aed;
  --mads-purple2:     #a78bfa;
  --mads-cyan:        #06b6d4;
  --mads-green:       #10b981;
  --mads-amber:       #f59e0b;
  --mads-red:         #ef4444;
  --mads-pink:        #ec4899;

  --mads-bg:          var(--bg,  #181a2e);
  --mads-bg2:         var(--bg2, #20224a);
  --mads-card:        var(--card,rgba(36,38,88,0.88));
  --mads-bord:        var(--bord,rgba(255,255,255,0.10));
  --mads-bord2:       var(--bord2,rgba(255,255,255,0.16));
  --mads-text:        var(--text, #e8edf8);
  --mads-text2:       var(--text2,#d4daf0);
  --mads-text3:       var(--text3,#8892b0);
  --mads-accent:      var(--accent,#7c3aed);
  --mads-accent2:     var(--accent2,#06b6d4);
  --mads-glass:       var(--glass,rgba(255,255,255,0.04));
  --mads-shadow:      var(--shadow-md,0 8px 32px rgba(0,0,0,0.35));
  --mads-glow:        var(--glow,0 0 30px rgba(124,58,237,0.30));
  --mads-r:           12px;
  --mads-r2:          16px;
  --mads-r3:          20px;

  font-family: var(--outfit,'Inter',sans-serif);
  color: var(--mads-text);
  background: var(--mads-bg);
  min-height: 100%;
  padding: 0;
}

/* ── Page layout ─────────────────────────────────────────────── */
.mads-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px);
  overflow: hidden;
}

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

.mads-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mads-module-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(6,182,212,0.10));
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--mads-purple2);
  text-transform: uppercase;
}

.mads-module-badge .badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--mads-green);
  box-shadow: 0 0 8px var(--mads-green);
  animation: mads-pulse 2s infinite;
}

.mads-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text1, #fff);
  letter-spacing: -.02em;
  line-height: 1;
}

.mads-subtitle {
  font-size: 12px;
  color: var(--mads-text3);
  font-weight: 500;
  margin-top: 2px;
}

/* ── Tabs navigation ─────────────────────────────────────────── */
.mads-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 14px 24px 0;
  border-bottom: 1px solid var(--mads-bord);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.mads-tabs::-webkit-scrollbar { display: none; }

.mads-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--mads-text3);
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  transition: color .15s, background .15s;
  position: relative;
}
.mads-tab:hover { color: var(--mads-text2); background: var(--mads-glass); }
.mads-tab.active {
  color: var(--mads-accent);
  background: var(--mads-card);
  border-color: var(--mads-bord);
  border-bottom-color: var(--mads-card);
}
.mads-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: var(--mads-card);
}
.mads-tab-icon { font-size: 13px; }
.mads-tab-badge {
  background: var(--mads-purple);
  color: #fff;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

/* ── Scroll container ────────────────────────────────────────── */
.mads-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--mads-bord2) transparent;
}
.mads-content::-webkit-scrollbar { width: 5px; }
.mads-content::-webkit-scrollbar-track { background: transparent; }
.mads-content::-webkit-scrollbar-thumb { background: var(--mads-bord2); border-radius: 4px; }

/* ── Tab panes ───────────────────────────────────────────────── */
.mads-pane { display: none; }
.mads-pane.active { display: block; }

/* ── KPI Grid ────────────────────────────────────────────────── */
.mads-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.mads-kpi {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: var(--mads-r);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  cursor: default;
}
.mads-kpi:hover {
  border-color: var(--mads-bord2);
  transform: translateY(-1px);
  box-shadow: var(--mads-shadow);
}
.mads-kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--kpi-color, var(--mads-accent));
}
.mads-kpi::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -20%, var(--kpi-glow, rgba(124,58,237,0.08)), transparent 70%);
  pointer-events: none;
}

.mads-kpi-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--mads-text3);
  font-family: var(--mono,'JetBrains Mono',monospace);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.mads-kpi-val {
  font-size: 28px;
  font-weight: 900;
  color: var(--text1, #fff);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.mads-kpi-sub {
  font-size: 10px;
  margin-top: 5px;
  color: var(--mads-text3);
  display: flex;
  align-items: center;
  gap: 4px;
}
.mads-kpi-delta {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}
.mads-kpi-delta.up   { background: rgba(16,185,129,.15); color: #10b981; }
.mads-kpi-delta.down { background: rgba(239,68,68,.12);  color: #ef4444; }

/* ── Chart row ───────────────────────────────────────────────── */
.mads-chart-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 1100px) {
  .mads-chart-row { grid-template-columns: 1fr; }
}

.mads-chart-card {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: var(--mads-r2);
  padding: 18px 20px;
}

.mads-chart-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--mads-text3);
  font-family: var(--mono,'JetBrains Mono',monospace);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Mini sparkline canvas */
.mads-sparkline {
  width: 100%;
  height: 80px;
  display: block;
}

/* ── Section headers ─────────────────────────────────────────── */
.mads-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mads-text3);
  font-family: var(--mono,'JetBrains Mono',monospace);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mads-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--mads-bord);
}

/* ── Filter bar ──────────────────────────────────────────────── */
.mads-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.mads-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: 8px;
  padding: 7px 12px;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  transition: border-color .2s;
}
.mads-search:focus-within { border-color: var(--mads-accent); }
.mads-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--mads-text);
  font-size: 12px;
  font-family: inherit;
  flex: 1;
}
.mads-search input::placeholder { color: var(--mads-text3); }

.mads-filter-select {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--mads-text2);
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color .2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%238892b0' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.mads-filter-select:focus { border-color: var(--mads-accent); }

.mads-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  font-family: inherit;
}
.mads-btn-primary {
  background: var(--mads-accent);
  color: #fff;
  border-color: var(--mads-accent);
}
.mads-btn-primary:hover { filter: brightness(1.12); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(124,58,237,.35); }
.mads-btn-secondary {
  background: var(--mads-glass);
  color: var(--mads-text2);
  border-color: var(--mads-bord);
}
.mads-btn-secondary:hover { border-color: var(--mads-bord2); background: var(--mads-card); }
.mads-btn-danger { background: rgba(239,68,68,.12); color: var(--mads-red); border-color: rgba(239,68,68,.2); }
.mads-btn-success { background: rgba(16,185,129,.12); color: var(--mads-green); border-color: rgba(16,185,129,.2); }
.mads-btn-sm { padding: 4px 10px; font-size: 11px; border-radius: 6px; }
.mads-btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

/* ── Data table ──────────────────────────────────────────────── */
.mads-table-wrap {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: var(--mads-r2);
  overflow: hidden;
}

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

.mads-table thead tr {
  background: rgba(255,255,255,.03);
  border-bottom: 1px solid var(--mads-bord);
}

.mads-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--mads-text3);
  font-family: var(--mono,'JetBrains Mono',monospace);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.mads-table th:hover { color: var(--mads-text2); }
.mads-table th.sort-asc::after  { content: ' ↑'; }
.mads-table th.sort-desc::after { content: ' ↓'; }

.mads-table tbody tr {
  border-bottom: 1px solid var(--mads-bord);
  transition: background .12s;
  cursor: pointer;
}
.mads-table tbody tr:last-child { border-bottom: none; }
.mads-table tbody tr:hover { background: rgba(255,255,255,.03); }
.mads-table tbody tr.selected { background: rgba(124,58,237,.08); }

.mads-table td {
  padding: 11px 14px;
  color: var(--mads-text2);
  vertical-align: middle;
}
.mads-table td .mads-td-primary { color: var(--text1,#fff); font-weight: 600; font-size: 12px; }
.mads-table td .mads-td-sub { color: var(--mads-text3); font-size: 10px; margin-top: 2px; }

/* Tabla ad preview */
.mads-ad-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 280px;
}
.mads-ad-thumb {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--mads-bg2), var(--mads-bg));
  border: 1px solid var(--mads-bord);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;
}
.mads-ad-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 7px; }

.mads-ad-copy {
  overflow: hidden;
}
.mads-ad-copy .mads-td-primary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
  display: block;
}

/* Score badge */
.mads-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mads-score.high   { background: rgba(16,185,129,.15); color: #10b981; }
.mads-score.medium { background: rgba(245,158,11,.15);  color: #f59e0b; }
.mads-score.low    { background: rgba(239,68,68,.12);   color: #ef4444; }
.mads-score.none   { background: rgba(136,146,176,.10); color: #8892b0; }

/* Platform pills */
.mads-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.mads-platform-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.mads-platform-pill.facebook   { background: rgba(59,130,246,.15);  color: #93c5fd; }
.mads-platform-pill.instagram  { background: rgba(236,72,153,.12);  color: #f9a8d4; }
.mads-platform-pill.messenger  { background: rgba(124,58,237,.15);  color: #c4b5fd; }
.mads-platform-pill.audience_network { background: rgba(6,182,212,.12); color: #67e8f9; }

/* Status badge */
.mads-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.mads-status.active   { background: rgba(16,185,129,.12); color: #10b981; }
.mads-status.inactive { background: rgba(136,146,176,.10); color: #8892b0; }
.mads-status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.mads-status.active .mads-status-dot { box-shadow: 0 0 6px currentColor; animation: mads-pulse 2s infinite; }

/* Days active */
.mads-days-active {
  font-size: 11px;
  color: var(--mads-text3);
  font-variant-numeric: tabular-nums;
}
.mads-days-active strong { color: var(--mads-amber); }

/* ── Ad detail panel (slide-in) ──────────────────────────────── */
.mads-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.mads-detail-overlay.open { opacity: 1; pointer-events: auto; }

.mads-detail-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 720px;
  max-width: 95vw;
  background: var(--mads-bg2);
  border-left: 1px solid var(--mads-bord2);
  z-index: 1001;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.25,.8,.25,1);
  display: flex;
  flex-direction: column;
}
.mads-detail-panel.open { transform: translateX(0); }

.mads-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--mads-bord);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--mads-bg2);
  z-index: 1;
}

.mads-detail-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--mads-glass);
  border: 1px solid var(--mads-bord);
  cursor: pointer;
  color: var(--mads-text3);
  font-size: 14px;
  transition: all .15s;
}
.mads-detail-close:hover { background: var(--mads-card); color: var(--mads-text); }

.mads-detail-body { flex: 1; padding: 20px 24px 32px; }

.mads-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 600px) {
  .mads-detail-grid { grid-template-columns: 1fr; }
}

/* ── Info cards (en detail) ──────────────────────────────────── */
.mads-info-card {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: var(--mads-r);
  padding: 14px 16px;
}
.mads-info-card.full { grid-column: 1 / -1; }

.mads-info-card-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--mads-text3);
  font-family: var(--mono,'JetBrains Mono',monospace);
  margin-bottom: 10px;
}

/* ── AI analysis display ─────────────────────────────────────── */
.mads-analysis-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mads-analysis-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.mads-analysis-label {
  color: var(--mads-text3);
  font-size: 10px;
  font-weight: 600;
  min-width: 90px;
  flex-shrink: 0;
}
.mads-analysis-value {
  color: var(--mads-text2);
  font-weight: 500;
}

/* Score ring */
.mads-score-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.mads-score-ring canvas { display: block; }
.mads-score-ring-label { font-size: 9px; color: var(--mads-text3); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }

/* Tag chips */
.mads-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.mads-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(124,58,237,.12);
  border: 1px solid rgba(124,58,237,.20);
  color: var(--mads-purple2);
}
.mads-tag.cyan   { background: rgba(6,182,212,.10); border-color: rgba(6,182,212,.20); color: var(--mads-cyan); }
.mads-tag.green  { background: rgba(16,185,129,.10); border-color: rgba(16,185,129,.20); color: var(--mads-green); }
.mads-tag.amber  { background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.20); color: var(--mads-amber); }
.mads-tag.red    { background: rgba(239,68,68,.10);  border-color: rgba(239,68,68,.20);  color: var(--mads-red); }
.mads-tag.pink   { background: rgba(236,72,153,.10); border-color: rgba(236,72,153,.20); color: var(--mads-pink); }

/* ── Discovery job panel ─────────────────────────────────────── */
.mads-discovery-panel {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: var(--mads-r2);
  padding: 20px;
  margin-bottom: 20px;
}

.mads-discovery-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 10px;
  align-items: end;
}
@media (max-width: 900px) {
  .mads-discovery-form { grid-template-columns: 1fr 1fr; }
}

.mads-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mads-form-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--mads-text3);
  font-family: var(--mono,'JetBrains Mono',monospace);
}
.mads-form-input {
  background: var(--mads-bg);
  border: 1px solid var(--mads-bord);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--mads-text);
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
  width: 100%;
}
.mads-form-input:focus { border-color: var(--mads-accent); }
.mads-form-input::placeholder { color: var(--mads-text3); }

/* Job progress bar */
.mads-progress-wrap {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: var(--mads-r2);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: none;
}
.mads-progress-wrap.visible { display: block; }

.mads-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.mads-progress-label { font-size: 12px; font-weight: 600; color: var(--mads-text); }
.mads-progress-pct   { font-size: 12px; font-weight: 700; color: var(--mads-accent); font-family: var(--mono,'JetBrains Mono',monospace); }

.mads-progress-bar {
  height: 4px;
  background: rgba(255,255,255,.06);
  border-radius: 99px;
  overflow: hidden;
}
.mads-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--mads-accent), var(--mads-cyan));
  border-radius: 99px;
  transition: width .4s ease;
  width: 0%;
  position: relative;
}
.mads-progress-fill::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 40px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.3));
  animation: mads-progress-shine 1.5s infinite;
}

.mads-progress-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 10px;
  color: var(--mads-text3);
}
.mads-progress-stats span strong { color: var(--mads-text2); }

/* ── Log stream ──────────────────────────────────────────────── */
.mads-log-stream {
  background: var(--mads-bg);
  border: 1px solid var(--mads-bord);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono,'JetBrains Mono',monospace);
  font-size: 10px;
  max-height: 140px;
  overflow-y: auto;
  margin-top: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--mads-bord2) transparent;
}
.mads-log-stream::-webkit-scrollbar { width: 3px; }
.mads-log-stream::-webkit-scrollbar-thumb { background: var(--mads-bord2); border-radius: 3px; }

.mads-log-line {
  padding: 2px 0;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.mads-log-ts    { color: var(--mads-text3); flex-shrink: 0; }
.mads-log-msg   { color: var(--mads-text2); }
.mads-log-line.info  .mads-log-msg { color: var(--mads-text2); }
.mads-log-line.warn  .mads-log-msg { color: var(--mads-amber); }
.mads-log-line.error .mads-log-msg { color: var(--mads-red); }
.mads-log-line.success .mads-log-msg { color: var(--mads-green); }

/* ── Insights cards ──────────────────────────────────────────── */
.mads-insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.mads-insight-card {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: var(--mads-r2);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .2s;
  cursor: pointer;
}
.mads-insight-card:hover { border-color: var(--mads-bord2); transform: translateY(-2px); }
.mads-insight-card.unread { border-color: rgba(124,58,237,.3); }
.mads-insight-card.unread::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--ins-color, var(--mads-accent)), transparent);
}

.mads-insight-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.mads-insight-type {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.mads-insight-priority {
  font-size: 9px;
  font-weight: 700;
  color: var(--mads-text3);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.mads-insight-priority.high   { color: var(--mads-red); }
.mads-insight-priority.medium { color: var(--mads-amber); }

.mads-insight-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text1,#fff);
  margin-bottom: 6px;
  line-height: 1.3;
}
.mads-insight-summary {
  font-size: 11px;
  color: var(--mads-text3);
  line-height: 1.5;
}
.mads-insight-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--mads-bord);
}
.mads-insight-time { font-size: 9px; color: var(--mads-text3); font-family: var(--mono,'JetBrains Mono',monospace); }

/* ── Campaign generator ──────────────────────────────────────── */
.mads-campaign-form {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: var(--mads-r2);
  padding: 22px;
  margin-bottom: 20px;
}

.mads-campaign-result {
  background: linear-gradient(135deg, rgba(124,58,237,.06), rgba(6,182,212,.04));
  border: 1px solid rgba(124,58,237,.2);
  border-radius: var(--mads-r2);
  padding: 20px;
  margin-top: 20px;
  display: none;
}
.mads-campaign-result.visible { display: block; animation: mads-fadeIn .3s ease; }

.mads-copy-variant {
  background: var(--mads-bg);
  border: 1px solid var(--mads-bord);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  position: relative;
  transition: border-color .2s;
}
.mads-copy-variant:hover { border-color: var(--mads-accent); }

.mads-copy-variant-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--mads-accent);
  font-family: var(--mono,'JetBrains Mono',monospace);
  margin-bottom: 8px;
}
.mads-copy-variant-text {
  font-size: 12px;
  line-height: 1.6;
  color: var(--mads-text2);
}
.mads-copy-variant-hook {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--mads-cyan);
}
.mads-copy-btn-copy {
  position: absolute;
  top: 10px; right: 10px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 700;
  background: var(--mads-glass);
  border: 1px solid var(--mads-bord);
  color: var(--mads-text3);
  cursor: pointer;
  transition: all .15s;
}
.mads-copy-btn-copy:hover { background: var(--mads-card); color: var(--mads-text2); }

/* ── Empty state ─────────────────────────────────────────────── */
.mads-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}
.mads-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .7; }
.mads-empty-title { font-size: 16px; font-weight: 700; color: var(--text1,#fff); margin-bottom: 6px; }
.mads-empty-desc  { font-size: 12px; color: var(--mads-text3); max-width: 340px; line-height: 1.6; margin-bottom: 20px; }

/* ── Skeleton loading ────────────────────────────────────────── */
.mads-skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,.04) 25%,
    rgba(255,255,255,.09) 50%,
    rgba(255,255,255,.04) 75%
  );
  background-size: 200% 100%;
  animation: mads-shimmer 1.5s infinite;
  border-radius: 6px;
}
.mads-skeleton-line { height: 12px; margin-bottom: 6px; }
.mads-skeleton-line.wide { width: 70%; }
.mads-skeleton-line.narrow { width: 40%; }
.mads-skeleton-kpi { height: 80px; border-radius: var(--mads-r); }
.mads-skeleton-row  { height: 48px; border-radius: 4px; margin-bottom: 1px; }

/* ── Pagination ──────────────────────────────────────────────── */
.mads-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--mads-bord);
  background: rgba(255,255,255,.015);
}
.mads-pagination-info { font-size: 11px; color: var(--mads-text3); }
.mads-pagination-btns { display: flex; gap: 6px; }

/* ── Monitor list ────────────────────────────────────────────── */
.mads-monitor-item {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color .2s;
}
.mads-monitor-item:hover { border-color: var(--mads-bord2); }
.mads-monitor-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  background: rgba(124,58,237,.12);
  flex-shrink: 0;
}
.mads-monitor-info { flex: 1; }
.mads-monitor-name { font-size: 13px; font-weight: 600; color: var(--text1,#fff); }
.mads-monitor-meta { font-size: 10px; color: var(--mads-text3); margin-top: 2px; }
.mads-monitor-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Toggle switch ───────────────────────────────────────────── */
.mads-toggle {
  width: 32px; height: 18px;
  background: rgba(255,255,255,.1);
  border-radius: 99px;
  cursor: pointer;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.mads-toggle.on { background: var(--mads-green); }
.mads-toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.mads-toggle.on::after { transform: translateX(14px); }

/* ── Toast notification ──────────────────────────────────────── */
.mads-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--mads-card);
  border: 1px solid var(--mads-bord2);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--mads-text2);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--mads-shadow);
  animation: mads-slideUp .25s ease;
  max-width: 320px;
}

/* ── Competitor card ─────────────────────────────────────────── */
.mads-competitor-card {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: var(--mads-r2);
  padding: 16px 18px;
  transition: border-color .2s, transform .2s;
}
.mads-competitor-card:hover { border-color: var(--mads-bord2); transform: translateY(-1px); }

.mads-competitor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.mads-competitor-avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--mads-accent), var(--mads-cyan));
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 16px; color: #fff;
  flex-shrink: 0;
}
.mads-competitor-name { font-size: 14px; font-weight: 700; color: var(--text1,#fff); }
.mads-competitor-meta { font-size: 10px; color: var(--mads-text3); margin-top: 2px; }

.mads-competitor-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.mads-competitor-stat {
  text-align: center;
  padding: 8px;
  background: var(--mads-bg);
  border-radius: 8px;
}
.mads-competitor-stat-val { font-size: 18px; font-weight: 800; color: var(--text1,#fff); }
.mads-competitor-stat-lbl { font-size: 9px; color: var(--mads-text3); margin-top: 2px; text-transform: uppercase; letter-spacing: .06em; }

/* ── Lead card (kanban-like) ─────────────────────────────────── */
.mads-lead-card {
  background: var(--mads-card);
  border: 1px solid var(--mads-bord);
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color .2s;
  cursor: pointer;
}
.mads-lead-card:hover { border-color: var(--mads-bord2); }

.mads-lead-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.mads-lead-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--mads-bg2);
  border: 1px solid var(--mads-bord);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--mads-accent);
  flex-shrink: 0;
}
.mads-lead-name { font-size: 13px; font-weight: 600; color: var(--text1,#fff); }
.mads-lead-meta { font-size: 10px; color: var(--mads-text3); }

.mads-lead-score-bar {
  height: 3px;
  background: rgba(255,255,255,.06);
  border-radius: 99px;
  overflow: hidden;
  margin: 10px 0 6px;
}
.mads-lead-score-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--mads-accent), var(--mads-cyan));
  transition: width .6s ease;
}

/* ── Metric mini-chart bar ───────────────────────────────────── */
.mads-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 40px;
}
.mads-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: rgba(124,58,237,.35);
  transition: height .4s ease, background .2s;
  min-height: 4px;
}
.mads-bar:hover { background: rgba(124,58,237,.7); }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes mads-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .4; }
}
@keyframes mads-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
@keyframes mads-progress-shine {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes mads-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes mads-slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes mads-countUp {
  from { opacity: 0; transform: scale(.9); }
  to   { opacity: 1; transform: scale(1); }
}

.mads-kpi-val { animation: mads-countUp .4s ease both; }
.mads-insight-card { animation: mads-fadeIn .25s ease both; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mads-header         { padding: 12px 16px 0; }
  .mads-tabs           { padding: 10px 16px 0; }
  .mads-content        { padding: 14px 16px 24px; }
  .mads-kpi-grid       { grid-template-columns: repeat(2, 1fr); }
  .mads-tab            { padding: 8px 12px; }
  .mads-discovery-form { grid-template-columns: 1fr; }
  .mads-detail-panel   { width: 100%; }
  .mads-insights-grid  { grid-template-columns: 1fr; }
}
