/* ═══════════════════════════════════════════════════════════
   planify · layout + componentes (dark premium, tokens de gestion-fran)
   ─────────────────────────────────────────────────────────
   Herramienta interna de Fran: hueso sobre oscuro, énfasis por
   luminosidad. Sin estilos inline (CSP style-src 'self').
   ═══════════════════════════════════════════════════════════ */

html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }

/* El atributo hidden SIEMPRE gana: sin esto, los display:flex de #login/#app
   (mayor especificidad que [hidden]) dejaban login y panel dibujados a la vez. */
[hidden] { display: none !important; }

/* ─── Login ─── */
#login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.login__box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: var(--sp-3); }
.login__box h1 { font-size: 28px; }
.login__box .eyebrow { margin-bottom: -8px; }

/* ─── Shell ─── */
#app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.topbar { flex: none; display: flex; align-items: center; gap: var(--sp-2);
  padding: calc(10px + env(safe-area-inset-top)) var(--sp-3) 10px;
  border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar h1 { font-size: 17px; letter-spacing: -0.01em; }
.topbar__spacer { flex: 1; }
.main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: var(--sp-3); padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.view[hidden] { display: none; }
.view h2 { font-size: 20px; margin-bottom: var(--sp-2); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex;
  background: rgba(20,19,18,0.94); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; padding: 9px 4px 11px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--text-subtle); }
.tab .ic { width: 20px; height: 20px; }
.tab.is-active { color: var(--hi); }

/* ─── Íconos SVG (icons.js) ─── */
.ic { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -0.18em; }
.ic--sm { width: 14px; height: 14px; }
.ic--lg { width: 22px; height: 22px; }
.ic--xl { width: 36px; height: 36px; }
@keyframes girar { to { transform: rotate(360deg); } }
.ic.is-girando { animation: girar 0.9s linear infinite; }

/* ─── Skeleton (shimmer de carga) ─── */
.skel { border-radius: var(--r-sm);
  background: linear-gradient(100deg, var(--surface-2) 40%, var(--surface-3) 50%, var(--surface-2) 60%);
  background-size: 200% 100%; animation: skel 1.2s linear infinite; }
@keyframes skel { to { background-position: -200% 0; } }
.skel--row { height: 48px; margin: 6px 0; }
.skel--linea { height: 14px; margin: 8px 0; width: 70%; }

/* ─── Reveal: delays por clase (CSP prohíbe style inline desde JS) ─── */
.rv-1 { --d: 40ms; } .rv-2 { --d: 90ms; } .rv-3 { --d: 140ms; }
.rv-4 { --d: 190ms; } .rv-5 { --d: 240ms; } .rv-6 { --d: 290ms; }

/* ─── Banners globales (token caído / cron sin latir) ─── */
.banner { display: flex; align-items: center; gap: 8px; padding: 10px var(--sp-3); font-size: 13px;
  border-bottom: 1px solid rgba(203,126,108,0.3); background: rgba(203,126,108,0.10); color: var(--alert); }
.banner[hidden] { display: none; }
.banner--warn { border-color: rgba(198,163,104,0.3); background: rgba(198,163,104,0.09); color: var(--warn); }
button.banner { width: 100%; text-align: left; border: none; border-bottom: 1px solid rgba(203,126,108,0.3); font: inherit; font-size: 13px; cursor: pointer; }
button.banner:hover { filter: brightness(1.15); }

/* ─── Chips de cuenta (selector en topbar) ─── */
.ctas { display: flex; gap: 6px; overflow-x: auto; max-width: 60vw; }
.ctas::-webkit-scrollbar { display: none; }
.cta-chip { flex: none; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; }
.cta-chip.is-active { color: var(--hi); background: var(--surface-3); border-color: var(--border-strong); }

