/* ============================================================
   Publicador de Canales — sistema de diseño
   ============================================================ */

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --surface-2: #fafbfc;
  --line:      #e5e7eb;
  --line-2:    #eef0f3;
  --ink:       #14161a;
  --ink-2:     #454b54;
  --muted:     #79808b;

  --brand:     #5b4bdb;
  --brand-ink: #efecfd;
  --brand-dk:  #4438b8;

  --wa:        #1fa855;
  --wa-bg:     #e7f7ee;
  --tg:        #2496d0;
  --tg-bg:     #e6f3fb;

  --ok:        #08875b;
  --ok-bg:     #e4f6ee;
  --warn:      #b45309;
  --warn-bg:   #fdf3e3;
  --err:       #c62f2f;
  --err-bg:    #fdeceb;
  --info-bg:   #eef2ff;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(16,18,22,.05), 0 4px 14px rgba(16,18,22,.05);
  --shadow-lg: 0 8px 30px rgba(16,18,22,.12);
  --sidebar:   236px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 15px; height: 15px; }

/* ---------- Estructura ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 18px;
  font-weight: 700; font-size: 15px; letter-spacing: -.01em;
  color: var(--ink);
}
/* Logo del proyecto: se usa si existe assets/logo.(svg|png|webp). */
.brand img.logo { height: 28px; width: auto; max-width: 100%; display: block; }
.auth img.logo { height: 40px; width: auto; max-width: 70%; display: block; margin-bottom: 4px; }

.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--brand), #8b7bf0);
  color: #fff; display: grid; place-items: center; font-size: 15px;
}

.nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 14.5px; font-weight: 500;
  text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--brand-ink); color: var(--brand-dk); font-weight: 600; }
.nav .sep { height: 1px; background: var(--line-2); margin: 10px 11px; }

.sidebar-foot { margin-top: auto; padding: 14px 12px; border-top: 1px solid var(--line-2); }
.quien {
  display: flex; align-items: center; gap: 9px; padding: 8px 9px; margin-bottom: 8px;
  border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; min-width: 0;
}
.quien:hover { background: var(--surface-2); text-decoration: none; }
.quien .datos { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.quien .datos b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quien .datos .muted { font-size: 11.5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 660; letter-spacing: -.015em; }
.topbar .sub { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }
.topbar > * { min-width: 0; }
.topbar .spacer { flex: 1; }

.content { padding: 24px 28px 56px; max-width: 1760px; width: 100%; }

/* ---------- Tarjetas ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card > .hd {
  padding: 15px 18px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px;
}
.card > .hd h2 { margin: 0; font-size: 14.5px; font-weight: 640; letter-spacing: -.01em; }
.card > .hd .spacer { flex: 1; }
.card > .bd { padding: 18px; }
.card > .bd.tight { padding: 6px 0; }

.grid { display: grid; gap: 18px; }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.k3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.k2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (min-width: 1500px) { .cols { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); } }

/* ---------- Métricas ---------- */

.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .top { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; font-weight: 550; }
.stat .n { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin-top: 8px; line-height: 1.1; }
.stat .chip { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }
.stat.c-brand .chip { background: var(--brand-ink); color: var(--brand-dk); }
.stat.c-ok    .chip { background: var(--ok-bg);   color: var(--ok); }
.stat.c-warn  .chip { background: var(--warn-bg); color: var(--warn); }
.stat.c-err   .chip { background: var(--err-bg);  color: var(--err); }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--brand); color: #fff; border: 1px solid transparent;
  padding: 9px 15px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 560; font-family: inherit;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-dk); text-decoration: none; color: #fff; }
