:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #17201c;
  --muted: #66736d;
  --line: #e2e7e4;
  --brand: #0f7a5c;
  --brand-ink: #0b5e47;
  --brand-soft: #e3f3ed;
  --side: #0f1f1a;
  --side-ink: #b9cbc4;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --ai: #5b4bd6;
  --ai-soft: #eeebff;
  --human: #c26a12;
  --human-soft: #fff1e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 26, .06), 0 2px 8px rgba(16, 32, 26, .05);
  font-size: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
small, .muted { color: var(--muted); }
code { background: #eef2f0; padding: 1px 6px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }

/* Layout */
.app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 700; font-size: 15px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #1fbf86, #0f7a5c); display: grid; place-items: center; font-size: 16px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: rgba(31,191,134,.16); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav .badge { margin-left: auto; background: #1fbf86; color: #062b1e; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.side .foot { margin-top: auto; font-size: 12px; padding: 8px; border-top: 1px solid rgba(255,255,255,.08); }
.side .foot b { color: #fff; display: block; }
.side .foot a { color: var(--side-ink); }
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top .grow { flex: 1; }
.content { padding: 22px 24px; overflow: auto; flex: 1; }
.banner { background: var(--warn-soft); color: #6b4300; padding: 8px 24px; font-size: 13px; border-bottom: 1px solid #f3dfb5; }

/* Componentes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c7d1cc; background: #fafcfb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label { display: block; font-weight: 550; font-size: 12.5px; margin-bottom: 4px; color: #33413b; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=datetime-local], input:not([type]), select, textarea {
  width: 100%; border: 1px solid #d3dbd7; border-radius: 8px; padding: 8px 10px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15,122,92,.25); border-color: var(--brand); }
textarea { resize: vertical; min-height: 70px; }
.field + .field { margin-top: 12px; }
.grid > .field { margin-top: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 13.5px; }
.check input { width: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef2f0; color: #44524b; }
.pill.green { background: var(--brand-soft); color: var(--brand-ink); }
.pill.ai { background: var(--ai-soft); color: var(--ai); }
.pill.human { background: var(--human-soft); color: var(--human); }
.pill.red { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-flex; align-items: center; gap: 4px; background: #eef2f0; border-radius: 6px; padding: 1px 7px; font-size: 12px; margin: 2px 4px 2px 0; }
.tag button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0; font-size: 13px; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 550; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--brand-ink); border-bottom-color: var(--brand); }
.toast { position: fixed; right: 20px; bottom: 20px; background: #13231d; color: #fff; padding: 11px 16px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 1000; max-width: 420px; font-size: 13.5px; }
.toast.err { background: #8e2a20; }
.modal-bg { position: fixed; inset: 0; background: rgba(10,20,16,.45); display: grid; place-items: center; z-index: 900; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 650; font-size: 15px; display: flex; justify-content: space-between; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.bar { height: 8px; background: #edf1ef; border-radius: 5px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 5px; }

/* Bandeja */
.inbox { display: grid; grid-template-columns: 320px 1fr 290px; height: 100%; min-height: 0; }
.inbox .content { padding: 0; }
.ilist { border-right: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; min-height: 0; }
.ilist .filters { padding: 12px; border-bottom: 1px solid var(--line); }
.ilist .filters .row { gap: 4px; margin-top: 8px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 3px 10px; font-size: 12px; cursor: pointer; font-weight: 550; color: #44524b; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.convs { overflow: auto; flex: 1; }
.conv { display: block; padding: 12px 14px; border-bottom: 1px solid #eef2f0; cursor: pointer; color: inherit; }
.conv:hover { background: #f7faf9; }
.conv.on { background: var(--brand-soft); }
.conv .n { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.conv .n .t { margin-left: auto; font-weight: 400; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.conv .p { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv .u { background: var(--brand); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; font-weight: 700; }
.chat { display: flex; flex-direction: column; min-height: 0; background: #efeae2; }
.chat .head { background: #fff; padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.msgs { flex: 1; overflow: auto; padding: 18px 6%; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 70%; padding: 7px 10px 5px; border-radius: 9px; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.08); word-wrap: break-word; font-size: 14px; }
.msg .tx { white-space: pre-wrap; }
.msg.out { align-self: flex-end; background: #d9fdd3; }
.msg.out.ai { background: #e9e5ff; }
.msg.out.campaign { background: #fff6d9; }
.msg.out.phone { background: #e7f4ff; }
.msg .meta { font-size: 11px; color: #667781; text-align: right; margin-top: 2px; }
.msg .who { font-size: 11px; font-weight: 700; margin-bottom: 2px; }
.msg .btns { margin-top: 6px; display: grid; gap: 4px; }
.msg .btns span { display: block; text-align: center; background: rgba(255,255,255,.7); border-radius: 6px; padding: 4px; color: #027eb5; font-size: 13px; }
.msg.failed { border: 1px solid var(--danger); }
.note { align-self: center; background: rgba(255,255,255,.75); font-size: 12px; color: #54656f; padding: 4px 10px; border-radius: 7px; max-width: 80%; text-align: center; }
.composer { background: #f0f2f5; padding: 10px 14px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 140px; border-radius: 20px; padding: 10px 14px; }
.details { border-left: 1px solid var(--line); background: #fff; padding: 16px; overflow: auto; }
.details .sec { margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* Editor de embudos */
.editor { display: grid; grid-template-columns: 190px 1fr 310px; height: 100%; min-height: 0; }
.palette { background: #fff; border-right: 1px solid var(--line); padding: 14px; overflow: auto; }
.palette .item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: grab; background: #fff; font-weight: 550; font-size: 13px; }
.palette .item:hover { border-color: var(--brand); }
.palette .item .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 14px; }
#drawflow { position: relative; background: #f6f8f7; background-image: radial-gradient(#d4dcd8 1px, transparent 1px); background-size: 22px 22px; overflow: hidden; }
.props { background: #fff; border-left: 1px solid var(--line); padding: 16px; overflow: auto; }
.drawflow .drawflow-node { width: 220px; padding: 0; border: 1px solid #d0d9d4; border-radius: 10px; background: #fff; box-shadow: var(--shadow); color: var(--ink); min-height: 40px; }
.drawflow .drawflow-node.selected { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(15,122,92,.25); background: #fff; }
.drawflow .drawflow-node:hover { cursor: move; }
.drawflow .drawflow-node .input, .drawflow .drawflow-node .output { width: 14px; height: 14px; border: 2px solid #fff; background: #8fa39a; }
.drawflow .drawflow-node .output:hover, .drawflow .drawflow-node .input:hover { background: var(--brand); }
.drawflow .drawflow-node { align-items: stretch; }
.drawflow .drawflow-node .inputs { display: flex; flex-direction: column; justify-content: center; }
.drawflow .drawflow-node .outputs { display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 12px; }
.drawflow .drawflow-node .input { left: -8px; top: 0; margin: 0; }
.drawflow .drawflow-node .output { right: 8px; top: 0; margin: 12px 0 0; }
.drawflow .connection .main-path { stroke: #7f958b; stroke-width: 2.5px; }
.drawflow .connection .main-path:hover, .drawflow .connection .main-path.selected { stroke: var(--brand); }
.drawflow-delete { background: var(--danger); border: 2px solid #fff; }
.nd .nh { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-bottom: 1px solid #eef2f0; font-weight: 650; font-size: 12.5px; border-radius: 10px 10px 0 0; }
.nd .nb { padding: 8px 10px; font-size: 12.5px; color: #3c4943; white-space: pre-wrap; word-break: break-word; max-height: 90px; overflow: hidden; }
.nd .nb:empty { display: none; }
.nd .outs { padding: 0 10px 8px; }
.nd .outs div { font-size: 11.5px; background: #f3f6f4; border-radius: 5px; height: 22px; line-height: 22px; padding: 0 9px; margin-top: 4px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nd .cnt { margin-left: auto; font-size: 11px; font-weight: 600; background: rgba(0,0,0,.06); padding: 0 6px; border-radius: 8px; }
.sim { position: fixed; right: 20px; bottom: 20px; width: 360px; height: 560px; background: #efeae2; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.3); display: flex; flex-direction: column; overflow: hidden; z-index: 500; }
.sim .sh { background: #075e54; color: #fff; padding: 12px 14px; display: flex; align-items: center; gap: 8px; }
.sim .sh .grow { flex: 1; }
.sim .sh button { background: none; border: 0; color: #fff; cursor: pointer; font-size: 13px; }
.sim .msgs { padding: 12px; }
.sim .msg { max-width: 85%; font-size: 13.5px; }
.sim .msg .btns span { cursor: pointer; }
.sim .msg .btns span:hover { background: #fff; }
.opt-row { display: flex; gap: 6px; margin-bottom: 6px; }
.opt-row input { flex: 1; }

@media (max-width: 1100px) {
  .inbox { grid-template-columns: 280px 1fr; }
  .details { display: none; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.zoombar { position: absolute; left: 14px; bottom: 14px; z-index: 5; display: flex; gap: 4px; }
.zoombar button { width: 34px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-size: 15px; box-shadow: var(--shadow); }
