:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #14181f; --muted: #5d6675; --line: #e3e6eb;
  --brand: #4f46e5; --brand-soft: #eef0ff; --ok: #12825b; --ok-soft: #e6f5ee;
  --warn: #b26a00; --warn-soft: #fff4e0; --bad: #c4314b; --bad-soft: #fdecef; --info: #1d6fd8; --info-soft: #e8f1fd;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }

.app { display: grid; grid-template-columns: 220px 1fr; height: 100%; }
.side { background: #101426; color: #c9cede; display: flex; flex-direction: column; padding: 16px 10px; }
.logo { color: #fff; font-weight: 700; font-size: 17px; padding: 6px 10px 18px; letter-spacing: -.2px; }
.logo span { color: #a5b4fc; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; border: 0; background: none; text-align: left; width: 100%; color: inherit; }
.nav:hover { background: #1c2238; }
.nav.on { background: #262d4a; color: #fff; }
.nav .badge { margin-left: auto; }
.side .foot { margin-top: auto; padding: 10px; font-size: 12px; color: #8b93ab; }
.side .foot button { background: none; border: 0; color: #a5b4fc; padding: 0; cursor: pointer; }

.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 18px; margin: 0; }
.top .sp { flex: 1; }
.content { padding: 20px 24px; overflow: auto; flex: 1; }
.simbar { background: var(--warn-soft); color: var(--warn); padding: 8px 24px; font-size: 13px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid #f3dfb8; }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c8cdd6; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost-bad { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.kpi .lbl { color: var(--muted); font-size: 12.5px; }
.kpi .val { font-size: 24px; font-weight: 650; margin-top: 4px; letter-spacing: -.3px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

input.in, select.in, textarea.in { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
input.in:focus, select.in:focus, textarea.in:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label.f { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr.click:hover td { background: #f8f9fc; cursor: pointer; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.neutral { background: #eef0f3; color: var(--muted); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 600; }

.drawer { position: fixed; inset: 0 0 0 auto; width: min(520px, 100%); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0,0,0,.08); z-index: 20; display: flex; flex-direction: column; }
.drawer .hd { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer .bd { padding: 16px 18px; overflow: auto; flex: 1; }
.scrim { position: fixed; inset: 0; background: rgba(15,20,35,.25); z-index: 19; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 14px; }
.timeline div { position: relative; margin-bottom: 10px; font-size: 13px; }
.timeline div::before { content: ""; position: absolute; left: -20px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

/* Bandeja */
.inbox { display: grid; grid-template-columns: 300px 1fr 280px; height: 100%; }
.inbox .list { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 4px; padding: 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab { border: 0; background: none; padding: 5px 9px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--muted); }
.tab.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.conv { padding: 11px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv:hover { background: #f8f9fc; }
.conv.on { background: var(--brand-soft); }
.conv .nm { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.conv .pv { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #eef0f4; }
.chat .hd { background: var(--panel); padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 72%; padding: 8px 11px; border-radius: 10px; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow); }
.bubble.in { background: #fff; align-self: flex-start; }
.bubble.out { background: #dcf8c6; align-self: flex-end; }
.bubble.bot { background: #e7e9ff; }
.bubble.note { background: #fff7db; align-self: center; font-size: 12.5px; max-width: 86%; border: 1px dashed #e9cf7a; box-shadow: none; }
.bubble .meta { font-size: 11px; color: var(--muted); margin-top: 3px; text-align: right; }
.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 10px; }
.composer textarea { resize: none; height: 64px; }
.warnbox { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.side-info { border-left: 1px solid var(--line); background: var(--panel); overflow: auto; padding: 14px; }

/* Plantillas */
.tpl-grid { display: grid; grid-template-columns: 280px 1fr 320px; gap: 14px; align-items: start; }
.wa-preview { background: #e5ddd5; border-radius: 10px; padding: 14px; }
.wa-preview .bubble { max-width: 100%; background: #fff; }
.wa-btn { background: #fff; text-align: center; color: #128c7e; padding: 7px; border-radius: 8px; margin-top: 4px; font-size: 13px; }
.errs { margin: 6px 0 0; padding-left: 18px; color: var(--bad); font-size: 13px; }
.warns { margin: 6px 0 0; padding-left: 18px; color: var(--warn); font-size: 13px; }

/* Auth */
.auth { min-height: 100%; display: grid; place-items: center; background: linear-gradient(160deg, #101426, #262d4a); padding: 20px; }
.auth .box { width: min(400px, 100%); }
.auth h1 { margin: 0 0 4px; font-size: 22px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column-reverse; min-width: 10px; max-width: 44px; }
.bars .b span { display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #14181f; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; font-size: 13.5px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.copy { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: #f3f4f7; padding: 6px 8px; border-radius: 6px; word-break: break-all; flex: 1; }

@media (max-width: 1100px) {
  .inbox { grid-template-columns: 260px 1fr; }
  .side-info { display: none; }
  .tpl-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; padding: 8px; }
  .logo, .side .foot { display: none; }
  .inbox { grid-template-columns: 1fr; }
}

/* ---------- v0.2: canales ---------- */
.chicon { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; letter-spacing: -.3px; }
.nav.setup { background: #2b2f55; color: #fff; margin-bottom: 6px; }
.badge.ok { background: var(--ok); }
.connect { display: grid; grid-template-columns: 200px 1fr; border-top: 1px solid var(--line); min-height: 240px; }
.connect-list { border-right: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.connect-item { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.connect-item:hover { background: #f4f5f8; }
.connect-item.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.connect-item .dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: #cfd3db; }
.connect-item .dot.ok { background: var(--ok); }
.connect-body { padding: 18px; min-width: 0; }
.linked { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 9px 12px; background: var(--ok-soft); border-radius: 8px; flex-wrap: wrap; }
.btn.big { padding: 10px 18px; font-weight: 600; }
.btn.fb { background: #0866FF; border-color: #0866FF; }
.btn.ig { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); border-color: transparent; }
.pages { margin-top: 14px; }
.page-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.page-row img, .img-ph { width: 34px; height: 34px; border-radius: 50%; background: #e7e9ef; flex: none; object-fit: cover; }

/* ---------- v0.2: asistente de configuración ---------- */
.ob { position: fixed; inset: 0; background: linear-gradient(180deg, #f3f4fb, #f6f7f9 40%); overflow: auto; z-index: 30; }
.ob-top { position: sticky; top: 0; display: flex; align-items: center; gap: 20px; padding: 14px 28px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); z-index: 2; }
.logo-dark { font-weight: 700; font-size: 17px; white-space: nowrap; }
.logo-dark span { color: var(--brand); }
.stepper { display: flex; gap: 6px; margin: 0 auto; }
.st { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 550; }
.st .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid #c8cdd6; font-size: 12px; }
.st.done { color: var(--ok); }
.st.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.st.cur { background: var(--brand-soft); color: var(--brand); }
.st.cur .n { border-color: var(--brand); }
.ob-body { max-width: 940px; margin: 0 auto; padding: 36px 24px 60px; }
.ob-body h1 { font-size: 28px; letter-spacing: -.4px; margin: 0 0 6px; text-align: center; }
.ob-body .lead { color: var(--muted); text-align: center; margin: 0 auto 26px; max-width: 620px; font-size: 15px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.cards.three { grid-template-columns: repeat(3, 1fr); }
.pick { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; text-align: left; box-shadow: var(--shadow); }
.pick:hover { border-color: #b9bfe9; }
.pick.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.pick b { font-size: 16px; }
.pick .muted { font-size: 13px; }
.howto ol { margin: 0 0 6px; padding-left: 20px; }
.howto li { margin-bottom: 10px; }
.waiting { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.waiting.ok { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ob-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; gap: 10px; }
.track { list-style: none; padding: 0; margin: 18px 0 0; }
.track li { padding: 8px 0; color: var(--muted); border-bottom: 1px dashed var(--line); }
.track li.ok { color: var(--ok); font-weight: 600; }
.track li.now { color: var(--info); font-weight: 600; }
.phone { background: #e5ddd5; border-radius: 22px; border: 8px solid #1d2230; min-height: 380px; display: flex; flex-direction: column; overflow: hidden; }
.phone-hd { background: #075e54; color: #fff; padding: 10px 12px; display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.phone-body { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow: auto; max-height: 420px; }
@media (max-width: 900px) {
  .ob-top { flex-wrap: wrap; }
  .stepper { order: 3; width: 100%; overflow-x: auto; }
  .cards.three { grid-template-columns: 1fr; }
  .connect { grid-template-columns: 1fr; }
  .connect-list { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
}

/* ---------- v0.3 ---------- */
.bar { height: 8px; background: #eceef3; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; border-radius: 999px; }
.plan { display: flex; flex-direction: column; gap: 6px; }
.plan.hot { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.plan .btn { margin-top: auto; }
.feat { list-style: none; padding: 0; margin: 8px 0 14px; font-size: 13.5px; }
.feat li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.plan .pill { align-self: flex-start; }