/* ─── Estados: dot + chip (una sola fuente de verdad de color) ─── */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--text-subtle); }
.dot--borrador   { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-subtle); }
.dot--programada { background: var(--info); }
.dot--pausada    { background: transparent; box-shadow: inset 0 0 0 2px var(--warn); }
.dot--publicando { background: var(--warn); animation: pulso 1.1s ease-in-out infinite; }
.dot--publicada  { background: var(--ok); }
.dot--error      { background: var(--alert); }
@keyframes pulso { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px;
  background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip--borrador   { color: var(--text-muted); }
.chip--borrador::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.chip--programada { color: var(--info); background: rgba(126,147,168,0.13); }
.chip--pausada    { color: var(--warn); background: rgba(198,163,104,0.13); }
.chip--publicando { color: var(--warn); background: rgba(198,163,104,0.13); }
.chip--publicando::before { animation: pulso 1.1s ease-in-out infinite; }
.chip--publicada  { color: var(--ok); background: rgba(127,160,127,0.13); }
.chip--error      { color: var(--alert); background: rgba(203,126,108,0.13); }
.chip--plano::before { display: none; }

/* ─── Calendario mensual ─── */
.cal__nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: var(--sp-2); }
.cal__mes { font-weight: 600; font-size: 15px; color: var(--hi); text-transform: capitalize; }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal__dow { text-align: center; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-subtle); padding-bottom: 2px; }
.cal__dia { display: flex; flex-direction: column; gap: 3px; min-height: 96px; padding: 5px 4px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
@media (min-width: 1024px) {
  .cal__dia { min-height: 124px; }
}
.cal__dia--fuera { opacity: .3; }
.cal__dia--hoy { border-color: var(--hi); }
.cal__num { font-size: 11px; color: var(--text-muted); line-height: 1; }
.cal__dia--hoy .cal__num { color: var(--hi); font-weight: 700; }
.cal__pz { display: flex; align-items: center; gap: 4px; width: 100%; padding: 2px 3px; border-radius: 5px;
  background: var(--surface-2); font-size: 10px; color: var(--text-muted); cursor: pointer;
  white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }
.cal__pz:hover { background: var(--surface-3); color: var(--text); }
.cal__pz .dot { width: 7px; height: 7px; }
.cal__pz b { font-weight: 600; }

/* tile con imagen: estado en el borde, hora en overlay */
.cal__pz--img { position: relative; padding: 0; height: 36px; border-radius: 6px; overflow: hidden; }
.cal__pz--img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cal__pz__hora { position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 4px; font-size: 9px; font-weight: 600;
  color: #fff; background: linear-gradient(180deg, transparent, rgba(6,10,16,0.75)); text-align: left; }
.cal__pz--borrador   { box-shadow: inset 0 0 0 2px var(--text-subtle); opacity: .75; }
.cal__pz--programada { box-shadow: inset 0 0 0 2px var(--info); }
.cal__pz--pausada    { box-shadow: inset 0 0 0 2px var(--warn); opacity: .8; }
.cal__pz--publicando { box-shadow: inset 0 0 0 2px var(--warn); }
.cal__pz--publicada  { box-shadow: inset 0 0 0 2px var(--ok); }
.cal__pz--error      { box-shadow: inset 0 0 0 2px var(--alert); }
.cal__mas { width: 100%; padding: 1px 3px; border-radius: 5px; font-size: 10px; font-weight: 700;
  color: var(--text-muted); background: var(--surface-3); cursor: pointer; }
.cal__mas:hover { color: var(--hi); }
.cal__dia.is-over { border-color: var(--hi); background: var(--surface-2); }
.cal__pz[draggable] { cursor: grab; }
.cal__pz[draggable]:active { cursor: grabbing; }
/* overrides desktop de los tiles: DESPUÉS de sus bases (si no, quedan muertos) */
@media (min-width: 1024px) {
  .cal__pz--img { height: 48px; }
  .cal__pz__hora { font-size: 10px; }
}

/* ─── Tarjeta héroe (lo próximo que sale) ─── */
.hero { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border-md); border-radius: var(--r);
  padding: var(--sp-3); margin-bottom: var(--sp-3); }
button.hero { cursor: pointer; }
button.hero:hover { background: var(--surface-2); }
.hero__titulo { font-family: var(--f-display); font-weight: 700; font-size: var(--fs-hero);
  letter-spacing: -0.02em; line-height: 1.05; color: var(--hi); }
.hero__sub { font-size: 13px; color: var(--text-muted); }
.hero__err { color: var(--alert); font-weight: 600; }

/* ─── Búsqueda + selección múltiple (Semana) ─── */
.sem__buscar { margin-bottom: var(--sp-2); }
.sem__buscar .form__input { background: var(--surface); }
.sel__chk { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: none;
  border-radius: 50%; border: 1.5px solid var(--border-strong); color: transparent; }
.sel__chk.is-on { background: var(--hi); border-color: var(--hi); color: #100F0E; }
.list__row.is-sel { background: var(--surface-2); }
.selbar { position: fixed; left: 12px; right: 12px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 9;
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; max-width: 480px; margin-inline: auto;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.selbar__n { flex: 1; font-size: 13px; font-weight: 600; color: var(--hi); }
@media (min-width: 1024px) { .selbar { left: calc(240px + 12px); bottom: 24px; } }

/* ─── Slot de día libre (Semana) ─── */
.sem__slot { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  padding: 12px; border: 1px dashed var(--border-md); border-radius: var(--r);
  color: var(--text-subtle); font-size: 13px; cursor: pointer; background: none; }
.sem__slot:hover { border-color: var(--text-muted); color: var(--text); background: var(--surface); }
.sem__slot--quieto { cursor: default; }
.sem__slot--quieto:hover { border-color: var(--border-md); color: var(--text-subtle); background: none; }

/* ─── Detalles colapsable (leyenda) ─── */
.detalles > summary { cursor: pointer; font-size: 12px; color: var(--text-subtle); list-style: none; margin: var(--sp-2) 0 var(--sp-1); }
.detalles > summary::before { content: "+ "; }
.detalles[open] > summary::before { content: "− "; }
.detalles > summary::-webkit-details-marker { display: none; }
/* glifo de formato: ■ post (cuadrado) · ▮ story (vertical) */
.glifo { display: inline-block; flex: none; background: currentColor; opacity: .75; }
.glifo--post  { width: 7px; height: 7px; border-radius: 1.5px; }
.glifo--story { width: 5px; height: 9px; border-radius: 1.5px; }

/* ─── Lista semanal ─── */
.sem__dia { margin: var(--sp-3) 2px 6px; font-size: 11px; font-weight: 600; color: var(--text-muted);
  letter-spacing: .06em; text-transform: uppercase; }
.sem__dia.es-hoy { color: var(--hi); }
.list { display: flex; flex-direction: column; gap: 1px; background: var(--border); border-radius: var(--r); overflow: hidden; }
.list__row { display: flex; align-items: center; gap: var(--sp-2); background: var(--surface); padding: 10px var(--sp-2); min-height: 56px; cursor: pointer; }
.list__row:hover { background: var(--surface-2); }
.pz__thumb { flex: none; width: 42px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--surface-3); }
.pz__thumb--post { height: 52px; }
.pz__thumb--vacia { display: flex; align-items: center; justify-content: center; color: var(--text-subtle); font-size: 16px; }
.pz__body { flex: 1 1 auto; min-width: 0; }
.pz__hora { font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.pz__con { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pz__right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }

/* ─── Feed preview (grilla del perfil de IG) ─── */
.feed__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.seg--mini .seg__btn { padding: 5px 11px; font-size: 12px; }
.feed__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  border-radius: var(--r); overflow: hidden; }
.feed__tile { position: relative; aspect-ratio: 3 / 4; padding: 0; overflow: hidden; cursor: pointer; background: var(--surface-2); }
.feed__tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--t-fast); }
.feed__tile:hover img { transform: scale(1.03); }
.feed__tile--borrador { outline: 2px dashed var(--text-subtle); outline-offset: -2px; opacity: .8; }
.feed__badge { position: absolute; left: 4px; bottom: 4px; padding: 2px 7px; border-radius: 6px;
  font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff;
  background: rgba(6,10,16,0.72); backdrop-filter: blur(4px); }
