:root {
  --bar: #2a1730;
  --bar-hover: rgba(255, 255, 255, 0.1);
  --accent: #e4f53b;
  --accent-ink: #2a1730;
  --ink: #1f1b24;
  --muted: #5f5868;
  --soft: #8a8392;
  --bg: #eef0f3;
  --card: #ffffff;
  --line: #e4e2e8;
  --side: #ffffff;
  --side-active: #2a1730;
  --banner: #ecebfd;
  --banner-line: #c9c6f5;
  --chip: #f4f2f7;
  --ok: #15803d;
  --ok-bg: #e7f6ec;
  --warn: #b45309;
  --warn-bg: #fdf3e2;
  --err: #b91c1c;
  --err-bg: #fdecec;
  --info: #4338ca;
  --info-bg: #ecebfd;
  --series: #6d28d9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 27, 36, 0.05), 0 4px 16px rgba(31, 27, 36, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
svg { flex: none; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 64px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px;
  background: var(--bar);
  border-bottom: 3px solid var(--accent);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 18px; font-weight: 800; font-size: 18px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.topnav { display: flex; gap: 4px; }
.topnav a {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 9px;
  text-decoration: none; font-weight: 700; font-size: 14.5px; color: #f2eef5;
}
.topnav a:hover { background: var(--bar-hover); }
.topnav a.active { background: rgba(255, 255, 255, 0.14); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.btn-accent {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 9px; padding: 9px 16px;
  font-weight: 800; cursor: pointer;
}
.btn-accent:hover { filter: brightness(0.96); }
.profile-switch { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; color: #fff; cursor: pointer;
  padding: 4px 6px; border-radius: 9px; font-weight: 700;
}
.profile-btn:hover { background: var(--bar-hover); }
.avatar {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 14px;
}
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 240px; background: #fff; color: var(--ink);
  border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  padding: 6px; display: none;
}
.menu.open { display: block; }
.menu button {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; text-align: left; font-weight: 600;
}
.menu button:hover { background: var(--chip); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.icon-btn { background: none; border: 0; color: inherit; cursor: pointer; padding: 8px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--bar-hover); }
.mobile-only { display: none; }

/* ---------- Estructura ---------- */
.layout { display: flex; min-height: calc(100vh - 64px); }
.sidebar {
  width: 250px; flex: none;
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 10px 8px;
  display: flex; flex-direction: column;
  position: sticky; top: 64px; height: calc(100vh - 64px);
}
.side-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; margin-bottom: 4px;
  border-radius: 10px; text-decoration: none;
  font-weight: 600; font-size: 15.5px; cursor: pointer;
  border: 0; background: none; width: 100%; text-align: left;
}
.side-item:hover { background: var(--chip); }
.side-item.active { background: var(--side-active); color: #fff; }
.side-item .end { margin-left: auto; display: grid; place-items: center; }
.side-item.disabled { opacity: 0.45; }
.side-item .plus {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.6px solid var(--soft); color: var(--soft);
  display: grid; place-items: center;
}
.side-item .check {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
.side-item.connected { background: #fafbe9; }
.side-item.connected.active { background: var(--side-active); }
.side-more {
  align-self: center; margin: 18px 0;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--ink); border-radius: 8px; background: #fff;
  padding: 6px 12px; font-weight: 700; cursor: pointer;
}
.side-bottom { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }

.main { flex: 1; min-width: 0; padding: 28px 40px 60px; }
.page-title { font-size: 26px; font-weight: 700; margin: 6px 0 24px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title .spacer { flex: 1; }
.page-title .btn-dark, .page-title .btn { font-size: 15px; }

/* ---------- Tarjetas ---------- */
.banner {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: var(--banner); border: 1px solid var(--banner-line);
  border-radius: var(--radius); padding: 26px 26px; margin-bottom: 24px;
}
.banner h2 { margin: 0 0 6px; font-size: 19px; font-weight: 800; }
.banner p { margin: 0; color: var(--muted); }
.banner .grow { flex: 1; min-width: 240px; }
.btn-dark {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bar); color: var(--accent);
  border: 0; border-radius: 9px; padding: 10px 18px;
  font-weight: 800; cursor: pointer; text-decoration: none;
}
.btn-dark:hover { filter: brightness(1.15); }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 9px; padding: 8px 14px;
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--soft); }
.btn.small { padding: 5px 10px; font-size: 13.5px; }
.btn.danger { color: var(--err); }
.btn:disabled, .btn-dark:disabled, .btn-accent:disabled { opacity: 0.5; cursor: not-allowed; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 24px; border-radius: var(--radius); overflow: hidden; }
.card { background: var(--card); border-radius: var(--radius); padding: 26px 30px; box-shadow: var(--shadow); }
.grid3 .card { border-radius: 0; box-shadow: none; }
.card h3 { margin: 0 0 6px; font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.card .sub { margin: 0; color: var(--muted); line-height: 1.55; }
.card + .card { margin-top: 20px; }
.grid3 .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: flex-start; gap: 16px; }
.card-head .grow { flex: 1; }
.round-icon { width: 46px; height: 46px; border-radius: 50%; background: var(--banner); display: grid; place-items: center; flex: none; }
.stat { margin-top: 26px; display: flex; align-items: baseline; gap: 10px; }
.stat b { font-size: 38px; font-weight: 800; letter-spacing: -0.02em; }
.stat span { color: var(--soft); font-weight: 600; }

/* ---------- Listas de publicaciones ---------- */
.post-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 12px; background: var(--chip);
  margin-top: 10px; cursor: pointer;
}
.post-row:hover { background: #ebe8f0; }
.thumb { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; background: #ddd; flex: none; }
.thumb.ph { display: grid; place-items: center; color: var(--soft); }
.post-row .txt { flex: 1; min-width: 0; }
.post-row .txt b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.post-row .txt small { color: var(--muted); }
.nets { display: flex; gap: 4px; align-items: center; }
.empty { color: var(--soft); padding: 18px 0 4px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 800; white-space: nowrap; }
.badge.scheduled, .badge.pending { background: var(--info-bg); color: var(--info); }
.badge.publishing { background: var(--warn-bg); color: var(--warn); }
.badge.done, .badge.published { background: var(--ok-bg); color: var(--ok); }
.badge.partial { background: var(--warn-bg); color: var(--warn); }
.badge.error { background: var(--err-bg); color: var(--err); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pill { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 14px; font-weight: 700; cursor: pointer; }
.pill.active { background: var(--bar); color: #fff; border-color: var(--bar); }

/* ---------- Calendario ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-head h3 { margin: 0 12px 0 4px; font-size: 20px; min-width: 170px; }
.cal-head h3::first-letter { text-transform: uppercase; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--line); gap: 1px; }
.cal .dow { background: #faf9fb; padding: 10px; font-weight: 800; font-size: 12.5px; color: var(--soft); text-transform: uppercase; letter-spacing: 0.04em; }
.cal .day { background: #fff; min-height: 118px; padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.cal .day:hover { background: #fcfcf3; }
.cal .day.out { background: #faf9fb; color: var(--soft); }
.cal .day.past { background: #fbfbfc; }
.cal .num { font-weight: 800; font-size: 13.5px; display: flex; justify-content: space-between; align-items: center; }
.cal .num .add { opacity: 0; color: var(--soft); }
.cal .day:hover .num .add { opacity: 1; }
.cal .today .num span:first-child { background: var(--bar); color: var(--accent); border-radius: 99px; padding: 1px 8px; }
.chip {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 6px; border-radius: 7px;
  background: var(--chip); font-size: 12.5px; font-weight: 700;
  border-left: 4px solid var(--c, var(--soft));
  overflow: hidden; white-space: nowrap;
}
.chip .t { color: var(--muted); }
.chip .cap { overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.chip.error { background: var(--err-bg); }
.chip.done { background: var(--ok-bg); }

/* ---------- Perfiles y ajustes ---------- */
.profile-card { display: flex; flex-direction: column; gap: 16px; }
.acc-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--chip); flex-wrap: wrap; }
.acc-row .grow { flex: 1; min-width: 160px; }
.acc-row small { color: var(--muted); display: block; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-weight: 800; font-size: 13.5px; }
.field .hint { color: var(--soft); font-size: 13px; }
input[type=text], input[type=password], input[type=datetime-local], input[type=color], select, textarea {
  border: 1.5px solid var(--line); border-radius: 9px; padding: 9px 12px; background: #fff; width: 100%;
}
input[type=color] { padding: 2px; height: 40px; width: 56px; }
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--bar); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--chip); }
.steps { margin: 10px 0 18px; padding-left: 20px; color: var(--muted); line-height: 1.7; }
.steps b { color: var(--ink); }
.note { background: var(--warn-bg); color: #7a4a0a; border-radius: 10px; padding: 10px 14px; font-size: 14px; line-height: 1.5; margin-bottom: 14px; }
.note.info { background: var(--info-bg); color: #312e81; }
.check-line { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 12, 24, 0.55); z-index: 50; display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-back.open { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 760px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 19px; flex: 1; }
.modal-body { padding: 20px 24px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 16px 24px; border-top: 1px solid var(--line); background: #faf9fb; border-radius: 0 0 16px 16px; }
.modal-foot .left { margin-right: auto; }

.drop {
  border: 2px dashed var(--banner-line); background: #f8f7ff; border-radius: 12px;
  padding: 22px; text-align: center; color: var(--muted); cursor: pointer;
}
.drop.over { border-color: var(--bar); background: #f1f0fe; }
.media-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.media-item { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; background: #eee; }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; }
.media-item .x { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, 0.6); color: #fff; border: 0; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }
.media-item .tag { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.media-item .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); }

.net-box { border: 1.5px solid var(--line); border-radius: 12px; margin-top: 12px; }
.net-box.on { border-color: var(--bar); }
.net-box .net-top { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; font-weight: 800; }
.net-box .net-top small { font-weight: 600; color: var(--muted); }
.net-box .net-body { padding: 0 14px 14px; display: none; }
.net-box.on .net-body { display: block; }
.counter { color: var(--soft); font-size: 12.5px; text-align: right; }

.target-line { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.target-line:first-child { border-top: 0; }
.target-line .grow { flex: 1; min-width: 140px; }
.target-line .err { color: var(--err); font-size: 13.5px; width: 100%; }
.target-line .warn { color: var(--warn); font-size: 13.5px; width: 100%; }

.preview { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.preview img, .preview video { max-height: 220px; max-width: 100%; border-radius: 10px; background: #000; }
.caption-view { white-space: pre-wrap; background: var(--chip); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bar); color: #fff; padding: 12px 20px; border-radius: 10px; font-weight: 700; z-index: 60; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); max-width: calc(100% - 32px); }
.toast.error { background: var(--err); }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bar); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 32px; border-top: 5px solid var(--accent); }
.auth-card h1 { margin: 14px 0 6px; font-size: 24px; }
.auth-card p { color: var(--muted); margin: 0 0 20px; }
.auth-card .btn-dark { width: 100%; justify-content: center; padding: 12px; }
.auth-err { color: var(--err); font-weight: 700; min-height: 22px; margin-top: 10px; }

/* ---------- Analítica ---------- */
.acc-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.acc-pills .pill { display: inline-flex; align-items: center; gap: 8px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.kpi .k-label { color: var(--muted); font-weight: 700; font-size: 13.5px; }
.kpi .k-value { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; }
.kpi .k-sub { color: var(--soft); font-size: 13px; font-weight: 600; margin-top: 2px; }
.kpi .k-sub.up { color: var(--ok); }
.kpi .k-sub.down { color: var(--err); }
.chart { position: relative; margin-top: 16px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--soft); font-size: 11px; font-family: inherit; }
.chart .bar { fill: var(--series); }
.chart .bar.dim { opacity: 0.35; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; }
.chart .dot { fill: var(--series); stroke: #fff; stroke-width: 2; }
.chart .cross { stroke: var(--soft); stroke-width: 1; stroke-dasharray: 3 3; }
.tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--bar); color: #fff; border-radius: 10px; padding: 10px 12px;
  font-size: 13px; line-height: 1.45; max-width: 260px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transform: translate(-50%, calc(-100% - 12px)); white-space: normal;
}
.tip b { color: var(--accent); }
.tip .muted { color: #cfc6d6; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: right; color: var(--soft); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td { text-align: right; padding: 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.post { display: flex; align-items: center; gap: 10px; white-space: normal; min-width: 240px; }
table.data td.post .thumb { width: 44px; height: 44px; }
table.data td.post span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.legend-note { color: var(--soft); font-size: 13px; margin-top: 6px; }

/* ---------- Comentarios ---------- */
.cmt { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 14px; }
.cmt-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cmt-head small { color: var(--soft); font-weight: 600; }
.cmt-head .avatar { width: 30px; height: 30px; font-size: 13px; border-radius: 50%; }
.cmt-text { margin: 10px 0 0 40px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.cmt-reply { margin: 10px 0 0 40px; padding: 10px 12px; background: var(--chip); border-radius: 10px; font-size: 14px; }
.cmt-reply b { margin-right: 6px; }
.cmt-reply.own { background: #f5f8d9; }
.cmt-post { display: flex; align-items: center; gap: 10px; margin: 12px 0 0 40px; color: var(--muted); font-size: 13px; }
.cmt-post .thumb { width: 36px; height: 36px; border-radius: 6px; }
.cmt-post span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmt-actions { display: flex; gap: 8px; margin: 12px 0 0 40px; flex-wrap: wrap; }
.cmt-form { margin: 12px 0 0 40px; display: none; gap: 8px; align-items: flex-end; }
.cmt-form.open { display: flex; }
.cmt-form textarea { min-height: 60px; flex: 1; }
.cmt.hidden-c .cmt-text { color: var(--soft); text-decoration: line-through; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topnav a span { display: none; }
}
@media (max-width: 820px) {
  .topbar { padding: 0 12px; }
  .topnav { display: none; }
  .mobile-only { display: grid; }
  .brand span { display: none; }
  .profile-btn .pname { display: none; }
  .btn-accent .lbl { display: none; }
  .sidebar { position: fixed; left: 0; top: 64px; z-index: 30; transform: translateX(-100%); transition: transform 0.2s; box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15); }
  .sidebar.open { transform: none; }
  .main { padding: 20px 16px 60px; }
  .cal .day { min-height: 74px; padding: 4px; }
  .chip .cap, .chip .t { display: none; }
  .cal .dow { padding: 6px 2px; font-size: 11px; text-align: center; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
}
