:root {
  --fondo: #121216; --panel: #1c1c22; --panel2: #24242c; --borde: #33333d;
  --texto: #ececf1; --sutil: #9a9aa8; --acento: #7c6cff; --bien: #34c38f; --mal: #ff5d6c;
  --fb: #1877f2; --ig: #e1306c; --yt: #ff3b30; --tt: #25f4ee;
  --radio: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.4rem; margin: 0 0 .6rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
code { background: var(--panel2); padding: .1rem .35rem; border-radius: 4px; }
.sutil { color: var(--sutil); } .chico { font-size: .82rem; } .error { color: var(--mal); min-height: 1.2em; margin: .3rem 0; }
[hidden] { display: none !important; }

.barra { position: sticky; top: 0; z-index: 5; display: flex; gap: 1rem; align-items: center; padding: .6rem 1rem; background: rgba(18,18,22,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--borde); }
.marca { font-weight: 700; white-space: nowrap; }
.pestanas { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.pestanas button { background: none; border: 0; color: var(--sutil); padding: .45rem .8rem; border-radius: 8px; cursor: pointer; font: inherit; white-space: nowrap; }
.pestanas button.activa { background: var(--panel2); color: var(--texto); }

main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem; margin-bottom: 1rem; }
.tarjeta.centrada { max-width: 380px; margin: 12vh auto; display: flex; flex-direction: column; gap: .7rem; }
.tarjeta-cab { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.tarjeta-cab h2 { margin: 0; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--sutil); }
input, select { background: var(--panel2); color: var(--texto); border: 1px solid var(--borde); border-radius: 8px; padding: .55rem .7rem; font: inherit; }

.btn { background: var(--acento); color: #fff; border: 0; border-radius: 8px; padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-chico { padding: .35rem .7rem; font-size: .85rem; }
.btn-borde { background: none; border: 1px solid var(--borde); color: var(--texto); }
.btn-meta { background: linear-gradient(90deg, var(--fb), var(--ig)); }
.btn-yt { background: var(--yt); }
.botones { display: flex; gap: .6rem; flex-wrap: wrap; }

.filtros { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.segmentado { display: inline-flex; background: var(--panel); border: 1px solid var(--borde); border-radius: 9px; padding: 3px; }
.segmentado button { background: none; border: 0; color: var(--sutil); padding: .35rem .7rem; border-radius: 7px; cursor: pointer; font: inherit; }
.segmentado button.activa { background: var(--panel2); color: var(--texto); }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--borde); background: none; color: var(--sutil); border-radius: 999px; padding: .3rem .75rem; cursor: pointer; font: inherit; font-size: .85rem; }
.chip.activa { color: var(--texto); border-color: var(--c, var(--acento)); background: color-mix(in srgb, var(--c, var(--acento)) 18%, transparent); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: .9rem 1rem; }
.kpi .t { color: var(--sutil); font-size: .82rem; }
.kpi .v { font-size: 1.6rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: .82rem; }
.sube { color: var(--bien); } .baja { color: var(--mal); }

.grafico { position: relative; height: 320px; }
.tabla-scroll { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.tabla th, .tabla td { padding: .5rem .6rem; text-align: right; border-bottom: 1px solid var(--borde); white-space: nowrap; }
.tabla th:first-child, .tabla td:first-child { text-align: left; }
.tabla th { color: var(--sutil); font-weight: 500; cursor: pointer; user-select: none; }
.tabla th.orden::after { content: " ↓"; }
.cuenta-celda { display: flex; align-items: center; gap: .55rem; }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--panel2); flex: none; }
.red { display: inline-block; font-size: .7rem; font-weight: 700; padding: .1rem .4rem; border-radius: 5px; color: #fff; text-transform: uppercase; letter-spacing: .03em; }
.red.facebook { background: var(--fb); } .red.instagram { background: var(--ig); } .red.youtube { background: var(--yt); } .red.tiktok { background: #000; color: var(--tt); }

.dos-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.mapa { display: grid; grid-template-columns: 2.4rem repeat(6, 1fr); gap: 3px; font-size: .75rem; }
.mapa div { padding: .35rem .2rem; text-align: center; border-radius: 4px; }
.mapa .cab { color: var(--sutil); }
.mapa .celda { background: color-mix(in srgb, var(--acento) calc(var(--i) * 100%), var(--panel2)); font-variant-numeric: tabular-nums; }

.lista-pubs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; }
.pub { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); overflow: hidden; display: flex; flex-direction: column; color: inherit; text-decoration: none; }
.pub .mini { aspect-ratio: 4/5; background: var(--panel2); position: relative; overflow: hidden; }
.pub .mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pub .mini .red { position: absolute; top: 8px; left: 8px; }
.pub .mini .tipo { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.65); font-size: .7rem; padding: .1rem .4rem; border-radius: 5px; }
.pub .cuerpo { padding: .7rem; display: flex; flex-direction: column; gap: .4rem; }
.pub .txt { font-size: .85rem; color: var(--sutil); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pub .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem; font-size: .78rem; }
.pub .nums b { display: block; font-size: .95rem; font-variant-numeric: tabular-nums; }

.cuenta-fila { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--borde); flex-wrap: wrap; }
.cuenta-fila .info { flex: 1; min-width: 180px; }
.cuenta-fila .estado { font-size: .8rem; color: var(--sutil); }
.cuenta-fila .estado.mal { color: var(--mal); }
.interruptor { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--sutil); flex-direction: row; }

.aviso { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--borde); padding: .7rem 1rem; border-radius: 10px; z-index: 10; max-width: calc(100% - 2rem); }
.aviso.mal { border-color: var(--mal); }
.vacio { text-align: center; color: var(--sutil); padding: 2rem 1rem; }

@media (max-width: 760px) {
  .barra { flex-wrap: wrap; } .marca { flex: 1; } .pestanas { order: 3; flex-basis: 100%; }
  .dos-col { grid-template-columns: 1fr; }
  .grafico { height: 260px; }
}