.btn.ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.ok  { background: var(--ok); } .btn.ok:hover  { background: #06724c; }
.btn.err { background: var(--err); } .btn.err:hover { background: #a82626; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 7px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---------- Formularios ---------- */

label.f { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 6px; }
.field { margin-bottom: 16px; }
.field .help { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.field .help.bad { color: var(--err); }

input[type=text], input[type=password], input[type=datetime-local], input[type=date], textarea, select {
  width: 100%; padding: 10px 12px;
  border: 1px solid #d6dae0; border-radius: var(--radius-sm);
  font-size: 14.5px; font-family: inherit; color: var(--ink);
  background: var(--surface);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91,75,219,.13);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2379808b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
input[type=file] { font-size: 13.5px; }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

.toggles { display: flex; gap: 10px; flex-wrap: wrap; }
.toggle {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px; font-weight: 550; background: var(--surface);
}
.toggle input { width: 16px; height: 16px; accent-color: var(--brand); }
.toggle.wa:has(input:checked) { border-color: var(--wa); background: var(--wa-bg); color: #0f6b38; }
.toggle.tg:has(input:checked) { border-color: var(--tg); background: var(--tg-bg); color: #10618c; }

/* ---------- Etiquetas y avatares ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 620; white-space: nowrap;
}
.b-scheduled { background: var(--info-bg); color: #4338ca; }
.b-published { background: var(--ok-bg);   color: var(--ok); }
.b-partial   { background: var(--warn-bg); color: var(--warn); }
.b-error     { background: var(--err-bg);  color: var(--err); }
.b-cancelled { background: #f0f1f3;        color: #5c636e; }
.b-publishing{ background: #f3ecfd;        color: #6b21a8; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.who { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.av {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.av.lg { width: 42px; height: 42px; border-radius: 12px; font-size: 15px; }
.who .nm { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 7px; font-size: 11.5px; font-weight: 640;
}
.pill.wa { background: var(--wa-bg); color: #0f6b38; }
.pill.tg { background: var(--tg-bg); color: #10618c; }
.pill.off { background: #f0f1f3; color: #868d97; }

/* ---------- Tablas ---------- */

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 18px; border-bottom: 1px solid var(--line-2); background: var(--surface-2);
}
.tbl td { padding: 13px 18px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl td.right, .tbl th.right { text-align: right; }
.tbl .when { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .when b { display: block; font-weight: 600; }
.tbl .when span { color: var(--muted); font-size: 12.5px; }

.excerpt { display: flex; gap: 11px; align-items: flex-start; max-width: 460px; }
.excerpt img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.excerpt p { margin: 0; color: var(--ink-2); line-height: 1.45; }
.errdetail { color: var(--err); font-size: 12.5px; margin-top: 5px; line-height: 1.45; word-break: break-word; }

/* ---------- Filtros ---------- */

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg a { padding: 7px 13px; font-size: 13.5px; font-weight: 550; color: var(--ink-2); text-decoration: none; border-right: 1px solid var(--line); }
.seg a:last-child { border-right: none; }
.seg a:hover { background: var(--surface-2); text-decoration: none; }
.seg a.on { background: var(--brand); color: #fff; }
.filters select { width: auto; min-width: 170px; padding: 7px 32px 7px 12px; font-size: 13.5px; }

/* ---------- Listas ---------- */

.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--line-2);
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .ttl { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 30px; margin-bottom: 10px; opacity: .5; }
.empty p { margin: 0 0 14px; }

/* ---------- Calendario ---------- */

.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cal-hd { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.cal-hd .mo { font-size: 16px; font-weight: 650; text-transform: capitalize; }
.cal-hd .spacer { flex: 1; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); border-bottom: 1px solid var(--line-2); }
.cal-dow div { padding: 8px 10px; font-size: 11.5px; font-weight: 640; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; }
.cal-day { min-height: 116px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); padding: 7px 8px; position: relative; }
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.out { background: var(--surface-2); }
.cal-day.today { background: #fbfaff; }
.cal-day .num { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 7px; }
.cal-day.out .num { color: #b7bcc4; }
.cal-day.today .num { background: var(--brand); color: #fff; }
.cal-day .add {
  position: absolute; top: 6px; right: 7px; width: 21px; height: 21px; border-radius: 6px;
  display: grid; place-items: center; color: var(--muted); opacity: 0; background: var(--surface-2);
}
.cal-day:hover .add { opacity: 1; }
.cal-day .add:hover { background: var(--brand-ink); color: var(--brand-dk); text-decoration: none; }
.cal-ev {
  display: flex; align-items: center; gap: 5px; margin-top: 4px;
  padding: 3px 6px; border-radius: 6px; font-size: 12px; font-weight: 550;
  background: var(--surface-2); border-left: 3px solid var(--muted);
  color: var(--ink-2); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-ev:hover { background: var(--brand-ink); text-decoration: none; }
.cal-ev .h { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11px; }
.cal-ev.done { opacity: .62; }
.cal-ev.bad { border-left-color: var(--err); background: var(--err-bg); color: #8f2323; }
.cal-more { display: block; margin-top: 4px; font-size: 11.5px; color: var(--muted); padding-left: 6px; }

/* ---------- Vista previa del compositor ---------- */

.preview-wrap { position: sticky; top: 20px; }
.phone {
  border-radius: 16px; padding: 16px; border: 1px solid var(--line);
  background: #e9e3db;
}
.phone.tg { background: #dfeaf3; }
.phone .hd { font-size: 12px; font-weight: 640; color: var(--ink-2); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.bubble {
  background: #fff; border-radius: 10px 10px 10px 3px; padding: 8px 10px;
  box-shadow: 0 1px 1px rgba(0,0,0,.1); max-width: 320px;
}
.bubble img { max-width: 100%; border-radius: 6px; display: block; margin-bottom: 7px; }
.bubble .txt { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: #10161c; }
.bubble .txt:empty::before { content: 'Vista previa del mensaje…'; color: #9aa1ab; }
.bubble .tm { text-align: right; font-size: 10.5px; color: #8d949d; margin-top: 3px; }
.counter { font-size: 12px; color: var(--muted); margin-top: 8px; }
.counter.over { color: var(--warn); font-weight: 600; }

/* ---------- Avisos ---------- */

.note { padding: 12px 15px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.55; margin: 0 0 16px; }
.note.info { background: var(--info-bg); color: #3730a3; }
.note.ok   { background: var(--ok-bg);   color: #075e42; }
.note.warn { background: var(--warn-bg); color: #8a4708; }
.note.err  { background: var(--err-bg);  color: #9b2626; }
.note code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

.flash {
  position: fixed; right: 22px; bottom: 22px; z-index: 50;
  padding: 13px 17px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 550; max-width: 380px;
  background: var(--ink); color: #fff;
}
.flash.error { background: var(--err); }

pre {
  background: #14161a; color: #e6e8ec; padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 12.5px; overflow-x: auto; margin: 0;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); font-size: 13px; }
h3.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 26px 0 12px; font-weight: 640; }
h3.sec:first-child { margin-top: 0; }

/* ---------- Acceso ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #211d47, #4438b8); }
.auth .box { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 32px; width: 100%; max-width: 400px; }
.auth h1 { font-size: 18px; margin: 14px 0 4px; letter-spacing: -.015em; }
.auth p.intro { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.auth .mark { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), #8b7bf0); color: #fff; display: grid; place-items: center; font-size: 19px; }
.auth .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* ---------- Adaptable ---------- */

@media (max-width: 940px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; border-right: none; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { padding: 12px 14px; }
  .brand span { display: none; }
  .nav { flex-direction: row; padding: 8px; gap: 4px; }
  .nav a { white-space: nowrap; }
  .nav a span { display: none; }
  .nav .sep { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; border: none; padding: 8px 12px; display: flex; align-items: center; gap: 8px; }
  .quien { margin-bottom: 0; }
  .quien .datos { display: none; }
  .sidebar-foot .btn { width: auto !important; }
  .cols { grid-template-columns: 1fr; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .cal-day { min-height: 92px; }
  .cal-ev .h { display: none; }
}

@media (max-width: 620px) {
  .tbl th:nth-child(3), .tbl td:nth-child(3) { display: none; }
  .flash { left: 16px; right: 16px; max-width: none; }
}

/* ============================================================
   Generador — flujo por pasos
   ============================================================ */

.steps {
  list-style: none; display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 20px; padding: 0;
}
.steps li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 9px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); font-size: 13px; font-weight: 550; white-space: nowrap;
}
.steps li b {
  width: 21px; height: 21px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
  font-size: 11.5px; font-weight: 700; border: 1px solid var(--line);
}
.steps li.done { color: var(--ok); border-color: #bfe6d4; background: var(--ok-bg); }
.steps li.done b { background: var(--ok); color: #fff; border-color: var(--ok); }
.steps li.on { color: var(--brand-dk); border-color: #c9c2f6; background: var(--brand-ink); }
.steps li.on b { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Número del paso en la cabecera de cada tarjeta */
.card > .hd .step-n {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; margin-right: 3px;
  background: var(--brand-ink); color: var(--brand-dk);
  font-size: 11.5px; font-weight: 700;
}

/* Resumen plegado del origen ya analizado */
.sum { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sum .who { font-weight: 600; font-size: 14px; }
.sum .u {
  color: var(--muted); font-size: 12.5px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}

/* Bloques plegables dentro de un paso */
details.fold { border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 12px; }
details.fold > summary {
  cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 600;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: '▸'; color: var(--muted); font-size: 11px; }
details.fold[open] > summary::before { content: '▾'; }
details.fold > summary:hover { color: var(--ink); }
details.fold .in { padding-top: 14px; }

/* Selector de formato como control segmentado */
.seg-radio { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-radio input { position: absolute; opacity: 0; pointer-events: none; }
.seg-radio label { margin: 0; cursor: pointer; }
.seg-radio span {
  display: block; padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  font-size: 13.5px; font-weight: 550; color: var(--ink-2); line-height: 1.25;
}
.seg-radio span small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.seg-radio label:hover span { background: var(--surface-2); }
.seg-radio input:checked + span {
  border-color: var(--brand); background: var(--brand-ink); color: var(--brand-dk);
}
.seg-radio input:checked + span small { color: var(--brand-dk); opacity: .75; }
.seg-radio input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Muestra de los colores de marca en la cabecera del paso de imagen */
.swatch { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0,0,0,.12); flex: none; }

/* Tarjeta final de publicación */
.card.go { border-color: #c9c2f6; background: linear-gradient(180deg, var(--brand-ink), var(--surface) 60%); }

@media (max-width: 900px) {
  .steps li span { display: none; }
  .steps li { padding: 8px; }
}

/* Calendario: arrastrar y soltar para reprogramar. Se ven todas las
   publicaciones de cada día, y todas las celdas comparten la altura de la más
   llena para que la rejilla no baile. */

.cal-hd .hint { font-style: italic; opacity: .8; }
.cal-ev.mov { cursor: grab; }
.cal-ev.mov:active { cursor: grabbing; }
.cal-ev { transition: opacity .16s ease, transform .16s ease, box-shadow .16s ease; }
.cal-ev.cogida { opacity: .35; transform: scale(.97); }

/* Al soltar, un destello breve para saber cuál se acaba de mover */
.cal-ev.recien { animation: cal-pop .4s ease; }
@keyframes cal-pop {
  0%   { transform: scale(.92); box-shadow: 0 0 0 3px var(--brand-ink); }
  55%  { transform: scale(1.03); box-shadow: 0 0 0 3px var(--brand-ink); }
  100% { transform: scale(1); box-shadow: none; }
}

.cal-day { transition: background .12s ease, box-shadow .12s ease; }
.cal-day.sobre { background: var(--brand-ink); box-shadow: inset 0 0 0 2px var(--brand); }
.cal-day.sobre .num { background: var(--brand); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .cal-ev, .cal-day { transition: none; }
  .cal-ev.recien { animation: none; }
}

/* ============================================================
   Mini calendario de carga en el formulario de publicación
   ============================================================ */

.mini {
  margin: 12px 0 4px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); overflow: hidden;
}
.mini-hd { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.mini-hd .mo { font-size: 13.5px; font-weight: 640; text-transform: capitalize; }
.mini-hd .spacer { flex: 1; }
.mini-dow { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); border-bottom: 1px solid var(--line-2); }
.mini-dow div { padding: 5px 0; text-align: center; font-size: 10.5px; font-weight: 700; color: var(--muted); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); }

.mini-day {
  appearance: none; background: none; font: inherit; cursor: pointer;
  border: none; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
  padding: 5px 2px 6px; min-height: 46px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: background .1s ease;
}
.mini-day:nth-child(7n) { border-right: none; }
.mini-day:hover { background: var(--brand-ink); }
.mini-day .n {
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  width: 21px; height: 21px; border-radius: 6px;
  display: grid; place-items: center;
}
.mini-day.out { background: var(--surface-2); }
.mini-day.out .n { color: #b7bcc4; }
.mini-day.today .n { box-shadow: inset 0 0 0 1.5px var(--brand); color: var(--brand-dk); }
.mini-day.sel .n { background: var(--brand); color: #fff; box-shadow: none; }

/* Un punto por publicación ya programada de ese cliente ese día */
.mini-day .pts { display: flex; align-items: center; gap: 2px; min-height: 6px; }
.mini-day .pts i { width: 5px; height: 5px; border-radius: 50%; display: block; }
.mini-day .pts b { font-size: 9px; font-weight: 700; color: var(--muted); line-height: 1; }

/* Barra superior: día elegido en palabras a la izquierda, hora a la derecha */
.mini-top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0; padding: 9px 10px; font-size: 13.5px; color: var(--ink);
  background: var(--brand-ink); border-bottom: 1px solid var(--line-2);
}
.mini-top #mini-resumen { font-weight: 640; text-transform: capitalize; color: var(--brand-dk); }
.mini-top .spacer { flex: 1; }
.mini-top .mini-hora { color: var(--brand-dk); }
.mini-hora { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 600; }
.mini-hora input[type=time] {
  width: auto; padding: 5px 8px; font-size: 13.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; margin: 0;
}
.mini { margin-bottom: 6px; }

/* ============================================================
   Historial de generación — rejilla de 4
   ============================================================ */

.gen-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
@media (min-width: 1700px) { .gen-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 1500px) { .gen-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1120px) { .gen-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .gen-grid { grid-template-columns: 1fr; } }

.gen {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: box-shadow .15s ease, transform .15s ease;
}
.gen:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

/* Portada vertical (4:5), la del formato por defecto. Se encaja la imagen
   entera en vez de recortarla: pierde más una creatividad cortada que un
   hueco. Las cuadradas se apoyan arriba y dejan el aire abajo. */
.gen-img {
  position: relative; display: block; line-height: 0;
  aspect-ratio: 4 / 5; background: var(--surface-2); overflow: hidden;
}
.gen-img img {
  width: 100%; height: 100%; display: block;
  object-fit: contain; object-position: top center;
}
.gen-img.sintexto {
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 14%, var(--surface));
}
.gen-img.sintexto .ini { font-size: 34px; font-weight: 750; color: var(--c); letter-spacing: -.02em; }
.gen-fmt {
  position: absolute; left: 8px; top: 8px; z-index: 1;
  padding: 3px 8px; border-radius: 999px; line-height: 1.5;
  background: rgba(20, 22, 26, .72); color: #fff;
  font-size: 10.5px; font-weight: 650; letter-spacing: .02em;
}

.gen-bd { display: flex; flex-direction: column; gap: 7px; padding: 13px 14px; flex: 1; }
.gen-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.gen-top .gen-cli {
  font-size: 12.5px; font-weight: 640; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.gen-tit {
  margin: 0; font-size: 14px; font-weight: 650; line-height: 1.32;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gen-txt {
  margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; white-space: pre-wrap;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.gen-meta { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.5; }
.gen-pie {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  margin-top: auto; padding-top: 9px; border-top: 1px solid var(--line-2);
}
.gen-pie .spacer { flex: 1; }
.gen-pie form { display: inline; }

/* Paginación */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 20px; }
.pager .spacer { flex: 1; }
.pager .hueco { color: var(--muted); padding: 0 2px; }
.pager .btn.off { opacity: .4; pointer-events: none; }

/* ============================================================
   Vista previa del generador: capas de descargar y copiar
   ============================================================ */

.phone .ov { position: relative; display: block; cursor: pointer; border-radius: 10px; overflow: hidden; }
.phone .ov img { display: block; }
.phone .ov-txt { border-radius: 8px; }

.phone .ov-cap {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  background: rgba(20, 22, 26, .55);
  color: #fff; font-size: 13px; font-weight: 640; text-align: center; padding: 8px;
  opacity: 0; transition: opacity .15s ease;
  backdrop-filter: blur(1.5px);
}
.phone .ov:hover .ov-cap,
.phone .ov:focus-visible .ov-cap { opacity: 1; }
.phone .ov:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.phone .ov.hecho .ov-cap { opacity: 1; background: rgba(8, 135, 91, .8); }

/* El texto vacío no tiene nada que copiar */
.phone .ov-txt:has(.txt:empty) { cursor: default; }
.phone .ov-txt:has(.txt:empty) .ov-cap { display: none; }

@media (hover: none) {
  /* Sin ratón no hay «encima»: se deja siempre visible pero discreto. */
  .phone .ov-cap { opacity: 1; background: linear-gradient(transparent 55%, rgba(20,22,26,.65)); align-items: flex-end; }
}

/* Referencias de estilo del generador */
.refs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ref { position: relative; width: 74px; height: 74px; flex: none; }
.ref img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2);
}
.ref .quita {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 11px; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow); display: grid; place-items: center;
}
.ref .quita:hover { background: var(--err); color: #fff; border-color: var(--err); }

/* Vídeo en el historial */
.gen-img video { width: 100%; height: 100%; object-fit: contain; display: block; background: #14161a; }

/* Cola de vídeos en el generador */
.cola { margin-top: 16px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.cola-fila {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 7px 0; font-size: 13px; border-bottom: 1px solid var(--line-2);
}
.cola-fila:last-of-type { border-bottom: none; }
.cola-fila .spacer { flex: 1; }

/* Fotograma de partida del vídeo */
.frame-sel { display: flex; gap: 14px; align-items: flex-start; }
.frame-sel > img {
  width: 84px; height: 149px; object-fit: cover; flex: none;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2);
}
.frame-sel > div { min-width: 0; flex: 1; }
.frame-sel form { display: inline; }

/* ============================================================
   EcommApp: destino y vista previa de la notificación
   ============================================================ */

.toggle.ea input:checked + span, .toggle.ea:has(input:checked) {
  border-color: #7a5af8; background: #f1eefe; color: #4438b8;
}

.push { margin-top: 14px; }
.push .hd { font-size: 12px; font-weight: 640; color: var(--ink-2); margin-bottom: 10px; }
.card-push {
  display: flex; gap: 11px; align-items: flex-start;
  background: #eceef2; border-radius: 14px; padding: 11px 12px;
  box-shadow: 0 1px 2px rgba(16,18,22,.08);
}
.card-push img {
  width: 46px; height: 46px; border-radius: 9px; object-fit: cover; flex: none;
  border: 1px solid rgba(0,0,0,.08);
}
.card-push .cuerpo { min-width: 0; flex: 1; }
.card-push b { display: block; font-size: 13.5px; line-height: 1.3; }
.card-push p {
  margin: 3px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.card-push .boton {
  display: inline-block; margin-top: 8px; padding: 4px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; font-weight: 640; color: var(--ink-2);
}
.ok-txt  { color: var(--ok);  font-weight: 600; font-size: 13px; }
.bad-txt { color: var(--err); font-weight: 600; font-size: 13px; }

/* Etiquetas que dicen a qué destino va cada campo */
.destino {
  display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 640; letter-spacing: .01em; vertical-align: middle;
  text-transform: none;
}
.destino:empty { display: none; }
.destino.comun { background: var(--info-bg); color: #3730a3; }
.destino.solo  { background: #f1eefe; color: #4438b8; }
.destino.base  { background: var(--surface-2); color: var(--muted); }

/* Recuadro de la notificación en la app: tiene que leerse como una zona aparte */
.panel-ea {
  border: 1px solid #cfc7f7; border-left: 3px solid var(--brand);
  border-radius: var(--radius); overflow: hidden; margin: 4px 0 18px;
  background: var(--surface);
}
.panel-ea .panel-hd {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 15px; background: var(--brand-ink); border-bottom: 1px solid #dcd6fa;
}
.panel-ea .panel-hd .ico { font-size: 17px; line-height: 1.2; }
.panel-ea .panel-hd .txt > b { display: block; font-size: 14px; color: var(--brand-dk); }
.panel-ea .panel-hd .txt span {
  display: block; margin-top: 2px; font-size: 12.5px; color: #5a51a8; line-height: 1.45;
}
.panel-ea .panel-bd { padding: 16px 15px 2px; }
.panel-ea .field:last-child { margin-bottom: 14px; }

/* Destino que este cliente no tiene configurado: visible pero apagado */
.toggle.na { opacity: .45; cursor: not-allowed; }
.toggle.na input { pointer-events: none; }

/* Destinos de cada publicación, visibles al pasar por encima en el calendario */
/* Globo elevado con los destinos y el nombre, solo al pasar por encima.
   La tarjeta recorta con overflow:hidden, así que el recorte se suelta durante
   el hover; el nombre no se desborda porque .n tiene el suyo propio. */
.cal-ev { position: relative; }
.cal-ev .n { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Destinos a la vista en la propia tarjeta; el nombre cede con puntos suspensivos. */
.cal-ev .ico { flex: none; margin-left: auto; font-size: 9px; letter-spacing: 1px; opacity: .9; }
.cal-ev .dest {
  position: absolute; right: 0; bottom: calc(100% + 3px); z-index: 8;
  display: none; padding: 3px 8px; border-radius: 7px;
  background: var(--ink); color: #fff; box-shadow: var(--shadow-lg);
  font-size: 11px; font-weight: 600; white-space: nowrap;
  /* Tope y puntos suspensivos: un texto largo no debe cruzar medio calendario. */
  max-width: 300px; overflow: hidden; text-overflow: ellipsis;
}
.cal-ev:hover, .cal-ev:focus-visible { overflow: visible; z-index: 7; }
.cal-ev:hover .dest, .cal-ev:focus-visible .dest { display: inline-block; }

/* En las dos primeras columnas el bocadillo crecería hacia fuera del calendario
   y el recorte del contenedor se lo come: ahí se ancla a la izquierda. */
.cal-day:nth-child(7n+1) .cal-ev .dest,
.cal-day:nth-child(7n+2) .cal-ev .dest { left: 0; right: auto; }