.feed__badge--programada { box-shadow: inset 0 0 0 1.5px var(--info); }
.feed__badge--publicando { box-shadow: inset 0 0 0 1.5px var(--warn); }
.feed__badge--pausada { box-shadow: inset 0 0 0 1.5px var(--warn); }
.feed__badge--borrador { box-shadow: inset 0 0 0 1.5px var(--text-subtle); }
.ctas--local { max-width: none; flex-wrap: wrap; }
@media (min-width: 1024px) { #view-feed { max-width: 820px; } }

/* ─── Barra de acciones de vista (Programar mes/semana) ─── */
.ctrlbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.ctrlbar__nav { display: inline-flex; align-items: center; gap: 8px; }
.resumen { font-size: 12.5px; color: var(--text-muted); }
.resumen b { color: var(--hi); font-variant-numeric: tabular-nums; }

/* ─── Botones ─── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--f-body); font-weight: 600; font-size: 14px; line-height: 1;
  padding: 11px 18px; border-radius: var(--r); border: 1px solid transparent;
  transition: all var(--t-fast); white-space: nowrap; }
.btn--solid { background: var(--hi); color: #100F0E; }
.btn--solid:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn--ghost { color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn--sm { padding: 7px 12px; font-size: 12.5px; }
.btn--peligro { color: var(--alert); border-color: rgba(203,126,108,0.4); }
.btn--peligro:hover { background: rgba(203,126,108,0.12); }
.btn[disabled] { opacity: .35; pointer-events: none; }
.btn.is-busy { opacity: .55; pointer-events: none; }
.btn:active { transform: scale(.98); }

/* ─── Cards / KPIs / avisos ─── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-3); }
.vacio { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 44px 16px; text-align: center;
  border: 1px dashed var(--border-md); border-radius: var(--r); }
.vacio p { font-size: 14px; color: var(--text-muted); max-width: 280px; line-height: 1.5; }
.aviso { display: flex; gap: 10px; align-items: flex-start; margin-top: var(--sp-2); padding: 12px 14px;
  background: rgba(198,163,104,0.07); border: 1px solid rgba(198,163,104,0.25); border-radius: var(--r);
  font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.aviso strong { color: var(--warn); font-weight: 600; }
.aviso--alert { background: rgba(203,126,108,0.07); border-color: rgba(203,126,108,0.3); }
.aviso--alert strong { color: var(--alert); }

/* ─── Detalle de pieza (overlay sheet) ─── */
.overlay { position: fixed; inset: 0; z-index: 10; }
.overlay[hidden] { display: none; }
.overlay__backdrop { position: absolute; inset: 0; background: rgba(13,12,11,0.72); backdrop-filter: blur(3px); }
.overlay__panel { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
@media (min-width: 640px) {
  .overlay { display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; }
  .overlay[hidden] { display: none; }
  .overlay__backdrop { position: fixed; }
  .overlay__panel { position: relative; inset: auto; width: 100%; max-width: 520px;
    max-height: calc(100dvh - 96px); background: var(--surface);
    border: 1px solid var(--border-md); border-radius: var(--r-lg); }
}
.sheet__head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) var(--sp-3) 10px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.sheet__head h2 { margin: 0; font-size: 17px; font-family: var(--f-body); font-weight: 600; }
.sheet__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; padding: var(--sp-3); padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); }
.btn--icono { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 50%; color: var(--text-muted); font-size: 20px; }
.btn--icono:hover { background: var(--surface-2); color: var(--hi); }
.sheet__acciones { display: flex; gap: 2px; align-items: center; }
body.overlay-abierta { overflow: hidden; }

