/* Ayuda bot · v0.5
   Colores: morado = selección y flujos · azul = conexiones · verde = éxito ·
   ámbar = pendiente · rojo = error o eliminación. Siempre acompañados de texto o icono. */
:root {
  --bg: #eceef3; --surface: #ffffff; --surface-2: #f8f7fc; --line: #e4e1ee; --line-strong: #cfcadf;
  --text: #1d1b26; --muted: #6b6880; --primary: #6d3fd8; --primary-strong: #5a2fc2; --primary-soft: #efe9fd; --on-primary: #ffffff;
  --blue: #2563eb; --blue-soft: #e7efff; --ok: #157347; --ok-soft: #e3f5ec; --on-ok: #ffffff; --warn: #a05a00; --warn-soft: #fdf1dc;
  --bad: #c0362c; --bad-soft: #fde8e6; --on-bad: #ffffff; --radius: 10px; --radius-sm: 7px; --shadow: 0 1px 2px rgba(29,27,38,.06), 0 4px 14px rgba(29,27,38,.05);
  --canvas: #fbfaff; --canvas-dot: #dcd6ee;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0c12; --surface: #1c1a24; --surface-2: #232030; --line: #2f2b3d; --line-strong: #433d57;
    --text: #ecebf3; --muted: #a29fb5; --primary: #a483ff; --primary-strong: #b99cff; --primary-soft: #2c2448; --on-primary: #160f2b;
    --blue: #7aa7ff; --blue-soft: #1d2a47; --ok: #5fd39a; --ok-soft: #173327; --on-ok: #0b2a1b; --warn: #f2b84b; --warn-soft: #3a2d12;
    --bad: #ff8b80; --bad-soft: #3f1d1b; --on-bad: #2a0b08; --shadow: none; --canvas: #17151f; --canvas-dot: #2f2a40;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
h1 { font-size: 1.35rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; margin: 0 0 10px; }
h3 { font-size: .98rem; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mt0 { margin-top: 0; } .mt8 { margin-top: 8px; } .my8 { margin: 8px 0; } .pad { padding: 10px; } .narrow { max-width: 320px; }

/* ---------- estructura: barra lateral + contenido ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: 0 0 232px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 1.05rem; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 800; }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-weight: 500; }
#nav a.sub { padding-left: 22px; font-size: .9rem; color: var(--muted); }
#nav a:hover { background: var(--surface-2); }
#nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; box-shadow: inset 3px 0 0 var(--primary); }
.ico { width: 19px; height: 19px; flex: 0 0 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.badge { margin-left: auto; background: var(--bad); color: var(--on-bad); border-radius: 999px; padding: 0 7px; font-size: .72rem; font-weight: 700; line-height: 1.6; }
.user { border-top: 1px solid var(--line); padding: 12px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .88rem; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sim-banner { background: var(--warn-soft); color: var(--warn); padding: 7px 20px; font-size: .88rem; border-bottom: 1px solid var(--line); }
main { padding: 22px 26px 40px; width: 100%; max-width: 1400px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text); display: block; box-shadow: var(--shadow); }
.stat .n { font-size: 1.8rem; font-weight: 750; display: block; line-height: 1.2; }
.stat .lbl { color: var(--muted); font-size: .88rem; }
.stat.alert { border-color: var(--warn); } .stat.alert .n { color: var(--warn); }
.stat.bad { border-color: var(--bad); } .stat.bad .n { color: var(--bad); }
button, .btn { font: inherit; font-weight: 550; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; }
button:hover, .btn:hover { border-color: var(--primary); }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button.primary, .btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
button.primary:hover, .btn.primary:hover { background: var(--primary-strong); }
button.ok, .btn.ok { background: var(--ok); color: var(--on-ok); border-color: var(--ok); }
button.danger, .btn.danger { color: var(--bad); border-color: var(--bad); background: var(--surface); }
button.ghost, .btn.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--surface-2); border-color: var(--line); }
button.link { border: 0; background: none; color: var(--primary); padding: 0; text-decoration: underline; font-weight: 500; }
button.small, .btn.small { padding: 5px 10px; font-size: .85rem; }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
label { display: block; font-weight: 600; margin: 12px 0 5px; font-size: .92rem; }
label.inline { display: inline-flex; gap: 7px; align-items: center; font-weight: 450; margin: 4px 0; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=search], input:not([type]), select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; }
.hint { font-size: .84rem; color: var(--muted); margin: 3px 0 0; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 12px; margin: 14px 0; }
legend { font-weight: 700; padding: 0 6px; font-size: .92rem; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.ok::before { content: "✓"; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.warn::before { content: "●"; font-size: .6rem; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.bad::before { content: "!"; font-weight: 800; }
.pill.purple { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.pill.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.pill.plain::before { content: none; }
.notice { padding: 10px 14px; border-radius: var(--radius-sm); margin: 10px 0; border: 1px solid transparent; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--surface-2); border-color: var(--line); }
details.help { margin: 10px 0; }
details.help > summary { cursor: pointer; color: var(--primary); font-size: .88rem; font-weight: 600; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
details.help > summary::before { content: "?"; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid currentColor; font-size: .72rem; }
details.help[open] > summary { margin-bottom: 6px; }
details.help > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; font-size: .88rem; color: var(--text); }
details.fold { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 0 0 12px; }
details.fold > summary { cursor: pointer; padding: 11px 14px; font-weight: 650; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
details.fold > summary::after { content: "▾"; color: var(--muted); transition: transform .15s; }
details.fold[open] > summary::after { transform: rotate(180deg); }
details.fold > .fold-body { padding: 0 14px 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: var(--radius-sm); max-width: calc(100% - 32px); z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.login { max-width: 380px; margin: 10vh auto; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.more { color: var(--primary); border-color: var(--primary-soft); background: var(--primary-soft); font-weight: 650; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button, .seg a { border: 0; border-radius: 0; padding: 7px 12px; background: var(--surface); }
.seg button.on, .seg a.on { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.seg button + button, .seg a + a { border-left: 1px solid var(--line-strong); }
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(620px, 94vw); max-height: 88vh; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 10, 30, .5); }
dialog form, dialog .dialog-body { padding: 20px 22px 0; overflow: auto; max-height: calc(88vh - 70px); }
dialog .dialog-foot, dialog form > .actions { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 16px; border-top: 1px solid var(--line); margin-top: 12px; }
.dialog-error { color: var(--bad); font-weight: 600; }
.lightbox { width: min(980px, 96vw); }
.lightbox img { display: block; max-width: 100%; max-height: 80vh; margin: 0 auto; background: #fff; }
.lightbox .dialog-body { padding: 14px; }

/* ---------- inicio ---------- */
.conn-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- conexiones ---------- */
.line-card { display: grid; grid-template-columns: 54px 1fr auto; gap: 14px; align-items: start; }
.line-icon { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); }
.line-icon .ico { width: 26px; height: 26px; }
.line-name { font-size: 1.1rem; font-weight: 700; }
.qr img { width: 260px; max-width: 100%; background: #fff; padding: 10px; border-radius: var(--radius); border: 1px solid var(--line); }
.conn-state { font-size: 1.1rem; font-weight: 700; }

/* ---------- conversaciones (Superchat) ---------- */
.superchat { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); height: calc(100vh - 150px); min-height: 520px; overflow: hidden; box-shadow: var(--shadow); }
.sc-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sc-list .sc-tools { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.sc-items { overflow-y: auto; flex: 1; }
.sc-item { display: block; padding: 11px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.sc-item:hover { background: var(--surface-2); }
.sc-item.sel { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.sc-item .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.sc-item .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-item .time { color: var(--muted); font-size: .76rem; white-space: nowrap; }
.sc-item .last { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 2px 0 5px; }
.sc-item .tags { display: flex; gap: 4px; flex-wrap: wrap; }
.sc-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.sc-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.sc-head .who { font-weight: 700; }
.chat { flex: 1; overflow-y: auto; padding: 16px; background: var(--surface-2); min-height: 0; }
.msg { max-width: 72%; margin: 8px 0; padding: 9px 12px; border-radius: 14px 14px 14px 4px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; }
.msg.out { margin-left: auto; background: var(--primary-soft); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.msg.system { max-width: 100%; text-align: center; background: none; border: 1px dashed var(--line-strong); color: var(--muted); font-size: .82rem; border-radius: var(--radius-sm); }
.msg .meta { display: block; font-size: .72rem; color: var(--muted); margin-top: 4px; }
.msg img { max-width: 240px; max-height: 240px; display: block; border-radius: 8px; cursor: zoom-in; }
.msg audio { max-width: 260px; }
.transcript { margin-top: 6px; padding: 6px 9px; border-left: 3px solid var(--blue); background: var(--blue-soft); border-radius: 0 6px 6px 0; font-size: .88rem; }
.transcript b { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--blue); }
.transcript.failed { border-left-color: var(--warn); background: var(--warn-soft); }
.transcript.failed b { color: var(--warn); }
.reply-box { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; background: var(--surface); }
.reply-box textarea { min-height: 46px; max-height: 160px; }
.reply-tools { display: flex; gap: 8px; align-items: center; padding: 0 12px 10px; background: var(--surface); flex-wrap: wrap; }
.sc-info { border-left: 1px solid var(--line); overflow-y: auto; padding: 14px; min-height: 0; }
.sc-info h3 { margin: 16px 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sc-info h3:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: .88rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs a, .thumb-ph { width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); display: grid; place-items: center; background: var(--surface-2); font-size: .7rem; color: var(--muted); text-align: center; text-decoration: none; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.sc-placeholder { display: grid; place-items: center; color: var(--muted); height: 100%; padding: 30px; text-align: center; }
.mobile-only { display: none; }

/* ---------- comprobantes ---------- */
.receipt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.rcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.rcard .thumb { height: 170px; background: var(--surface-2); display: grid; place-items: center; border-bottom: 1px solid var(--line); cursor: zoom-in; overflow: hidden; border-left: 0; border-right: 0; border-top: 0; border-radius: 0; width: 100%; padding: 0; }
.rcard .thumb img { width: 100%; height: 100%; object-fit: cover; }
.rcard .thumb.noimg { cursor: default; color: var(--muted); font-size: .85rem; padding: 12px; text-align: center; }
.rcard .body { padding: 12px 14px 14px; display: grid; gap: 8px; flex: 1; }
.rcard .who { font-weight: 700; }
.fields { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: .86rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.fields dt { color: var(--muted); } .fields dd { margin: 0; }
.receipt-analysis { white-space: pre-wrap; font-size: .78rem; max-height: 200px; overflow: auto; }
.receipt { display: grid; grid-template-columns: 220px 1fr; gap: 14px; }

/* ---------- flujos: directorio ---------- */
.flow-directory { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.flow-filters { position: sticky; top: 16px; padding: 12px; }
.flow-filters h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 4px 6px; }
.flow-filters h3:first-child { margin-top: 2px; }
.flow-filters button { display: flex; width: 100%; justify-content: space-between; text-align: left; margin: 2px 0; border-color: transparent; background: transparent; font-weight: 500; padding: 7px 9px; }
.flow-filters button:hover { background: var(--surface-2); }
.flow-filters button.selected { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.flow-rows { display: grid; gap: 8px; }
.flow-row { display: grid; grid-template-columns: 38px minmax(0, 1.4fr) minmax(0, 1fr) auto auto; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 10px 14px; box-shadow: var(--shadow); }
.flow-row:hover { border-color: var(--primary); }
.flow-row-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.flow-row-name { font-size: 1rem; font-weight: 700; color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-row-name:hover { color: var(--primary); }
.flow-row-meta { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-menu { position: relative; }
.flow-menu summary { cursor: pointer; list-style: none; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-size: 20px; color: var(--muted); }
.flow-menu summary:hover { background: var(--surface-2); color: var(--text); }
.flow-menu > div { position: absolute; right: 0; top: 38px; width: 230px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 20; }
.flow-menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; margin: 1px 0; font-weight: 500; }
.flow-menu button:hover, .flow-menu button:focus-visible { background: var(--surface-2); }
.flow-menu button[data-action="delete"] { color: var(--bad); }
.flow-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.flow-dialog { width: min(640px, 94vw); }

/* ---------- flujos: editor ---------- */
.editor-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.editor-head h1 { font-size: 1.15rem; flex: 1; min-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-settings { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 4px 16px; }
.flow-settings label { margin-top: 8px; }
.flow-settings > div label { display: block; margin: 6px 0; font-weight: 450; }
.flow-channels { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 8px 0 0; }
.flow-channels label { display: block; font-weight: 450; margin: 4px 0; }
/*old*/.flow-toolbar { display: flex; gap: 10px; align-items: center; margin: 0 0 10px; flex-wrap: wrap; }
.flow-toolbar label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
.flow-toolbar select { width: auto; }
/* editor v0.7: ver bloque al final */
.type-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- palabras clave ---------- */
.kw-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 14px; cursor: pointer; box-shadow: var(--shadow); text-align: left; width: 100%; font-weight: 400; }
.kw-row:hover { border-color: var(--primary); }
.kw-name { font-weight: 700; }
.kw-phrase { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; }
.kw-list { display: grid; gap: 8px; }

/* ---------- ofertas (sin cambios funcionales) ---------- */
.step { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 10px; background: var(--surface-2); }
.step.disabled { opacity: .65; }
.step-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }

.info-toggle { display: none !important; }

/* ---------- pantallas pequeñas ---------- */
@media (max-width: 1180px) {
  .superchat { grid-template-columns: 290px minmax(0, 1fr); }
  .superchat .sc-info { display: none; }
  .superchat.show-info .sc-info { display: block; position: absolute; right: 0; top: 0; bottom: 0; width: min(340px, 92vw); background: var(--surface); z-index: 5; box-shadow: -10px 0 30px rgba(0,0,0,.15); }
  .superchat { position: relative; }
  .info-toggle { display: inline-flex !important; }
  .flow-editor { grid-template-columns: 1fr; }
  .flow-inspector { height: auto; min-height: 0; }
  .flow-row { grid-template-columns: 38px minmax(0, 1fr) auto auto; }
  .flow-row .flow-row-triggers { display: none; }
}
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: sticky; top: 0; z-index: 30; flex-direction: row; align-items: center; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); gap: 6px; }
  .brand { padding: 0 6px 0 2px; } .brand-name { display: none; }
  #nav { flex-direction: row; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  #nav a { flex-direction: column; gap: 2px; padding: 5px 8px; font-size: .68rem; white-space: nowrap; }
  #nav a.sub { padding-left: 8px; font-size: .68rem; color: var(--text); }
  #nav a.active { box-shadow: inset 0 -3px 0 var(--primary); }
  .badge { position: absolute; margin: 0 0 0 16px; font-size: .62rem; }
  #nav a { position: relative; }
  .user { border: 0; padding: 0; } #whoami { display: none; }
  main { padding: 14px 12px 30px; }
  .flow-directory { grid-template-columns: 1fr; }
  .flow-filters { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .flow-filters h3 { width: 100%; margin: 6px 4px 0; }
  .flow-filters button { width: auto; }
  .flow-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .flow-row .flow-row-status { grid-column: 2; justify-self: start; }
  .superchat { grid-template-columns: 1fr; height: calc(100vh - 140px); }
  .superchat.has-detail .sc-list { display: none; }
  .superchat:not(.has-detail) .sc-chat { display: none; }
  .mobile-only { display: inline-flex; }
  .msg { max-width: 88%; }
  .kw-row { grid-template-columns: 1fr auto; }
  .kw-row .kw-target { grid-column: 1 / -1; }
  .line-card { grid-template-columns: 44px 1fr; } .line-card > :last-child { grid-column: 1 / -1; }
  .line-icon { width: 44px; height: 44px; }
  .flow-settings { grid-template-columns: 1fr; }

  .receipt { grid-template-columns: 1fr; }
}
.push-right { margin-left: auto; }
/* Campos de archivo: nunca más anchos que su contenedor (pantallas pequeñas). */
input[type="file"] { max-width: 100%; min-width: 0; }

/* ---------- v0.6: conteo, vendedores, respuestas rápidas, seguimiento ---------- */
.count-head { margin-top: 22px; }
.count-head h2 { margin: 0; }
.count-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-top: 12px; }
.count-cols .card { margin: 0; min-width: 0; }
.hour-chart { width: 100%; height: auto; max-height: 190px; display: block; }
.hour-chart rect { fill: var(--primary); opacity: .55; }
.hour-chart rect.top { opacity: 1; }
.hour-chart text { fill: var(--muted); font-size: 10px; }
.funnel-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin-bottom: 10px; font-size: .92rem; }
.funnel-row progress { grid-column: 1 / -1; width: 100%; height: 10px; accent-color: var(--primary); }
.table-wrap { overflow-x: auto; }
.seller-list { display: grid; gap: 8px; }
.seller-row { display: grid; grid-template-columns: minmax(170px, 2fr) minmax(110px, 1fr) minmax(140px, 1.5fr) minmax(120px, 1fr) minmax(130px, 1fr) auto auto; gap: 12px; align-items: center; margin: 0; padding: 12px 14px; }
.seller-name { font-weight: 700; }
@media (max-width: 1100px) { .seller-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .seller-row { grid-template-columns: 1fr; } }
.quick-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 12px 10px; }
.chip-btn { border-radius: 999px; padding: 4px 11px; font-size: .85rem; background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary-soft); font-weight: 650; }
.quick-list { display: grid; gap: 8px; margin-bottom: 12px; max-height: 240px; overflow-y: auto; }
.quick-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.fu-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px; }
.price-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sc-tools .seg { display: flex; flex-wrap: wrap; }
.sc-tools .seg button { flex: 1 1 auto; }
.toolbar select { width: auto; }
.seller-row > div { min-width: 0; overflow-wrap: anywhere; }
.seller-row .pill { white-space: normal; }
.count-head select { width: auto; }

