/* ===== Smartiza brand system ===== */
@font-face { font-family: 'Delight'; src: url('/assets/fonts/Delight-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Delight'; src: url('/assets/fonts/Delight-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Delight'; src: url('/assets/fonts/Delight-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Delight'; src: url('/assets/fonts/Delight-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --deep-teal: #00656F;
  --deep-teal-dark: #004b53;
  --deep-teal-darker: #003b42;
  --mist-blue: #8ECAD0;
  --mist-soft: #cfe7ea;
  --ivory: #EAE4D8;
  --onyx: #272727;
  --cloud: #F8F7F3;
  --white: #ffffff;
  --danger: #b4443c;
  --ok: #2e7d4f;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 75, 83, .12);
  --font: 'Delight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--onyx);
  background: var(--cloud);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: var(--font); font-size: 1rem; color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }

/* ===== Login ===== */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(142, 202, 208, .35), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(142, 202, 208, .25), transparent 55%),
    linear-gradient(160deg, var(--deep-teal) 0%, var(--deep-teal-dark) 70%, var(--deep-teal-darker) 100%);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--cloud);
  border-radius: 26px;
  padding: 44px 40px 36px;
  box-shadow: 0 24px 70px rgba(0, 30, 34, .45);
}
.login-card .logo { display: block; width: 210px; margin: 0 auto 8px; }
.login-card h1 { font-size: 1.32rem; font-weight: 600; text-align: center; color: var(--deep-teal); margin: 14px 0 4px; }
.login-card p.sub { text-align: center; color: #6b6b66; font-size: .95rem; margin-bottom: 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .85rem; font-weight: 600; color: var(--deep-teal); margin-bottom: 6px; letter-spacing: .02em; }
.field input, .field textarea, .field select {
  width: 100%; padding: 13px 16px;
  border: 1.5px solid #d8d4c9; border-radius: 12px;
  background: var(--white); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--deep-teal); box-shadow: 0 0 0 3px rgba(0, 101, 111, .12);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; border: none; border-radius: 999px;
  background: var(--deep-teal); color: var(--cloud);
  font-weight: 600; font-size: 1rem; cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--deep-teal-dark); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--deep-teal); border: 1.5px solid var(--deep-teal); }
