/* Panel de redes — estilos base (neutros).
   Para aplicar la identidad de marca, cambiá las variables de :root. */
:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: var(--font-sans);
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --line: #e3e6ea;
  --fg: #1d2330;
  --muted: #6b7380;
  --brand: #2b59c3;
  --brand-soft: #e8eefb;
  --ok: #1e8e5a;
  --bad: #c8412b;
  --warn: #b7791f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --c-facebook: #1877f2;
  --c-instagram: #d6246e;
  --c-tiktok: #111111;
  --c-youtube: #e62117;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--fg); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; word-break: break-all; }

/* ---------- Botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--fg);
  padding: 7px 12px; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c5cad2; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea.code { width: 100%; font-family: ui-monospace, monospace; font-size: 12px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 500; }
.form input, .form select { width: 100%; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.alert { padding: 10px 12px; border-radius: 8px; margin: 10px 0; }
.alert-error { background: #fdecea; color: #8a2a1b; }
.alert-ok { background: #e7f6ee; color: #135e3c; }
.alert-warn { background: #fdf5e6; color: #7a5212; }

/* ---------- Login / instalación ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); padding: 28px; border-radius: 14px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; }
.auth-card .btn { justify-content: center; width: 100%; }

/* ---------- Layout ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.topbar .brand { font-weight: 700; font-size: 16px; font-family: var(--font-display); }
.topbar .sync { margin-left: auto; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs a:hover { background: var(--panel-2); text-decoration: none; color: var(--fg); }
.tabs a.active { background: var(--brand-soft); color: var(--brand); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 20px; background: var(--panel-2); border-bottom: 1px solid var(--line); position: sticky; top: 53px; z-index: 30; }
.filters .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.filters input[type=date] { padding: 5px 8px; }
.presets { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.presets button { border: 0; background: transparent; padding: 6px 10px; font: inherit; cursor: pointer; color: var(--muted); }
.presets button + button { border-left: 1px solid var(--line); }
.presets button.active { background: var(--brand); color: #fff; }
main.content { padding: 20px; max-width: 1600px; margin: 0 auto; }
.section { margin-bottom: 22px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.section-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .grid-2, .grid-3, .grid-21 { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 200px; }
.chart-box.lg { height: 340px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.loading { opacity: .55; pointer-events: none; transition: opacity .2s; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; margin-top: 2px; }
.up { color: var(--ok); }
.down { color: var(--bad); }

/* ---------- Posteos ---------- */
.post-card { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; }
.post-card .thumb, .thumb { width: 120px; height: 150px; border-radius: 8px; object-fit: cover; background: var(--panel-2); display: grid; place-items: center; color: var(--muted); font-size: 12px; overflow: hidden; }
.thumb.sm { width: 44px; height: 44px; border-radius: 6px; }
.post-card .title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.post-card .caption { margin: 6px 0 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.metrics-row { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; }
.metrics-row b { font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--fg); white-space: nowrap; }
.badge.net { color: #fff; border: 0; }
.badge.net.facebook { background: var(--c-facebook); }
.badge.net.instagram { background: var(--c-instagram); }
.badge.net.tiktok { background: var(--c-tiktok); }
.badge.net.youtube { background: var(--c-youtube); }
.badge.index { background: var(--brand); color: #fff; border: 0; font-size: 12px; }
.badge.index.low { background: #9aa3af; }
.badge.warn { background: #fdf5e6; color: var(--warn); border-color: #f2dfb9; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); background: var(--panel); margin: 0 4px 4px 0; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip.manual { border-style: solid; border-color: var(--brand); }
.chip.rejected { text-decoration: line-through; opacity: .55; }
.chip button { border: 0; background: none; cursor: pointer; padding: 0 0 0 2px; color: var(--muted); font-size: 13px; line-height: 1; }
.acc { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.acc img, .acc .av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: var(--panel-2); flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.acc .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sorted::after { content: " ▾"; }
table.data th.sorted.asc::after { content: " ▴"; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tbody tr:hover { background: var(--panel-2); }
table.data tr.clickable { cursor: pointer; }
td .caption-cell { max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.bar-cell { position: relative; }
.bar-cell .bar { position: absolute; left: 0; top: 50%; height: 6px; transform: translateY(-50%); background: var(--brand-soft); border-radius: 3px; z-index: 0; }
.bar-cell span { position: relative; z-index: 1; }

/* ---------- Multiselect ---------- */
.ms { position: relative; }
.ms > .btn { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.ms > .btn.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.ms-panel { position: absolute; top: calc(100% + 4px); left: 0; min-width: 240px; max-width: 320px; max-height: 380px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; z-index: 50; }
.ms-panel input[type=search] { width: 100%; margin-bottom: 6px; }
.ms-panel label { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.ms-panel label:hover { background: var(--panel-2); }
.ms-panel .ms-actions { display: flex; justify-content: space-between; padding: 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.ms-panel .group { font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 6px 6px 2px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 980px; max-height: 92vh; overflow: auto; padding: 22px; position: relative; }
.modal .close { position: absolute; top: 12px; right: 12px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 200; box-shadow: var(--shadow); max-width: 420px; }
.toast.error { background: var(--bad); }

/* ---------- Temas ---------- */
.topic-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--panel); }
.topic-block .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.topic-block .swatch { width: 14px; height: 14px; border-radius: 4px; }
.topic-block .terms { display: flex; flex-wrap: wrap; }
.sugg-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sugg-row .term { font-weight: 600; min-width: 140px; }

/* ---------- Subtabs ---------- */
.subtabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.subtabs button { border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; color: var(--muted); }
.subtabs button.active { background: var(--fg); color: #fff; border-color: var(--fg); }

/* ---------- Informe ---------- */
.report-builder { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .report-builder { grid-template-columns: 1fr; } }
.report-builder .opts label { display: flex; gap: 8px; align-items: center; padding: 3px 0; }
.report-page { background: #fff; color: #111; max-width: 900px; margin: 0 auto; padding: 40px 48px; box-shadow: var(--shadow); border-radius: 4px; }
.report-page .r-head { border-bottom: 3px solid var(--fg); padding-bottom: 14px; margin-bottom: 20px; }
.report-page .r-head h1 { font-size: 28px; }
.report-page .r-sec { margin-bottom: 26px; break-inside: avoid; }
.report-page .r-sec h2 { font-size: 17px; margin-bottom: 10px; border-left: 4px solid var(--brand); padding-left: 8px; }
.report-page .notes { white-space: pre-wrap; }

/* ---------- Modo monitor ---------- */
body.tv { --bg: #0e1116; --panel: #161b22; --panel-2: #1c222b; --line: #2a313c; --fg: #eef1f5; --muted: #9aa4b2; --brand-soft: #1f2b44; background: var(--bg); font-size: 16px; }
body.tv .topbar, body.tv .filters, body.tv .tabs { display: none; }
.tv-wrap { padding: 24px 32px; min-height: 100vh; display: flex; flex-direction: column; }
.tv-head { display: flex; align-items: baseline; gap: 18px; margin-bottom: 18px; }
.tv-head h1 { font-size: 30px; }
.tv-head .clock { margin-left: auto; font-size: 30px; font-variant-numeric: tabular-nums; font-weight: 700; }
.tv-slide { flex: 1; }
.tv .kpi .value { font-size: 40px; }
.tv .kpi .label { font-size: 14px; }
.tv .chart-box { height: calc(100vh - 430px); min-height: 260px; }
.tv-dots { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.tv-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.tv-dots span.on { background: var(--brand); }
.tv .post-card { grid-template-columns: 200px minmax(0, 1fr); }
.tv .post-card .thumb { width: 200px; height: 250px; }
.tv .post-card .caption { -webkit-line-clamp: 4; font-size: 18px; }
.tv-exit { position: fixed; bottom: 12px; right: 12px; opacity: .15; }
.tv-exit:hover { opacity: 1; }

/* ---------- Impresión ---------- */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .topbar, .filters, .no-print, .report-builder > .opts, .toast { display: none !important; }
  main.content { padding: 0; max-width: none; }
  .report-builder { display: block; }
  .report-page { box-shadow: none; padding: 0; max-width: none; }
  .chart-box { height: 240px; }
}
