/* ==========================================================================
   Pappitas — Piloto Automático (Fase 2.2)
   Estética sobria: neutros + un solo acento (--brand-primary, Config Global).
   ========================================================================== */
.pl { --pl-ink: var(--text-primary); --pl-muted: var(--text-secondary); --pl-soft: var(--text-muted);
      --pl-line: var(--border); --pl-card: var(--bg-card); --pl-bg: var(--bg-app); --pl-acc: var(--brand-primary);
      --pl-hero: color-mix(in srgb, var(--brand-primary) 9%, black);
      --pl-hero-2: color-mix(in srgb, var(--brand-primary) 22%, black);
      width: 100%; font-family: var(--font); color: var(--pl-ink); -webkit-font-smoothing: antialiased; }
.pl *, .pl *::before, .pl *::after { box-sizing: border-box; }
.pl .icon { width: 16px; height: 16px; flex: none; }

/* Cabecera */
.pl-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.pl-eyebrow { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; font-weight: 800; color: var(--pl-acc); }
.pl-h1 { margin: 6px 0 0; font-size: 34px; font-weight: 900; letter-spacing: -.03em; line-height: 1.05; }
.pl-seg { display: inline-flex; background: color-mix(in srgb, var(--pl-ink) 7%, transparent); border-radius: 14px; padding: 4px; gap: 2px; }
.pl-seg button { appearance: none; border: 0; background: transparent; cursor: pointer; font: inherit; padding: 9px 18px; border-radius: 11px; font-size: 14px; font-weight: 800; color: var(--pl-muted); }
.pl-seg button.on { background: var(--pl-card); color: var(--pl-ink); box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 10px rgba(0,0,0,.05); }

/* Hero — motor en movimiento */
.pl-hero { position: relative; overflow: hidden; border-radius: 24px; padding: 26px 28px; margin-bottom: 26px;
  background: linear-gradient(135deg, var(--pl-hero) 0%, var(--pl-hero-2) 100%); color: white;
  display: grid; grid-template-columns: 1fr 1.1fr; gap: 20px; align-items: center; }
.pl-live { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; color: color-mix(in srgb, var(--c-success) 45%, white); margin-bottom: 12px; }
.pl-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c-success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-success) 22%, transparent); animation: pl-blink 1.6s ease-in-out infinite; }
.pl-live.off { color: rgba(255,255,255,.55); }
.pl-live.off::before { background: rgba(255,255,255,.4); box-shadow: none; animation: none; }
.pl-big { font-size: 40px; font-weight: 900; letter-spacing: -.03em; line-height: 1; }
.pl-hero small { display: block; margin-top: 8px; font-size: 12.5px; color: rgba(255,255,255,.62); font-weight: 600; }
.pl-mini { display: flex; gap: 28px; margin-top: 18px; }
.pl-mini b { display: block; font-size: 20px; font-weight: 800; line-height: 1; }
.pl-mini small { margin-top: 5px !important; }
.pl-engine svg { width: 100%; height: auto; display: block; }
.pl-engine .ln { stroke: rgba(255,255,255,.18); }
.pl-engine .node { fill: rgba(255,255,255,.85); }
.pl-engine .lbl { fill: rgba(255,255,255,.45); font-size: 11px; font-weight: 700; font-family: var(--font); }
.pl-engine .glow { fill: var(--pl-acc); opacity: .28; filter: blur(22px); }
.pl-engine .r1 { fill: none; stroke: rgba(255,255,255,.22); stroke-width: 1.5; stroke-dasharray: 3 9; transform-origin: 210px 100px; animation: pl-rot 14s linear infinite; }
.pl-engine .r2 { fill: none; stroke: var(--pl-acc); stroke-width: 2.2; stroke-dasharray: 40 174; stroke-linecap: round; transform-origin: 210px 100px; animation: pl-rot 2.2s linear infinite; }
.pl-engine .hub { fill: var(--pl-hero); stroke: rgba(255,255,255,.25); }
.pl-engine .core { fill: var(--pl-acc); transform-origin: 210px 100px; animation: pl-pulse 1.4s ease-in-out infinite; }
.pl-engine .pk-in { fill: white; }
.pl-engine .pk-out { fill: var(--pl-acc); }
.pl-hero.idle .r1, .pl-hero.idle .r2, .pl-hero.idle .core { animation-play-state: paused; }
.pl-hero.idle .pk-in, .pl-hero.idle .pk-out { display: none; }
.pl-count-bump { animation: pl-bump .45s ease; }