.btn.ghost:hover { background: rgba(0, 101, 111, .07); }
.btn.small { padding: 8px 14px; font-size: .85rem; }
.btn.danger { background: transparent; border: 1.5px solid var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(180, 68, 60, .08); }
.error-msg { background: #fbeae9; color: var(--danger); border-radius: 10px; padding: 10px 14px; font-size: .9rem; margin-bottom: 14px; }
.login-foot { text-align: center; margin-top: 22px; color: rgba(248,247,243,.75); font-size: .85rem; }
.login-screen .login-foot { position: absolute; bottom: 20px; left: 0; right: 0; }

/* ===== Chat (portal cliente) ===== */
.chat-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--cloud); }
.chat-header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  background: var(--deep-teal);
  color: var(--cloud);
  box-shadow: 0 2px 14px rgba(0, 59, 66, .25);
  z-index: 5;
}
.chat-header .iso { width: 40px; height: 40px; object-fit: contain; }
.chat-header .who { flex: 1; min-width: 0; }
.chat-header .who .agent-name { font-weight: 600; font-size: 1.05rem; line-height: 1.2; }
.chat-header .who .agent-sub { font-size: .8rem; opacity: .8; display: flex; align-items: center; gap: 6px; }
.dot-online { width: 8px; height: 8px; border-radius: 50%; background: #7be0a2; display: inline-block; }
.chat-header .actions { display: flex; gap: 8px; align-items: center; }
.chip {
  font-size: .78rem; font-weight: 600; padding: 5px 12px; border-radius: 999px;
  background: rgba(248, 247, 243, .16); color: var(--cloud); letter-spacing: .02em;
}
.chip.approved { background: rgba(123, 224, 162, .25); color: #d9f5e4; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(248,247,243,.14); color: var(--cloud);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
}
.icon-btn:hover { background: rgba(248,247,243,.26); }

.chat-scroll { flex: 1; overflow-y: auto; padding: 26px 18px 12px; }
.chat-inner { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.day-sep { text-align: center; font-size: .75rem; color: #9a978e; margin: 10px 0 2px; font-weight: 500; }
.msg { max-width: 78%; padding: 12px 16px; border-radius: var(--radius); line-height: 1.45; font-size: .97rem; word-wrap: break-word; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--deep-teal); color: var(--cloud); border-bottom-right-radius: 6px; }
.msg.agent { align-self: flex-start; background: var(--white); border: 1px solid #e7e3d8; border-bottom-left-radius: 6px; }
.msg img.attach { border-radius: 12px; display: block; max-height: 280px; margin-bottom: 6px; }
.msg audio { width: 240px; max-width: 100%; display: block; margin-bottom: 4px; }
.msg .time { display: block; font-size: .68rem; opacity: .6; margin-top: 5px; text-align: right; }
.msg.typing { display: inline-flex; gap: 5px; align-items: center; padding: 16px 18px; }
.msg.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--mist-blue); animation: bounce 1.2s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; }
.msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.welcome-card {
  align-self: center; text-align: center; background: var(--white);
  border: 1px solid #e7e3d8; border-radius: 22px; padding: 30px 34px; max-width: 480px;
  box-shadow: var(--shadow);
}
.welcome-card img { width: 54px; margin-bottom: 12px; }
.welcome-card h2 { color: var(--deep-teal); font-size: 1.15rem; font-weight: 600; margin-bottom: 8px; }
.welcome-card p { color: #6b6b66; font-size: .92rem; line-height: 1.5; }

.chat-inputbar { padding: 12px 18px 18px; background: linear-gradient(transparent, var(--cloud) 40%); }
.inputbar-inner {
  max-width: 780px; margin: 0 auto;
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--white); border: 1.5px solid #e2ddd0; border-radius: 26px;
  padding: 8px 10px 8px 18px;
  box-shadow: var(--shadow);
}
.inputbar-inner textarea {
  flex: 1; border: none; outline: none; resize: none;
  max-height: 120px; padding: 9px 0; background: transparent; line-height: 1.4;
}
.in-btn {
  width: 42px; height: 42px; min-width: 42px; border-radius: 50%;
  border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--deep-teal); transition: background .15s, color .15s;
}
.in-btn:hover { background: rgba(0,101,111,.08); }
.in-btn.send { background: var(--deep-teal); color: var(--cloud); }
.in-btn.send:hover { background: var(--deep-teal-dark); }
.in-btn.rec { background: var(--danger); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(180,68,60,.45);} 70% { box-shadow: 0 0 0 12px rgba(180,68,60,0);} 100% { box-shadow: 0 0 0 0 rgba(180,68,60,0);} }
.preview-strip { max-width: 780px; margin: 0 auto 8px; display: flex; gap: 10px; }
.preview-item { position: relative; background: var(--white); border: 1px solid #e2ddd0; border-radius: 14px; padding: 8px; display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.preview-item img { height: 54px; border-radius: 8px; }
.preview-item .x {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--onyx); color: #fff; border: none; cursor: pointer; font-size: .75rem; line-height: 1;
}
.rec-hint { max-width: 780px; margin: 0 auto 8px; font-size: .85rem; color: var(--danger); font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* ===== Admin ===== */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; min-width: 240px; background: var(--deep-teal);
  color: var(--cloud); display: flex; flex-direction: column;
  padding: 26px 18px;
}
.sidebar .logo { width: 160px; margin: 0 auto 6px; }
.sidebar .tag { text-align: center; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; opacity: .7; margin-bottom: 30px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px; border: none; background: transparent;
  color: rgba(248,247,243,.82); font-size: .95rem; font-weight: 500; cursor: pointer;
  text-align: left; width: 100%; margin-bottom: 4px; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(248,247,243,.1); color: var(--cloud); }
.nav-item.active { background: var(--cloud); color: var(--deep-teal); font-weight: 600; }
.sidebar .spacer { flex: 1; }
.sidebar .whoami { font-size: .8rem; opacity: .75; padding: 0 14px 10px; }

