:root {
  --ink: #1d2626; --ink2: #4a5656; --ink3: #7b8787;
  --bg: #f5f3ee; --panel: #ffffff; --line: #e4e0d7; --line2: #efece5;
  --side: #0f3d3e; --side2: #165152; --sideInk: #cfe3df;
  --pri: #127c6b; --pri2: #0e6456; --priSoft: #e2f2ee;
  --amber: #f4b942; --amberSoft: #fdf3dc;
  --ok: #1f9d55; --okSoft: #e3f5ea; --warn: #c98a06; --warnSoft: #fff3d1; --bad: #d23c3c; --badSoft: #fde6e6;
  --chat: #efeae2; --bubbleIn: #ffffff; --bubbleOut: #d9f5e4; --note: #fff4c2;
  --r: 12px; --shadow: 0 1px 2px rgba(20,30,30,.06), 0 4px 16px rgba(20,30,30,.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--pri); }
.boot { display: grid; place-items: center; height: 100%; color: var(--ink3); }
.muted { color: var(--ink3); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 8px; }
.hide { display: none !important; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Botões */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: #faf9f6; border-color: #d5d0c4; }
.btn.pri { background: var(--pri); color: #fff; border-color: var(--pri); }
.btn.pri:hover { background: var(--pri2); }
.btn.amber { background: var(--amber); border-color: var(--amber); color: #3a2a00; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); border-color: #f0c9c9; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.big { padding: 13px 20px; font-size: 16px; border-radius: 12px; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { border: 0; background: transparent; cursor: pointer; padding: 8px; border-radius: 8px; font-size: 18px; line-height: 1; }
.iconbtn:hover { background: rgba(0,0,0,.06); }

input[type=text], input[type=password], input[type=tel], input[type=email], input[type=date], input[type=time], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 11px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--pri); box-shadow: 0 0 0 3px var(--priSoft); }
textarea { resize: vertical; min-height: 70px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink2); font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--pri); }