/* Pestañas */
.pl-mode { display: flex; gap: 26px; border-bottom: 1px solid var(--pl-line); margin-bottom: 20px; }
.pl-mode button { appearance: none; border: 0; background: none; cursor: pointer; font: inherit; padding: 0 0 12px; font-size: 15px; font-weight: 800; color: var(--pl-soft); }
.pl-mode button.on { color: var(--pl-ink); box-shadow: inset 0 -2px 0 var(--pl-acc); }

/* Tarjetas de automatización */
.pl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pl-tile { background: var(--pl-card); border: 1px solid var(--pl-line); border-radius: 20px; padding: 20px 20px 18px; display: grid; gap: 14px; transition: border-color .2s; }
.pl-tile-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.pl-tile b { font-size: 16.5px; font-weight: 800; letter-spacing: -.01em; display: block; }
.pl-tile p { margin: 4px 0 0; font-size: 13px; color: var(--pl-muted); line-height: 1.45; }
.pl-tile-f { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12.5px; color: var(--pl-muted); }
.pl-tile-f em { font-style: normal; font-weight: 800; color: var(--pl-ink); }
.pl-tile.off b, .pl-tile.off p { opacity: .55; }
.pl-tile.na { opacity: .55; }
.pl-edit { appearance: none; border: 0; background: none; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 800; color: var(--pl-ink); padding: 0; }
.pl-edit:hover { color: var(--pl-acc); }

/* Interruptor */
.pl-sw { position: relative; width: 46px; height: 28px; flex: none; }
.pl-sw input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.pl-sw span { position: absolute; inset: 0; border-radius: 99px; background: color-mix(in srgb, var(--pl-ink) 12%, transparent); transition: background .2s; }
.pl-sw span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.pl-sw input:checked + span { background: var(--pl-acc); }
.pl-sw input:checked + span::after { transform: translateX(18px); }
.pl-sw input:disabled { cursor: not-allowed; }
.pl-sw.sm { width: 36px; height: 22px; }
.pl-sw.sm span::after { width: 16px; height: 16px; }
.pl-sw.sm input:checked + span::after { transform: translateX(14px); }

/* Pie: conexión + actividad */
.pl-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; font-size: 13px; color: var(--pl-muted); }
.pl-conn b { color: var(--pl-ink); }
.pl-conn::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c-success); margin-right: 8px; vertical-align: 1px; }
.pl-toggle { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.pl-adv { appearance: none; border: 0; background: none; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--pl-soft); padding: 0; }
.pl-adv:hover { color: var(--pl-ink); }
.pl-diag { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--pl-bg); border: 1px dashed var(--pl-line); font-size: 12px; color: var(--pl-muted); line-height: 1.5; word-break: break-word; }
.pl-diag b { color: var(--pl-ink); }

.pl-activity { margin-top: 14px; background: var(--pl-card); border: 1px solid var(--pl-line); border-radius: 18px; overflow: hidden; animation: pl-in .25s ease both; }
.pl-act-row { display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--pl-line); font-size: 13px; }
.pl-act-row:last-child { border-bottom: 0; }
.pl-act-row small { color: var(--pl-soft); }
.pl-act-row .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-act-row .st { font-weight: 800; font-size: 12px; }
.pl-act-row .st.sent { color: var(--c-success); }
.pl-act-row .st.failed { color: var(--c-danger); }
.pl-act-row .st.queued { color: var(--pl-soft); }
.pl-empty { padding: 18px 16px; font-size: 13px; color: var(--pl-soft); text-align: center; }

/* Conectar (cuando el canal no está listo) */
.pl-connect { background: var(--pl-card); border: 1px solid var(--pl-line); border-radius: 20px; padding: 22px; margin-bottom: 14px; display: grid; gap: 14px; }
.pl-connect-h b { font-size: 17px; font-weight: 800; display: block; }
.pl-connect-h p { margin: 4px 0 0; font-size: 13px; color: var(--pl-muted); }
.pl-qr { width: 220px; max-width: 100%; aspect-ratio: 1; margin: 0 auto; border-radius: 16px; border: 1px solid var(--pl-line); background: white; padding: 10px; display: grid; place-items: center; }
.pl-qr img { width: 100%; height: 100%; object-fit: contain; }
.pl-note { font-size: 12.5px; color: var(--pl-muted); text-align: center; line-height: 1.5; }
.pl-spin { width: 28px; height: 28px; margin: 14px auto; border-radius: 50%; border: 3px solid var(--pl-line); border-top-color: var(--pl-acc); animation: pl-rot .8s linear infinite; }