/* ---------- v0.7: editor de flujos amplio y por colores ---------- */
:root { --t-start: #16a34a; --t-content: #7c3aed; --t-ai: #0891b2; --t-choice: #ea580c; --t-reply: #ca8a04; --t-payment: #db2777; --t-flow: #2563eb; --t-end: #475569;
  --a-text: #2563eb; --a-wait: #64748b; --a-image: #16a34a; --a-audio: #ea580c; --a-video: #9333ea; --a-document: #dc2626; }
@media (prefers-color-scheme: dark) { :root { --t-start: #4ade80; --t-content: #a78bfa; --t-ai: #22d3ee; --t-choice: #fb923c; --t-reply: #facc15; --t-payment: #f472b6; --t-flow: #60a5fa; --t-end: #94a3b8;
  --a-text: #60a5fa; --a-wait: #94a3b8; --a-image: #4ade80; --a-audio: #fb923c; --a-video: #c084fc; --a-document: #f87171; } }
.t-start { --tc: var(--t-start); } .t-content { --tc: var(--t-content); } .t-ai { --tc: var(--t-ai); } .t-choice { --tc: var(--t-choice); } .t-reply { --tc: var(--t-reply); }
.t-payment { --tc: var(--t-payment); } .t-flow { --tc: var(--t-flow); } .t-end { --tc: var(--t-end); }
.a-text { --ac: var(--a-text); } .a-wait { --ac: var(--a-wait); } .a-image { --ac: var(--a-image); } .a-audio { --ac: var(--a-audio); } .a-video { --ac: var(--a-video); } .a-document { --ac: var(--a-document); }

.flow-editor { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 14px; align-items: start; }
.flow-stage { position: relative; height: calc(100vh - 205px); min-height: 520px; border: 1px solid var(--line-strong); border-radius: 14px; overflow: hidden; background: var(--canvas); }
.flow-canvas { position: absolute; inset: 0; overflow: auto; cursor: grab; background-color: var(--canvas); background-image: radial-gradient(var(--canvas-dot) 1.2px, transparent 1.2px); background-size: 22px 22px; }
.flow-canvas.panning { cursor: grabbing; }
.flow-canvas svg { display: block; }
.flow-palette { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 3; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; pointer-events: none; }
.flow-palette > * { pointer-events: auto; }
.palette-title { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface); padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line); }
.pal-btn { background: var(--surface); border: 1px solid var(--line-strong); border-left: 5px solid var(--tc); padding: 6px 11px 6px 8px; font-size: .86rem; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.pal-btn:hover { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 10%, var(--surface)); }
.pal-ico { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--tc); color: #fff; font-size: .75rem; }
.zoom-ctl { position: absolute; right: 12px; bottom: 12px; z-index: 3; display: flex; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.zoom-ctl button { border: 0; border-radius: 0; padding: 7px 12px; font-weight: 700; background: var(--surface); }
.zoom-ctl button + button { border-left: 1px solid var(--line); }
.zoom-ctl button:hover { background: var(--surface-2); }
.canvas-hint { position: absolute; left: 12px; bottom: 12px; z-index: 2; font-size: .76rem; color: var(--muted); background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 4px 9px; border-radius: 8px; max-width: calc(100% - 280px); pointer-events: none; }

.flow-node { cursor: grab; touch-action: none; user-select: none; }
.flow-node rect.box { fill: var(--surface); stroke: color-mix(in srgb, var(--tc) 55%, var(--line-strong)); stroke-width: 1.5; filter: drop-shadow(0 2px 4px rgba(0,0,0,.08)); }
.flow-node path.head { fill: var(--tc); }
.flow-node rect.halo { fill: none; stroke: none; }
.flow-node.selected rect.halo { stroke: var(--tc); stroke-width: 3; stroke-dasharray: 0; fill: color-mix(in srgb, var(--tc) 10%, transparent); }
.flow-node.selected rect.box { stroke: var(--tc); stroke-width: 2.5; }
.flow-node text { font: 14px system-ui, -apple-system, sans-serif; fill: var(--text); pointer-events: none; }
.flow-node .flow-node-type { font-size: 11px; font-weight: 800; fill: #fff; letter-spacing: .04em; }
.flow-node .flow-node-label { font-size: 15px; font-weight: 700; }
.flow-node .flow-node-info { font-size: 12px; fill: var(--muted); }
.flow-port { fill: var(--surface); stroke: var(--blue); stroke-width: 3; cursor: crosshair; touch-action: none; }
.flow-port.paid { stroke: var(--ok); }
.flow-port:hover { fill: var(--blue-soft); }
.flow-edge { fill: none; stroke: var(--blue); stroke-width: 2.2; pointer-events: none; opacity: .85; }
.flow-edge.paid { stroke: var(--ok); }
.flow-edge-hit { fill: none; stroke: transparent; stroke-width: 18; cursor: pointer; }
.flow-edge.selected { stroke: var(--bad); stroke-width: 4; opacity: 1; }
.flow-edge.preview { stroke-dasharray: 6 4; }
.flow-edge-label { font: 600 12px system-ui; fill: var(--text); paint-order: stroke; stroke: var(--canvas); stroke-width: 4px; }
#arrow path { fill: var(--blue); }
.edge-delete { cursor: pointer; } .edge-delete circle { fill: var(--bad); stroke: #fff; stroke-width: 2; } .edge-delete text { fill: #fff; font: 22px system-ui; pointer-events: none; }
.port-label { font-size: 11px !important; fill: var(--muted) !important; font-weight: 700; }

/* Panel derecho: cabecera del color del cuadro y secciones separadas */
.flow-inspector { height: calc(100vh - 205px); min-height: 520px; overflow: auto; margin: 0; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; }
.insp-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: color-mix(in srgb, var(--tc) 14%, var(--surface)); border-bottom: 3px solid var(--tc); }
.insp-ico { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; background: var(--tc); color: #fff; display: grid; place-items: center; font-weight: 800; }
.insp-title { flex: 1; min-width: 0; }
.insp-title small { display: block; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--tc); }
.insp-title input { font-weight: 700; padding: 5px 8px; margin-top: 2px; }
.btn-del { background: var(--bad); color: var(--on-bad); border-color: var(--bad); font-size: .85rem; padding: 7px 10px; white-space: nowrap; }
.btn-del:hover { filter: brightness(1.08); border-color: var(--bad); }
.insp-body { padding: 12px; display: grid; gap: 12px; }
.insp-sec { --sc: var(--muted); border: 1px solid var(--line); border-left: 4px solid var(--sc); border-radius: 10px; padding: 10px 12px 12px; background: var(--surface); }
.insp-sec h3 { margin: 0 0 4px; font-size: .9rem; color: var(--sc); }
.insp-sec > .hint { margin-bottom: 8px; }
.insp-sec label { font-size: .88rem; margin: 10px 0 4px; }
.insp-sec label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; margin: 8px 0; }
.insp-sec label.check input { margin-top: 3px; flex: 0 0 16px; }
.sec-msg { --sc: var(--t-content); } .sec-ai { --sc: var(--t-ai); } .sec-pay { --sc: var(--ok); } .sec-choice { --sc: var(--t-choice); }
.sec-link { --sc: var(--t-flow); } .sec-fu { --sc: var(--warn); } .sec-out { --sc: var(--blue); }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; background: var(--ok-soft); border-radius: 8px; padding: 2px 10px 10px; }
.pay-grid .span2 { grid-column: 1 / -1; }
.pay-grid[hidden] { display: none; }

/* Pasos del cuadro Contenido */
.act { border: 1px solid var(--line); border-left: 4px solid var(--ac); border-radius: 10px; margin: 0 0 10px; background: var(--surface-2); overflow: hidden; }
.act > :not(.act-head) { margin-left: 10px; margin-right: 10px; }
.act > :last-child { margin-bottom: 10px; }
.act textarea, .act select { margin-top: 8px; background: var(--surface); }
.act.moved { animation: moved 1s ease-out; }
@keyframes moved { from { box-shadow: 0 0 0 3px var(--ac); } to { box-shadow: none; } }
.act-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: color-mix(in srgb, var(--ac) 12%, var(--surface)); }
.act-num { width: 22px; height: 22px; border-radius: 50%; background: var(--ac); color: #fff; display: grid; place-items: center; font-size: .75rem; font-weight: 800; flex: 0 0 22px; }
.act-type { font-weight: 700; font-size: .86rem; color: var(--ac); flex: 1; min-width: 0; }
.act-ctl { display: flex; gap: 4px; }
.act-ctl button { padding: 3px 8px; font-size: .78rem; background: var(--surface); }
.act-ctl button:disabled { opacity: .35; }
.mini-del { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--surface); padding: 3px 8px; font-size: .78rem; }
.mini-del:hover { background: var(--bad); color: var(--on-bad); border-color: var(--bad); }
.add-acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 4px; }
.add-act { justify-content: center; font-size: .8rem; padding: 7px 4px; border: 1px dashed var(--ac); color: var(--ac); background: color-mix(in srgb, var(--ac) 6%, var(--surface)); }
.add-act:hover { border-style: solid; background: color-mix(in srgb, var(--ac) 14%, var(--surface)); border-color: var(--ac); }
.upload-box { margin-top: 12px; padding: 4px 10px 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.rec-btn.on { background: var(--bad); color: var(--on-bad); border-color: var(--bad); }
.sec-input { width: 90px !important; display: inline-block; margin: 0 6px; }
.act label.inline { margin: 8px 0; }
.empty-small { color: var(--muted); font-size: .86rem; text-align: center; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 8px; }
.fu-top { display: flex; justify-content: space-between; align-items: center; }
.fu-item { background: var(--warn-soft); border-color: transparent; }
.add-wide { width: 100%; justify-content: center; border-style: dashed; }

@media (max-width: 1180px) { .flow-editor { grid-template-columns: 1fr; } .flow-inspector { height: auto; min-height: 0; } .flow-stage { height: 70vh; } }
@media (max-width: 860px) { .canvas-hint { display: none; } .flow-stage { height: 64vh; min-height: 380px; } .add-acts { grid-template-columns: 1fr 1fr; } }
/* barra de cuadros fija arriba del lienzo (no tapa los cuadros) */
.flow-palette { top: 0; left: 0; right: 0; padding: 8px 10px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
.flow-palette .pal-btn, .palette-title { flex: 0 0 auto; white-space: nowrap; box-shadow: none; }
.palette-title { border: 0; background: none; padding: 0 4px; }
.flow-canvas { top: 51px; }
.flow-editor { grid-template-columns: minmax(0, 1fr) 420px; }
.act-type { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-btn { padding: 5px 9px 5px 6px; font-size: .82rem; gap: 5px; }
@media (max-width: 1180px) { .flow-editor { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-color-scheme: dark) {
  .flow-node .flow-node-type { fill: #0d0c12; }
  .pal-ico, .insp-ico, .act-num { color: #0d0c12; }
}

/* subir archivo directamente en un paso */
.step-file { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.step-file select { flex: 1 1 180px; }
.step-up { position: relative; display: inline-flex; align-items: center; gap: 4px; margin: 8px 0 0; padding: 7px 11px; border-radius: var(--radius-sm); border: 1px solid var(--ac); color: var(--ac); background: var(--surface); font-weight: 650; font-size: .82rem; cursor: pointer; white-space: nowrap; }
.step-up:hover { background: color-mix(in srgb, var(--ac) 12%, var(--surface)); }
.step-up input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
/* ---------- v0.7: reacciones ---------- */
.rx-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
.rx-chip { border-radius: 999px; padding: 6px 12px; font-size: .86rem; background: var(--surface); }
.rx-chip b { font-size: 1rem; }
.rx-chip.rx-ok { border-color: var(--ok); color: var(--ok); } .rx-chip.rx-blue { border-color: var(--blue); color: var(--blue); } .rx-chip.rx-purple { border-color: var(--primary); color: var(--primary); }
.rx-chip.rx-bad { border-color: var(--bad); color: var(--bad); } .rx-chip.rx-warn { border-color: var(--warn); color: var(--warn); }
.rx-chip.on { box-shadow: inset 0 0 0 2px currentColor; background: var(--surface-2); }
.rx-node { margin: 0 0 12px; } .rx-node-top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: .92rem; }
.rx-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tc, var(--muted)); flex: 0 0 10px; align-self: center; }
.rx-node progress { width: 100%; height: 10px; accent-color: var(--tc, var(--primary)); }
.rx-stop { color: var(--bad); font-weight: 650; }

/* v0.8 — Conexión con IA e Ideas */
button.chip { cursor: pointer; color: var(--text); }
button.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }
code.token { display: inline-block; word-break: break-all; padding: 4px 8px; background: var(--surface-2); border-radius: 6px; user-select: all; }
.idea-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.idea-head h2 { margin: 0; }
.idea-note { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; margin: 8px 0; }
.idea-note p { margin: 2px 0; }
.idea-ai { color: var(--primary); }

.summary-card { border-left: 4px solid var(--t-ai); }
.summary-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.summary-head h2 { margin: 0; flex: 1; }
.summary-text { line-height: 1.55; }
input.tiny { width: 4.2em; display: inline-block; padding: 2px 6px; }

/* Palabras clave agrupadas por flujo */
.kw-group-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kw-group-head h2 { margin: 0; }
.kw-sentence { line-height: 2; margin: 10px 0 4px; }
.kw-chip { display: inline-block; padding: 1px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 600; font-size: .92rem; cursor: pointer; color: var(--text); }
.kw-chip:hover { border-color: var(--primary); color: var(--primary); }
.kw-chip.off { text-decoration: line-through; opacity: .55; }
.kw-sep { color: var(--muted); margin: 0 4px; }
.kw-sub { margin: 18px 0 8px; font-size: 1rem; }

/* v0.8.1: aviso de desconexión */
.alert-banner { background: #b91c1c; color: #fff; padding: 10px 16px; font-size: 14px; line-height: 1.45; }
.alert-banner a { color: #fff; text-decoration: underline; font-weight: 600; }