.admin-main { flex: 1; padding: 34px 40px; max-width: 1200px; }
.admin-main h1 { font-size: 1.5rem; font-weight: 700; color: var(--deep-teal); margin-bottom: 4px; }
.admin-main .subtitle { color: #7b786e; margin-bottom: 28px; font-size: .95rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.card {
  background: var(--white); border: 1px solid #e9e5da; border-radius: var(--radius);
  padding: 20px 22px; box-shadow: 0 4px 16px rgba(0,75,83,.05);
}
.card .k { font-size: .8rem; font-weight: 600; color: #8a8779; text-transform: uppercase; letter-spacing: .08em; }
.card .v { font-size: 2rem; font-weight: 700; color: var(--deep-teal); margin-top: 6px; }
.card .v small { font-size: .95rem; color: #8a8779; font-weight: 500; }

.panel { background: var(--white); border: 1px solid #e9e5da; border-radius: var(--radius); padding: 24px; margin-bottom: 24px; box-shadow: 0 4px 16px rgba(0,75,83,.05); }
.panel h2 { font-size: 1.05rem; font-weight: 600; color: var(--deep-teal); margin-bottom: 16px; }

.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 150px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-col .bar { width: 100%; max-width: 46px; background: linear-gradient(180deg, var(--mist-blue), var(--deep-teal)); border-radius: 8px 8px 4px 4px; min-height: 4px; transition: height .4s; }
.bar-col .lbl { font-size: .72rem; color: #8a8779; }
.bar-col .num { font-size: .78rem; font-weight: 700; color: var(--deep-teal); }

table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: #8a8779; padding: 10px 12px; border-bottom: 1.5px solid #eae6db; }
.tbl td { padding: 13px 12px; border-bottom: 1px solid #f0ede4; vertical-align: middle; }
.tbl tr:hover td { background: #faf9f5; }
.status-pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.status-pill.testing { background: #fdf3d7; color: #8a6d1a; }
.status-pill.approved { background: #ddf2e4; color: var(--ok); }
.status-pill.installed { background: #d9ecee; color: var(--deep-teal); }
.status-pill.off { background: #f3e2e0; color: var(--danger); }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }

/* Modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(20, 40, 43, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--cloud); border-radius: 22px; padding: 30px;
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,30,34,.5);
}
.modal h2 { color: var(--deep-teal); font-size: 1.2rem; margin-bottom: 20px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.cred-box {
  background: var(--deep-teal); color: var(--cloud); border-radius: 16px;
  padding: 22px; text-align: center; margin: 10px 0 4px;
}
.cred-box .lbl { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; opacity: .75; }
.cred-box .val { font-size: 1.5rem; font-weight: 700; letter-spacing: .04em; margin: 4px 0 14px; user-select: all; }
.cred-note { font-size: .85rem; color: #8a8779; text-align: center; margin-top: 10px; }

/* Conversación (vista admin) */
.convo-view { max-height: 480px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px; }

/* Conexión n8n */
.webhook-box {
  background: #eef4f4; border: 1.5px dashed var(--mist-blue); border-radius: 14px;
  padding: 16px 18px; margin: 6px 0 4px;
}
.webhook-box h3 { color: var(--deep-teal); font-size: .95rem; margin-bottom: 4px; }
.webhook-box > p { font-size: .85rem; color: #6b6b66; margin-bottom: 12px; }
.webhook-box summary { cursor: pointer; font-size: .85rem; color: var(--deep-teal); font-weight: 600; }
.wh-doc { font-size: .83rem; color: #55534c; margin-top: 8px; }
.wh-doc pre {
  background: var(--onyx); color: #d8efe9; border-radius: 10px; padding: 12px 14px;
  overflow-x: auto; font-size: .78rem; line-height: 1.5; margin: 8px 0;
}
.wh-doc p { margin: 6px 0; }
.n8n-tag {
  display: inline-block; background: #e3f0ec; color: var(--deep-teal);
  border: 1px solid var(--mist-blue); border-radius: 999px;
  font-size: .7rem; font-weight: 700; padding: 2px 8px; margin-left: 6px; vertical-align: middle;
}

/* ===== Ejecuciones: grafo del flujo del agente ===== */
.ex-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.ex-controls select { padding: 9px 12px; border: 1.5px solid #d8d4c9; border-radius: 10px; background: var(--white); font-size: .9rem; }
.notice { background: #fdf3d7; color: #8a6d1a; border-radius: 12px; padding: 14px 16px; font-size: .9rem; margin-bottom: 18px; line-height: 1.45; }
.notice code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }
.graph-panel { padding: 18px; }
.graph-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.graph-head h2 { margin: 0; flex: 1; min-width: 200px; }
.graph-legend { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: #eef4f4; color: #3b4a4c; }
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chip b { font-weight: 800; }
.btn.tiny { padding: 5px 10px; font-size: .75rem; }
.graph-wrap { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 14px; }
.fg { position: relative; height: 540px; border-radius: 16px; overflow: hidden; background: #0b1220; }
.fg-canvas { position: absolute; inset: 0; }
.fg-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fg-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  color: #e6f4f1; background: rgba(11, 18, 32, .78); border: 1px solid rgba(142, 202, 208, .4); white-space: nowrap;
  transition: background .15s;
}
.fg-label small { font-weight: 500; opacity: .75; margin-left: 6px; }
.fg-label.error { border-color: #ff6b81; color: #ffd3da; }
.fg-label.warn { border-color: #f6c344; color: #fff0c2; }
.fg-label.selected, .fg-label:hover { background: #8ECAD0; color: #0b1220; }
.fg-label.selected small, .fg-label:hover small { opacity: .9; }
.fg-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #8ECAD0; font-size: .9rem; text-align: center; padding: 30px; }
.graph-side { background: #0f1a2b; color: #dce9ec; border-radius: 16px; padding: 16px; height: 540px; overflow: auto; font-size: .86rem; line-height: 1.45; }
.graph-side h3 { color: #8ECAD0; font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; margin: 14px 0 8px; }
.graph-side h3:first-child { margin-top: 0; }
.graph-side .kv { display: grid; grid-template-columns: 92px 1fr; gap: 4px 10px; align-items: start; }
.graph-side .kv b { color: #8ECAD0; font-weight: 600; }
.graph-side .chip { background: rgba(142,202,208,.15); color: #dce9ec; }
.err-box { background: rgba(255,107,129,.12); border: 1px solid rgba(255,107,129,.55); border-radius: 10px; padding: 10px 12px; margin: 6px 0; }
.err-box .where { font-family: ui-monospace, Consolas, monospace; font-size: .78rem; color: #ffd3da; margin-top: 4px; }
.step { border-left: 3px solid rgba(142,202,208,.4); padding: 6px 10px; margin: 6px 0; }
.step.error { border-color: #ff6b81; background: rgba(255,107,129,.07); }
.step.warn { border-color: #f6c344; background: rgba(246,195,68,.07); }
.step .t { font-family: ui-monospace, Consolas, monospace; font-size: .72rem; opacity: .7; }
.step .e { font-weight: 700; font-size: .72rem; letter-spacing: .06em; margin-left: 6px; color: #8ECAD0; }
.step.error .e { color: #ff9aa9; }
.step.warn .e { color: #f6c344; }
.step pre { background: rgba(0,0,0,.35); border-radius: 8px; padding: 8px; font-size: .72rem; overflow-x: auto; margin-top: 6px; white-space: pre-wrap; word-break: break-word; }
.stage-bars .row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 10px; margin: 6px 0; font-size: .82rem; }
.stage-bars .bar { height: 10px; border-radius: 6px; background: linear-gradient(90deg, #ff6b81, #ff9aa9); min-width: 4px; }
.ex-row { cursor: pointer; }
.ex-row td.txt { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill.OK { background: #ddf2e4; color: var(--ok); }
.status-pill.FALLO { background: #f3e2e0; color: var(--danger); }
.status-pill.PARCIAL, .status-pill.SIN_RESPUESTA { background: #fdf3d7; color: #8a6d1a; }
@media (max-width: 1000px) {
  .graph-wrap { grid-template-columns: 1fr; }
  .graph-side { height: auto; max-height: 420px; }
  .fg { height: 420px; }
}

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--onyx); color: var(--cloud); border-radius: 999px;
  padding: 12px 24px; font-size: .92rem; font-weight: 500; z-index: 99;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
}

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; flex-direction: row; align-items: center; gap: 6px; padding: 12px 14px; overflow-x: auto; }
  .sidebar .logo { width: 110px; margin: 0; }
  .sidebar .tag, .sidebar .whoami { display: none; }
  .sidebar .spacer { display: none; }
  .nav-item { width: auto; white-space: nowrap; margin-bottom: 0; }
  .admin-main { padding: 22px 18px; }
  .modal .row { grid-template-columns: 1fr; }
  .msg { max-width: 88%; }
}

/* ===== Código del bot (codebase-memory MCP) ===== */
.err-box .code-open { margin-top: 8px; }
.modal.code-modal { max-width: 980px; }
.code-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.code-fn { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--deep-teal); font-size: 1.05rem; }
.code-file { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; color: #6b6b66; margin-left: 10px; }
.code-modal .notice { margin-bottom: 10px; }
.code-view {
  position: relative; background: #0f1a2b; color: #dce9ec; border-radius: 12px; padding: 10px 0;
  max-height: 52vh; overflow: auto; font-family: ui-monospace, Consolas, monospace; font-size: .78rem; line-height: 1.55; margin: 6px 0 16px;
}
.code-view .ln { display: block; white-space: pre; padding-right: 14px; }
.code-view .ln i {
  display: inline-block; width: 3.6em; padding-right: 12px; margin-right: 12px; text-align: right; font-style: normal;
  color: #5f7a86; border-right: 1px solid rgba(142,202,208,.18); user-select: none;
}
.code-view .ln.hit { background: rgba(255,107,129,.2); box-shadow: inset 3px 0 0 #ff6b81; }
.code-view .ln.hit i { color: #ffd3da; }
.code-modal h3 { color: var(--deep-teal); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 4px 0 8px; }
.code-count { display: inline-block; background: #eef4f4; color: var(--deep-teal); border-radius: 999px; padding: 0 8px; margin-left: 4px; letter-spacing: 0; }
.code-callers { display: flex; flex-wrap: wrap; gap: 6px; }
.code-caller { border: 1px solid var(--mist-blue); cursor: pointer; font-family: ui-monospace, Consolas, monospace; font-weight: 500; }
.code-caller:hover { background: var(--mist-blue); color: var(--onyx); }
.code-loading, .code-empty { color: #6b6b66; font-size: .88rem; }
.code-loading { padding: 30px 0; text-align: center; }

/* ===== Mapa de fallos sobre el código ===== */
.seg { display: inline-flex; background: #eef4f4; border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; color: #3b4a4c; font: inherit; font-size: .78rem; font-weight: 600; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.seg button.active { background: var(--deep-teal); color: var(--cloud); }
.seg button:not(.active):hover { background: rgba(0, 101, 111, .08); }
.fg-label.module { border-radius: 8px; font-family: ui-monospace, Consolas, monospace; font-weight: 600; }
.fg-label.fn { font-size: .66rem; font-family: ui-monospace, Consolas, monospace; }
.graph-side .fn-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; cursor: pointer;
  padding: 7px 10px; margin: 6px 0; border-left: 3px solid #ff6b81; border-radius: 0 8px 8px 0; background: rgba(255,107,129,.07);
}
.graph-side .fn-row:hover { background: rgba(255,107,129,.16); }
.graph-side .fn-row code { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; color: #ffd3da; overflow-wrap: anywhere; }
.graph-side .fn-row .n { font-weight: 800; color: #ffd3da; }
.graph-side .fn-row small { grid-column: 1 / -1; opacity: .7; font-size: .74rem; }
.graph-side .side-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
/* Los mensajes de error traen tokens largos sin espacios (claves enmascaradas, URLs): que no desborden el panel. */
.graph-side .err-box, .graph-side .step, .graph-side pre { overflow-wrap: anywhere; }
.graph-side pre { white-space: pre-wrap; }
.graph-side .mod-list { display: flex; flex-wrap: wrap; gap: 6px; }
.graph-side .mod-list .chip { cursor: pointer; font-family: ui-monospace, Consolas, monospace; }
.graph-side .mod-list .chip:hover { background: rgba(142,202,208,.35); }

/* ===== Actividad en vivo ===== */
.ex-actions { display: flex; align-items: center; gap: 10px; }
.live-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1.5px solid #d8d4c9; background: var(--white); color: #6b6b66;
  border-radius: 999px; padding: 7px 14px; font: inherit; font-size: .85rem; font-weight: 600;
}
.live-toggle i { width: 9px; height: 9px; border-radius: 50%; background: #b9b4a7; }
.live-toggle.on { border-color: var(--deep-teal); color: var(--deep-teal); }
.live-toggle.on i { background: #1fb57a; animation: live-dot 1.8s infinite; }
.live-toggle.error { border-color: var(--danger); color: var(--danger); }
.live-toggle.error i { background: var(--danger); }
@keyframes live-dot {
  0% { box-shadow: 0 0 0 0 rgba(31,181,122,.55); }
  70% { box-shadow: 0 0 0 8px rgba(31,181,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(31,181,122,0); }
}
.live-feed { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 12px; }
.live-item {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: #eef4f4; color: #3b4a4c; border: 1.5px solid transparent; border-radius: 999px;
  padding: 5px 12px 5px 9px; font: inherit; font-size: .78rem; animation: live-in .5s ease-out;
}
.live-item:hover { border-color: var(--mist-blue); }
.live-item i { width: 8px; height: 8px; border-radius: 50%; background: #8ECAD0; }
.live-item.warn i { background: #f6c344; }
.live-item.error i { background: #ff6b81; }
.live-item b { font-weight: 700; margin-right: 2px; }
.live-item.playing { border-color: var(--deep-teal); box-shadow: 0 0 0 3px rgba(0,101,111,.14); }
@keyframes live-in { from { opacity: 0; transform: translateY(-6px) scale(.96); } to { opacity: 1; transform: none; } }
.fg-label.pulse { animation: fg-pulse 1.1s ease-out; }
.fg-label.pulse-error { animation: fg-pulse-err 1.1s ease-out; }
@keyframes fg-pulse {
  0% { background: #8ECAD0; color: #0b1220; box-shadow: 0 0 0 0 rgba(142,202,208,.85); }
  100% { box-shadow: 0 0 0 16px rgba(142,202,208,0); }
}
@keyframes fg-pulse-err {
  0% { background: #ff6b81; color: #0b1220; box-shadow: 0 0 0 0 rgba(255,107,129,.85); }
  100% { box-shadow: 0 0 0 16px rgba(255,107,129,0); }
}
.tbl tr.row-new td { animation: row-new 2.6s ease-out; }
@keyframes row-new { from { background: rgba(142,202,208,.38); } to { background: transparent; } }

/* ===== Alertas ===== */
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f6c344; color: #272727; font-size: .72rem; font-weight: 800;
}
.nav-badge.crit { background: #ff6b81; color: #fff; }
.alerts-state { font-size: .88rem; color: #6b6b66; }
.alerts-state .bad { color: var(--danger); }
.alert-card { border-left: 4px solid #f6c344; background: #fffaf0; border-radius: 0 14px 14px 0; padding: 14px 16px; margin: 10px 0; }
.alert-card.crit { border-color: #ff6b81; background: #fff3f5; }
.alert-card.resolved { border-color: #8ECAD0; background: #f4f8f8; }
.alert-card.acked { opacity: .8; }
.alert-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.alert-head b { color: var(--onyx); font-size: .98rem; overflow-wrap: anywhere; }
.alert-level { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: 2px 8px; border-radius: 999px; background: #f6c344; color: #272727; }
.alert-card.crit .alert-level { background: #ff6b81; color: #fff; }
.alert-card.resolved .alert-level { background: #8ECAD0; color: #0b1220; }
.alert-kind { margin-left: auto; font-size: .76rem; color: #8a8779; }
.alert-detail { margin-top: 6px; font-size: .9rem; color: #3b3b37; line-height: 1.45; overflow-wrap: anywhere; }
.alert-meta { margin-top: 6px; font-size: .78rem; color: #8a8779; }
.alert-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.empty-note { color: #8a8779; font-size: .9rem; }
.alerts-config { display: grid; gap: 10px; font-size: .88rem; }
.alerts-config > div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; }
.alerts-config b { color: var(--deep-teal); }
.alerts-config code { font-size: .78rem; background: rgba(0,0,0,.05); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }

/* ===== Reproducir en demo ===== */
.modal.replay-modal { max-width: 640px; }
.replay-intro { font-size: .92rem; color: #3b3b37; margin-bottom: 10px; }
.replay-quote { background: #eef4f4; border-left: 3px solid var(--deep-teal); border-radius: 0 10px 10px 0; padding: 10px 14px; font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.replay-notes { margin: 12px 0 0 18px; font-size: .84rem; color: #55534c; line-height: 1.55; }
.replay-target { margin-top: 10px; font-size: .8rem; color: #8a8779; overflow-wrap: anywhere; }
.replay-target code { font-size: .78rem; }
.replay-progress { margin-top: 18px; display: grid; gap: 12px; }
.rp-step { display: grid; grid-template-columns: 16px 1fr; gap: 10px; align-items: start; font-size: .9rem; }
.rp-step i { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; background: #d8d4c9; }
.rp-step.wait i { background: #8ECAD0; animation: live-dot 1.6s infinite; }
.rp-step.done i { background: #1fb57a; }
.rp-step.bad i { background: #ff6b81; }
.rp-reply { margin-top: 6px; background: #f4f8f8; border-radius: 10px; padding: 8px 12px; font-size: .88rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.rp-meta { margin-top: 4px; font-size: .82rem; color: #6b6b66; }
.rp-err { margin-top: 6px; font-size: .8rem; color: #9b2c3d; background: #fff3f5; border-radius: 8px; padding: 6px 10px; overflow-wrap: anywhere; }
.rp-verdict { border-radius: 14px; padding: 14px 16px; }
.rp-verdict.bad { background: #fff3f5; border: 1px solid #ffc2cc; }
.rp-verdict.ok { background: #eefaf4; border: 1px solid #b9e8d0; }
.rp-verdict p { font-size: .88rem; color: #55534c; margin-top: 4px; }
.rp-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; font-size: .88rem; }
.rp-compare small { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #8a8779; }

/* ===== Pausa del bot y toma de conversación ===== */
.bot-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1.5px solid #1fb57a; background: var(--white); color: #17865b;
  border-radius: 999px; padding: 7px 14px; font: inherit; font-size: .85rem; font-weight: 600;
}
.bot-toggle i { width: 9px; height: 9px; border-radius: 50%; background: #1fb57a; }
.bot-toggle.paused { border-color: #3b6fd8; background: #3b6fd8; color: #fff; }
.bot-toggle.paused i { background: #fff; border-radius: 2px; width: 8px; height: 10px; box-shadow: none; background: linear-gradient(90deg, #fff 35%, transparent 35% 65%, #fff 65%); }
.takeover-strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #f6effc; border: 1px solid #e3d2f3; border-radius: 14px; padding: 10px 12px; margin-bottom: 16px; }
.takeover-label { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #6b3fa0; margin-right: 4px; }
.takeover-chip { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; border: 1.5px solid #c9a8ea; background: #fff; color: #4a2a73; border-radius: 999px; padding: 5px 12px 5px 9px; font: inherit; font-size: .82rem; font-weight: 600; }
.takeover-chip:hover { background: #efe3fa; }
.takeover-chip i { width: 8px; height: 8px; border-radius: 50%; background: #9b59d0; }
.takeover-chip small { font-weight: 400; color: #7a6390; }
.graph-side .human-chip { background: rgba(155,89,208,.25); color: #ecdcfb; }
.graph-side .btn.ghost { color: #8ECAD0; border-color: #8ECAD0; }
.graph-side .btn.ghost:hover { background: rgba(142,202,208,.12); }
.status-pill.PAUSADO { background: #dfe8fb; color: #2d5bbf; }
.status-pill.HUMANO { background: #efe3fa; color: #6b3fa0; }
.live-item.human i { background: #9b59d0; }
.pause-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.pause-options label { display: flex; align-items: center; gap: 8px; border: 1.5px solid #d8d4c9; border-radius: 12px; padding: 10px 12px; cursor: pointer; font-size: .9rem; }
.pause-options label:has(input:checked) { border-color: var(--deep-teal); background: #eef4f4; }
.field-label { display: grid; gap: 6px; font-size: .85rem; color: #55534c; }
.field-label input { padding: 10px 12px; border: 1.5px solid #d8d4c9; border-radius: 10px; font: inherit; }
.modal.conv-modal { max-width: 720px; }
.conv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.conv-state { border-radius: 12px; padding: 10px 14px; font-size: .86rem; display: grid; gap: 2px; flex: 1; min-width: 260px; }
.conv-state.bot { background: #eefaf4; color: #17865b; }
.conv-state.paused { background: #dfe8fb; color: #2d5bbf; }
.conv-state.human { background: #f6effc; color: #6b3fa0; }
.conv-state span { color: #55534c; }
.conv-body { background: #f4f2ec; border-radius: 14px; padding: 14px; height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 78%; border-radius: 16px; padding: 9px 13px; font-size: .9rem; line-height: 1.4; display: grid; gap: 3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble small { font-size: .7rem; opacity: .7; white-space: normal; }
.bubble.user { align-self: flex-start; background: #fff; color: var(--onyx); border-bottom-left-radius: 5px; }
.bubble.bot { align-self: flex-end; background: var(--deep-teal); color: var(--cloud); border-bottom-right-radius: 5px; }
.bubble.human { align-self: flex-end; background: #7a45b0; color: #fff; border-bottom-right-radius: 5px; }
.conv-event { align-self: center; font-size: .76rem; color: #8a8779; background: rgba(0,0,0,.04); border-radius: 999px; padding: 3px 12px; }
.conv-event.bad { color: #9b2c3d; background: #fff3f5; }
.conv-compose { margin-top: 12px; display: grid; gap: 8px; }
.conv-compose textarea { width: 100%; resize: vertical; min-height: 70px; padding: 10px 12px; border: 1.5px solid #d8d4c9; border-radius: 12px; font: inherit; font-size: .92rem; }
.conv-compose-foot { display: flex; justify-content: space-between; align-items: center; }
.conv-count { font-size: .76rem; color: #8a8779; }

/* ===== Flujo del agente como red neuronal ===== */
/* Claro y con un color suave por capa, como un esquema de red neuronal; el
   rojo queda reservado para los errores, así que salta a la vista. */
.fg.nn-light { background: #fbfaf6; box-shadow: inset 0 0 0 1px #e7e3da; }
.fg.nn-light .fg-empty { color: #5d6f72; }
.nn { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.nn-mesh line { stroke: #3d4a4d; stroke-opacity: .07; stroke-width: 1; }
.nn-link { fill: none; stroke: #3d4a4d; stroke-opacity: .8; stroke-linecap: round; }
.nn-link.err { stroke: #d6334c; stroke-opacity: 1; }
.nn-node { cursor: pointer; outline: none; }
.nn-node .ball { stroke: #4b5a5d; stroke-width: 1.8; transition: stroke-width .15s; }
.nn-node.l0 .ball { fill: #fde7a4; }
.nn-node.l1 .ball { fill: #c3e2f7; }
.nn-node.l2 .ball { fill: #bde7df; }
.nn-node.l3 .ball { fill: #c9e9b3; }
.nn-node.l4 .ball { fill: #ddd4f4; }
.nn-node .halo { fill: none; stroke: transparent; stroke-width: 2.5; }
.nn-node .num { fill: #1d2b2e; font-size: 16px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.nn-node .name { fill: #3d4a4d; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-anchor: middle; pointer-events: none; }
.nn-node.idle .ball { fill: #fff; stroke: #d3cfc3; stroke-dasharray: 3 4; }
.nn-node.idle .name { fill: #b9b5a9; font-weight: 600; }
.nn-node.warn .ball { stroke: #d99a00; stroke-width: 3.2; }
.nn-node.error .ball { fill: #f4667c; stroke: #a81f37; stroke-width: 2.4; }
.nn-node.error .num { fill: #fff; }
.nn-node.error .halo { stroke: #f4667c; animation: nn-breathe 2.4s ease-in-out infinite; }
.nn-node.error .name { fill: #a81f37; }
.nn-node .badge circle { fill: #a81f37; stroke: #fbfaf6; stroke-width: 2; }
.nn-node .badge text { fill: #fff; font-size: 11px; font-weight: 800; text-anchor: middle; pointer-events: none; }
.nn-node:hover .ball, .nn-node:focus-visible .ball { stroke-width: 3.4; }
.nn-node.selected .halo { stroke: #00656F; animation: none; }
.nn-node.pulse .ball { animation: nn-pulse 1.1s ease-out; }
.nn-node.pulse-error .ball { animation: nn-pulse-err 1.1s ease-out; }
.nn .layer { fill: #00656F; font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; text-anchor: middle; }
.nn-spark { fill: #00656F; filter: drop-shadow(0 0 5px rgba(0,101,111,.7)); }
.nn-spark.err { fill: #d6334c; filter: drop-shadow(0 0 5px rgba(214,51,76,.7)); }
@keyframes nn-breathe { 0%, 100% { stroke-opacity: .15; } 50% { stroke-opacity: .9; } }
@keyframes nn-pulse { 0% { stroke: #00656F; stroke-width: 10; } 100% { stroke-width: 1.8; } }
@keyframes nn-pulse-err { 0% { stroke: #d6334c; stroke-width: 10; } 100% { stroke-width: 2.4; } }
.nn-tip {
  position: absolute; z-index: 3; max-width: 300px; pointer-events: none; padding: 10px 12px; border-radius: 10px;
  overflow-wrap: anywhere; background: #fff; color: #1d2b2e; font-size: .78rem; line-height: 1.4; box-shadow: 0 12px 30px -10px rgba(0,0,0,.35), 0 0 0 1px #e0dccf;
}
.nn-tip b { letter-spacing: .05em; margin-right: 8px; }
.nn-tip span, .nn-tip .muted { color: #5d6f72; }
.nn-tip em { font-style: normal; font-weight: 700; }
.nn-tip em.err { color: #c02740; }
.nn-tip em.warn { color: #96700a; }
.nn-tip .tip-err { margin-top: 7px; padding-top: 7px; border-top: 1px solid #e0dccf; color: #8f1d31; }
.nn-tip .tip-err small { display: block; color: #5d6f72; margin-bottom: 2px; }
.nn-tip .tip-err code { display: block; margin-top: 4px; font-size: .72rem; color: #1d2b2e; word-break: break-all; }
@media (prefers-reduced-motion: reduce) { .nn-node.error .halo { animation: none; stroke-opacity: .8; } }