/* Formularios */
.pl-field { display: grid; gap: 7px; }
.pl-label { font-size: 12px; font-weight: 800; color: var(--pl-soft); letter-spacing: .06em; text-transform: uppercase; }
.pl-input, .pl-textarea, .pl-select { width: 100%; font: inherit; font-size: 15px; font-weight: 700; color: var(--pl-ink); background: var(--pl-card);
  border: 1.5px solid var(--pl-line); border-radius: 14px; padding: 12px 14px; }
.pl-textarea { min-height: 110px; resize: vertical; font-weight: 600; line-height: 1.5; }
.pl-input:focus, .pl-textarea:focus, .pl-select:focus { outline: none; border-color: var(--pl-ink); }
.pl-hint { font-size: 12px; color: var(--pl-soft); line-height: 1.45; }
.pl-vars { display: flex; gap: 6px; flex-wrap: wrap; }
.pl-var { appearance: none; cursor: pointer; font: inherit; font-size: 12px; font-weight: 800; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--pl-line); background: var(--pl-bg); color: var(--pl-muted); }
.pl-var:hover { color: var(--pl-ink); border-color: var(--pl-ink); }

.pl-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.pl-chip { appearance: none; cursor: pointer; font: inherit; padding: 8px 14px; border-radius: 11px; border: 1.5px solid var(--pl-line); background: var(--pl-card); font-size: 13px; font-weight: 800; color: var(--pl-muted); }
.pl-chip.on { border-color: var(--pl-ink); color: var(--pl-ink); }

.pl-btn { appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 800; font-size: 15px; min-height: 48px; padding: 0 24px;
  border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .2s, opacity .2s, transform .1s; }
.pl-btn:active { transform: scale(.98); }
.pl-btn:disabled { opacity: .45; cursor: not-allowed; }
.pl-btn-primary { background: var(--pl-acc); color: var(--text-on-primary, white); }
.pl-btn-primary:hover:not(:disabled) { background: var(--brand-primary-mid, var(--pl-acc)); }
.pl-btn-ghost { background: var(--pl-card); color: var(--pl-ink); border: 1.5px solid var(--pl-line); }
.pl-btn-ghost:hover:not(:disabled) { border-color: var(--pl-ink); }
.pl-btn-block { width: 100%; }

/* Editor de email (misma barra que Marketing) */
.pl-rte { border: 1.5px solid var(--pl-line); border-radius: 14px; overflow: hidden; background: var(--pl-card); }
.pl-rte .rte-toolbar { border-radius: 0; border: 0; border-bottom: 1px solid var(--pl-line); }
.pl-rte .rte-editor { border: 0; border-radius: 0; min-height: 180px; }

