/* Reporte de campañas (Meta Ads). Usa los tokens de app.css. */

/* Encabezado */
.ads-hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.ads-eyebrow { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); margin-bottom: 4px; }
.ads-acc-field { max-width: 100%; }
.ads-acc-field select { max-width: min(420px, 78vw); }
.ads-notes { margin-top: 14px; }

/* Conectar anuncios */
.ads-connect {
  margin: 28px 0; padding: 36px clamp(20px, 4vw, 48px); border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: grid; justify-items: start; gap: 14px; max-width: 720px;
}
.ads-connect-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--secondary); color: var(--accent); }
.ads-connect h2 { font-size: 24px; letter-spacing: -0.01em; }
.ads-connect p { color: var(--ink-2); max-width: 60ch; }

/* KPI de resultados (resaltados) */
.kpi--result { border-top: 3px solid var(--accent); }

/* Tablas */
.table-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow); }
.atable { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
.atable--seg { min-width: 560px; }
.atable th, .atable td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.atable tbody tr:last-child th, .atable tbody tr:last-child td { border-bottom: 0; }
.atable thead th { font-size: 12px; color: var(--faint); font-weight: 600; background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.atable tbody th { font-weight: 600; min-width: 200px; }
.atable tbody th .pbadge { margin-right: 6px; vertical-align: -3px; }
.atable .num { text-align: right; white-space: nowrap; }
.atable td.num small { display: block; color: var(--faint); font-size: 12px; font-weight: 500; }
.atable td.num .delta { margin-top: 4px; }
.atable tbody tr:hover { background: color-mix(in srgb, var(--secondary) 3%, transparent); }
.camp-name { line-height: 1.35; }
.camp-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 6px; font-size: 12.5px; font-weight: 500; }
.share-bar { display: block; height: 4px; margin: 6px 0 3px auto; width: 72px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; }
.share-bar i { display: block; height: 100%; background: var(--secondary); border-radius: inherit; }
.best-cost { color: var(--up); }
.subhead { font-size: 15px; font-weight: 700; margin: 22px 0 10px; }

/* Estado */
.ad-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.ad-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.ad-status--on i { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 18%, transparent); }
.ad-status--warn i { background: #C98A12; }
.ad-status--bad i { background: var(--down); }

/* Embudo */
.funnel { padding: 18px 22px; display: grid; gap: 4px; }
.funnel-row { display: grid; grid-template-columns: minmax(130px, 180px) 1fr minmax(96px, 120px); gap: 14px; align-items: center; padding: 8px 0; }
.funnel-label { font-weight: 600; font-size: 14px; }
.funnel-bar { height: 34px; background: var(--surface-2); border-radius: 10px; display: flex; align-items: center; min-width: 0; }
.funnel-bar i { flex: none; align-self: stretch; max-width: calc(100% - 92px); background: linear-gradient(90deg, var(--secondary), color-mix(in srgb, var(--secondary) 70%, var(--primary))); border-radius: 10px; }
.funnel-bar strong { margin-left: 10px; color: var(--ink); font-size: 14px; white-space: nowrap; }
.funnel-rate { text-align: right; font-weight: 700; font-size: 15px; }
.funnel-rate small { display: block; font-weight: 500; font-size: 11.5px; color: var(--faint); }

/* Audiencias */
.aud-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.aud-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 18px; box-shadow: var(--shadow); display: grid; gap: 12px; align-content: start; }
.aud-card--best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.aud-card header { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.aud-card h3 { font-size: 15.5px; font-weight: 700; line-height: 1.3; }
.aud-badge { flex: none; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: var(--r-pill); white-space: nowrap; }
.aud-badge--best { background: var(--up-bg); color: var(--up); }
.aud-badge--review { background: var(--down-bg); color: var(--down); }
.tchips { display: flex; flex-wrap: wrap; gap: 6px; }
.tchip { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-2); }
.tlist { margin: 0; display: grid; gap: 4px; font-size: 13px; }
.tlist div { display: grid; grid-template-columns: 96px 1fr; gap: 8px; }
.tlist dt { color: var(--faint); }
.tlist dd { margin: 0; color: var(--ink-2); }
.aud-metrics { margin: 0; padding-top: 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; }
.aud-metrics dt { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aud-metrics dd { margin: 0; font-weight: 700; font-size: 14.5px; }
.aud-metrics small { display: block; font-size: 11px; font-weight: 600; }
.aud-metrics .good { color: var(--up); }
.aud-metrics .bad { color: var(--down); }

/* Edad y género */
.demo-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; }
.demo-grid .card-plain { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; box-shadow: var(--shadow); }
.demo-grid h3 { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.demo-row { display: grid; grid-template-columns: 56px 1fr 64px 84px; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.demo-row--head { font-size: 12px; color: var(--faint); padding-top: 0; }
.demo-row--head span:nth-child(3), .demo-row--head span:nth-child(4), .demo-v, .demo-cost { text-align: right; }
.demo-bar { height: 10px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; }
.demo-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.demo-v { font-weight: 600; }
.demo-cost { font-weight: 700; }
.ads-glegend li { grid-template-columns: 12px 1fr auto auto; }
.gdot { width: 12px; height: 12px; border-radius: 3px; display: block; }
.gdot--female { background: var(--primary); }
.gdot--male { background: var(--secondary); }
.gdot--unknown { background: var(--line-strong); }

/* Anuncios */
.ad-card .ad-name { font-size: 14.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 900px) {
  .demo-grid { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: 1fr minmax(84px, auto); }
  .funnel-bar { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) {
  .aud-cards { grid-template-columns: 1fr; }
  .aud-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ads-acc-field select { max-width: 100%; }
}

@media print {
  .table-wrap { overflow: visible; border: 0; box-shadow: none; }
  .atable { min-width: 0; font-size: 11.5px; }
  .atable th, .atable td { padding: 6px 8px; }
  .aud-card, .atable tr, .funnel-row { break-inside: avoid; }
  .aud-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Variación vs. promedio dentro de las tarjetas de anuncio */
.ad-card .pc-metrics small { display: block; font-size: 11px; font-weight: 600; margin-top: 1px; }
.ad-card .pc-metrics .good { color: var(--up); }
.ad-card .pc-metrics .bad { color: var(--down); }
