:root {
  --bg: #f4f5f3;
  --panel: #ffffff;
  --panel-2: #f7f8f6;
  --line: #e3e6e1;
  --text: #1b1f1c;
  --muted: #687069;
  --accent: #128c5e;
  --accent-2: #0f7a52;
  --accent-soft: #e2f4ec;
  --bubble-out: #d9f5e3;
  --bubble-in: #ffffff;
  --chat-bg: #efeae2;
  --canvas: #f0f2ee;
  --canvas-dot: #d5dad3;
  --danger: #c2372f;
  --danger-soft: #fde6e4;
  --warn: #a8690f;
  --warn-soft: #fdf1dc;
  --info: #2a7de1;
  --info-soft: #e3eefc;
  --violet: #7a5af8;
  --rail: #13261d;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .1);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --panel: #161c19; --panel-2: #1b2320; --line: #28322d; --text: #e6ebe7; --muted: #8e9a93;
    --accent: #25b37a; --accent-2: #1f9c6a; --accent-soft: #163a2b; --bubble-out: #144d37; --bubble-in: #1e2724;
    --chat-bg: #0c1210; --canvas: #101613; --canvas-dot: #24302a; --warn-soft: #3a2c12; --danger-soft: #3d1a17;
    --info-soft: #172a45; --rail: #0a110e; --shadow: 0 8px 28px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input[type=checkbox], input[type=radio], input[type=color] { width: auto; }
input[type=color] { padding: 0; height: 30px; width: 40px; border: 0; background: none; cursor: pointer; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
code { background: var(--panel-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- Login ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 50%), var(--bg); }
.auth-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px 28px 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.auth-logo { width: 52px; height: 52px; border-radius: 14px; background: #25d366; color: #fff; display: grid; place-items: center; margin-bottom: 8px; }
.auth-card h1 { font-size: 22px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.auth-error { background: var(--danger-soft); color: var(--danger); padding: 8px 10px; border-radius: 8px; margin: 0; font-size: 13px; }
.auth-foot { display: flex; align-items: center; gap: 6px; justify-content: center; color: var(--muted); font-size: 12px; margin: 14px 0 0; }
.auth-foot svg { width: 14px; height: 14px; }
.btn.block { width: 100%; padding: 10px; }

/* ---------- Estructura ---------- */
.app { display: flex; height: 100vh; }
.rail { width: 74px; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 2px; flex: none; overflow-y: auto; }
.rail-spacer { flex: 1; }
.logo { color: #fff; background: #25d366; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 10px; flex: none; }
.nav { position: relative; width: 62px; background: none; border: 0; color: #a9bbb1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; border-radius: 10px; font-size: 10.5px; flex: none; }
.nav:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav.active { background: rgba(37, 211, 102, .16); color: #fff; }
.nav-badge { position: absolute; top: 3px; right: 9px; background: #25d366; color: #06301c; font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.demo-banner { background: var(--warn-soft); padding: 7px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 0 4px; }
.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; }
.view.page { flex-direction: column; overflow: auto; padding: 26px 30px 40px; gap: 18px; }

/* ---------- Controles ---------- */
.btn { text-decoration: none; color: inherit; border: 1px solid var(--line); background: var(--panel); padding: 7px 13px; border-radius: 8px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; border-color: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { background: none; border: 0; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.sm svg { width: 15px; height: 15px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.chip-select { width: auto; border-radius: 999px; padding: 3px 8px; font-size: 12px; color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; border-radius: 5px; padding: 1px 7px; color: var(--tc, var(--accent)); background: color-mix(in srgb, var(--tc, var(--accent)) 14%, transparent); white-space: nowrap; }
.tag button { background: none; border: 0; padding: 0; line-height: 1; color: inherit; opacity: .7; font-size: 13px; }
.tag button:hover { opacity: 1; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
label small { font-weight: 400; }
.switch-row { flex-direction: row; justify-content: space-between; align-items: center; color: var(--text); font-size: 13.5px; gap: 10px; }
input.switch { appearance: none; width: 38px; height: 22px; padding: 0; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; border: 0; flex: none; transition: background .15s; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(16px); }
.pill { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; white-space: nowrap; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.violet { background: color-mix(in srgb, var(--violet) 15%, transparent); color: var(--violet); }
.pill.gray { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.pill.red { background: var(--danger-soft); color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ---------- Páginas ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; margin-bottom: 4px; }
.page-head p { margin: 0; color: var(--muted); max-width: 680px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }
.card-empty { text-align: center; color: var(--muted); padding: 34px 20px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--accent); border-color: var(--accent); }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi small { color: var(--muted); font-size: 12px; display: block; }
.kpi b { font-size: 26px; font-weight: 700; display: block; margin-top: 2px; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi.alert b { color: var(--warn); }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; height: 100%; min-width: 0; }
.bars .stack { width: 100%; max-width: 28px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; }
.bars .stack i { display: block; }
.bars small { font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.list-rows { display: flex; flex-direction: column; }
.list-rows > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-rows > div:last-child { border-bottom: 0; }

/* Tablas */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; z-index: 1; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
td .who { display: flex; align-items: center; gap: 10px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { width: 260px; }
.toolbar select { width: auto; }
.bulkbar { display: flex; gap: 8px; align-items: center; background: var(--accent-soft); padding: 8px 12px; border-radius: 8px; flex-wrap: wrap; }

/* ---------- Chats ---------- */
.list-pane { width: 330px; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; flex: none; }
.pane-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px 16px; }
.pane-head h2 { font-size: 19px; }
.search { padding: 0 12px 8px; }
.filters { display: flex; gap: 5px; padding: 0 12px 10px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.contact-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.contact-list li { display: flex; gap: 11px; align-items: center; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.contact-list li:hover { background: var(--panel-2); }
.contact-list li.active { background: var(--accent-soft); }
.contact-list .meta { flex: 1; min-width: 0; }
.contact-list .r { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.contact-list .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-list time { font-size: 11.5px; color: var(--muted); flex: none; }
.contact-list .preview { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-list .unread .preview { color: var(--text); font-weight: 500; }
.contact-list .unread time { color: var(--accent); font-weight: 600; }
.contact-list .badge { background: #25d366; color: #06301c; font-size: 11px; font-weight: 700; border-radius: 10px; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 6px; flex: none; }
.contact-list .tags { margin-top: 3px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.pending { background: var(--warn); }
.list-empty { padding: 30px 20px; text-align: center; color: var(--muted); cursor: default !important; }

.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-size: 15px; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.xl { width: 72px; height: 72px; font-size: 26px; }

.conversation { flex: 1; display: flex; min-width: 0; background: var(--chat-bg); }
.empty-state { margin: auto; text-align: center; color: var(--muted); }
.empty-state svg { width: 64px; height: 64px; stroke-width: 1.2; opacity: .5; }
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.chat-head .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-head .who strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head small { color: var(--muted); }
.chat-head .back { display: none; }
.status-select { width: auto; padding: 4px 8px; font-size: 12.5px; }

.messages { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 4px; }
.day-sep { align-self: center; background: var(--panel); color: var(--muted); font-size: 11.5px; padding: 3px 10px; border-radius: 6px; margin: 10px 0 6px; box-shadow: 0 1px 1px rgba(0, 0, 0, .05); }
.msg { max-width: min(540px, 75%); padding: 6px 9px 4px; border-radius: 8px; box-shadow: 0 1px 1px rgba(0, 0, 0, .07); white-space: pre-wrap; word-wrap: break-word; position: relative; line-height: 1.38; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 2px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 2px; }
.msg .foot { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 10.5px; color: var(--muted); margin-top: 2px; float: right; padding-left: 10px; position: relative; top: 4px; }
.msg .label { display: block; font-size: 10.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; letter-spacing: .02em; }
.msg .label.bot { color: var(--violet); }
.msg .label.bc { color: var(--info); }
.msg.failed { outline: 1px solid var(--danger); }
.msg .ad-ref { display: block; font-size: 11.5px; background: var(--info-soft); color: var(--info); border-radius: 6px; padding: 4px 8px; margin: 0 0 5px; white-space: normal; }
.msg .ad-ref b { color: var(--text); }
.msg .err { color: var(--danger); font-size: 12px; display: block; clear: both; }
.msg img.media, .msg video.media { max-width: 280px; max-height: 320px; border-radius: 6px; display: block; margin-bottom: 4px; }
.msg audio { max-width: 260px; display: block; }
.msg .media-link { display: inline-flex; gap: 6px; align-items: center; }
.msg-btns { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; clear: both; }
.msg-btns button, .msg-btns span { background: var(--panel); border: 0; color: var(--info); text-align: center; padding: 6px; border-radius: 6px; font-size: 13px; white-space: normal; }
.msg-btns button:hover { background: var(--info-soft); }
.msg-btns.demo button::after { content: " ↩"; opacity: .6; font-size: 11px; }
.ticks svg { width: 15px; height: 15px; }
.ticks.read { color: #34b7f1; }
.ticks.failed { color: var(--danger); }

.closed-window { background: var(--warn-soft); padding: 9px 16px; font-size: 13px; display: flex; align-items: center; gap: 12px; justify-content: space-between; border-top: 1px solid var(--line); }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 8px 10px; background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { resize: none; max-height: 160px; border-radius: 20px; padding: 9px 14px; }
.composer.disabled textarea { opacity: .5; }
.send { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); border: 0; color: #fff; display: grid; place-items: center; flex: none; }
.send svg { width: 18px; height: 18px; }
.send:disabled { opacity: .5; }
.quick-pop { position: absolute; bottom: 62px; left: 90px; right: 60px; max-height: 240px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 5; }
.quick-pop button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.quick-pop button.active, .quick-pop button:hover { background: var(--accent-soft); }
.quick-pop b { color: var(--accent); margin-right: 6px; }
.quick-pop span { color: var(--muted); font-size: 12.5px; }

.info-pane { width: 310px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; flex: none; }
.info-pane:empty { display: none; }
.info-section { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.info-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.info-top { align-items: center; text-align: center; }
.tag-add { position: relative; }
.suggest { position: absolute; top: 100%; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); z-index: 10; max-height: 200px; overflow-y: auto; margin-top: 2px; }
.suggest button { display: flex; width: 100%; align-items: center; gap: 8px; background: none; border: 0; padding: 7px 10px; text-align: left; }
.suggest button:hover, .suggest button.active { background: var(--panel-2); }
.field-row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: center; font-size: 13px; }
.field-row span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-row input { padding: 5px 8px; }

/* ---------- Plantillas ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.tpl { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.tpl-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tpl-top strong { font-family: Consolas, monospace; font-size: 13px; word-break: break-all; }
.tpl-preview { background: var(--chat-bg); border-radius: 8px; padding: 10px; flex: 1; display: flex; flex-direction: column; }
.tpl-preview .msg { max-width: 100%; align-self: stretch; }
.status { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; letter-spacing: .03em; }
.status.APPROVED { background: var(--accent-soft); color: var(--accent); }
.status.PENDING, .status.IN_APPEAL { background: var(--warn-soft); color: var(--warn); }
.status.REJECTED, .status.DISABLED, .status.PAUSED { background: var(--danger-soft); color: var(--danger); }

/* ---------- Flujos (lista) ---------- */
.flow-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.flow-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.flow-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.flow-card .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.flow-card h3 { font-size: 15px; }
.flow-card .trg { display: flex; flex-wrap: wrap; gap: 4px; }
.flow-card .stats { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: auto; }
.preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.preset { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.preset:hover, .preset.active { border-color: var(--accent); background: var(--accent-soft); }
.preset b { font-size: 14px; }
.preset span { font-size: 12.5px; color: var(--muted); }

/* ---------- Editor de flujos ---------- */
.builder { flex-direction: column; }
.b-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.b-top input.b-name { width: 260px; font-weight: 600; font-size: 15px; border-color: transparent; background: none; }
.b-top input.b-name:hover { border-color: var(--line); }
.b-body { flex: 1; display: flex; min-height: 0; position: relative; }
.palette { width: 64px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px; flex: none; overflow-y: auto; }
.palette button { width: 54px; background: none; border: 0; border-radius: 8px; padding: 7px 0; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--muted); }
.palette button:hover { background: var(--panel-2); color: var(--text); }
.palette button i { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.palette button i svg { width: 17px; height: 17px; }
.canvas { flex: 1; position: relative; overflow: hidden; background-color: var(--canvas); background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1px); cursor: grab; touch-action: none; }
.canvas.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.edges { position: absolute; left: 0; top: 0; overflow: visible; width: 1px; height: 1px; pointer-events: none; }
.edges path { fill: none; stroke: var(--muted); stroke-width: 2.2; pointer-events: stroke; cursor: pointer; }
.edges path.hit { stroke: transparent; stroke-width: 14; }
.edges path.hit:hover + path, .edges path.sel { stroke: var(--danger); }
.edges path.draft { stroke: var(--accent); stroke-dasharray: 6 5; }
.node { position: absolute; width: 250px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px; box-shadow: 0 2px 8px rgba(0, 0, 0, .06); cursor: default; user-select: none; }
.node.sel { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent), var(--shadow); }
.node.drop { border-color: var(--accent); }
.node .nh { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: move; }
.node .nh i { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: #fff; flex: none; }
.node .nh i svg { width: 15px; height: 15px; }
.node .nh b { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .nh .cnt { font-size: 11px; color: var(--muted); font-weight: 600; }
.node .nb { padding: 8px 10px; font-size: 12.5px; color: var(--text); display: flex; flex-direction: column; gap: 6px; }
.node .nb .txt { white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; background: var(--panel-2); border-radius: 8px; padding: 7px 9px; }
.node .nb .ph { color: var(--muted); font-style: italic; }
.node .nb .media { font-size: 11.5px; color: var(--info); }
.node .ports { display: flex; flex-direction: column; gap: 4px; padding: 0 0 8px; }
.port-row { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 5px 22px 5px 10px; font-size: 12px; min-height: 26px; }
.port-row.btn-row { margin: 0 10px; padding-right: 12px; border: 1px solid var(--line); border-radius: 7px; justify-content: center; color: var(--info); font-weight: 600; }
.port-row .pc { font-size: 10.5px; color: var(--muted); font-weight: 500; }
.port-row.yes { color: var(--accent); font-weight: 600; }
.port-row.no { color: var(--danger); font-weight: 600; }
.port-row .muted { font-size: 11.5px; }
.port { position: absolute; right: -8px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--panel); border: 2.5px solid var(--muted); cursor: crosshair; z-index: 2; }
.port-row.btn-row .port { right: -19px; }
.port:hover, .port.on { border-color: var(--accent); background: var(--accent); }
.in-port { position: absolute; left: -8px; top: 20px; width: 14px; height: 14px; border-radius: 50%; background: var(--panel); border: 2.5px solid var(--muted); }
.node.drop .in-port { border-color: var(--accent); background: var(--accent); }
.zoom-ctl { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; box-shadow: var(--shadow); align-items: center; }
.zoom-ctl span { font-size: 11.5px; color: var(--muted); width: 42px; text-align: center; }
.b-panel { width: 360px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; flex: none; min-height: 0; }
.b-panel header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.b-panel header h3 { flex: 1; font-size: 15px; }
.b-panel .pb { padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.b-panel .pf { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.item-box { border: 1px solid var(--line); border-radius: 9px; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--panel-2); }
.item-box .ih { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.item-box .ih span { flex: 1; }
.var-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.var-chips button { font-size: 11px; border: 1px dashed var(--line); background: var(--panel); border-radius: 5px; padding: 1px 6px; color: var(--muted); font-family: Consolas, monospace; }
.var-chips button:hover { color: var(--accent); border-color: var(--accent); }
.help-hint { position: absolute; left: 14px; max-width: calc(100% - 210px); bottom: 14px; font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }

/* ---------- Difusiones ---------- */
.bc-row { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.bc-row .top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bc-row h3 { font-size: 15px; flex: 1; }
.progress { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; display: flex; }
.progress i { display: block; height: 100%; }
.bc-stats { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.bc-stats b { color: var(--text); font-size: 14px; margin-right: 3px; }

/* ---------- Modal y avisos ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .42); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: min(620px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.pick { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 9px 11px; }
.pick:hover, .pick.active { border-color: var(--accent); background: var(--accent-soft); }
.pick small { display: block; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { flex-direction: row; align-items: center; gap: 4px; color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; pointer-events: none; }
.toast { background: #1b1f1c; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 90vw; pointer-events: auto; animation: tin .2s ease; }
.toast.error { background: var(--danger); }
.toast.notify { background: var(--warn); cursor: pointer; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .info-pane { position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: var(--shadow); }
  .info-pane.closed { display: none; }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (min-width: 1181px) { .info-pane.closed { display: none; } }
@media (max-width: 900px) {
  .b-panel { position: absolute; right: 0; top: 0; bottom: 0; z-index: 6; box-shadow: var(--shadow); width: min(360px, 100%); }
  .b-panel.empty { display: none; }
}
@media (max-width: 760px) {
  .app { flex-direction: column-reverse; }
  .rail { width: 100%; flex-direction: row; padding: 4px; overflow-x: auto; }
  .logo, .rail-spacer { display: none; }
  .nav { width: 56px; }
  .list-pane { width: 100%; border-right: 0; }
  .chats.in-chat .list-pane { display: none; }
  .chats:not(.in-chat) .conversation { display: none; }
  .chat-head .back { display: grid; }
  .chat-head .pill { display: none; }
  .view.page { padding: 18px 16px 30px; }
  .messages { padding: 12px 10px; }
  .msg { max-width: 88%; }
  .grid2, .grid3, .preset-grid { grid-template-columns: 1fr; }
  .info-pane { width: 100%; }
  .toolbar input[type=search] { width: 100%; }
  .palette { width: 52px; }
}