.pieza__img { width: 100%; max-width: 300px; margin: 0 auto var(--sp-3); border-radius: var(--r); border: 1px solid var(--border-md); }
.pieza__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.pieza__id { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--text-subtle); }
.pieza__detalle { font-size: 12.5px; color: var(--alert); margin-top: 4px; line-height: 1.45; }
.pieza__acciones { display: flex; gap: 8px; flex-wrap: wrap; margin: var(--sp-3) 0; }

/* Historial del log */
.hist { margin-top: var(--sp-3); border-top: 1px solid var(--border); padding-top: var(--sp-2); }
.hist h3 { font-size: 12px; color: var(--text-muted); letter-spacing: .06em; text-transform: uppercase; margin-bottom: var(--sp-1); }
.hist__row { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--text-muted); padding: 4px 0; }
.hist__row time { flex: none; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.hist__row b { color: var(--text); font-weight: 600; }

/* ─── Segmented control (Story/Post, filtros excluyentes) ─── */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg::-webkit-scrollbar { display: none; }
.seg__btn { padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--text-muted); white-space: nowrap; transition: background var(--t-fast), color var(--t-fast); }
.seg__btn.is-active { background: var(--surface-3); color: var(--hi); font-weight: 600; }

/* ─── Formularios ─── */
.form__label { display: block; font-size: 12px; color: var(--text-muted); margin: var(--sp-2) 0 4px; }
/* Desplegable estilizado (chevron embebido; data: permitido por img-src) */
.form__input.form__select { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-color: var(--surface-2); border-radius: var(--r-sm);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ECE7DD' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
.form__input.form__select:hover { border-color: var(--border-md); }
.form__input { width: 100%; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text); font-size: 16px; color-scheme: dark; font-family: var(--f-body); }
.form__input:focus { outline: none; border-color: var(--text-muted); }
.form__textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.msg { min-height: 20px; font-size: 13px; margin-top: var(--sp-1); }
.msg.is-ok { color: var(--ok); }
.msg.is-err { color: var(--alert); }