/* Enviar ahora */
.pl-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.pl-opt { appearance: none; text-align: left; cursor: pointer; font: inherit; color: inherit; background: var(--pl-card); border: 1.5px solid var(--pl-line); border-radius: 20px; padding: 18px 20px; display: grid; gap: 6px; }
.pl-opt.on { border-color: var(--pl-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pl-ink) 6%, transparent); }
.pl-opt:disabled { opacity: .5; cursor: not-allowed; }
.pl-opt b { font-size: 16px; font-weight: 800; }
.pl-opt p { margin: 0; font-size: 13px; color: var(--pl-muted); line-height: 1.45; }
.pl-badge { justify-self: start; margin-top: 4px; font-size: 11px; font-weight: 800; padding: 4px 9px; border-radius: 8px; background: var(--pl-bg); color: var(--pl-muted); }
.pl-badge.free { background: var(--c-success-bg); color: var(--c-success); }
.pl-comp { background: var(--pl-card); border: 1px solid var(--pl-line); border-radius: 20px; padding: 20px; display: grid; gap: 16px; }
.pl-send { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pl-who { font-size: 13px; color: var(--pl-muted); }
.pl-who b { color: var(--pl-ink); font-size: 18px; }
.pl-warn { font-size: 12.5px; line-height: 1.5; padding: 12px 14px; border-radius: 14px; background: var(--c-warning-bg); color: var(--pl-ink); display: grid; gap: 8px; }
.pl-warn label { display: flex; gap: 8px; align-items: flex-start; font-weight: 700; cursor: pointer; }
.pl-warn input { margin-top: 2px; accent-color: var(--pl-acc); }
.pl-locked { text-align: center; display: grid; gap: 12px; justify-items: center; padding: 26px 20px; }
.pl-locked b { font-size: 17px; }
.pl-locked p { margin: 0; font-size: 13px; color: var(--pl-muted); }

/* Editor (modal) */
.pl-modal { position: fixed; inset: 0; z-index: 9990; display: flex; align-items: flex-end; justify-content: center; background: color-mix(in srgb, black 45%, transparent); backdrop-filter: blur(4px); animation: pl-fade .2s ease both; }
@media (min-width: 700px) { .pl-modal { align-items: center; } }
.pl-sheet { width: 100%; max-width: 520px; max-height: 94vh; overflow-y: auto; background: var(--pl-card); color: var(--pl-ink); border-radius: 22px 22px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 16px; font-family: var(--font); animation: pl-up .3s cubic-bezier(.2,.9,.3,1.1) both; }
@media (min-width: 700px) { .pl-sheet { border-radius: 22px; padding: 26px; } }
.pl-sheet-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.pl-sheet-h b { font-size: 19px; font-weight: 900; letter-spacing: -.02em; display: block; }
.pl-sheet-h p { margin: 4px 0 0; font-size: 13px; color: var(--pl-muted); }
.pl-x { appearance: none; border: 0; cursor: pointer; width: 34px; height: 34px; border-radius: 50%; background: var(--pl-bg); color: var(--pl-muted); font-size: 18px; line-height: 1; flex: none; }
.pl-sheet-f { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.pl-loading { padding: 60px 0; }

@media (max-width: 720px) {
  .pl-h1 { font-size: 28px; }
  .pl-hero { grid-template-columns: 1fr; padding: 22px; }
  .pl-engine { margin: -4px -8px -10px; }
  .pl-big { font-size: 34px; }
  .pl-grid, .pl-opts { grid-template-columns: 1fr; }
  .pl-send .pl-btn { width: 100%; }
}

@keyframes pl-rot { to { transform: rotate(360deg); } }
@keyframes pl-pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .6; transform: scale(1.35); } }
@keyframes pl-blink { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes pl-bump { 0% { opacity: .35; transform: translateY(3px); } 100% { opacity: 1; transform: none; } }
@keyframes pl-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes pl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pl-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .pl-engine .r1, .pl-engine .r2, .pl-engine .core, .pl-live::before, .pl-spin { animation: none !important; }
  .pl-engine .pk-in, .pl-engine .pk-out { display: none; }
}

/* Mini alerta: automatizaciones encendidas pero el canal sin conectar */
.pl-alert { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 10px 14px; border-radius: 12px; background: var(--c-warning-bg, #fff7e6); border: 1px solid color-mix(in srgb, var(--c-warning, #d97706) 30%, transparent); color: var(--pl-ink); font-size: 13px; font-weight: 600; line-height: 1.4; }
.pl-alert .icon { width: 18px; height: 18px; flex: none; color: var(--c-warning, #d97706); }
.pl-alert b { font-weight: 800; }

/* Título + insignia premium (reemplaza el antetítulo "PILOTO AUTOMÁTICO") */
.pl-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pl-title .pl-h1 { margin: 0; }
.pl-badge { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 13px 0 11px; border-radius: 999px;
  background: linear-gradient(135deg, var(--pl-hero, #1a0b1e) 0%, var(--pl-hero-2, #2a0f30) 100%); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.10), 0 4px 12px -6px rgba(0,0,0,.45); }
.pl-badge::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.14) 50%, transparent 70%); background-size: 250% 100%; animation: pl-badge-sheen 4.5s ease-in-out infinite; }
.pl-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--pl-acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pl-acc) 28%, transparent); animation: pl-badge-pulse 2s ease-in-out infinite; }
@keyframes pl-badge-sheen { 0%, 60% { background-position: 150% 0; } 100% { background-position: -100% 0; } }
@keyframes pl-badge-pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--pl-acc) 10%, transparent); } }
@media (prefers-reduced-motion: reduce) { .pl-badge::before, .pl-badge i { animation: none; } }
@media (max-width: 768px) { .pl-badge { height: 26px; font-size: 10px; padding: 0 11px 0 9px; } }
