:root { color-scheme: light dark; font-family: system-ui, sans-serif; --brand: #1a73e8; accent-color: var(--brand); }
/* --brand: el color principal de la marca del sitio; /marca.css lo cambia (el de la agencia con marca blanca). */
body { margin: 0; padding: 2rem 1rem; border-top: 4px solid var(--brand); }
.brand { display: flex; gap: 0.6rem; align-items: center; }
.brand-logo { height: 2.25rem; width: auto; max-width: 10rem; object-fit: contain; }
/* En el inicio de sesión, el nombre solo si no hay logo (el logo ya lo lleva: su alt es el nombre). */
.brand-logo + .brand-name { display: none; }
/* Marca en el panel de agencia: vista previa, logo e ícono */
label.button { display: inline-block; margin: 0; padding: 0.5rem 1rem; border: 1px solid #8888; border-radius: 4px; cursor: pointer; }
label.button:focus-within { outline: 2px solid var(--brand); }
.brand-preview { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.75rem 1rem; border: 1px solid #8884; border-top: 4px solid var(--brand); border-radius: 6px; }
.brand-preview-chip { padding: 0.15rem 0.7rem; border-radius: 999px; background: var(--brand); color: #fff; }
.brand-images { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.brand-image { display: block; max-width: 100%; max-height: 5rem; object-fit: contain; padding: 0.5rem; border: 1px solid #8884; border-radius: 6px; }
main { max-width: 26rem; margin: 0 auto; }
label { display: block; margin: 0.75rem 0; }
input { display: block; width: 100%; box-sizing: border-box; padding: 0.5rem; margin-top: 0.25rem; font: inherit; }
button { padding: 0.5rem 1rem; font: inherit; cursor: pointer; }
#message { min-height: 1.5em; }
.error { color: #b3261e; }
code, pre { display: block; padding: 0.5rem; background: #8882; overflow-x: auto; }
main.wide { max-width: 52rem; }
header { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; max-width: 52rem; margin: 0 auto 1rem; }
nav { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
textarea, select { display: block; width: 100%; box-sizing: border-box; padding: 0.5rem; margin-top: 0.25rem; font: inherit; }
fieldset { margin: 1rem 0; border: 1px solid #8886; }
label.check { display: flex; gap: 0.5rem; align-items: center; }
label.check input { width: auto; margin: 0; }
table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { text-align: left; padding: 0.4rem; border-bottom: 1px solid #8884; }
button.link { background: none; border: none; padding: 0; color: LinkText; text-decoration: underline; }
.hint { font-size: 0.9em; opacity: 0.8; }
code.inline { display: inline; padding: 0 0.2rem; }
form.inline { display: flex; gap: 0.5rem; align-items: end; }
form.inline label { flex: 1; margin: 0; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
[hidden] { display: none !important; }

/* La pantalla del bot usa todo el ancho para el tablero */
main.wide:has(section[data-view="editor"]:not([hidden])) { max-width: 80rem; }

/* Bandeja de conversaciones: lista a la izquierda, hilo a la derecha (una sola columna en pantallas angostas) */
main.wide:has(section[data-view="conversations"]:not([hidden])) { max-width: 72rem; }
.inbox-filters { flex-wrap: wrap; }
.inbox-filters label { min-width: 9rem; }
.inbox { display: grid; grid-template-columns: minmax(15rem, 22rem) minmax(0, 1fr); gap: 1rem; align-items: start; margin-top: 1rem; }
/* minmax(0, …): la columna se achica aunque adentro haya texto de una línea (la vista previa de cada conversación). */
.inbox > * { min-width: 0; }
@media (max-width: 720px) { .inbox { grid-template-columns: minmax(0, 1fr); } }
.inbox-list { display: flex; flex-direction: column; border: 1px solid #8884; border-radius: 10px; overflow: hidden; }
.inbox-list:empty { display: none; }
.inbox-row { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.6rem 0.75rem; border: 0; border-bottom: 1px solid #8883;
  background: none; color: inherit; text-align: left; }
.inbox-row:last-child { border-bottom: 0; }
.inbox-row:hover, .inbox-row.is-selected { background: #8882; }
.inbox-row-head { display: flex; justify-content: space-between; gap: 0.5rem; }
.inbox-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9em; opacity: 0.85; }
.inbox-thread { border: 1px solid #8884; border-radius: 10px; padding: 0.75rem 1rem; min-height: 12rem; }
.inbox-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; padding-bottom: 0.75rem;
  margin-bottom: 0.75rem; border-bottom: 1px solid #8883; }
.inbox-messages { display: flex; flex-direction: column; gap: 0.5rem; }
.inbox-msg { max-width: 75%; padding: 0.5rem 0.75rem; border-radius: 12px; }
.inbox-msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.inbox-msg.from-user { align-self: flex-start; background: #8882; }
.inbox-msg.from-bot { align-self: flex-end; background: oklch(0.62 0.12 250 / 0.2); }
.inbox-time { display: block; margin-top: 0.2rem; font-size: 0.75em; opacity: 0.7; }
.inbox-tool, .inbox-run { align-self: flex-end; max-width: 75%; font-size: 0.85em; }
.inbox-tool pre, .inbox-tool-call pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 12rem; overflow-y: auto; font-size: 0.9em; }
.inbox-run table { margin: 0.25rem 0 0; font-size: 0.95em; }
/* Atención humana: quién atiende, sin leer, mensajes del equipo y el cuadro para responder */
.inbox-row-head strong { flex: 1; }
.inbox-badge { min-width: 1.4em; padding: 0 0.4em; border-radius: 999px; background: oklch(0.6 0.19 25); color: #fff;
  font-size: 0.8em; font-weight: 600; text-align: center; line-height: 1.5; }
.inbox-tags { display: flex; flex-wrap: wrap; gap: 0.3em; margin: 0.2em 0; }
.inbox-tag { padding: 0 0.5em; border-radius: 999px; font-size: 0.8em; background: color-mix(in oklch, currentColor 12%, transparent); }
.inbox-waiting { font-size: 0.85em; font-weight: 600; color: oklch(0.6 0.15 60); }
.inbox-msg.from-human { align-self: flex-end; background: oklch(0.75 0.13 70 / 0.25); }
.inbox-delivery { display: block; font-size: 0.75em; opacity: 0.8; margin-top: 0.15rem; }
.inbox-delivery.error { color: #b3261e; opacity: 1; }
.inbox-delivery.receipt-read { color: var(--brand); opacity: 1; }
.wa-preview { white-space: pre-wrap; }
.inbox-who { display: block; font-size: 0.75em; font-weight: 600; opacity: 0.8; margin-bottom: 0.15rem; }
.inbox-head .actions { flex-shrink: 0; justify-content: flex-end; }
@media (max-width: 720px) { .inbox-head { flex-wrap: wrap; } .inbox-head .actions { flex-shrink: 1; justify-content: flex-start; } }
.inbox-reply { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid #8883; }
.inbox-reply label { margin: 0 0 0.5rem; }
.inbox-reply .actions { align-items: center; }

/* Tablero: lienzo claro siempre, con su propia paleta (los nodos son blancos) */
.board { position: relative; height: 72vh; min-height: 440px; margin: 1rem 0; border: 1px solid #deded9; border-radius: 12px;
  overflow: hidden; color: #26262a; color-scheme: light; }
.board, .board-modal { --green: oklch(0.58 0.15 150); --red: oklch(0.6 0.19 25); --amber: oklch(0.72 0.15 70); }
.board-canvas { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; cursor: default;
  background-color: #f4f4f2; background-image: radial-gradient(#c9c9c4 1.1px, transparent 1.2px); }
.board-canvas.can-pan, .board-canvas.can-pan .board-node, .board-canvas.can-pan .board-port { cursor: grab; }
.board-canvas.is-panning, .board-canvas.is-panning .board-node { cursor: grabbing; }
.board-marquee { position: absolute; pointer-events: none; border: 1px solid oklch(0.58 0.15 150);
  background: oklch(0.58 0.15 150 / 0.08); border-radius: 2px; }
.board-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.board-edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.board-edge { fill: none; stroke: #b4b4b0; stroke-width: 2; transition: stroke .2s; }
.board-edge.is-sub { stroke-dasharray: 6 5; }
.board-edge.is-ok { stroke: var(--green); }
.board-edge.is-error { stroke: var(--red); }
/* Por donde va el trabajo ahora: ámbar y en movimiento hacia el nodo que corre */
.board-edge.is-live { stroke: var(--amber); stroke-width: 2.5; stroke-dasharray: 6 5; animation: board-flow .6s linear infinite; }
@keyframes board-flow { to { stroke-dashoffset: -11; } }
.board-edge-label { font-size: 13px; fill: #55555c; stroke: #f4f4f2; stroke-width: 4; paint-order: stroke; text-anchor: middle; }
.board-edge-label.is-ok { fill: oklch(0.45 0.14 150); font-weight: 600; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.board-edge-label.is-bad { fill: oklch(0.5 0.19 25); font-weight: 600; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.is-running .board-node-box { animation: board-pulse 1.1s ease-in-out infinite; }
@keyframes board-pulse { 50% { box-shadow: 0 0 0 10px oklch(0.72 0.15 70 / 0.12); } }
@media (prefers-reduced-motion: reduce) {
  .board-edge.is-live, .is-running .board-node-box { animation: none; }
}

.board-node { position: absolute; padding: 0; margin: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.board-node:focus-visible { outline: none; }
.board-node-box { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 0 24px;
  background: #fff; border: 2px solid #d4d4d0; box-shadow: 0 1px 3px #0000000d; transition: border-color .2s, box-shadow .2s; }
.board-node:hover .board-node-box, .board-node:focus-visible .board-node-box {
  box-shadow: 0 0 0 6px oklch(0.58 0.15 150 / 0.18), 0 6px 18px #00000014; }
.shape-trigger .board-node-box { border-radius: 46px 12px 12px 46px; }
.shape-square .board-node-box { border-radius: 14px; padding: 0; }
.shape-agent .board-node-box { border-radius: 10px; justify-content: flex-start; }
.shape-sub .board-node-box { border-radius: 50%; padding: 0; }
.is-success .board-node-box { border-color: var(--green); }
.is-error .board-node-box { border-color: var(--red); }
.is-running .board-node-box { border-color: var(--amber); box-shadow: 0 0 0 6px oklch(0.72 0.15 70 / 0.2); }
.board-badge { position: absolute; right: 12px; bottom: 8px; font-size: 15px; font-weight: 600; line-height: 1; }
.shape-sub .board-badge { right: 44px; bottom: 6px; }
.is-success .board-badge { color: var(--green); }
.is-error .board-badge { color: var(--red); }
.is-running .board-badge { color: var(--amber); }

.board-tag { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; letter-spacing: .04em; padding: 7px 8px; border-radius: 6px; }
.tag-chat { background: oklch(0.95 0.035 50); color: oklch(0.42 0.13 50); }
.tag-agent { background: oklch(0.95 0.035 255); color: oklch(0.42 0.13 255); }
.tag-model { background: oklch(0.95 0.035 300); color: oklch(0.42 0.13 300); }
.tag-memory { background: oklch(0.95 0.035 190); color: oklch(0.42 0.13 190); }
.tag-tool { background: oklch(0.95 0.035 85); color: oklch(0.42 0.13 85); }
.board-node-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; text-align: left; }
.board-node-name { font-size: 17px; font-weight: 500; line-height: 1.3; }
.board-node-kind { font-size: 13px; color: #75757c; }
.board-node-below { position: absolute; width: 160px; transform: translateX(-50%); padding-top: 10px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; text-align: center; pointer-events: none; }
.board-node-problem { font-size: 12px; font-weight: 500; color: oklch(0.52 0.13 70); }
/* Bajo un Modelo, una Memoria o una herramienta (van a 150 px uno de otro): el nombre se parte en líneas, sin montarse. */
.shape-sub .board-node-below { width: 136px; }
.board-node-below .board-node-name { overflow-wrap: anywhere; }

.board-port { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; background: #fff; border: 1.5px solid #9a9aa0; pointer-events: none; }
.board-port.round { width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; }
.board-port.diamond { transform: rotate(45deg); border-radius: 2px; }
.board-port-label { position: absolute; transform: translateX(-50%); font-size: 13px; color: #75757c; white-space: nowrap; pointer-events: none; }
.board-output-label { position: absolute; transform: translateX(-100%); font-size: 12px; color: #55555c; white-space: nowrap;
  pointer-events: none; max-width: 110px; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.has-branches .board-node-title { max-width: 150px; }
.board-name-input { border: 0; border-bottom: 1.5px solid transparent; padding: 2px 0; margin: 0; background: transparent; color: #26262a; width: 100%; }
.board-name-input:hover, .board-name-input:focus { border-bottom-color: var(--green); outline: none; }
/* Puntos: se arrastran para conectar. Mientras se arrastra, los que aceptan se marcan en verde. */
.board-port { pointer-events: auto; cursor: crosshair; }
.board-port::after { content: ""; position: absolute; inset: -8px; }
.board-port:hover, .board-port.is-target { background: oklch(0.94 0.06 150); border-color: var(--green); }
.board-port.is-source { background: var(--green); border-color: var(--green); }
.board-port.is-dim { opacity: 0.35; }
.board-node.is-highlighted .board-node-box { border-color: oklch(0.7 0.15 85); box-shadow: 0 0 0 6px oklch(0.8 0.14 85 / 0.35); }
.board-node.is-selected .board-node-box { border-color: #8a8a90; box-shadow: 0 0 0 6px oklch(0.58 0.15 150 / 0.18), 0 6px 18px #00000014; }
.board-edge-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.board-edge-group.is-hover .board-edge { stroke: var(--red); stroke-width: 2.5; animation: none; }
.board-edge-group.is-hover .board-edge-label { display: none; }
/* La × que aparece al pasar sobre una conexión: un clic la quita */
.board-edge-x { display: none; pointer-events: none; }
.board-edge-group.is-hover .board-edge-x { display: inline; }
.board-edge-x circle { fill: #fff; stroke: var(--red); stroke-width: 1.5; }
.board-edge-x text { fill: var(--red); font-size: 15px; text-anchor: middle; }
.board-arrow path { fill: #b4b4b0; }
.board-arrow.is-ok path { fill: var(--green); }
.board-arrow.is-live path { fill: var(--amber); }
.board-arrow.is-error path, .board-arrow.is-hover path { fill: var(--red); }
/* Marcos: abiertos, un recuadro de color detrás de sus nodos (solo su nombre recibe el puntero); cerrados, una caja */
.board-frame { position: absolute; box-sizing: border-box; border: 1.5px solid color-mix(in oklch, var(--frame) 45%, transparent);
  border-radius: 16px; background: color-mix(in oklch, var(--frame) 7%, transparent); pointer-events: none; }
.board-frame.color-blue { --frame: oklch(0.58 0.14 255); }
.board-frame.color-green { --frame: oklch(0.58 0.14 150); }
.board-frame.color-amber { --frame: oklch(0.66 0.14 70); }
.board-frame.color-purple { --frame: oklch(0.56 0.15 300); }
.board-frame.color-red { --frame: oklch(0.58 0.17 25); }
.board-frame.color-gray { --frame: oklch(0.55 0 0); }
.board-frame-head { position: absolute; left: 10px; top: 8px; right: 10px; display: flex; align-items: center; gap: 6px; min-width: 0;
  pointer-events: auto; cursor: grab; }
.board-frame-head button { flex: none; padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.board-frame-head .board-frame-toggle { width: 26px; height: 26px; border: 1px solid color-mix(in oklch, var(--frame) 40%, transparent); border-radius: 6px;
  background: #fff; color: color-mix(in oklch, var(--frame) 80%, black); font-size: 18px; line-height: 1; }
.board-frame-toggle:hover, .board-frame-color:hover, .board-frame-ungroup:hover { background: color-mix(in oklch, var(--frame) 14%, white); }
.board-frame-head .board-frame-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 6px;
  border-radius: 6px; color: color-mix(in oklch, var(--frame) 75%, black); font-size: 15px; font-weight: 600; text-align: left; }
.board-frame-head .board-frame-name:not(:disabled):hover { background: color-mix(in oklch, var(--frame) 14%, white); cursor: text; }
.board-frame-head .board-frame-name:disabled { cursor: grab; }
.board-frame-input { flex: 1; min-width: 60px; margin: 0; padding: 2px 6px; border: 1px solid var(--frame); border-radius: 6px; background: #fff;
  color: #26262a; font: inherit; font-size: 15px; font-weight: 600; }
.board-frame-count { flex: none; font-size: 12px; color: #75757c; white-space: nowrap; }
.board-frame-head .board-frame-color { width: 26px; height: 26px; margin-left: auto; border-radius: 6px; }
.board-frame-color::after { content: ""; display: block; width: 12px; height: 12px; margin: auto; border-radius: 50%; background: var(--frame); }
.board-frame-head .board-frame-ungroup { width: 26px; height: 26px; border-radius: 6px; color: #75757c; font-size: 17px; line-height: 1; }
/* Cerrado: una caja blanca con el borde del color del marco */
.board-frame.is-collapsed { z-index: 1; pointer-events: auto; cursor: grab; background: #fff; border: 2px solid var(--frame);
  border-radius: 14px; box-shadow: 0 1px 3px #0000000d; }
.board-frame.is-collapsed:hover { box-shadow: 0 0 0 6px color-mix(in oklch, var(--frame) 16%, transparent), 0 6px 18px #00000014; }
.board-frame.is-collapsed .board-frame-head { right: 8px; }
.board-frame-tags { position: absolute; left: 14px; right: 14px; top: 44px; display: flex; gap: 4px; overflow: hidden; }
.board-frame-tags .board-tag { padding: 4px 6px; font-size: 11px; }
.board-frame-summary { position: absolute; left: 16px; bottom: 9px; font-size: 12px; color: #75757c; white-space: nowrap; }
.board-frame.is-success { border-color: var(--green); }
.board-frame.is-error { border-color: var(--red); }
.board-frame.is-running { border-color: var(--amber); box-shadow: 0 0 0 6px oklch(0.72 0.15 70 / 0.2); }
.board-frame.is-success .board-badge { color: var(--green); }
.board-frame.is-error .board-badge { color: var(--red); }
.board-frame.is-running .board-badge { color: var(--amber); }
.board-frame.is-highlighted { box-shadow: 0 0 0 6px oklch(0.8 0.14 85 / 0.35); }
.board-port.is-static { pointer-events: none; }
/* Barra sobre el nodo bajo el puntero: configurar, ejecutar, duplicar, eliminar */
.board-node-bar { position: absolute; transform: translate(-50%, -100%); z-index: 2; display: flex; gap: 2px; padding: 3px; background: #fff;
  border: 1px solid #e2e2de; border-radius: 8px; box-shadow: 0 4px 14px #00000014; }
.board-node-bar button { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 6px; background: none; color: #3a3a40; font-size: 14px; }
.board-node-bar button:hover, .board-node-bar button:focus-visible { background: #f0f0ec; outline: none; }
.board-node-bar button.is-danger { color: var(--red); }
.board-link { fill: none; stroke: var(--green); stroke-width: 2; stroke-dasharray: 5 5; pointer-events: none; }
.board-add { position: absolute; right: 12px; top: 10px; height: 36px; padding: 0 14px; border-radius: 8px; background: #fff;
  border: 1px solid #deded9; color: #26262a; font-weight: 500; }
.board-add:hover { background: #f0f0ec; }
.board-toast { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); max-width: min(460px, 90%); padding: 10px 16px;
  background: #26262a; color: #fff; border-radius: 8px; font-size: 14px; text-align: center; box-shadow: 0 8px 24px #0000002e; z-index: 5; }
/* Menú del clic derecho */
.board-menu { position: absolute; z-index: 25; min-width: 250px; padding: 6px; box-sizing: border-box; background: #fff; color: #26262a;
  border: 1px solid #e2e2de; border-radius: 12px; box-shadow: 0 12px 32px #0000001f, 0 2px 6px #0000000f; }
.board-menu button { display: flex; align-items: center; justify-content: space-between; gap: 28px; width: 100%; margin: 0; padding: 8px 10px;
  border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; font-size: 15px; text-align: left; }
.board-menu button:not(:disabled):hover, .board-menu button:focus-visible { background: #f0f0ec; outline: none; }
.board-menu button:disabled { color: #b4b4b0; cursor: default; }
.board-menu-keys { display: flex; gap: 4px; }
.board-menu kbd { min-width: 18px; padding: 2px 6px; border: 1px solid #deded9; border-radius: 5px; background: #fafaf8; color: #55555c;
  font-family: inherit; font-size: 12px; text-align: center; }
.board-menu button:disabled kbd { color: #c4c4c0; border-color: #ededea; }
.board-menu hr { margin: 6px 4px; border: 0; border-top: 1px solid #ededea; }

/* Panel para agregar nodos */
.board-panel { position: absolute; top: 0; right: 0; bottom: 0; width: 340px; max-width: 90%; z-index: 6; display: flex; flex-direction: column;
  gap: 10px; padding: 14px; box-sizing: border-box; background: #fff; border-left: 1px solid #e2e2de; box-shadow: -12px 0 32px #00000014; }
.board-panel-head { display: flex; justify-content: space-between; align-items: center; font-size: 17px; }
.board-panel-search { padding: 10px 12px; border: 1px solid #deded9; border-radius: 8px; background: #fafaf8; color: #26262a; margin: 0; }
.board-panel-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.board-panel-title { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: #75757c; padding: 4px 6px; }
.board-panel-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: none;
  color: #26262a; text-align: left; font: inherit; }
.board-panel-item:hover, .board-panel-item:focus-visible { background: #f0f0ec; }
.board-panel-item .board-tag { min-width: 44px; text-align: center; }
.board-panel-text { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.board-panel-text span { font-size: 13px; color: #6a6a70; }
/* Listas dentro del modal (categorías del clasificador) */
.board-collection { display: flex; flex-direction: column; gap: 10px; margin: 1rem 0; }
.board-collection-item { border: 1px solid #e2e2de; border-radius: 12px; padding: 4px 14px 2px; }
.board-collection-head { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px;
  font-weight: 600; color: #55555c; }
.board-collection .board-field { margin: 0.6rem 0; }
/* Varias opciones a la vez (días de la semana de un Horario) */
.board-multi { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-weight: 400; }
.board-link-button { border: 0; background: none; padding: 2px 6px; color: oklch(0.5 0.19 25); font-size: 13px; }
.board-secondary { align-self: flex-start; border: 1px solid #deded9; border-radius: 8px; padding: 0.45rem 0.9rem; background: #fff; color: #26262a; }
.board-plus { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; padding: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; background: #fff; color: #55555c; border: 1px solid #d4d4d0; font-size: 17px; line-height: 1; }
.board-plus:hover { background: oklch(0.92 0.05 150); color: oklch(0.35 0.12 150); border-color: oklch(0.75 0.1 150); }

.board-saved { position: absolute; left: 12px; top: 12px; display: flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px;
  background: #e9e9e5; font-size: 12px; color: #6a6a70; pointer-events: none; }
.board-saved::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.board-saved.is-dirty::before { background: var(--amber); }
.board-tools { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; }
.board-controls { display: flex; background: #fff; border: 1px solid #deded9; border-radius: 8px; overflow: hidden; }
.board-controls button { min-width: 40px; height: 40px; padding: 0 10px; border: 0; background: none; color: #3a3a40; font-size: 17px; }
.board-controls button:not(:disabled):hover { background: #f0f0ec; }
.board-controls button:disabled { color: #c4c4c0; cursor: default; }
/* "?": los atajos del teclado (en pantallas táctiles no sirven y no aparece) */
.board-help-corner { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 4; }
.board-help-button { width: 40px; height: 40px; padding: 0; border: 1px solid #deded9; border-radius: 8px; background: #fff; color: #3a3a40; font-weight: 500; }
.board-help-button:hover { background: #f0f0ec; }
.board-help { width: 290px; max-height: 60vh; overflow: auto; padding: 14px 16px; box-sizing: border-box; display: flex; flex-direction: column; gap: 8px;
  background: #fff; border: 1px solid #deded9; border-radius: 10px; box-shadow: 0 8px 24px #00000014; font-size: 13px; }
.board-help-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #55555c; }
.board-help kbd { min-width: 18px; padding: 2px 6px; border: 1px solid #deded9; border-radius: 5px; background: #fafaf8; color: #3a3a40;
  font-family: inherit; font-size: 11px; text-align: center; white-space: nowrap; }
@media (pointer: coarse) { .board-help-corner { display: none; } }
.board-controls .board-zoom { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; color: #55555c; }
.board-bottom { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 8px; }
.board-chat-button { padding: 10px 22px; border-radius: 8px;
  background: #fff; border: 1px solid #deded9; color: #26262a; font-weight: 500; white-space: nowrap; }
.board-chat-button:hover { background: #f0f0ec; }
@media (max-width: 600px) {
  .board-bottom { left: auto; right: 12px; bottom: 64px; transform: none; }
  .board-chat-button { padding: 10px 14px; }
}

/* Modal de cada nodo */
.board-modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(28, 28, 33, .42); color: #26262a; color-scheme: light; }
.board-dialog { width: min(640px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border-radius: 18px; box-shadow: 0 24px 64px #00000038; }
.board-dialog-head { display: flex; align-items: center; gap: 14px; padding: 20px 22px 16px; border-bottom: 1px solid #ededea; }
.board-dialog-head .board-node-title { flex: 1; }
.board-dialog-title { font-size: 20px; font-weight: 600; }
.board-dialog-body { flex: 1; overflow: auto; padding: 8px 22px 18px; }
.board-dialog-body .board-field { margin: 1rem 0; font-size: 14px; font-weight: 500; }
.board-dialog-body input:not([type=checkbox]), .board-dialog-body select, .board-dialog-body textarea {
  padding: 10px 12px; border: 1px solid #deded9; border-radius: 10px; background: #fafaf8; color: #26262a; font-weight: 400; }
.board-dialog-body .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.board-dialog-body .hint { display: block; margin-top: 6px; font-weight: 400; color: #75757c; }
/* Pestañas Parámetros · Ajustes */
.board-tabs { display: flex; gap: 22px; margin: 6px 0 4px; border-bottom: 1px solid #ededea; }
.board-tabs button { margin: 0 0 -1px; padding: 6px 0 10px; border: 0; border-bottom: 2px solid transparent; background: none; color: #75757c;
  font: inherit; font-size: 14px; font-weight: 500; }
.board-tabs button.is-active { color: #26262a; border-bottom-color: #26262a; }
/* Sí/no del tablero: interruptor a la derecha, en una fila con borde */
.board-dialog .board-toggle { justify-content: space-between; flex-direction: row-reverse; margin: 1rem 0 0; padding: 12px 14px;
  border: 1px solid #e2e2de; border-radius: 12px; font-size: 14px; font-weight: 500; cursor: pointer; }
.board-dialog .board-toggle + .hint { margin: 6px 2px 1rem; }
.board-dialog input.switch { appearance: none; position: relative; flex: none; width: 38px; height: 22px; margin: 0; border-radius: 11px;
  background: #d4d4d0; cursor: pointer; transition: background .15s; }
.board-dialog input.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px #00000033; transition: left .15s; }
.board-dialog input.switch:checked { background: var(--green); }
.board-dialog input.switch:checked::after { left: 18px; }
.board-dialog input.switch:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.board-dialog input.switch:disabled { opacity: .5; cursor: default; }
.board-dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 22px; border-top: 1px solid #ededea; }
.board-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #8a8a90; }
.board-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #c4c4c0; }
.board-status.is-success { color: oklch(0.45 0.13 150); }
.board-status.is-success::before { background: var(--green); }
.board-status.is-error { color: oklch(0.5 0.19 25); }
.board-status.is-error::before { background: var(--red); }
.board-status.is-running::before { background: var(--amber); }
.board-close { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: none; color: #6a6a70; font-size: 21px; }
.board-close:hover { background: #f0f0ec; }
.board-primary { border: 0; border-radius: 8px; padding: 0.55rem 1.1rem; background: oklch(0.55 0.15 150); color: #fff; font-weight: 500; }
.board-primary:hover { background: oklch(0.5 0.15 150); }
.board-danger { border: 1px solid currentColor; border-radius: 8px; padding: 0.5rem 1rem; background: none; color: oklch(0.5 0.19 25); }

/* Chat de prueba: panel lateral que abre "Abrir chat" en el tablero */
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin: 1.5rem 0 0.5rem; font-size: 1.15em; }
#test-chat, #widget-panel, #assistant-panel, #quick-replies-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 20; width: 380px; max-width: 92vw; overflow: auto;
  padding: 0 1.25rem 1rem; box-sizing: border-box; background: Canvas; border-left: 1px solid #8886; box-shadow: -12px 0 32px #00000014; }
#test-chat:not(.is-open), #widget-panel:not(.is-open), #assistant-panel:not(.is-open), #quick-replies-panel:not(.is-open) { display: none; }
/* Respuestas rápidas: panel para administrarlas y, en la respuesta de la bandeja, sugerencias con "/" y buscador */
#quick-replies-panel { width: 460px; }
#quick-reply-form label { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.6rem 0; }
#quick-reply-form textarea, #quick-reply-form input { width: 100%; box-sizing: border-box; }
.quick-row { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid #8883; }
.quick-excerpt { display: block; margin: 0.2rem 0 0; font-size: 0.9em; color: #6b6b70; white-space: pre-wrap; overflow-wrap: anywhere; }
.quick-vars { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; font-size: 0.9em; }
.quick-var { padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.9em; }
.quick-preview { padding: 0.6rem 0.8rem; border-radius: 10px; background: #8881; white-space: pre-wrap; overflow-wrap: anywhere; }
.quick-suggest, .quick-picker { border: 1px solid #8885; border-radius: 10px; background: Canvas; box-shadow: 0 8px 24px #0002; padding: 0.3rem; margin: 0.3rem 0; max-height: 18rem; overflow: auto; }
.quick-search { width: 100%; box-sizing: border-box; margin-bottom: 0.3rem; }
.quick-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 0.45rem 0.6rem; border-radius: 8px; cursor: pointer; color: inherit; font: inherit; }
.quick-item:hover, .quick-item.is-active { background: oklch(0.58 0.15 150 / 0.12); }
/* Asistente del tablero: la conversación, los cambios de cada respuesta y «Deshacer» */
#assistant-panel textarea { width: 100%; box-sizing: border-box; }
.assistant-msg { margin: 0.75rem 0; padding: 0.6rem 0.75rem; border-radius: 10px; background: #8881; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-msg.from-user { background: oklch(0.58 0.15 150 / 0.12); }
.assistant-msg ul { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.9em; white-space: normal; }
.assistant-msg .actions { margin-top: 0.4rem; }
/* Widget web: vista previa (el marco aislado, del tamaño que pide el diseño, en la esquina) y código para el sitio */
#widget-panel { width: 480px; }
.widget-stage { position: relative; height: 620px; max-height: 70vh; border: 1px dashed #8886; border-radius: 8px; overflow: hidden;
  background: repeating-linear-gradient(45deg, #8881 0 10px, transparent 10px 20px); }
.widget-stage iframe { position: absolute; bottom: 0; right: 0; width: 0; height: 0; max-width: 100%; max-height: 100%; border: 0; background: transparent; }
.widget-stage.is-left iframe { right: auto; left: 0; }
#widget-code, #widget-link { width: 100%; box-sizing: border-box; font-size: 0.85em; }
input[type="color"] { width: 3rem; height: 2rem; padding: 0; }
.drawer-close { display: inline-block; padding: 0 0.6rem; font-size: 1.3em; border: 0; background: none; color: inherit; }
#test-chat form.inline { flex-wrap: wrap; }
#test-chat form.inline label { flex-basis: 100%; }
#test-chat table { table-layout: fixed; font-size: 0.9em; }
#test-chat td { overflow-wrap: anywhere; vertical-align: top; }
#test-chat .chat-attach { font-size: 0.9em; }
#test-chat .chat-attach input { display: block; max-width: 100%; margin-top: 0.25em; }
.chat-files { display: flex; flex-wrap: wrap; gap: 0.4em; margin: 0.25em 0 0.5em; }
.chat-thumb { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid #8886; }

/* Base de conocimiento: pestañas para agregar fuentes, renglones de preguntas y resultados de "Probar búsqueda" */
.knowledge-tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.knowledge-tabs button { border-radius: 8px 8px 0 0; border-bottom-width: 2px; }
.knowledge-tabs button.is-active { border-bottom-color: oklch(0.55 0.15 150); font-weight: 600; }
.faq-row { display: grid; grid-template-columns: 1fr 2fr; gap: 0.75rem; margin-bottom: 0.75rem; }
.faq-row label, #source-text label, #source-file label { display: flex; flex-direction: column; gap: 0.25rem; }
.faq-row input, .faq-row textarea, #source-text textarea { width: 100%; box-sizing: border-box; }
@media (max-width: 600px) { .faq-row { grid-template-columns: 1fr; } }
.knowledge-result { margin: 0.75rem 0; padding: 0.6rem 0.8rem; border-left: 3px solid oklch(0.55 0.15 150); background: #8881; border-radius: 0 8px 8px 0; }
.knowledge-result p { margin: 0.2rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#source-rows td { overflow-wrap: anywhere; }

/* Formulario de credenciales: mismos campos que el modal del tablero (campos.js) */
.credential-form { margin-top: 2rem; }
.credential-form .board-field { margin: 0.75rem 0; }
.credential-form .hint { display: block; margin-top: 0.25rem; }
.credential-form .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.9em; }
.credential-form .board-collection-item { border-color: #8886; }
.credential-form .board-secondary { background: none; color: inherit; border-color: #8886; }

/* Credencial que se conecta con una cuenta (OAuth) */
.oauth-box { margin: 0.75rem 0; padding: 0.75rem 1rem; border: 1px solid #8886; border-radius: 10px; }
.oauth-box p { margin: 0.25rem 0; }
.oauth-box ul { margin: 0.5rem 0 0; padding-left: 1.2rem; font-size: 0.85em; word-break: break-all; }
.oauth-box .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* Apps en el tablero (Gmail) y el panel para agregarlas */
.tag-app { background: oklch(0.95 0.035 145); color: oklch(0.42 0.13 145); }
.board-panel-more { margin-left: auto; font-size: 18px; color: #9a9aa0; }
.board-panel-back { margin: 0 0 8px; padding: 4px 0; color: inherit; }
.board-add-option { align-self: flex-start; width: auto; }

/* Modal del nodo en tres columnas: Entrada · Parámetros · Salida (datos de la última prueba) */
.board-dialog.is-wide { width: min(1440px, 100%); height: calc(100vh - 48px); }
.board-dialog-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 460px) minmax(0, 1fr); }
.board-dialog-main.no-input { grid-template-columns: minmax(360px, 520px) minmax(0, 1fr); }
.board-dialog-main .board-dialog-body { border-inline: 1px solid #ededea; padding-top: 14px; }
.board-data { display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 14px 16px; background: #f7f7f5; }
.board-data-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.board-data-title { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: #75757c; }
.board-data-tabs { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: #ebebe7; }
.board-data-tabs button { border: 0; border-radius: 7px; padding: 4px 11px; background: none; color: #4a4a50; font-size: 13px; }
.board-data-tabs button.is-active { background: #fff; color: #26262a; box-shadow: 0 1px 2px #0000001f; }
.board-data-meta { margin: 10px 0 8px; font-size: 13px; color: #6a6a70; overflow-wrap: anywhere; }
.board-data-meta strong { color: #26262a; font-weight: 600; }
.board-data-body { flex: 1; min-height: 0; overflow: auto; border: 1px solid #e4e4df; border-radius: 10px; background: #fff; }
.board-data-empty, .board-data-error { margin: 0; padding: 16px; font-size: 14px; color: #75757c; }
.board-data-error { color: var(--red); }
.board-data-tip { margin: 8px 0 0; font-size: 12px; color: #8a8a90; }
.board-schema { list-style: none; margin: 0; padding: 6px 10px; }
.board-schema .board-schema { padding: 0 0 0 18px; border-left: 1px dashed #dcdcd6; margin-left: 9px; }
.board-schema-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; font-size: 13px; }
.board-type { flex: none; min-width: 26px; text-align: center; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11px; color: #75757c; }
.board-data-key { flex: none; padding: 2px 8px; border-radius: 6px; background: #efefeb; font-weight: 600; color: #26262a; }
.board-data-key.is-draggable { cursor: grab; }
.board-data-key.is-draggable:hover { background: oklch(0.93 0.05 150); }
.board-data-key.is-draggable:active { cursor: grabbing; }
.board-data-value { min-width: 0; color: #5a5a60; overflow-wrap: anywhere; white-space: pre-wrap; }
.board-data-table { width: max-content; min-width: 100%; margin: 0; font-size: 13px; }
.board-data-table th, .board-data-table td { padding: 8px 10px; vertical-align: top; max-width: 360px; overflow-wrap: anywhere; white-space: pre-wrap; }
.board-data-table th { position: sticky; top: 0; background: #fafaf8; }
.board-data-json { margin: 0; padding: 12px; background: none; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* Mientras se arrastra un dato, se marcan los campos que lo aceptan */
.board-modal.is-dragging-data .accepts-data { outline: 2px dashed var(--green); outline-offset: 2px; background: oklch(0.98 0.02 150); }
@media (max-width: 960px) {
  .board-dialog-main, .board-dialog-main.no-input { display: flex; flex-direction: column; overflow: auto; }
  .board-dialog-main .board-dialog-body { order: -1; overflow: visible; border-inline: 0; }
  .board-data { flex: none; }
  .board-data-body { max-height: 45vh; }
}

/* Dirección de un Webhook o Formulario en el modal del nodo */
.board-trigger-link { margin: 0.5rem 0 1rem; padding: 0.6rem 0.75rem; border: 1px solid #8884; border-radius: 8px; background: #8881; }
.board-trigger-link label { margin: 0 0 0.4rem; }
.board-link-input { font-family: ui-monospace, monospace; font-size: 0.85em; }

/* Panel de agencia y administración: en pantallas angostas las tablas dejan fuera las columnas secundarias. */
@media (max-width: 600px) {
  .wide-only { display: none; }
}
.admin-agencies input[type=number] { width: 6rem; }
.admin-agencies form.inline { align-items: center; }
@media (max-width: 600px) { .admin-agencies input[type=number] { width: 4.5rem; } }
