:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #1f6feb; --ok: #12805c; --warn: #b45309; --me: #dcf3e6;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111418; --panel: #1a1f26; --text: #e6e9ee; --muted: #9aa3ae; --line: #2a313b;
    --accent: #4c8dff; --ok: #3ccf91; --warn: #f0a44b; --me: #183428; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 6px; padding: 8px 14px; background: var(--accent); color: #fff; }
button.sec { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.link { background: none; color: var(--muted); padding: 4px 8px; }
button:disabled { opacity: .6; cursor: wait; }
input, select, textarea { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
textarea { width: 100%; resize: vertical; }
.muted { color: var(--muted); }
.ok { color: var(--ok); } .warn { color: var(--warn); }

header { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
header form { margin-left: auto; }
nav { display: flex; gap: 4px; }
nav button { background: none; color: var(--muted); }
nav button.active { background: var(--bg); color: var(--text); font-weight: 600; }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; } .tab.active { display: block; }
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; }
.toolbar input { min-width: 280px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi, .card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi b { font-size: 22px; }
.card { margin-bottom: 16px; } .card h3 { margin: 0 0 12px; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 180px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 8px; }
.bar i { display: block; width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar small { font-size: 10px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); } th { color: var(--muted); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }

.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { min-width: 230px; width: 230px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: calc(100vh - 170px); overflow-y: auto; }
.col.over { outline: 2px dashed var(--accent); }
.col h4 { margin: 0 0 10px; display: flex; justify-content: space-between; } .col h4 span { color: var(--muted); }
.card-c { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; cursor: grab; display: flex; flex-direction: column; }
.card-c small { color: var(--muted); } .card-c small.ok { color: var(--ok); } .card-c small.warn { color: var(--warn); }

.split { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 110px); }
.split aside { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); }
#listaConversas { list-style: none; margin: 0; padding: 0; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; flex: 1; }
#listaConversas li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; }
#listaConversas li.sel { background: var(--bg); }
#listaConversas li small { color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; background: var(--warn); border-radius: 50%; margin-left: 6px; }
.detalhe { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; min-height: 0; }
.detalhe.vazio { align-items: center; justify-content: center; color: var(--muted); }
.det-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.det-head h2 { margin: 0; font-size: 17px; }
.det-body { display: grid; grid-template-columns: 1fr 260px; flex: 1; min-height: 0; }
.msgs { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 70%; background: var(--bg); border-radius: 10px; padding: 6px 10px; align-self: flex-start; }
.msg.me { background: var(--me); align-self: flex-end; }
.msg p { margin: 0; white-space: pre-wrap; word-break: break-word; } .msg small { color: var(--muted); font-size: 11px; }
.side { border-left: 1px solid var(--line); padding: 12px; overflow-y: auto; }
.side h4 { margin: 8px 0; } .sale { display: flex; flex-direction: column; margin-bottom: 8px; } .sale small { color: var(--muted); }
.envio { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }

.toolbar.wrap { flex-wrap: wrap; }
a.btn { display: inline-block; text-decoration: none; border-radius: 6px; padding: 8px 14px; }
a.btn.sec { color: var(--accent); border: 1px solid var(--accent); }
.grid2.eq { grid-template-columns: 1fr 1fr; }
.scroll { overflow-x: auto; }
tr.click { cursor: pointer; } tr.click:hover { background: var(--bg); }
.tag { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.tag.st-paga { color: var(--ok); border-color: var(--ok); }
.tag.st-recusada, .tag.st-chargeback, .tag.st-reembolsada { color: #d14343; border-color: #d14343; }
.tag.st-aguardando, .tag.st-carrinho_abandonado { color: var(--warn); border-color: var(--warn); }
.card form, form.card { display: flex; flex-direction: column; gap: 10px; }
.qr-list { list-style: none; margin: 0; padding: 0; }
.qr-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.qr-list p { margin: 4px 0 0; white-space: pre-wrap; color: var(--muted); }
.row { display: flex; gap: 6px; } .row input { flex: 1; min-width: 0; }
.small { font-size: 12px; margin: 0 0 6px; }
.envio select { max-width: 170px; }

.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 32px; width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-box h1 { margin: 0; } .erro { color: #d14343; margin: 0; min-height: 1em; }

@media (max-width: 900px) {
  .grid2, .grid2.eq, .split, .det-body { grid-template-columns: 1fr; }
  .split { height: auto; } .side { border-left: 0; border-top: 1px solid var(--line); }
  .toolbar input { min-width: 0; width: 100%; }
}