/* ─── Cuentas (cards) ─── */
.cta-cards { display: flex; flex-direction: column; gap: var(--sp-2); }
.cta-card { background: var(--surface); border: 1px solid var(--border-md); border-radius: var(--r); padding: var(--sp-3); }
.cta-card--pausada { opacity: .82; }
.cta-card--inactiva { opacity: .6; }
/* cuando el token bloquea la publicación, el card entero grita (terracota) */
.cta-card--alerta { border-color: var(--alert); box-shadow: inset 3px 0 0 var(--alert); }

/* token: la línea que más importa, prominente */
.cta-tok { display: flex; align-items: center; gap: 8px; margin-top: var(--sp-2);
  padding: 11px 12px; border-radius: var(--r-sm); font-size: 14px; }
.cta-tok .grow { flex: 1 1 auto; min-width: 0; }
.cta-tok b { color: var(--text); }
.cta-tok__sub { color: var(--text-subtle); font-size: 12px; }
.cta-tok--ok { background: rgba(127,160,127,0.10); }
.cta-tok--mal { background: rgba(203,126,108,0.14); }
.cta-tok--mal b { color: var(--alert); }
.cta-tok--gris { background: var(--surface-2); }

.cta-card__pie { display: flex; gap: 8px; margin-top: var(--sp-3); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.cta-edit { margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.cta-edit[hidden] { display: none; }
.cta-card__head { display: flex; align-items: flex-start; gap: var(--sp-2); }
.cta-card__head .grow { flex: 1 1 auto; min-width: 0; }
.cta-card__nom { font-family: var(--f-display); font-weight: 600; font-size: 17px; color: var(--hi); }
.cta-card__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cta-card__mut { color: var(--text-subtle); }
.cta-card__tok { display: flex; align-items: center; gap: 8px; margin-top: var(--sp-2);
  padding: 8px 10px; background: var(--surface-2); border-radius: var(--r-sm); font-size: 13px; }
.cta-card__tok .grow { flex: 1 1 auto; min-width: 0; }
.cta-card__tok b { color: var(--text); }
.cta-tokform { display: flex; gap: 8px; margin-top: var(--sp-2); }
.cta-tokform .form__input { flex: 1 1 auto; min-width: 0; }
.cta-tokform .btn { flex: none; }

/* mini-métricas por estado */
.cta-stats { display: flex; gap: var(--sp-1); margin-top: var(--sp-2); }
.cta-stat { flex: 1; min-width: 0; text-align: center; padding: 8px 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.cta-stat__n { display: block; font-family: var(--f-display); font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; color: var(--text); }
.cta-stat__n--publicada { color: var(--ok); }
.cta-stat__n--programada { color: var(--info); }
.cta-stat__n--error { color: var(--alert); }
.cta-stat__n--pausada { color: var(--warn); }
.cta-stat__l { display: block; font-size: 10.5px; color: var(--text-muted); margin-top: 1px; letter-spacing: .02em; }

.cta-card__linea { margin-top: var(--sp-2); display: flex; flex-direction: column; gap: 4px; }
.cta-card__ev { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.cta-card__evlbl { color: var(--text-subtle); flex: none; }
.cta-card__evval { color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: right;
  display: inline-flex; align-items: center; gap: 6px; }
button.cta-card__evval:hover { color: var(--hi); }
.cta-card__evval .dot { width: 7px; height: 7px; }

/* toggle Publicando / En pausa — ON (verde) = activo, intuitivo */
.cta-toggle { display: flex; align-items: center; gap: 8px; flex: none; }
.cta-toggle__lbl { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.cta-toggle__lbl--on { color: var(--ok); }
.cta-toggle__lbl--off { color: var(--warn); }
.switch { position: relative; width: 44px; height: 26px; flex: none; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-md); transition: background var(--t-fast); cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--text-muted); transition: transform var(--t-fast), background var(--t-fast); }
/* ON = cuenta activa/publicando (verde). OFF = pausada (apagado). */
.switch.is-on { background: rgba(127,160,127,0.28); border-color: var(--ok); }
.switch.is-on::after { transform: translateX(18px); background: var(--ok); }

/* alta de cuenta (colapsable) */
.alta { margin-top: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.alta > summary { cursor: pointer; list-style: none; padding: 12px var(--sp-3); color: var(--text); font-weight: 600; font-size: 14px; }
.alta > summary::-webkit-details-marker { display: none; }
.alta__body { padding: 0 var(--sp-3) var(--sp-3); }
.mono { font-family: ui-monospace, monospace; font-size: 12px; color: var(--text); }

/* leyenda de estados (calendario) */
.leyenda { display: flex; flex-wrap: wrap; gap: 10px; margin: var(--sp-2) 0 var(--sp-1); font-size: 11.5px; color: var(--text-muted); }
.leyenda span { display: inline-flex; align-items: center; gap: 5px; }
.leyenda .dot { width: 8px; height: 8px; }

/* ─── FAB "+" (nueva publicación) ─── */
.fab { position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 8;
  width: 56px; height: 56px; border-radius: 50%; background: var(--hi); color: #100F0E;
  display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 300; line-height: 1;
  box-shadow: var(--shadow); transition: transform var(--t-fast); }
.fab:hover { transform: translateY(-2px); }
.fab:active { transform: scale(.94); }
body.overlay-abierta .fab, #app[hidden] ~ .fab { display: none; }
body.sel-activa .fab { display: none; }   /* la selbar ocupa su lugar */

/* ─── Nueva publicación: contador + preview phone-frame ─── */
.nv-count { float: right; font-weight: 400; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.nv-preview { margin-top: var(--sp-3); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.nv-frame { position: relative; width: 60%; max-width: 240px; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border-md); background: var(--surface-3); }
.nv-frame--story { aspect-ratio: 9 / 16; }
.nv-frame--feed { aspect-ratio: 4 / 5; }
.nv-frame img { width: 100%; height: 100%; object-fit: cover; }
.nv-frame__ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-subtle); font-size: 12px; text-align: center; padding: 12px; }
.nv-safe { position: absolute; left: 0; right: 0; height: 14%; background: rgba(203,126,108,0.16);
  border: 1px dashed rgba(203,126,108,0.4); pointer-events: none; }
.nv-safe--top { top: 0; } .nv-safe--bot { bottom: 0; }
.nv-cap { width: 60%; max-width: 240px; font-size: 12px; color: var(--text-muted); line-height: 1.45; }

/* base mobile del detalle de pieza (los overrides desktop van en el media de abajo) */
.pieza__col-a .nv-frame { margin: 0 auto var(--sp-3); width: 70%; max-width: 260px; }

/* ─── Desktop (≥1024px): sidenav + contenido centrado ─── */
.sidenav { display: none; }
@media (min-width: 1024px) {
  .sidenav { display: flex; flex-direction: column; gap: 2px;
    position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 6;
    padding: 20px 14px 16px; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--border); }
  .sidenav__brand { font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: -0.01em;
    color: var(--hi); padding: 4px 10px 14px; }
  .sidenav__nueva { justify-content: flex-start; margin: 0 0 14px; }
  .sidenav__spacer { flex: 1; }
  .snav { display: flex; align-items: center; gap: 10px; padding: 9px 10px;
    border-radius: var(--r-sm); font-size: 14px; color: var(--text-muted); text-align: left; }
  .snav .ic { width: 17px; height: 17px; }
  .snav:hover { background: var(--surface-2); color: var(--text); }
  .snav.is-active { background: var(--surface-2); color: var(--hi); font-weight: 600; }

  #app { padding-left: 240px; }
  .topbar h1 { display: none; }                 /* la marca vive en la sidenav */
  .topbar [data-accion] { display: none; }      /* refresh/salir viven en la sidenav */
  .ctas { max-width: none; }
  .tabbar { display: none; }
  .fab { display: none; }
  .main { padding-bottom: 48px; }
  .view { max-width: 1080px; margin-inline: auto; }
  #view-cuentas { max-width: 760px; }

  /* Detalle de pieza a 2 columnas (preview grande | edición) */
  #overlay .overlay__panel { max-width: 920px; }
  .pieza__cols { display: grid; grid-template-columns: 320px 1fr; gap: var(--sp-4); align-items: start; }
  .pieza__col-a { position: sticky; top: 0; }
  .pieza__col-a .nv-frame { width: 100%; max-width: 320px; }
}

/* ─── Centro de avisos (campanita) ─── */
.avisos-btn { position: relative; }
.avisos-badge { display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--alert); color: var(--bg); font-size: 10px; font-weight: 700; line-height: 1; }
.avisos-btn .avisos-badge { position: absolute; top: 2px; right: 2px; }
.snav .avisos-badge { margin-left: auto; }
.avisos { position: fixed; inset: 0; z-index: 20; }
.avisos[hidden] { display: none; }
.avisos__backdrop { position: absolute; inset: 0; background: rgba(13,12,11,0.72); backdrop-filter: blur(3px); }
.avisos__sheet { position: absolute; top: calc(52px + env(safe-area-inset-top)); left: 12px; right: 12px;
  margin-inline: auto; max-width: 440px; max-height: 72dvh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border-md); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.avisos__head { flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 10px 14px 18px; border-bottom: 1px solid var(--border); }
.avisos__head strong { font-size: 17px; display: block; }
.avisos__sub { font-size: 12px; color: var(--text-subtle); display: block; }
.avisos__body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 8px; }
.avisos__item { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px; border-radius: var(--r); background: transparent; border: none; color: var(--text); cursor: pointer; }
.avisos__item:hover { background: var(--surface-2); }
.avisos__item strong { display: block; font-size: 14.5px; font-weight: 600; }
.avisos__nom { display: block; font-size: 12.5px; color: var(--text-subtle); margin-top: 2px; }
.avisos__ic { flex: none; width: 38px; height: 38px; border-radius: 11px; display: inline-flex;
  align-items: center; justify-content: center; }
