/* Sistema comercial (CRM, mensagens, desempenho, tarefas). Usa as variáveis de cor de style.css. */
:root { --src-meta: #2563eb; --src-google: #b45309; --src-ig: #9333ea; --src-wa: #15803d; --src-site: #a16207; --src-other: #64748b; }
@media (prefers-color-scheme: dark) { :root { --src-meta: #60a5fa; --src-google: #fbbf24; --src-ig: #c084fc; --src-wa: #4ade80; --src-site: #facc15; --src-other: #94a3b8; } }
body.wide main { max-width: 1680px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wraptabs { flex-wrap: wrap; }
.tabs a.tab { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a.tab:hover { color: var(--accent); }
.tabs a.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.kpi.tone-warn .value { color: var(--warn); }
.kpi.tone-bad .value { color: var(--bad); }
.small-kpis { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.small-kpis .kpi .value { font-size: 1.3rem; }
.alertbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.ok-t { color: var(--good); font-weight: 600; }
.bad-t { color: var(--bad); font-weight: 600; }
.tag.okt { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good); }
.tag.warnt { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
table.mini th, table.mini td { padding: 6px 8px; font-size: .9rem; }
table.mini caption { text-align: left; font-weight: 600; padding: 8px 0 4px; color: var(--heading); }
.plainlist { list-style: none; margin: 0; padding: 0; }
.plainlist li { padding: 6px 0; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.pre { white-space: pre-wrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
@media (max-width: 640px) { .two, .three { grid-template-columns: 1fr; } }
label.inline { display: inline-flex; margin: 0; }

/* campo de senha com olhinho */
.pwwrap { position: relative; display: block; }
.pwwrap input { width: 100%; padding-right: 48px; }
.pweye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 0; width: 40px; height: 36px; padding: 0; border: 0; background: none; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.pweye:hover { color: var(--accent); }

/* usuário logado e acessos */
.userbox { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.permtable th.c, .permtable td.c { text-align: center; white-space: normal; font-size: .75rem; padding: 8px 4px; width: 72px; }
.permtable td:first-child { white-space: normal; min-width: 160px; font-weight: 500; }
.permtable td.c input { width: 18px; height: 18px; }

/* página CRM */
.crm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.crm-client { display: block; color: inherit; text-decoration: none; margin: 0; transition: border-color var(--ease); }
.crm-client:hover { border-color: var(--accent); }
.crm-client-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.crm-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 12px; }
.crm-nums dt { font-size: .75rem; color: var(--muted); }
.crm-nums dd { margin: 0; font-size: 1.4rem; font-weight: 700; color: var(--heading); }
.crm-links { display: flex; flex-wrap: wrap; gap: 6px; font-size: .8rem; color: var(--accent); }
.crm-links span { background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }
.warn-t { color: var(--warn) !important; }

/* origem do lead */
.srcb { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600; border: 1px solid currentColor; color: var(--src-other); background: color-mix(in srgb, currentColor 8%, transparent); white-space: nowrap; }
.srcb.meta { color: var(--src-meta); } .srcb.google { color: var(--src-google); } .srcb.ig { color: var(--src-ig); } .srcb.wa { color: var(--src-wa); } .srcb.site { color: var(--src-site); }
.ch { display: inline-block; width: 4px; align-self: stretch; min-height: 16px; border-radius: 2px; background: var(--border); }
.ch.wa { background: var(--src-wa); } .ch.ig { background: var(--src-ig); }

/* barras horizontais */
.hbars { display: grid; gap: 6px; }
.hbar-row { display: grid; grid-template-columns: minmax(120px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar { height: 10px; border-radius: 5px; background: var(--accent-soft); overflow: hidden; }
.hbar > i { display: block; height: 100%; background: var(--accent-2); border-radius: 5px; }
.hbar > i.good { background: var(--good); } .hbar > i.bad { background: var(--bad); }
.hbar > i.src-meta { background: var(--src-meta); } .hbar > i.src-google { background: var(--src-google); } .hbar > i.src-ig { background: var(--src-ig); } .hbar > i.src-wa { background: var(--src-wa); } .hbar > i.src-site { background: var(--src-site); }
.hbar > i.src-org, .hbar > i.src-ind, .hbar > i.src-prosp { background: var(--src-other); }
.hbar-val { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }

/* filtros */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filterbar input[type="search"] { min-width: 220px; flex: 1; max-width: 360px; }
.filterbar.compact input[type="search"] { min-width: 0; max-width: none; }

/* kanban */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: 60vh; }
.col { flex: 0 0 272px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.col header { padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.col.won header { box-shadow: inset 0 3px 0 var(--good); } .col.lost header { box-shadow: inset 0 3px 0 var(--bad); } .col.open header { box-shadow: inset 0 3px 0 var(--accent-2); }
.colname { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.colval { font-size: .8rem; color: var(--muted); }
.dot-meta { width: 10px; height: 10px; border-radius: 50%; background: var(--src-meta); display: inline-block; }
.cards { padding: 8px; display: grid; gap: 8px; overflow-y: auto; }
.col.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.empty { text-align: center; padding: 12px 0; }
.lcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; cursor: grab; display: grid; gap: 4px; box-shadow: var(--shadow); transition: border-color var(--ease); }
.lcard:hover { border-color: var(--accent); }
.lcard.late { border-left: 3px solid var(--bad); }
.lcard.dragging { opacity: .5; }
.dropbar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); display: none; gap: 12px; z-index: 5; }
body.dragging-lead .dropbar { display: flex; }
.drop-target { min-width: 220px; padding: 18px 24px; border-radius: var(--radius); border: 2px dashed currentColor; background: var(--surface); text-align: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.drop-target.won { color: var(--good); } .drop-target.lost { color: var(--bad); }
.drop-target.over { background: color-mix(in srgb, currentColor 12%, var(--surface)); }
.lc-top { display: flex; gap: 8px; align-items: center; }
.lc-top b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-ad { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-meta, .lc-flags, .lc-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lc-val { font-weight: 600; font-size: .85rem; color: var(--heading); }

/* ficha do lead e da tarefa */
dialog.wide { width: min(1180px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; }
.leadpanel, .taskpanel { display: flex; flex-direction: column; max-height: calc(100vh - 26px); }
.lp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.lp-head h2 { margin: 0 0 4px; font-size: 1.25rem; }
.lp-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); overflow: hidden; flex: 1; min-height: 0; }
.lp-fields { padding: 16px 20px 0; overflow-y: auto; border-right: 1px solid var(--border); }
.lp-side { padding: 16px 20px; overflow-y: auto; }
@media (max-width: 860px) { .lp-grid { grid-template-columns: 1fr; overflow-y: auto; } .lp-fields { border-right: 0; overflow: visible; } .lp-side { overflow: visible; } }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: 10px 0 14px; border-top: 1px solid var(--border); justify-content: flex-end; }
.sticky-actions .danger { margin-right: auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.timeline li { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; font-size: .9rem; }
.timeline li.ev-etapa { border-color: var(--accent-2); } .timeline li.ev-meta { border-color: var(--src-meta); } .timeline li.ev-pagamento { border-color: var(--good); }
.timeline li.ev-nota, .timeline li.note-nota { border-color: var(--highlight); } .timeline li.note-mensagem { border-color: var(--src-wa); }
.timeline .xbtn, .checklist .xbtn, table .xbtn, .stage-btns .xbtn, .an-meta .xbtn { position: static; display: inline-flex; align-items: center; justify-content: center; }

/* conversa */
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.chat.tall { max-height: none; flex: 1; border: 0; border-radius: 0; }
.chat-day { align-self: center; font-size: .75rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 10px; margin: 6px 0; }
.bubble { max-width: 78%; padding: 6px 10px 4px; border-radius: 10px; font-size: .92rem; white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow); }
.bubble span { display: block; text-align: right; font-size: .7rem; color: var(--muted); }
.bubble.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.bubble.out { align-self: flex-end; background: color-mix(in srgb, var(--src-wa) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--src-wa) 30%, var(--border)); }

/* caixa de mensagens */
.inbox { display: grid; grid-template-columns: 340px 1fr; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); height: calc(100vh - 260px); min-height: 420px; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.inbox-list .filterbar { padding: 8px; margin: 0; border-bottom: 1px solid var(--border); }
.inbox-list ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.conv { width: 100%; display: flex; gap: 8px; align-items: stretch; text-align: left; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: none; padding: 10px; min-height: 0; }
.conv.sel { background: var(--accent-soft); }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-main b, .conv-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.dot-wait { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); }
.inbox-thread { display: flex; flex-direction: column; min-height: 0; }
.thread-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
@media (max-width: 760px) { .inbox { grid-template-columns: 1fr; height: auto; } .inbox-list ul { max-height: 40vh; } }

/* desempenho */
.goalbar { height: 14px; border-radius: 7px; background: var(--accent-soft); overflow: hidden; }
.goalbar > i { display: block; height: 100%; background: var(--good); }
table.hist th, table.hist td { padding: 6px 8px; font-size: .85rem; }
table.hist tr.cur td { background: var(--accent-soft); font-weight: 600; }
tr.selling td:first-child { box-shadow: inset 3px 0 0 var(--good); }
.sim .kpis { margin: 8px 0 0; }

/* análise semanal */
.analysis-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .analysis-layout { grid-template-columns: 1fr; } }
.an-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.an-list .linkbtn { text-decoration: none; }
.an-list .linkbtn.sel { font-weight: 700; text-decoration: underline; }
.an-list .linkbtn:hover { color: var(--accent); }
.an-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mdtext h2 { font-size: 1.3rem; margin: 22px 0 10px; }
.mdtext h3 { font-size: 1.05rem; text-transform: none; letter-spacing: 0; color: var(--heading); margin: 18px 0 8px; }
.mdtext h4 { margin: 14px 0 6px; color: var(--heading); }
.mdtext p, .mdtext li { line-height: 1.6; }
.mdtext li { margin-bottom: 4px; }
.mdtext code { background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }

/* funil: editor de etapas */
.stage-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1.2fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.stage-row input, .stage-row select { width: 100%; }
.stage-btns { display: flex; gap: 4px; }
@media (max-width: 760px) { .stage-row { grid-template-columns: 1fr 1fr; } }
#pe-form { padding: 20px; overflow-y: auto; max-height: calc(100vh - 40px); }
#cm-form { padding: 20px; }

/* tarefas */
.quickadd { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px; }
.quickadd input[name="title"] { flex: 1; min-width: 220px; }
.tasktable td { white-space: normal; vertical-align: middle; }
.tasktable td.chk { width: 36px; }
.tasktable tr.done b { text-decoration: line-through; color: var(--muted); }
.prio { font-size: .75rem; font-weight: 600; }
.prio.p-urgente { color: var(--bad); } .prio.p-alta { color: var(--warn); } .prio.p-normal, .prio.p-baixa { color: var(--muted); }
.checklist { list-style: none; padding: 0; margin: 0 0 8px; }
.checklist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.checklist label.check { margin: 0; font-weight: 400; }

@media print {
  .wraptabs, .an-list, #crm-body > .banner, .an-meta .xbtn { display: none !important; }
  .analysis-layout { grid-template-columns: 1fr; }
}
