:root {
  --bg: #f3f6f7;
  --surface: #ffffff;
  --ink: #10242a;
  --muted: #5d727a;
  --line: #dde6e8;
  --brand: #0f766e;
  --brand-dark: #0b5a54;
  --side: #0c2529;
  --wa: #128c5e;
  --danger: #c22f2f;
  --warn-bg: #fff7e6;
  --warn-line: #f2c46d;
  --good-bg: #e6f6ee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 36, 42, .06), 0 4px 14px rgba(16, 36, 42, .05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
#root { height: 100%; display: flex; flex-direction: column; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 21px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.center { text-align: center; }
.pre { white-space: pre-wrap; }
.boot { margin: auto; color: var(--muted); }
.icon { width: 18px; height: 18px; fill: currentColor; flex: none; }

/* Estrutura */
.demo { background: #7a4b00; color: #fff; text-align: center; padding: 5px 10px; font-size: 12px; font-weight: 600; letter-spacing: .03em; }
.shell { flex: 1; display: grid; grid-template-columns: 216px 1fr; min-height: 0; }
aside { background: var(--side); color: #d7e7e8; display: flex; flex-direction: column; padding: 14px 10px; gap: 14px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.brand img { width: 32px; height: 32px; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; opacity: .7; font-size: 12px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: inherit; text-decoration: none; }
.nav a:hover { background: rgba(255, 255, 255, .07); }
.nav a.active { background: var(--brand); color: #fff; }
.nav .badge { margin-left: auto; }
.me { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px; font-size: 13px; }
.me .iconbtn { color: inherit; }
main { min-width: 0; min-height: 0; overflow: auto; }
.page { padding: 18px 22px 28px; display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.page-funil, .page-conversas { height: 100%; padding-bottom: 12px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.back { font-size: 13px; text-decoration: none; }

/* Controles */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 8px 13px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #b8cbce; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.link, .btn.dangerlink { border-color: transparent; background: transparent; color: var(--brand); padding-left: 4px; padding-right: 4px; }
.btn.dangerlink { color: var(--danger); }
.btn.block { width: 100%; }
.btn.big { padding: 12px 22px; font-size: 15px; }
.btn.more { width: 100%; border-style: dashed; font-weight: 500; }
.btn.backbtn { display: none; }
.iconbtn { border: 0; background: transparent; cursor: pointer; padding: 4px; border-radius: 6px; display: inline-flex; color: var(--muted); }
.iconbtn:hover { background: rgba(16, 36, 42, .07); }
.input { width: 100%; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 10px; font: inherit; }
.input:focus, .btn:focus-visible, .card:focus-visible, .choice:focus-visible, .drop:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea.input { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; min-width: 0; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand); }
.checks { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.row.end { justify-content: flex-end; margin-top: 10px; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
.span2 { grid-column: 1 / -1; }

.badge { background: #e5484d; color: #fff; border-radius: 20px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.chip { display: inline-block; background: #e8f0f1; color: var(--ink); border: 0; border-radius: 20px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; }
.chip.danger { background: #fdeaea; color: var(--danger); }
.chip.good { background: var(--good-bg); color: #0a6b45; }
.chip.action { cursor: pointer; font-family: inherit; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.chip + .chip { margin-left: 2px; }
p .chip, td .chip { margin-left: 8px; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 8px 12px; margin: 6px 0; }
.okline { background: var(--good-bg); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.warning { background: #fdf0f0; border: 1px solid #f0b6b6; border-radius: 8px; padding: 12px 14px; margin: 10px 0; }
.warning ul { margin: 6px 0 0; padding-left: 18px; }

/* Funil */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters .input { width: auto; min-width: 180px; }
.filters input[type="search"] { min-width: 280px; }
.board { flex: 1; display: flex; gap: 12px; overflow-x: auto; align-items: stretch; min-height: 340px; padding-bottom: 6px; }
.column { flex: 0 0 272px; display: flex; flex-direction: column; background: #e9eff0; border-radius: var(--radius); min-height: 0; border: 2px solid transparent; }
.column.over { border-color: var(--brand); background: #ddedec; }
.column > header { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 10px 8px; border-top: 4px solid; border-radius: 8px 8px 0 0; background: var(--surface); }
.column header small { color: var(--muted); }
.column.won > header small { color: #0a6b45; font-weight: 600; }
.cards { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.card { background: var(--surface); border-radius: 8px; padding: 10px 11px; box-shadow: var(--shadow); cursor: pointer; border: 1px solid transparent; flex: none; }
.card:hover { border-color: #b8cbce; }
.card.dragging { opacity: .45; }
.card-top { display: flex; justify-content: space-between; gap: 8px; }
.card-top strong { overflow-wrap: anywhere; }
.card p { font-size: 12.5px; margin-top: 2px; }
.card-line { display: flex; justify-content: space-between; gap: 8px; }
.appointment { color: #9a5b00; font-weight: 600; }
.addstage { flex: 0 0 200px; align-self: flex-start; display: flex; align-items: center; justify-content: center; gap: 8px; border: 2px dashed #bfd0d3; background: transparent; border-radius: var(--radius); padding: 18px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.addstage:hover { border-color: var(--brand); color: var(--brand); }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu > div { position: absolute; right: 0; top: 28px; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .14); padding: 5px; min-width: 210px; display: flex; flex-direction: column; }
.menu > div .btn { justify-content: flex-start; border: 0; font-weight: 500; padding: 7px 10px; }
.menu > div .btn:hover { background: var(--bg); }

/* Painéis, tabelas e números */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: block; margin-bottom: 14px; }
.panel h2 { margin-bottom: 10px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 10px; overflow-x: auto; flex: none; }
.tabs button, .tabs a { border: 0; background: transparent; padding: 9px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; text-decoration: none; white-space: nowrap; }
.tabs .active { color: var(--brand); border-bottom-color: var(--brand); }
.tablewrap { overflow: auto; max-height: 460px; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f6f9f9; position: sticky; top: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f2f8f8; }
td .input { width: auto; padding: 4px 6px; }
.tiles { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; min-width: 120px; }
.tile b { display: block; font-size: 22px; }
.tile span { color: var(--muted); font-size: 12px; }
.tile.good { background: var(--good-bg); border-color: transparent; }
.tile.bad { background: #fdeeee; border-color: transparent; }
.progress { height: 6px; background: #e6eeef; border-radius: 6px; overflow: hidden; margin: 8px 0; }
.progress div { height: 100%; background: var(--wa); }
.status { display: inline-block; border-radius: 20px; padding: 2px 10px; font-size: 12px; font-weight: 700; background: #e8f0f1; }
.status.running, .status.sending { background: #e3efff; color: #1d54b0; }
.status.scheduled, .status.paused, .status.pending { background: #fff2d6; color: #8a5a00; }
.status.completed, .status.delivered, .status.read, .status.sent { background: var(--good-bg); color: #0a6b45; }
.status.failed { background: #fdeaea; color: var(--danger); }
.campaigns { display: grid; gap: 12px; }
.campaign { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.campaign:hover { border-color: var(--brand); }
.numbers { font-size: 13px; }
.empty { text-align: center; padding: 30px 16px; display: flex; flex-direction: column; gap: 8px; align-items: center; color: var(--muted); }
.empty h3 { color: var(--ink); }

/* Assistente de disparo e importação */
.wizard { max-width: 900px; width: 100%; }
.step h2 { display: flex; align-items: center; gap: 10px; }
.step h2 i { font-style: normal; background: var(--brand); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 6px; color: inherit; }
.choice strong { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.choice span { color: var(--muted); font-size: 13px; }
.choice .chip.good { color: #0a6b45; font-size: 11px; }
.choice .chip.danger { color: var(--danger); font-size: 11px; }
.choice.active { border-color: var(--brand); background: #f0f9f8; }
.countbox { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; background: #eef6f6; border-radius: 8px; padding: 10px 14px; margin-top: 8px; }
.countbox b { font-size: 24px; }
.countbox small { color: var(--muted); }
.importer { display: flex; flex-direction: column; gap: 10px; }
.drop { border: 2px dashed #b5cacd; background: #f6fafa; border-radius: var(--radius); padding: 30px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; font: inherit; color: inherit; align-items: center; }
.drop strong { font-size: 15px; }
.drop span { color: var(--muted); }
.drop.over, .drop:hover { border-color: var(--brand); background: #edf8f7; }
.varrow { display: grid; grid-template-columns: 150px 1fr 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.preview { background: #e8ded3; border-radius: var(--radius); padding: 14px; margin: 8px 0; }
.preview .bubble { margin-left: auto; }
.fakebtn { background: #fff; color: #1b72c4; text-align: center; border-radius: 8px; padding: 7px; margin: 4px 0 0 auto; max-width: 78%; font-weight: 600; }

/* Conversa */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; flex: 1; }
.messages { flex: 1; overflow-y: auto; padding: 14px; background: #ece5dd; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.bubble { max-width: 78%; background: #fff; border-radius: 10px; padding: 7px 10px; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); width: fit-content; flex: none; }
.bubble.in { align-self: flex-start; }
.bubble.out { align-self: flex-end; background: #dcf8c6; }
.bubble.failed { background: #fde8e8; }
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.bubble small.err { color: var(--danger); }
.tick.read { color: #1b8fe0; font-weight: 700; }
.composer { border-top: 1px solid var(--line); padding: 10px 14px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.composer .row { width: 100%; flex-wrap: nowrap; align-items: flex-end; }
.composer select.input { width: auto; padding: 4px 8px; }
.inbox { flex: 1; display: grid; grid-template-columns: 330px 1fr; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); min-height: 380px; }
.inbox-list { overflow-y: auto; border-right: 1px solid var(--line); }
.conv { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 10px 14px; font: inherit; cursor: pointer; color: inherit; }
.conv.active, .conv:hover { background: #eef6f6; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.conv .row { flex-wrap: nowrap; }
.inbox-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.inbox-chat > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.inbox-chat > header > div { margin-right: auto; display: flex; flex-direction: column; }
.inbox-chat > .empty { margin: auto; }

/* Janelas */
.veil { position: fixed; inset: 0; background: rgba(8, 25, 29, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.veil.side { justify-content: flex-end; padding: 0; }
.modal { background: var(--surface); border-radius: 12px; width: min(460px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(700px, 100%); }
.modal header, .drawer > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 18px 10px; }
.modal .body { padding: 4px 18px 14px; overflow-y: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.drawer { background: var(--surface); width: min(620px, 100%); height: 100%; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0, 0, 0, .18); }
.drawer-tools { display: flex; gap: 8px; padding: 0 18px 10px; }
.drawer-tools select { flex: 1; }
.drawer .tabs { padding: 0 10px; margin: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px; min-height: 0; }
.drawer-body.flush { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.extra { background: var(--bg); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
.timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.timeline li { border-left: 3px solid var(--line); padding: 4px 0 8px 12px; }
.timeline li.note { border-left-color: var(--brand); }
.timeline li.optout { border-left-color: var(--danger); }
.timeline li p { white-space: pre-wrap; }
.timeline small { color: var(--muted); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatches button.active { box-shadow: 0 0 0 3px var(--ink); }
.stagelist { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.stagerow { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.stagerow i { width: 10px; height: 34px; border-radius: 4px; }
.stagerow small { display: block; }
.qr { display: block; width: 280px; height: 280px; margin: 12px 0; border: 1px solid var(--line); border-radius: 8px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 40; max-width: min(380px, calc(100% - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 8px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }

/* Entrada */
.auth { margin: auto; padding: 20px; width: min(420px, 100%); }
.authcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.authcard h1 { margin: 16px 0 10px; }
.authcard .brand { padding: 0; }
.authcard .brand small { color: var(--muted); max-width: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  aside { order: 2; flex-direction: row; padding: 4px; gap: 4px; }
  aside .brand, .me span { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; position: relative; }
  .nav .badge { position: absolute; top: 0; right: 0; }
  .me { margin: 0; }
  .page { padding: 12px 12px 18px; }
  .filters .input, .filters input[type="search"] { width: 100%; min-width: 0; }
  .grid2, .choices { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .varrow { grid-template-columns: 1fr; }
  .column { flex-basis: 82vw; }
  .inbox { grid-template-columns: 1fr; }
  .inbox-chat { display: none; }
  .inbox.open .inbox-list { display: none; }
  .inbox.open .inbox-chat { display: flex; }
  .btn.backbtn { display: inline-flex; }
}
