:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e3e7eb;
  --text: #17202a;
  --muted: #64707d;
  --accent: #0f766e;
  --accent-soft: #e6f4f2;
  --side-bg: #0f1d24;
  --side-text: #c9d4da;
  --side-muted: #7f929c;
  --side-hover: #17303a;
  --side-active: #1f4a4f;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --err: #c2410c;
  --err-soft: #fdeee6;
  --warn: #b45309;
  --warn-soft: #fdf4e3;
  --st-sent: #c2410c; --st-sent-soft: #fff1e6;
  --st-delivered: #1d4ed8; --st-delivered-soft: #e6eefc;
  --st-read: #15803d; --st-read-soft: #e7f6ec;
  --st-failed: #b91c1c; --st-failed-soft: #fdeaea;
  --off: #94a3b8;
  --skip-soft: #eef1f4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 1px 1px rgba(16, 24, 32, .04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1418; --surface: #151d22; --surface-2: #1a242a; --border: #26333b;
    --text: #e3e9ed; --muted: #8fa0aa; --accent: #2dd4bf; --accent-soft: #10302d;
    --side-bg: #0a1115; --side-hover: #13232a; --side-active: #163a3d;
    --ok: #4ade80; --ok-soft: #12291b; --err: #fb923c; --err-soft: #33190d;
    --warn: #fbbf24; --warn-soft: #30240b; --off: #64748b; --skip-soft: #1d272d;
    --st-sent: #fb923c; --st-sent-soft: #33190d;
    --st-delivered: #60a5fa; --st-delivered-soft: #102540;
    --st-read: #4ade80; --st-read-soft: #12291b;
    --st-failed: #f87171; --st-failed-soft: #3a1414;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1418; --surface: #151d22; --surface-2: #1a242a; --border: #26333b;
  --text: #e3e9ed; --muted: #8fa0aa; --accent: #2dd4bf; --accent-soft: #10302d;
  --side-bg: #0a1115; --side-hover: #13232a; --side-active: #163a3d;
  --ok: #4ade80; --ok-soft: #12291b; --err: #fb923c; --err-soft: #33190d;
  --warn: #fbbf24; --warn-soft: #30240b; --off: #64748b; --skip-soft: #1d272d;
  --st-sent: #fb923c; --st-sent-soft: #33190d;
  --st-delivered: #60a5fa; --st-delivered-soft: #102540;
  --st-read: #4ade80; --st-read-soft: #12291b;
  --st-failed: #f87171; --st-failed-soft: #3a1414;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 18px; }