.avisos__ic--alert { background: rgba(203,126,108,0.16); color: var(--alert); }
.avisos__ic--warn  { background: rgba(198,163,104,0.16); color: var(--warn); }
.avisos__ic--info  { background: rgba(126,147,168,0.16); color: var(--info); }
.avisos__chev { flex: none; color: var(--text-subtle); }
.avisos__vacio { padding: 36px 16px; text-align: center; color: var(--text-muted); }
.avisos__vacio .ic { color: var(--ok); margin-bottom: 6px; }
body.avisos-abierto { overflow: hidden; }
@media (min-width: 1024px) { .avisos__sheet { top: 64px; left: 260px; } }

/* ─── Diálogo de confirmación propio ─── */
#dialogo { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 24px; }
#dialogo[hidden] { display: none; }
.dlg__backdrop { position: absolute; inset: 0; background: rgba(13,12,11,0.72); backdrop-filter: blur(3px); }
.dlg__panel { position: relative; width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border-md); border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-lg); }
.dlg__titulo { font-family: var(--f-display); font-weight: 700; font-size: 19px; color: var(--hi); letter-spacing: -0.01em; }
.dlg__texto { margin-top: 8px; font-size: 14px; color: var(--text-muted); line-height: 1.55; }
.dlg__texto:empty { display: none; }
.dlg__btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: var(--sp-4); }

/* ─── Toast ─── */
.toast__accion { margin-left: 8px; background: none; border: none; color: var(--hi); font-weight: 700;
  font-size: 13.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  z-index: 30; max-width: 90vw; padding: 11px 18px; border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--border-strong); color: var(--text); font-size: 13.5px; opacity: 0;
  transition: opacity var(--t-fast), transform var(--t-fast); box-shadow: var(--shadow); }
#toast.is-in { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 1024px) { #toast { left: calc(50% + 120px); bottom: 32px; } }

/* ─── Utilidades ─── */
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.grow { flex: 1 1 auto; min-width: 0; }
:focus-visible { outline: 2px solid var(--border-strong); outline-offset: 2px; }
