:root {
  --green: #00a884; --green-dark: #008069; --green-soft: #d9fdd3;
  --bg: #eae6df; --rail: #f0f2f5; --panel: #ffffff; --panel-2: #f0f2f5; --hover: #f5f6f6; --active: #f0f2f5;
  --text: #111b21; --muted: #667781; --border: #e9edef; --border-2: #d1d7db;
  --bubble-in: #ffffff; --bubble-out: #d9fdd3; --chat-bg: #efeae2; --system: #ffeecd; --note: #fff5c4;
  --danger: #ea0038; --author: #008069; --author-bot: #6b52e0; --warn: #ffbc38; --blue: #53bdeb; --shadow: 0 1px .5px rgba(11,20,26,.13);
  --input: #ffffff; --modal: #ffffff; --overlay: rgba(11,20,26,.45); --pattern-opacity: .06;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1317; --author: #06cf9c; --author-bot: #b3a6ff; --rail: #202c33; --panel: #111b21; --panel-2: #202c33; --hover: #202c33; --active: #2a3942;
    --text: #e9edef; --muted: #8696a0; --border: #222d34; --border-2: #313d45;
    --bubble-in: #202c33; --bubble-out: #005c4b; --chat-bg: #0b141a; --system: #182229; --note: #3b3515;
    --input: #2a3942; --modal: #233138; --overlay: rgba(0,0,0,.6); --green-soft: #005c4b; --pattern-opacity: .04;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1317; --author: #06cf9c; --author-bot: #b3a6ff; --rail: #202c33; --panel: #111b21; --panel-2: #202c33; --hover: #202c33; --active: #2a3942;
  --text: #e9edef; --muted: #8696a0; --border: #222d34; --border-2: #313d45;
  --bubble-in: #202c33; --bubble-out: #005c4b; --chat-bg: #0b141a; --system: #182229; --note: #3b3515;
  --input: #2a3942; --modal: #233138; --overlay: rgba(0,0,0,.6); --green-soft: #005c4b; --pattern-opacity: .04;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14.2px/1.4 "Segoe UI", "Helvetica Neue", Helvetica, "Lucida Grande", Arial, Ubuntu, Cantarell, sans-serif; color: var(--text); background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); }
.hidden { display: none !important; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 18px; height: 18px; }
svg.i.xs { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- shell */
.app { display: flex; height: 100vh; width: 100%; background: var(--panel); }

.rail { width: 64px; transition: width .18s cubic-bezier(.16,1,.3,1); background: var(--rail); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px; flex: none; }
.rail .brand { width: 40px; height: 40px; border-radius: 12px; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 700; margin-bottom: 10px; font-size: 15px; }
.rail-btn { position: relative; width: 44px; height: 44px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.active { background: var(--active); color: var(--text); }
.rail-btn .badge { position: absolute; top: 3px; right: 1px; }
.rail-btn[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 52px; top: 50%; transform: translateY(-50%); background: #111b21; color: #fff; font-size: 12.5px; padding: 5px 9px; border-radius: 6px; white-space: nowrap; z-index: 50; pointer-events: none; }
.rail .sep { width: 28px; height: 1px; background: var(--border-2); margin: 6px 0; }
.rail .spacer { flex: 1; }
.rail-scroll { display: flex; flex-direction: column; align-items: center; gap: 4px; overflow-y: auto; overflow-x: visible; scrollbar-width: none; }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; flex: none; font-size: 15px; position: relative; text-transform: uppercase; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 49px; height: 49px; font-size: 18px; }
.avatar.xl { width: 120px; height: 120px; font-size: 44px; }
.avatar .dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--rail); }
.dot.online { background: #25d366; } .dot.away { background: var(--warn); } .dot.offline { background: #8696a0; }

.badge { background: var(--green); color: #fff; border-radius: 11px; min-width: 20px; height: 20px; padding: 0 6px; font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; }
.badge.gray { background: var(--muted); }

/* ---------------------------------------------------------------- side panel */
.side { width: 30%; min-width: 340px; max-width: 460px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--panel); flex: none; }
.side-head { height: 59px; background: var(--panel-2); display: flex; align-items: center; padding: 0 12px 0 16px; gap: 8px; flex: none; }
.side-head h2 { font-size: 19px; font-weight: 600; margin: 0; flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn:hover { background: rgba(134,150,160,.15); color: var(--text); }
.icon-btn.on { color: var(--green); }
.search { padding: 7px 12px; display: flex; gap: 8px; align-items: center; border-bottom: 1px solid var(--border); }
.search-box { flex: 1; display: flex; align-items: center; background: var(--panel-2); border-radius: 8px; height: 36px; padding: 0 12px; gap: 12px; color: var(--muted); }
.search-box input { border: 0; background: none; outline: 0; flex: 1; min-width: 0; color: var(--text); }
.tabs { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; scrollbar-width: none; flex: none; border-bottom: 1px solid var(--border); }
.chip { border: 0; background: var(--panel-2); color: var(--muted); border-radius: 16px; padding: 6px 12px; font-size: 13.5px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.chip.active { background: var(--green-soft); color: var(--green-dark); }
:root[data-theme="dark"] .chip.active { color: #e9edef; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.active { color: #e9edef; } }
.chip .badge { height: 18px; min-width: 18px; font-size: 11px; }

.list { flex: 1; overflow-y: auto; }
.item { display: flex; gap: 13px; padding: 0 0 0 13px; cursor: pointer; align-items: center; height: 72px; }
.item:hover { background: var(--hover); }
.item.active { background: var(--active); }
.item .body { flex: 1; min-width: 0; border-bottom: 1px solid var(--border); height: 100%; display: flex; flex-direction: column; justify-content: center; padding-right: 15px; }
.item .row { display: flex; align-items: center; gap: 6px; }
.item .name { flex: 1; font-size: 16.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .time { font-size: 12px; color: var(--muted); }
.item .time.unread { color: var(--green); }
.item .preview { flex: 1; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .tags { display: flex; gap: 4px; margin-top: 2px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--panel-2); color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.tag.q { color: #fff; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.load-more { display: block; margin: 12px auto; }

/* ---------------------------------------------------------------- main / chat */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--chat-bg); }
.welcome { flex: 1; display: grid; place-items: center; text-align: center; background: var(--panel-2); border-bottom: 6px solid var(--green); color: var(--muted); padding: 24px; }
.welcome h1 { color: var(--text); font-weight: 300; font-size: 32px; margin: 24px 0 12px; }
.welcome .logo { width: 110px; height: 110px; border-radius: 30px; margin: 0 auto; background: var(--green); display: grid; place-items: center; color: #fff; font-size: 42px; font-weight: 700; }
.chat-head { height: 59px; background: var(--panel-2); display: flex; align-items: center; gap: 13px; padding: 0 12px 0 16px; flex: none; border-left: 1px solid var(--border); z-index: 2; }
.chat-head .who { flex: 1; min-width: 0; cursor: pointer; }
.chat-head .who .n { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .who .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn { border: 0; border-radius: 20px; padding: 8px 16px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); color: var(--text); white-space: nowrap; }
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--green); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: none; color: var(--green-dark); border: 1px solid var(--border-2); }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.messages { flex: 1; overflow-y: auto; padding: 16px 7% 8px; position: relative; }
.chat-bg::before { content: ""; position: absolute; inset: 0; opacity: var(--pattern-opacity); pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.2'%3E%3Ccircle cx='14' cy='14' r='6'/%3E%3Cpath d='M50 10l8 8m0-8l-8 8'/%3E%3Crect x='10' y='48' width='12' height='9' rx='2'/%3E%3Cpath d='M48 50q6-8 12 0t12 0'/%3E%3C/g%3E%3C/svg%3E"); }
:root[data-theme="dark"] .chat-bg::before { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chat-bg::before { filter: invert(1); } }
.chat-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.msg-row { display: flex; margin-bottom: 2px; position: relative; }
.msg-row.out { justify-content: flex-end; }
.msg-row.gap { margin-top: 10px; }
.bubble { max-width: 65%; padding: 6px 7px 8px 9px; border-radius: 7.5px; box-shadow: var(--shadow); background: var(--bubble-in); position: relative; word-wrap: break-word; }
.bubble .txt, .note .txt { white-space: pre-wrap; }
.out .bubble { background: var(--bubble-out); }
.bubble .author { font-size: 12.8px; font-weight: 500; color: var(--author); margin-bottom: 2px; }
.bubble.bot .author { color: var(--author-bot); }
.bubble .meta { float: right; margin: 8px 0 -6px 12px; font-size: 11px; color: var(--muted); display: inline-flex; gap: 3px; align-items: center; position: relative; top: 3px; }
.bubble .meta .tick { width: 16px; height: 11px; }
.tick.read { color: var(--blue); }
.tick.failed { color: var(--danger); }
.bubble img.media { max-width: 330px; max-height: 330px; border-radius: 6px; display: block; margin-bottom: 4px; cursor: pointer; }
.bubble audio, .bubble video { max-width: 320px; display: block; margin-bottom: 4px; }
.bubble .doc { display: flex; gap: 10px; align-items: center; background: rgba(0,0,0,.05); padding: 10px; border-radius: 6px; margin-bottom: 4px; text-decoration: none; color: var(--text); }
.bubble .err { color: var(--danger); font-size: 12px; display: block; margin-top: 2px; }
.bubble .mact { position: absolute; top: 2px; right: 2px; opacity: 0; background: inherit; border: 0; border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.bubble:hover .mact { opacity: 1; }
.sys { text-align: center; margin: 10px 0; }
.sys span { background: var(--system); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 7.5px; box-shadow: var(--shadow); display: inline-block; max-width: 80%; }
.day { text-align: center; margin: 12px 0; position: sticky; top: 0; z-index: 1; }
.day span { background: var(--panel); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 7.5px; box-shadow: var(--shadow); text-transform: uppercase; }

.banner { padding: 10px 16px; background: var(--panel-2); border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; justify-content: center; color: var(--muted); flex-wrap: wrap; z-index: 1; }
.composer { min-height: 62px; background: var(--panel-2); display: flex; align-items: flex-end; gap: 8px; padding: 10px 16px; flex: none; z-index: 1; position: relative; }
.composer textarea { flex: 1; border: 0; outline: 0; border-radius: 8px; background: var(--input); padding: 10px 12px; resize: none; max-height: 140px; min-height: 42px; line-height: 21px; }
.composer .icon-btn { height: 42px; }
.qr-pop { position: absolute; bottom: 100%; left: 16px; right: 16px; background: var(--modal); border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.2); max-height: 260px; overflow-y: auto; z-index: 5; }
.qr-pop div { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.qr-pop div.sel, .qr-pop div:hover { background: var(--hover); }
.qr-pop b { color: var(--green-dark); margin-right: 8px; }
.attach-prev { position: absolute; bottom: 100%; left: 16px; background: var(--modal); border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.2); padding: 10px 14px; display: flex; align-items: center; gap: 10px; z-index: 5; }

/* ---------------------------------------------------------------- drawer (info / notas) */
.drawer { width: 30%; max-width: 420px; min-width: 320px; background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; flex: none; }
.drawer-head { height: 59px; background: var(--panel-2); display: flex; align-items: center; gap: 12px; padding: 0 16px; flex: none; }
.drawer-head h3 { margin: 0; font-size: 16px; font-weight: 500; flex: 1; }
.drawer-tabs { display: flex; border-bottom: 1px solid var(--border); flex: none; }
.drawer-tabs button { flex: 1; border: 0; background: none; padding: 12px 4px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 500; }
.drawer-tabs button.active { color: var(--green); border-color: var(--green); }
.drawer-body { flex: 1; overflow-y: auto; background: var(--panel-2); }
.card { background: var(--panel); padding: 16px 20px; margin-bottom: 10px; box-shadow: var(--shadow); }
.card h4 { margin: 0 0 12px; font-size: 14px; color: var(--green-dark); font-weight: 500; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.note { background: var(--note); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; font-size: 13.5px; position: relative; }
.note .by { font-size: 11.5px; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; }
.timeline { font-size: 13px; }
.timeline div { padding: 6px 0 6px 14px; border-left: 2px solid var(--border-2); position: relative; }
.timeline div::before { content: ""; position: absolute; left: -5px; top: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.timeline small { color: var(--muted); display: block; }
.hist { padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13.5px; }
.hist:hover { color: var(--green); }

/* ---------------------------------------------------------------- páginas admin */
.page { flex: 1; overflow-y: auto; background: var(--panel-2); }
.page-head { background: var(--panel); padding: 18px 28px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 3; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 500; flex: 1; display: flex; align-items: center; gap: 10px; }
.page-head p { width: 100%; margin: 0; color: var(--muted); font-size: 13px; }
.page-body { padding: 20px 28px 40px; }
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.grid th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 12px 14px; border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .02em; }
.grid td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr.click { cursor: pointer; } .grid tr.click:hover td { background: var(--hover); }
.grid .actions { text-align: right; white-space: nowrap; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; background: var(--panel-2); color: var(--muted); }
.pill.green { background: var(--green-soft); color: var(--green-dark); }
.pill.red { background: rgba(234,0,56,.12); color: var(--danger); }
.pill.yellow { background: rgba(255,188,56,.2); color: #a86f00; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--panel); border-radius: 10px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat .v { font-size: 28px; font-weight: 600; }
.stat .l { color: var(--muted); font-size: 13px; }
.panel-box { background: var(--panel); border-radius: 10px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 20px; }
.panel-box h3 { margin: 0 0 14px; font-size: 15px; font-weight: 500; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; background: var(--green); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; opacity: .85; }
.bars .b:hover { opacity: 1; }
.bars .b:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #111b21; color: #fff; padding: 4px 8px; font-size: 11.5px; border-radius: 4px; white-space: nowrap; margin-bottom: 4px; z-index: 3; }
.hbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13.5px; }
.hbar .n { width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .t { flex: 1; background: var(--panel-2); border-radius: 4px; height: 12px; overflow: hidden; }
.hbar .t div { height: 100%; background: var(--green); }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; }
.codebox { background: var(--panel-2); border-radius: 6px; padding: 10px 12px; word-break: break-all; display: flex; gap: 8px; align-items: center; }
.codebox code { flex: 1; }
pre.codebox { white-space: pre-wrap; display: block; max-height: 300px; overflow: auto; margin: 0; }

/* ---------------------------------------------------------------- forms / modal */
.modal-bg { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--modal); border-radius: 10px; width: 560px; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 17px 50px rgba(11,20,26,.3); }
.modal.wide { width: 820px; }
.modal-head { padding: 18px 24px 8px; display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 500; flex: 1; }
.modal-body { padding: 8px 24px 16px; overflow-y: auto; }
.modal-foot { padding: 14px 24px 20px; display: flex; justify-content: flex-end; gap: 10px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--green-dark); margin-bottom: 5px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input { width: 100%; border: 0; border-bottom: 2px solid var(--border-2); background: var(--input); padding: 8px 10px; border-radius: 6px 6px 0 0; outline: 0; }
.input:focus { border-color: var(--green); }
textarea.input { resize: vertical; min-height: 80px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; font-size: 13.5px; }
.check input { accent-color: var(--green); width: 16px; height: 16px; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-2); border-radius: 20px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(16px); }

.menu { position: fixed; background: var(--modal); border-radius: 6px; box-shadow: 0 2px 10px rgba(11,20,26,.25); padding: 8px 0; z-index: 200; min-width: 200px; }
.menu button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 10px 20px; cursor: pointer; }
.menu button:hover { background: var(--hover); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #111b21; color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.3); font-size: 14px; max-width: 480px; cursor: pointer; }
.toast.err { background: var(--danger); }

/* ---------------------------------------------------------------- workflow editor */
.wf-wrap { flex: 1; display: flex; min-height: 0; }
.wf-palette { width: 210px; background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; padding: 12px; flex: none; }
.wf-palette h5 { margin: 12px 0 6px; font-size: 11.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.wf-tool { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--panel-2); margin-bottom: 6px; cursor: grab; font-size: 13.5px; user-select: none; }
.wf-tool:hover { outline: 1px solid var(--green); }
.wf-tool .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: #fff; flex: none; }
.wf-canvas { flex: 1; position: relative; background: var(--panel-2); background-image: radial-gradient(var(--border-2) 1px, transparent 1px); background-size: 22px 22px; }
#drawflow { width: 100%; height: 100%; }
.wf-props { width: 340px; background: var(--panel); border-left: 1px solid var(--border); overflow-y: auto; padding: 16px 18px; flex: none; }
.wf-props h3 { margin: 0 0 4px; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.wf-props .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.wf-zoom { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 6px; z-index: 5; }
.wf-zoom .icon-btn { background: var(--panel); box-shadow: var(--shadow); }
.opt-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.opt-row .num { width: 22px; color: var(--muted); font-size: 12px; text-align: right; }
.vars-help { font-size: 12px; color: var(--muted); background: var(--panel-2); padding: 8px 10px; border-radius: 6px; line-height: 1.6; }

/* Drawflow theme */
.drawflow .drawflow-node { background: var(--panel); border: 1px solid var(--border-2); border-radius: 10px; width: 230px; padding: 0; box-shadow: 0 2px 6px rgba(11,20,26,.08); color: var(--text); min-height: 0; }
.drawflow .drawflow-node.selected { border-color: var(--green); box-shadow: 0 0 0 2px var(--green); background: var(--panel); }
.drawflow .drawflow-node .drawflow_content_node { width: 100%; }
.drawflow .drawflow-node .input, .drawflow .drawflow-node .output { width: 14px; height: 14px; background: var(--panel); border: 2px solid var(--muted); padding: 0; border-radius: 50%; }
.drawflow .drawflow-node .output:hover, .drawflow .drawflow-node .input:hover { background: var(--green); border-color: var(--green); }
.drawflow .drawflow-node .inputs { left: -8px; } .drawflow .drawflow-node .outputs { right: -8px; }
.drawflow .connection .main-path { stroke: var(--muted); stroke-width: 2.5px; }
.drawflow .connection .main-path.selected, .drawflow .connection .main-path:hover { stroke: var(--green); }
.drawflow-delete { background: var(--danger); border: 2px solid #fff; line-height: 26px; font-family: sans-serif; }
.nd-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; border-radius: 10px 10px 0 0; color: #fff; font-weight: 600; font-size: 13px; }
.nd-body { padding: 8px 10px 10px; font-size: 12.5px; color: var(--muted); max-height: 120px; overflow: hidden; white-space: pre-wrap; word-break: break-word; }
.nd-outs { font-size: 11.5px; padding: 0 10px 8px; color: var(--muted); }
.nd-outs div { text-align: right; height: 22px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- login */
.login-page { display: grid; place-items: center; grid-template-columns: minmax(0, 460px); justify-content: center; min-height: 100vh; background: linear-gradient(180deg, var(--green) 0 222px, var(--bg) 222px); padding: 16px; overflow: auto; }
.login-card { background: var(--panel); border-radius: 6px; box-shadow: 0 17px 50px rgba(11,20,26,.19); padding: 48px 56px; width: 100%; }
@media (max-width: 500px) { .login-card { padding: 32px 24px; } }
.login-card h1 { font-weight: 300; font-size: 28px; margin: 18px 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 28px; }

@media (max-width: 900px) {
  .drawer { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; width: 100%; max-width: none; min-width: 0; }
  .side { width: auto; flex: 1 1 auto; max-width: none; min-width: 0; }
  .qbar { gap: 8px; padding: 8px 10px; }
  .qbar-txt small { display: none; }
  .app.chat-open .side { display: none; }
  .app:not(.chat-open) .main.chatmode { display: none; }
  .messages { padding: 12px 10px; }
  .bubble { max-width: 85%; }
  .wf-palette { width: 150px; } .wf-props { position: absolute; right: 0; top: 0; bottom: 0; z-index: 10; width: 100%; }
  .row2, .row3, .checks { grid-template-columns: 1fr; }
  .page-head, .page-body { padding-left: 16px; padding-right: 16px; }
  .rail { width: 56px; }
  .app { overflow: hidden; }
  .chat-head { gap: 6px; padding: 0 4px 0 6px; }
  .chat-head [data-act=notes], .chat-head [data-act=close] { display: none; }
}

/* Drawflow: entradas no topo, saídas alinhadas às legendas no rodapé do bloco */
.drawflow .drawflow-node { align-items: stretch; }
.drawflow .drawflow-node .inputs { position: absolute; left: -9px; top: 9px; width: auto; }
.drawflow .drawflow-node .outputs { position: absolute; right: -9px; bottom: 8px; width: auto; }
.drawflow .drawflow-node .input { left: 0; top: 0; margin: 0; }
.drawflow .drawflow-node .output { right: 0; top: 0; margin: 3px 0; width: 16px; height: 16px; }
.drawflow .drawflow-node .input { width: 16px; height: 16px; }

/* menu lateral expandido (ícone + nome) */
.rail .lbl { display: none; }
.rail-toggle { margin-bottom: 6px; }
.rail.expanded { width: 236px; align-items: stretch; padding: 10px 10px; }
.rail.expanded .brand-row { display: flex; align-items: center; gap: 10px; padding: 0 2px 10px; }
.rail.expanded .brand { margin-bottom: 0; }
.rail .brand-row .brand-name { display: none; font-weight: 600; font-size: 16px; flex: 1; }
.rail.expanded .brand-row .brand-name { display: block; }
.rail .brand-row { display: flex; flex-direction: column; align-items: center; }
.rail.expanded .brand-row { flex-direction: row; }
.rail.expanded .rail-scroll { align-items: stretch; }
.rail.expanded .rail-btn { width: 100%; height: 42px; border-radius: 10px; display: flex; align-items: center; gap: 14px; padding: 0 12px; justify-content: flex-start; }
.rail.expanded .rail-btn .lbl { display: block; flex: 1; text-align: left; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail.expanded .rail-btn.active .lbl { font-weight: 600; }
.rail.expanded .rail-btn .badge { position: static; }
.rail.expanded .rail-btn[data-tip]:hover::after { display: none; }
.rail.expanded .sep { width: auto; margin: 6px 8px; }
.rail.expanded #me-btn .lbl small { display: block; color: var(--muted); font-size: 12px; }
.rail.expanded .rail-toggle { width: 40px !important; height: 40px !important; padding: 0 !important; justify-content: center !important; margin: 0; }
@media (max-width: 900px) { .rail.expanded { position: absolute; z-index: 60; height: 100%; box-shadow: 4px 0 18px rgba(11,20,26,.18); } }

@media (max-width: 900px) { .tpl-grid { grid-template-columns: 1fr !important; } }

.grid .actions .icon-btn { display: inline-grid; vertical-align: middle; }
.grid .actions .btn { vertical-align: middle; }
.hint { font-size: 12.5px; color: var(--muted); }

/* Configurações: lista de seções */
.cfg-group { padding: 18px 20px 6px; font-size: 13px; color: var(--green-dark); font-weight: 600; }
.cfg-item { display: flex; gap: 14px; align-items: center; width: 100%; border: 0; background: none; text-align: left; padding: 10px 16px 10px 18px; cursor: pointer; color: var(--text); }
.cfg-item:hover { background: var(--hover); }
.cfg-item.active { background: var(--active); }
.cfg-ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: var(--panel-2); flex: none; }
.cfg-item.active .cfg-ic { color: var(--green-dark); background: var(--green-soft); }
.cfg-txt { display: flex; flex-direction: column; min-width: 0; }
.cfg-txt b { font-weight: 500; font-size: 15px; }
.cfg-txt small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main.chatmode .page { width: 100%; }
.cfg-back { display: none; }
@media (max-width: 900px) { .cfg-back { display: grid; } }
@media (max-width: 900px) { table.grid { display: block; overflow-x: auto; } table.grid td, table.grid th { white-space: nowrap; } table.grid td small { white-space: normal; } }

.brand-co { display: block; font-weight: 400; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
#dp-stats { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.page-body { overflow-x: auto; }

/* barra de clientes aguardando (acima da lista de conversas) */
.qbar { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; background: #fff4d6; border-bottom: 1px solid var(--border); flex: none; }
:root[data-theme="dark"] .qbar { background: #3a3013; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .qbar { background: #3a3013; } }
.qbar.empty { background: none; color: var(--muted); font-size: 13px; padding: 8px 16px; gap: 8px; }
.qbar-bell { position: relative; color: #a86f00; display: grid; place-items: center; }
.qbar-bell .badge { position: absolute; top: -9px; right: -12px; background: var(--danger); height: 18px; min-width: 18px; font-size: 11px; }
.qbar-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.qbar-txt small { color: var(--muted); font-size: 12px; }
.qbar .btn { flex: none; }

/* página Filas */
.qboard { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.qcol { background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); width: 300px; flex: none; display: flex; flex-direction: column; max-height: calc(100vh - 300px); }
.qcol-head { padding: 14px 14px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.qcol-title { display: flex; align-items: center; gap: 8px; }
.qcol-title .tag { font-size: 13px; padding: 3px 10px; }
.qcol-title small { color: var(--muted); font-size: 12px; }
.qcol-stats { display: flex; gap: 12px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.qcol-stats b { color: var(--text); font-weight: 600; }
.qcol-oldest { font-size: 12.5px; color: var(--muted); }
.qcol-take { align-self: stretch; justify-content: center; }
.qcol-list { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.qcol-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 8px; }
.qitem { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.qitem-top { display: flex; align-items: center; gap: 8px; }
.qitem-top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.qitem-pos { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.qitem-wait { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.qitem-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.qitem-msg { margin-top: 6px; color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qitem-act { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.warn { color: #a86f00 !important; }
.late { color: var(--danger) !important; font-weight: 600; }
.stat.warn .v { color: #a86f00; } .stat.late .v { color: var(--danger); }
@media (max-width: 900px) { .qcol { width: 82vw; max-height: none; } }
.qitem .btn.ghost { background: var(--panel); }

/* marca: logo + CHAT branco / IQ laranja */
:root { --brand-orange: #ff8a1f; --brand-graphite: #2f3a42; }
.wm { font-weight: 700; letter-spacing: -0.01em; }
.wm-chat { color: #ffffff; } .wm-iq { color: var(--brand-orange); }
.rail .brand { padding: 0; overflow: hidden; background: var(--brand-graphite); }
.rail .brand img { width: 30px; height: 30px; }
/* no tema claro a marca fica num selo escuro para o "Chat" branco aparecer */
.rail.expanded .brand-row { background: #111b21; border-radius: 14px; padding: 6px 4px 6px 6px; margin-bottom: 6px; }
.rail.expanded .brand-row .brand-co { color: #aebac1; }
.rail.expanded .rail-toggle { color: #aebac1; } .rail.expanded .rail-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }
.welcome .logo { background: var(--brand-graphite); }
.welcome .logo img { width: 78px; height: 78px; }
.wm-lockup { display: inline-block; background: #111b21; border-radius: 14px; padding: 6px 18px; font-size: 30px; }

/* Filas (monitor) */
.qchips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex: none; }
.qchip .qsw { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.qtabs { flex: none; }
.qtab-n { font-size: 12px; background: var(--panel-2); color: var(--muted); border-radius: 9px; padding: 0 6px; margin-left: 2px; }
.qtabs button.active .qtab-n { background: var(--green); color: #fff; }
.item .time.warn { color: #a86f00; } .item .time.late { color: var(--danger); font-weight: 600; }

.credit { font-size: 12.5px; color: var(--muted); margin-top: 18px; }
.credit a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.credit a:hover { color: var(--green); }