h2 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.spacer { margin-left: auto; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.brand-text { display: flex; flex-direction: column; font-weight: 600; color: #fff; line-height: 1.2; }
.brand-text small { color: var(--side-muted); font-weight: 400; font-size: 11.5px; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 12px; color: var(--side-muted); border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-foot strong { color: var(--side-text); }

/* ---------- accordion menu ---------- */
.menu { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.group-head {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  background: none; border: 0; border-radius: 8px; color: var(--side-text);
  font: inherit; font-weight: 500; cursor: pointer; text-align: left;
}
.group-head:hover { background: var(--side-hover); }
.group-head:focus-visible, .item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.group.has-active > .group-head .glabel::after {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-left: 8px; vertical-align: middle;
}
.glabel { flex: 1; }
.chev { width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .2s; opacity: .7; }
.group.open > .group-head .chev { transform: rotate(45deg); }
.sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .22s ease; }
.group.open > .sub { grid-template-rows: 1fr; }
.sub-inner { overflow: hidden; display: flex; flex-direction: column; padding-left: 30px; }
.group.open > .sub > .sub-inner { padding-bottom: 6px; }
/* nested groups (Backend / Administración inside whats_dem_caf) */
.sub-inner > .group > .group-head { padding: 7px 10px; font-size: 13.5px; font-weight: 600; }
.sub-inner > .group > .sub > .sub-inner { padding-left: 14px; }
.item {
  display: block; padding: 7px 10px; border-radius: 7px; color: var(--side-muted); font-size: 13.5px;
}
.item:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.item.active { background: var(--side-active); color: #fff; }
.item-form { margin: 0; }
.item-button { width: 100%; text-align: left; background: none; border: 0; font: inherit; cursor: pointer; }
.gicon { width: 16px; height: 16px; flex: 0 0 16px; background: currentColor; opacity: .85;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.gicon-grid { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 3h8v8H3zM13 3h8v8h-8zM3 13h8v8H3zM13 13h8v8h-8z'/%3E%3C/svg%3E"); }
.gicon-chat { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h16v12H8l-4 4z'/%3E%3C/svg%3E"); }
.gicon-store { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 4h18l-1 5a3 3 0 0 1-5.5 1A3 3 0 0 1 12 11a3 3 0 0 1-2.5-1A3 3 0 0 1 4 9zM5 12.5V20h14v-7.5a4.6 4.6 0 0 1-2.5-.3V18h-9v-5.8a4.6 4.6 0 0 1-2.5.3z'/%3E%3C/svg%3E"); }
.gicon-server { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 4h18v6H3zM3 14h18v6H3z'/%3E%3C/svg%3E"); }
.gicon-user { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c0-4.4 3.6-7 8-7s8 2.6 8 7z'/%3E%3C/svg%3E"); }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.clock { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.content { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }
.hamburger { display: none; background: none; border: 0; padding: 6px; cursor: pointer; flex-direction: column; gap: 4px; }
.hamburger span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 19; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.narrow { max-width: 460px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13.5px; }
.alert.error { background: var(--err-soft); color: var(--err); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- kpis ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-small { font-size: 20px; padding: 5px 0; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.kpi-bad .kpi-value { color: var(--err); }
a.kpi-link { color: inherit; text-decoration: none; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.kpi-link:hover, a.kpi-link:focus-visible { border-color: var(--accent, #0f766e); transform: translateY(-1px); }
a.kpi-link:active { transform: translateY(0); }
.kpi-go { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--accent, #0f766e); }
.inline-form { display: inline-flex; margin: 0; }

/* ---------- lists, pills, dots ---------- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--off); flex: 0 0 8px; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.err { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.dot.warn { background: var(--warn); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; background: var(--skip-soft); color: var(--muted); white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-err { background: var(--err-soft); color: var(--err); }
.pill-off, .pill-warn { background: var(--warn-soft); color: var(--warn); }
/* delivery status: enviado · entregado · leído · falló */
.pill.st-sent { background: var(--st-sent-soft); color: var(--st-sent); }
.pill.st-delivered { background: var(--st-delivered-soft); color: var(--st-delivered); }
.pill.st-read { background: var(--st-read-soft); color: var(--st-read); }
.pill.st-failed { background: var(--st-failed-soft); color: var(--st-failed); font-weight: 600; }
.svc-list, .msg-list, .recent { list-style: none; margin: 0 0 10px; padding: 0; }
.svc-list li { display: grid; grid-template-columns: 14px minmax(110px, auto) 1fr; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); }
.svc-name { font-weight: 500; }
.msg-list li a, .recent li a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.msg-list li a:hover, .recent li a:hover { background: var(--surface-2); text-decoration: none; }
.recent li a.sel { background: var(--accent-soft); }
.msg-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.msg-text { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { font-size: 13px; }

/* ---------- forms, buttons, tables ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1 1 220px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:hover { background: var(--surface-2); }
.msg-cell { min-width: 220px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.logview, .logs-box pre {
  margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font: 12px/1.55 var(--mono); max-height: 70vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.logview .t, .logs-box .t { color: var(--muted); }
.logview .u, .logs-box .u { color: var(--accent); }
.logview .e { color: var(--err); }

/* ---------- flow ---------- */
.flow-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.trace-card { grid-column: 1 / -1; }
.recent-card { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 14px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.flow { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: stretch; }
.stage { display: grid; grid-template-columns: 1fr; gap: 12px; position: relative; padding-bottom: 22px; }
.stage.two { grid-template-columns: 1fr 1fr; }
.stage:not(:last-child)::after {
  content: ""; position: absolute; left: 25%; bottom: 3px; width: 2px; height: 16px; background: var(--border);
}
.stage:not(.two):not(:last-child)::after { left: 50%; }
.stage:not(:last-child)::before {
  content: ""; position: absolute; bottom: 0; width: 8px; height: 8px; border-right: 2px solid var(--border); border-bottom: 2px solid var(--border);
  transform: rotate(45deg); left: calc(25% - 3px);
}
.stage:not(.two):not(:last-child)::before { left: calc(50% - 3px); }
.node {
  position: relative; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  padding: 10px 12px 10px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0;
  transition: border-color .2s, background .2s, opacity .2s;
}
.node.ext { border-style: dashed; }
.node.side { background: var(--surface); }
.n-title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.n-sub { color: var(--muted); font-size: 12px; }
.n-live { color: var(--muted); font-size: 11.5px; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.tag { align-self: flex-start; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 6px; margin-bottom: 2px; }
.tag-alt { color: var(--warn); background: var(--warn-soft); }
.node[data-trace="ok"] { border-color: var(--ok); background: var(--ok-soft); }
.node[data-trace="error"] { border-color: var(--err); background: var(--err-soft); }
.node[data-trace="wait"] { border-color: var(--warn); background: var(--warn-soft); }
.node[data-trace="skip"] { opacity: .45; }
.badge { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 700; color: #fff; flex: 0 0 18px; }
.b-ok { background: var(--ok); }
.b-error { background: var(--err); }
.b-wait { background: var(--warn); }
.b-skip, .b-unknown { background: var(--off); }
.node .badge { position: absolute; top: -8px; right: -8px; }

.trace-summary { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.trace-summary b { font-weight: 600; }
.trace-summary .quote { flex-basis: 100%; }
.timeline { list-style: none; margin: 0 0 14px; padding: 0; }
.timeline li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); align-items: start; }
.timeline .t-title { font-weight: 500; }
.timeline .t-detail { color: var(--muted); font-size: 12.5px; word-break: break-word; }
.timeline .t-time { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.logs-box summary { cursor: pointer; font-weight: 500; padding: 4px 0 10px; }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 18px; }
.brand-login { padding: 0; }
.brand-login .brand-text { color: var(--text); }
.brand-login .brand-text small { color: var(--muted); }
.login-card .btn { width: 100%; padding: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .flow-layout { grid-template-columns: 1fr; }
  .recent-card { position: static; max-height: none; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .hamburger { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 32px; }
}
@media (max-width: 560px) {
  .stage.two { grid-template-columns: 1fr; }
  .stage::after, .stage::before { left: 50% !important; }
  .stage::before { left: calc(50% - 3px) !important; }
  .timeline li { grid-template-columns: 22px 1fr; }
  .timeline .t-time { grid-column: 2; text-align: left; }
  .kpi-value { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- connection map ---------- */
:root { --c-http: #0f766e; --c-mqtt: #7c3aed; --c-sql: #2563eb; --c-api: #c2410c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --c-http: #2dd4bf; --c-mqtt: #a78bfa; --c-sql: #60a5fa; --c-api: #fb923c; } }
:root[data-theme="dark"] { --c-http: #2dd4bf; --c-mqtt: #a78bfa; --c-sql: #60a5fa; --c-api: #fb923c; }
.map-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.map { display: block; width: 100%; min-width: 900px; height: auto; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.map .edge path { fill: none; stroke-width: 2; transition: opacity .15s, stroke-width .15s; }
.map .edge.k-http path { stroke: var(--c-http); }
.map .edge.k-mqtt path { stroke: var(--c-mqtt); }
.map .edge.k-sql path { stroke: var(--c-sql); }
.map .edge.k-api path { stroke: var(--c-api); }
.map .edge.dash path { stroke-dasharray: 6 5; }
.map .mk-http { fill: var(--c-http); } .map .mk-mqtt { fill: var(--c-mqtt); }
.map .mk-sql { fill: var(--c-sql); } .map .mk-api { fill: var(--c-api); }
.map .eb circle { fill: var(--surface); stroke: var(--muted); stroke-width: 1.2; }
.map .eb text { font-size: 10.5px; font-weight: 700; fill: var(--text); text-anchor: middle; dominant-baseline: central; }
.map .mnode { cursor: pointer; outline: none; transition: opacity .15s; }
.map .mnode rect { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; }
.map .mnode.m-ext rect { stroke-dasharray: 5 4; fill: var(--surface); }
.map .mnode.m-db rect { fill: var(--surface); stroke: var(--c-sql); }
.map .mnode.m-hub rect { stroke: var(--c-mqtt); stroke-width: 2; }
.map .mnode.m-soft rect { fill: var(--surface); stroke-dasharray: 2 4; }
.map .mnode:focus-visible rect { stroke: var(--accent); stroke-width: 3; }
.map .mt { font-size: 13px; font-weight: 600; fill: var(--text); text-anchor: middle; }
.map .ms { font-size: 10.5px; fill: var(--muted); text-anchor: middle; }
.map .topics text { font-size: 10.5px; fill: var(--c-mqtt); text-anchor: middle; font-family: var(--mono); }
.map .mdot { fill: var(--off); }
.map .mdot.ok { fill: var(--ok); } .map .mdot.err { fill: var(--err); }
.map.focus .edge:not(.hl), .map.focus .eb:not(.hl) { opacity: .12; }
.map.focus .mnode:not(.hl) { opacity: .3; }
.map.focus .edge.hl path { stroke-width: 3.2; }
.map .mnode.hl rect { stroke-width: 2.4; }
.kind { display: inline-block; width: 18px; height: 0; border-top: 3px solid; vertical-align: middle; margin-right: 6px; }
.kind.k-http { border-color: var(--c-http); } .kind.k-mqtt { border-color: var(--c-mqtt); }
.kind.k-sql { border-color: var(--c-sql); } .kind.k-api { border-color: var(--c-api); }
.kind.k-dash { border-top-style: dashed; border-color: var(--muted); }
.conn-table code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.conn-table .num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--muted); font-size: 11.5px; }
.conn-table tr.hl { background: var(--accent-soft); }
.conn-table td:nth-child(3) { white-space: nowrap; }
@media (max-width: 860px) { .conn-table td:nth-child(3) { white-space: normal; } }

/* ---------- details window (map) ---------- */
.modal {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.25);
  display: none; flex-direction: column;
}
.modal[open] { display: flex; animation: modal-in .16s ease-out; }
.modal::backdrop { background: rgba(10, 17, 21, .55); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 10px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 18px; }
.modal-kind { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-bottom: 2px; }
.modal-x { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; border-radius: 6px; }
.modal-x:hover { color: var(--text); background: var(--surface-2); }
.modal-body { padding: 14px 20px; overflow-y: auto; }
.modal-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.modal-summary { margin: 0; font-size: 14.5px; line-height: 1.6; }
.modal-live { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 14px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-size: 13px; }
.modal-live .pill { display: inline-flex; align-items: center; gap: 6px; }
.modal-dl { display: grid; grid-template-columns: minmax(110px, 30%) 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.modal-dl dt { color: var(--muted); }
.modal-dl dd { margin: 0; word-break: break-word; }
.modal-conns { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.modal-conns li { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.modal-conns .num { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--muted); font-size: 11px; font-weight: 700; margin-right: 8px; }
.modal-conns .dir { font-size: 11.5px; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.modal-conns .dir.out { color: var(--c-api); background: var(--err-soft); }
.modal-conns .dir.in { color: var(--c-sql); background: var(--accent-soft); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (max-width: 560px) {
  .modal { max-height: calc(100vh - 24px); }
  .modal-dl { grid-template-columns: 1fr; gap: 2px; }
  .modal-dl dd { margin-bottom: 8px; }
}

/* ---------- documentation page ---------- */
.doc { max-width: 860px; line-height: 1.65; }
.doc h3 { font-size: 15px; margin: 22px 0 8px; }
.doc ol, .doc ul { padding-left: 22px; margin: 6px 0; }
.doc li { margin: 4px 0; }
.doc code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.doc-url { margin: 8px 0; padding: 10px 12px; background: var(--accent-soft); color: var(--text); border-radius: 8px; font: 600 14px var(--mono); user-select: all; white-space: pre-wrap; word-break: break-all; }
.doc-status { margin: 12px 0; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-size: 13.5px; }
.copy-row { display: flex; gap: 8px; margin: 8px 0 4px; flex-wrap: wrap; }
.doc-url-input { flex: 1 1 260px; font: 600 13.5px var(--mono); background: var(--accent-soft); border-color: transparent; }
/* single-binary box on the connection map */
.map .mnode.m-app rect { stroke: var(--c-http); stroke-width: 2; }
.map .topics.app text { fill: var(--c-http); }

/* ---------- new restaurant form ---------- */
.form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0; }
.form legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; align-self: end; }
textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0; resize: vertical; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 12px 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
input.wide { width: min(100%, 520px); }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dd { margin-bottom: 6px; }
}
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.plain-list { margin: 8px 0 16px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.kb-preview { max-height: 520px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 0; }
.upload-form { margin-top: 8px; }
input[type=file] { padding: 6px; }

/* ---------- flujo de datos ---------- */
.op { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; text-decoration: none; white-space: nowrap; border: 1px solid transparent; }
a.op:hover { text-decoration: none; filter: brightness(.95); }
.op .mono { font-weight: 500; }
.op-insert { background: var(--ok-soft); color: var(--ok); }
.op-update { background: var(--warn-soft); color: var(--warn); }
.op-delete { background: var(--st-failed-soft); color: var(--st-failed); }
.op-select { background: var(--st-delivered-soft); color: var(--st-delivered); }
.op-file { background: var(--skip-soft); color: var(--muted); border-color: var(--border); }
.legend .op { margin: 0 2px 0 10px; }
.legend .op:first-child { margin-left: 0; }
.df-phases { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 12px; }
.df-phase h3 { margin: 0 0 8px; font-size: 14px; }
.df-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: dfs; }
.df-step { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); }
.df-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.df-step p { margin: 6px 0; }
.df-ops { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.df-ops li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.df-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.df-table { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; scroll-margin-top: 16px; transition: box-shadow .2s, border-color .2s; min-width: 0; }
.df-table:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.df-thead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.df-thead h3 { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.df-table p { margin: 6px 0; }
.df-cols summary { cursor: pointer; font-size: 13px; font-weight: 500; margin-top: 4px; }
.table.compact td { padding: 4px 6px; vertical-align: top; }
@media (max-width: 720px) { .df-tables, .df-phases { grid-template-columns: 1fr; } }
.op .op-db { opacity: .7; font-weight: 400; }
.df-db { color: var(--muted); font-weight: 400; }
.df-ops .op { white-space: normal; overflow-wrap: anywhere; }

/* source table/view name shown next to a card title */
h2 .src { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--muted, inherit);
  background: var(--surface-2); padding: 2px 7px; border-radius: 5px; margin-left: 8px; vertical-align: middle; }

/* clickable rows (dashboard › Webhook (Meta)) */
.table tbody tr.row-link { cursor: pointer; }
.table tbody tr.row-link a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
/* latency histogram bars (webhook detail) */
.hbar { display: block; height: 10px; border-radius: 3px; background: var(--accent, #3b82f6); min-width: 2px; width: 0; }
.hbar-cell { width: 60%; }

/* "← origin page" link (app.js) */
.back-link { margin: 0 0 12px; }
.back-link a { text-decoration: none; }
.back-link a:hover { text-decoration: underline; }

/* ===== Conversaciones (2026-11-17): cards per phone + chat view ===== */
.conv-search { flex: 1 1 260px; gap: 8px; }
.conv-search input[type=search] { flex: 1 1 200px; min-width: 0; }
.conv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.conv-card { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); min-width: 0; }
.conv-card:hover { background: var(--surface-2); border-color: var(--accent); text-decoration: none; }
.conv-avatar { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 17px; }
.conv-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pill.conv-pill-human { background: var(--warn-soft); color: var(--warn); }
.conv-head { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.conv-head-main { display: flex; gap: 12px; align-items: center; }
.conv-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); width: 100%; overflow-x: auto; }
.conv-tab { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.conv-tab:hover { color: var(--text); text-decoration: none; }
.conv-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.bubble-row { display: flex; }
.bubble-row.out { justify-content: flex-end; }
.bubble { max-width: min(78%, 620px); padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); min-width: 0; }
.bubble-row.in .bubble { border-top-left-radius: 4px; }
.bubble-row.out .bubble { border-top-right-radius: 4px; }
/* authors: cliente (default surface-2), IA, human, system text, Meta */
.q-ia_openai { background: var(--accent-soft); }
.q-sistema { background: var(--skip-soft); }
.q-humano_telegram { background: var(--warn-soft); border-color: var(--warn); }
.q-meta { background: var(--st-failed-soft); border-color: var(--st-failed); }
.q-cliente { background: var(--surface-2); }
.bubble.bubble-err { border-color: var(--err); }
.bubble-who { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.q-humano_telegram .bubble-who { color: var(--warn); }
.q-meta .bubble-who { color: var(--st-failed); }
.legend { display: inline-block; padding: 0 8px; border-radius: 999px; border: 1px solid var(--border); margin: 2px 2px 2px 0; white-space: nowrap; }
.bubble-details { margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.bubble-details summary { cursor: pointer; }
.bubble-details > div { margin-top: 3px; overflow-wrap: anywhere; }
.bubble-json { white-space: pre-wrap; }
.bubble-type { font-weight: 400; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--surface); }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.bubble-opt { padding: 3px 10px; border-radius: 8px; border: 1px solid var(--accent); color: var(--accent); background: var(--surface); font-size: 12.5px; }
.bubble-error { color: var(--err); font-size: 12px; margin-top: 4px; }
.bubble-meta { display: flex; gap: 8px; justify-content: flex-end; align-items: center; font-size: 11px; color: var(--muted); margin-top: 4px; flex-wrap: wrap; }
.tick { color: var(--muted); letter-spacing: -2px; }
.tick.read { color: var(--st-delivered); }
.tick.failed { color: var(--st-failed); letter-spacing: 0; }
.bubble-trace { color: var(--muted); }
@media (max-width: 640px) {
  .bubble { max-width: 92%; }
  .conv-grid { grid-template-columns: 1fr; }
}

/* Audios: play button per voice note (2026-11-18) */
.table audio { width: 240px; max-width: 70vw; height: 36px; display: block; }