/* Farol */
.farol { border: 0; background: rgba(255,255,255,.06); border-radius: 14px; padding: 8px 4px 6px; margin-bottom: 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #fff; }
.farol:hover { background: rgba(255,255,255,.12); }
.farol .luz { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff; }
.farol .fl { font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.f-verde .luz { background: #22c55e; box-shadow: 0 0 14px rgba(34,197,94,.7); }
.f-amarelo .luz { background: #f5b301; color: #3a2a00; box-shadow: 0 0 16px rgba(245,179,1,.8); }
.f-vermelho .luz { background: #ef4444; box-shadow: 0 0 18px rgba(239,68,68,.9); animation: pulse 1.1s infinite; }
.f-vermelho { background: rgba(239,68,68,.18); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); box-shadow: 0 0 26px rgba(239,68,68,1); } }
.team-farol { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tf { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; gap: 12px; align-items: center; cursor: pointer; }
.tf:hover { border-color: #cfc9bc; }
.tf .luz { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; }
.tf.f-vermelho { background: #fff1f1; border-color: #f3b4b4; }

/* Layout */
.layout { display: grid; grid-template-columns: 92px 1fr; height: 100%; }
#app { height: 100%; }
.side { background: var(--side); color: var(--sideInk); display: flex; flex-direction: column; align-items: stretch; padding: 10px 8px; gap: 4px; overflow-y: auto; }
.side .logo { display: grid; place-items: center; padding: 6px 0 12px; }
.side .logo img { width: 40px; height: 40px; }
.nav { border: 0; background: transparent; color: var(--sideInk); border-radius: 12px; padding: 10px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; position: relative; }
.nav .ic { font-size: 22px; line-height: 1; }
.nav:hover { background: var(--side2); }
.nav.on { background: var(--amber); color: #2b2000; font-weight: 600; }
.nav .badge { position: absolute; top: 4px; right: 10px; }
.side .spacer { flex: 1; }
.side .me { text-align: center; font-size: 12px; padding: 6px 2px; opacity: .9; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.banners:empty { display: none; }
.banner { display: flex; align-items: center; gap: 12px; padding: 10px 16px; font-size: 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.banner.amber { background: var(--amberSoft); } .banner.bad { background: var(--badSoft); } .banner.pause { background: #fde8b0; font-weight: 500; } .banner.info { background: var(--priSoft); }
.page { flex: 1; min-height: 0; overflow: auto; }
.page-pad { padding: 20px 24px 40px; max-width: 1200px; }
.page h1 { font-size: 22px; margin: 0 0 4px; } .page h2 { font-size: 17px; margin: 22px 0 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }

.badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 2px 6px; min-width: 18px; text-align: center; display: inline-block; line-height: 14px; }
.badge.gray { background: #cfd5d4; color: #213; } .badge.green { background: var(--ok); }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 500; background: #eef0ef; color: var(--ink2); white-space: nowrap; border: 1px solid transparent; }
.chip.tag { color: #fff; }
.tag-who { margin-left: 5px; margin-right: -6px; border-radius: 99px; padding: 0 6px; font-size: 11px; border: 1.5px solid rgba(255,255,255,.85); }
.head-bar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; width: 100%; }
.head-bar select { width: auto; padding: 6px 8px; font-size: 13px; }
.multi-warn { width: 100%; background: var(--warnSoft); color: #6b4b00; border-radius: 10px; padding: 7px 10px; font-size: 13.5px; }
.campaign-bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: #e4ecfb; border-bottom: 1px solid var(--line); font-size: 14px; flex-wrap: wrap; }
.campaign-bar .progress { flex: 1; min-width: 120px; max-width: 360px; }
.chip.num { background: #fff; border-color: var(--line); color: var(--ink2); }
.chip.num::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, #999); }
.chip.ok { background: var(--okSoft); color: #17663b; } .chip.warn { background: var(--warnSoft); color: #855c00; } .chip.bad { background: var(--badSoft); color: #a32424; }
.chip.toggle { cursor: pointer; background: #fff; border-color: var(--line); color: var(--ink2); }
.chip.toggle.on { color: #fff; border-color: transparent; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; font-size: 16px; }

/* Conversas */
.inbox { display: grid; grid-template-columns: 370px 1fr; height: 100%; min-height: 0; }
.inbox.details-open { grid-template-columns: 370px 1fr 330px; }
.list { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line2); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; background: #f1efe9; padding: 4px; border-radius: 12px; }
.tab { flex: 1 0 auto; border: 0; background: transparent; border-radius: 9px; padding: 8px 2px; cursor: pointer; font-size: 12.5px; white-space: nowrap; font-weight: 500; color: var(--ink2); display: flex; align-items: center; justify-content: center; gap: 5px; }
.tab.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.items { overflow-y: auto; flex: 1; }
.item { display: flex; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line2); cursor: pointer; position: relative; }
.item:hover { background: #faf9f6; } .item.on { background: var(--priSoft); }
.item .nm { font-weight: 600; }
.item .pv { color: var(--ink2); font-size: 13.5px; }
.item .meta { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; align-items: center; }
.item.prio1::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--bad); }
.empty { padding: 40px 20px; text-align: center; color: var(--ink3); }
.empty .big { font-size: 44px; margin-bottom: 8px; }

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat); }
.chat-head { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.chat-head .who { min-width: 160px; }
.chat-head .who b { font-size: 16px; }
.chat-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.chat-actions select { width: auto; padding: 7px 9px; font-size: 13.5px; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 4px; }
.day-sep { align-self: center; background: #fff; border-radius: 8px; font-size: 12px; padding: 4px 10px; color: var(--ink2); margin: 10px 0; box-shadow: 0 1px 1px rgba(0,0,0,.06); }
.bubble { max-width: 70%; padding: 7px 10px 5px; border-radius: 10px; background: var(--bubbleIn); box-shadow: 0 1px 1px rgba(0,0,0,.08); word-wrap: break-word; align-self: flex-start; font-size: 14.5px; }
.bubble.out { background: var(--bubbleOut); align-self: flex-end; }
.bubble.auto { background: #e4ecfb; }
.bubble.err { background: #fde2e2; }
.bubble.note { background: var(--note); align-self: center; max-width: 80%; border: 1px dashed #e0c25e; }
.txt { white-space: pre-wrap; }
.bubble .by { font-size: 11.5px; font-weight: 600; color: var(--pri2); margin-bottom: 2px; }
.bubble .tm { font-size: 11px; color: var(--ink3); text-align: right; margin-top: 2px; }
.bubble img, .bubble video { max-width: 280px; max-height: 320px; border-radius: 8px; display: block; cursor: pointer; }
.bubble audio { width: 260px; max-width: 100%; }
.event-line { align-self: center; font-size: 12px; color: var(--ink3); padding: 2px 8px; }
.composer { background: #f0eee8; padding: 10px 12px; border-top: 1px solid var(--line); position: relative; }
.composer .modes { display: flex; gap: 4px; margin-bottom: 6px; }
.composer .mode { border: 0; background: transparent; padding: 5px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--ink2); }
.composer .mode.on { background: #fff; color: var(--ink); font-weight: 600; }
.composer .mode.on.note { background: var(--note); }
.composer textarea { min-height: 46px; max-height: 180px; resize: none; border-radius: 12px; }
.composer.note textarea { background: #fffbe6; }
.qr-pop { position: absolute; bottom: 100%; left: 12px; right: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; z-index: 5; }
.qr-pop div { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line2); font-size: 14px; }
.qr-pop div:hover, .qr-pop div.on { background: var(--priSoft); }
.qr-pop b { color: var(--pri2); margin-right: 6px; }

.details { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.details h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink3); margin: 14px 0 6px; }
.details h3:first-child { margin-top: 0; }
.prio-btns { display: flex; gap: 4px; }
.prio-btns button { flex: 1; }
.prio-btns .on.p1 { background: var(--bad); color: #fff; border-color: var(--bad); }
.prio-btns .on.p2 { background: var(--pri); color: #fff; border-color: var(--pri); }
.prio-btns .on.p3 { background: #8a9696; color: #fff; border-color: #8a9696; }
.sched-item { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.ev { font-size: 12.5px; color: var(--ink2); padding: 3px 0; border-bottom: 1px dashed var(--line2); }

/* Agenda */
.agenda-day { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sched-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--line2); }
.sched-row:last-child { border-bottom: 0; }
.sched-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--pri); }
.progress { height: 10px; background: #eceae4; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--pri); transition: width .3s; }

/* Funil */
.kanban { display: flex; gap: 12px; padding: 16px; overflow-x: auto; height: 100%; align-items: flex-start; }
.kcol { background: #ebe8e1; border-radius: 14px; width: 270px; flex: none; display: flex; flex-direction: column; max-height: 100%; }
.kcol-head { padding: 12px 12px 8px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kcol-body { padding: 0 8px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kcol.drop { outline: 3px dashed var(--pri); }
.kcard { background: #fff; border-radius: 10px; padding: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.08); cursor: grab; font-size: 13.5px; }
.kcard:active { cursor: grabbing; }

/* Tabelas */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #faf9f6; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }

/* Painel */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.kpi .v { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--ink2); }
.kpi .s { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .b .stack { width: 100%; max-width: 38px; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 0 0; overflow: hidden; }
.bars .b .lbl { font-size: 11px; color: var(--ink3); white-space: nowrap; }
.hbar { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13.5px; }
.hbar .track { flex: 1; background: #f0eee8; border-radius: 6px; height: 14px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Config */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 18px; }
.subtabs .btn.on { background: var(--side); color: #fff; border-color: var(--side); }
.ncard { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 8px; flex-wrap: wrap; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.st-conectado { background: var(--ok); } .st-desconectado, .st-erro { background: var(--bad); } .st-aguardando_qr, .st-aguardando_codigo, .st-conectando, .st-reconectando { background: var(--amber); }
.sched-grid { display: grid; grid-template-columns: 90px repeat(4, 1fr); gap: 6px; align-items: center; font-size: 13px; }
.sched-grid input { padding: 6px; }
.help { background: var(--priSoft); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; color: #0d4d42; }
.help.amber { background: var(--amberSoft); color: #6b4b00; }

/* Modal & toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(15,30,30,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal-head { padding: 16px 18px 8px; display: flex; align-items: center; gap: 8px; }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; }
.modal-body { padding: 8px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 18px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; }
.toast { background: #1d2626; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--bad); }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% 0%, #1b5a5b, var(--side)); }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { margin: 10px 0 2px; font-size: 24px; }

.qrbox { display: grid; place-items: center; min-height: 290px; background: #f7f6f2; border-radius: 12px; }
.pair-code { font-size: 34px; font-weight: 800; letter-spacing: .12em; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* Celular */
.only-mobile { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { flex-direction: row; order: 2; padding: 4px; overflow-x: auto; overflow-y: hidden; gap: 2px; }
  .side .logo, .side .spacer, .side .me { display: none; }
  .farol { margin: 0; padding: 4px 6px; min-width: 62px; }
  .farol .luz { width: 34px; height: 34px; font-size: 15px; }
  .nav { flex: 1; padding: 6px 2px; font-size: 11px; min-width: 62px; }
  .nav .ic { font-size: 20px; }
  .inbox, .inbox.details-open { grid-template-columns: 1fr; }
  .inbox.has-conv .list { display: none; }
  .inbox:not(.has-conv) .chat { display: none; }
  .inbox.details-open .chat { display: none; }
  .details { border-left: 0; }
  .only-mobile { display: inline-flex; }
  .msgs { padding: 12px 10px; }
  .bubble { max-width: 88%; }
  .page-pad { padding: 14px; }
  .grid2 { grid-template-columns: 1fr; }
  .chat-actions { margin-left: 0; width: 100%; }
  .hide-mobile { display: none !important; }
  #toasts { bottom: 86px; }
}

/* Farol de cada conversa (lista e topo da conversa aberta) */
.farol-dot { flex: none; width: 11px; height: 11px; border-radius: 50%; display: inline-block; margin-right: 6px; box-shadow: 0 0 0 3px rgba(0,0,0,.05); }
.farol-dot.ok { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.farol-dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.22); }
.farol-dot.bad { background: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.22); animation: farolPulse 1.4s ease-in-out infinite; }
@keyframes farolPulse { 50% { box-shadow: 0 0 0 6px rgba(220,38,38,.08); } }
.farol-chip .farol-dot { width: 9px; height: 9px; margin-right: 2px; }
.farol-chip.big { font-size: 13px; font-weight: 600; padding: 4px 12px; }
.farol-chip.big .farol-dot { width: 12px; height: 12px; margin-right: 4px; }
