/* ============================================================
   Central de Atendimento — Design System (light / dark)
   ============================================================ */

/* ---------- Tema: variaveis ---------- */
:root,
html[data-theme="light"] {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f1f3f5;
    --surface-3: #e9ecef;
    --border: #e4e7eb;
    --border-strong: #d2d7de;
    --text: #1b1f27;
    --text-2: #4a5263;
    --text-muted: #8a93a2;
    --accent: #10b981;
    --accent-strong: #059669;
    --accent-soft: #e7f8f1;
    --accent-text: #047857;
    --danger: #ef4444;
    --danger-soft: #fdecec;
    --warning: #d97706;
    --warning-soft: #fef6e7;
    --bubble-in: #ffffff;
    --bubble-out: #d8f3e5;
    --ia: #6366f1;
    --ia-strong: #4f46e5;
    --ia-soft: #eef0ff;
    --ia-bubble: #eef1ff;
    --chat-bg: #eef1f4;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
    --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
    --shadow-lg: 0 12px 28px rgba(16,24,40,.12);
    --radius: 12px;
    --radius-sm: 8px;
}

html[data-theme="dark"] {
    --bg: #0e1014;
    --surface: #161922;
    --surface-2: #1c212b;
    --surface-3: #252b37;
    --border: #2a313d;
    --border-strong: #3a414f;
    --text: #e7eaf0;
    --text-2: #b6bdca;
    --text-muted: #7f8897;
    --accent: #10b981;
    --accent-strong: #34d399;
    --accent-soft: #10271e;
    --accent-text: #6ee7b7;
    --danger: #f87171;
    --danger-soft: #2a1517;
    --warning: #fbbf24;
    --warning-soft: #2a210f;
    --bubble-in: #1c212b;
    --bubble-out: #11362a;
    --ia: #818cf8;
    --ia-strong: #a5b4fc;
    --ia-soft: #1b1f3a;
    --ia-bubble: #1a1e33;
    --chat-bg: #0b0d11;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 1px 3px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.35);
    --shadow-lg: 0 14px 30px rgba(0,0,0,.55);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background .2s ease, color .2s ease;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4,h5 { color: var(--text); margin: 0 0 .5rem; font-weight: 650; }

/* ---------- Layout ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: .65rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); font-size: 1rem; }
.brand .logo {
    width: 30px; height: 30px; border-radius: 9px;
    display: grid; place-items: center; color: #fff; font-size: 1rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}
.topbar-actions { display: flex; align-items: center; gap: .6rem; }
.container { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem; }
.container-wide { max-width: 1320px; margin: 0 auto; padding: 1.25rem; }

/* ---------- Botoes ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: inherit; font-weight: 600; line-height: 1;
    padding: .55rem .9rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .05s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--border-strong); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: .38rem .6rem; font-size: .8rem; }
.btn-icon { padding: .45rem; width: 36px; height: 36px; border-radius: var(--radius-sm); }

/* status pill (online/offline) */
.status-pill {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem .7rem; border-radius: 999px; font-weight: 600; font-size: .8rem;
    border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2);
    cursor: pointer;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-pill.on { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.status-pill.on .dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-header { padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.card-body { padding: 1.1rem; }
.card-footer { padding: .85rem 1.1rem; border-top: 1px solid var(--border); }

/* ---------- Inputs ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; color: var(--text-2); margin-bottom: .35rem; font-size: .85rem; }
.input {
    width: 100%; font: inherit; color: var(--text);
    padding: .6rem .75rem; border-radius: var(--radius-sm);
    background: var(--surface); border: 1px solid var(--border-strong);
    transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-muted); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; padding: .15rem .5rem;
    border-radius: 999px; font-size: .72rem; font-weight: 650;
    background: var(--surface-3); color: var(--text-2);
}
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-count { background: var(--danger); color: #fff; min-width: 20px; height: 20px; justify-content: center; }
.badge-muted { background: var(--surface-3); color: var(--text-muted); }

/* ---------- Avatar ---------- */
.avatar {
    width: 42px; height: 42px; border-radius: 50%; flex: none;
    display: grid; place-items: center; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, #34d399, #10b981);
    font-size: .95rem; text-transform: uppercase;
}
.avatar.sm { width: 34px; height: 34px; font-size: .8rem; }

/* ---------- Lista de conversas ---------- */
.conv-list { display: flex; flex-direction: column; }
.conv {
    display: flex; gap: .75rem; align-items: center;
    padding: .8rem .9rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer; color: inherit;
    transition: background .12s, border-color .12s;
}
.conv:hover { background: var(--surface-2); text-decoration: none; }
.conv.active { background: var(--accent-soft); border-color: transparent; }
.conv-main { min-width: 0; flex: 1; }
.conv-name { font-weight: 650; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-sub { color: var(--text-muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Responsavel (quem atende) DESTACADO na linha — pill de destaque; 'na fila' fica discreto. */
.conv-resp { display: inline-flex; align-items: center; gap: .2rem; font-weight: 700;
  color: var(--accent-text); background: var(--accent-soft); padding: 0 .45rem; border-radius: 6px; }
.conv-fila { color: var(--text-muted); font-style: italic; }
.conv-meta { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.conv-time { color: var(--text-muted); font-size: .72rem; }

/* ---------- Chat ---------- */
.chat-wrap { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
/* Painel do precatorio = gaveta que desliza da direita; o chat ocupa a tela toda */
.side-right { position: fixed; top: 0; right: 0; height: 100vh; width: min(440px, 94vw);
  background: var(--bg); z-index: 1200; overflow-y: auto; padding: 1rem 1rem 2rem;
  transform: translateX(100%); transition: transform .25s ease; box-shadow: -12px 0 40px rgba(0,0,0,.28); }
.side-right.open { transform: translateX(0); }
.side-right .card-body { max-height: none; }
.prec-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1150; opacity: 0; pointer-events: none; transition: opacity .25s; }
.prec-backdrop.open { opacity: 1; pointer-events: auto; }
.prec-tab { position: fixed; right: 0; top: 42%; z-index: 1100; background: #009640; color: #fff; border: none;
  cursor: pointer; padding: .9rem .5rem; border-radius: 10px 0 0 10px; box-shadow: -3px 3px 14px rgba(0,0,0,.2);
  font-weight: 700; font-size: .8rem; letter-spacing: .02em; }
.prec-tab:hover { background: #007d35; }
.prec-tab .prec-tab-txt { writing-mode: vertical-rl; text-orientation: mixed; }
.prec-close { float: right; border: none; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--text-muted); padding: 0 .2rem; }
.prec-close:hover { color: var(--text); }
/* Aba/gaveta "Gerar mensagem" (chat de melhoria) — 2a aba na borda direita, abaixo do Precatorio */
.msg-tab { position: fixed; right: 0; top: 42%; transform: translateY(calc(-100% - 8px)); z-index: 1100;
  background: #6d5df6; color: #fff; border: none; cursor: pointer; padding: .9rem .5rem;
  border-radius: 10px 0 0 10px; box-shadow: -3px 3px 14px rgba(0,0,0,.2);
  font-weight: 700; font-size: .8rem; letter-spacing: .02em; }
.msg-tab:hover { background: #5b4bd6; }
.msg-tab .prec-tab-txt { writing-mode: vertical-rl; text-orientation: mixed; }
.msg-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1150; opacity: 0; pointer-events: none; transition: opacity .25s; }
.msg-backdrop.open { opacity: 1; pointer-events: auto; }
/* header do chat nao estoura quando o chat fica estreito (3 colunas): quebra em linhas */
.chat .card-header { flex-wrap: wrap; row-gap: .5rem; }
/* Toolbar de acoes do topo da conversa: controles com MESMA altura/alinhamento (clean e simetrico) */
.chat-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.chat-actions form { margin: 0; display: inline-flex; }
.chat-actions .btn,
.chat-actions .badge,
.chat-actions .ia-pill,
.chat-actions select.input {
  height: 34px; box-sizing: border-box; display: inline-flex; align-items: center;
  font-size: .8rem; line-height: 1; margin: 0; white-space: nowrap; border-radius: 8px; }
.chat-actions .btn { padding: 0 .7rem; }
.chat-actions select.input { width: auto; padding: 0 1.4rem 0 .6rem; }
.chat-actions .badge, .chat-actions .ia-pill { padding: 0 .7rem; border-radius: 999px; }
.chat .card-header .flex { flex-wrap: wrap; min-width: 0; }
/* cards da lateral recolhiveis (layout clean; Ficha aberta por padrao) */
.side:not(.side-right) .card.is-collapsed > .card-body { display: none; }
.prec-sec { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: .2rem 0 .5rem; }
.prec-grid { display: flex; flex-wrap: wrap; gap: .5rem .6rem; }
.prec-grid label { display: flex; flex-direction: column; gap: .18rem; flex: 1 1 45%; min-width: 0; }
.prec-grid label.full { flex-basis: 100%; }
.prec-grid label > span { font-size: .7rem; color: var(--text-muted); }
.prec-grid .input { width: 100%; }
.prec-grid label.prec-check { flex-direction: row; align-items: center; gap: .45rem; }
.prec-grid label.prec-check > span { font-size: .8rem; color: inherit; }
/* cards de processo (1 por precatorio; recolhiveis) */
.side-right .card.proc-card { margin-bottom: .55rem; }
.side-right .card.proc-card > .proc-head { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.side-right .card.proc-card.is-collapsed > .card-body { display: none; }
/* campos obrigatorios para o calculo automatico (destaque verde) */
.prec-grid label.req-field { border-left: 3px solid #009640; padding-left: .5rem; }
.prec-grid label.req-field > span { color: #009640; font-weight: 700; }
.prec-grid label.req-field > span::after { content: " *"; }
.prec-grid label.req-field .input { border-color: #009640; }
/* Proposta de compra (layout espelhado do sgnaples) */
.prop-abrir { margin-top: .5rem; width: 100%; background: #009640; color: #fff; }
.prop-abrir:hover { background: #007d35; }
.prec-actions { display: flex; gap: .5rem; margin-top: .8rem; }
.prec-actions > .btn { flex: 1; margin: 0; }
.prop-calc { width: 100%; background: #0369a1; color: #fff; }
.prop-calc:hover { background: #075985; }
/* Modo "Utilizar valor Cheio SG" (proposta exata) x motor automatico (independente) */
.sg-toggle { display: flex; gap: .5rem; align-items: flex-start; padding: .5rem .6rem; margin-bottom: .7rem;
  background: #ecfdf5; border: 1px solid #6ee7b7; border-radius: 8px; cursor: pointer; }
.sg-toggle > span { font-size: .74rem; line-height: 1.25; color: #065f46; }
.sg-toggle input { margin-top: .15rem; width: auto; }
.sg-only { display: none; }
.side-right .card-body.sg-mode .motor-field { opacity: .4; pointer-events: none; }
.side-right .card-body.sg-mode .motor-only { display: none; }
.side-right .card-body.sg-mode .sg-only { display: block; }
.side-right .card-body.sg-mode .sg-value > span { color: #065f46; font-weight: 700; }
.side-right .card-body.sg-mode .sg-value .input { border-color: #009640; box-shadow: 0 0 0 2px rgba(0,150,64,.15); }
.prop-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 1rem; }
.prop-card { position: relative; overflow: hidden; background: #fff; color: #1f2937; width: 430px; max-width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 12px; padding: 1.6rem 1.6rem .4rem; font-family: Inter, sans-serif; box-shadow: 0 20px 60px rgba(0,0,0,.35); text-align: left; }
.prop-watermark { position: absolute; right: -40px; top: 30px; width: 280px; height: 280px; opacity: .06; pointer-events: none; z-index: 0; }
.prop-card > *:not(.prop-watermark) { position: relative; z-index: 1; }
.prop-logo { margin-bottom: .7rem; }
.prop-logo-img { height: 2.2rem; width: auto; display: block; }
.prop-title { color: #009640; font-weight: 800; font-size: 1.85rem; line-height: 1.05; }
.prop-subtitle { color: #4b5563; margin: .2rem 0 1rem; font-size: .95rem; }
.prop-row { margin: .35rem 0; font-size: .92rem; }
.prop-row span { color: #009640; font-weight: 700; }
.prop-ded { color: #6b7280; font-size: .8rem; margin: .8rem 0 1rem; }
.prop-tiers { display: flex; gap: .5rem; margin-bottom: .8rem; }
.prop-tier { flex: 1; border: 1px solid #009640; background: #fff; color: #009640; border-radius: 999px; padding: .38rem 0; font-weight: 700; cursor: pointer; }
.prop-tier.active { background: #009640; color: #fff; }
.prop-valorbox { background: #009640; color: #fff; border-radius: 8px; padding: .9rem; text-align: center; }
.prop-valor-lbl { font-size: .85rem; opacity: .95; }
.prop-valor-num { font-size: 2rem; font-weight: 800; }
.prop-valida { text-align: center; color: #6b7280; font-size: .82rem; margin: .7rem 0; }
.prop-rodape { background: #009640; color: #fff; border-radius: 8px 8px 0 0; padding: .9rem; text-align: center; font-size: .82rem; margin-top: .4rem; }
.prop-phones { display: flex; justify-content: center; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .55rem; font-weight: 700; font-size: .8rem; }
.prop-fechar { display: block; margin: .7rem auto .4rem; }
/* telas medias: estreita a coluna da lista lateral (o precatorio ja e gaveta) */
@media (max-width: 1100px) {
    .chat-wrap { grid-template-columns: 300px minmax(0, 1fr); }
}
.chat { display: flex; flex-direction: column; height: calc(100vh - 130px); }
.chat-body {
    flex: 1; overflow-y: auto; padding: 1.25rem;
    background: var(--chat-bg); display: flex; flex-direction: column; gap: .5rem;
}
/* Notas internas no topo do chat (recolhivel; editaveis). Nunca vao ao lead. */
.notas-top { flex: none; border-bottom: 1px solid var(--border); background: var(--surface); }
.notas-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between;
    gap: .5rem; background: none; border: 0; cursor: pointer; padding: .5rem .9rem;
    font-weight: 700; color: inherit; font-size: .88rem; font-family: inherit; }
.notas-toggle:hover { background: rgba(127,127,127,.07); }
.notas-corpo { padding: .5rem .9rem .7rem; max-height: 42vh; overflow-y: auto; }
.notas-corpo .nota-item { border-top: 1px solid var(--border); padding: .45rem 0; font-size: .83rem; }
.notas-corpo .nota-item:first-of-type { border-top: 0; }
.notas-corpo .nota-meta { font-size: .72rem; margin-top: .2rem; }
.notas-corpo .nota-del { color: var(--danger); }
.bubble {
    max-width: 68%; padding: .55rem .8rem; border-radius: 14px;
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    word-wrap: break-word; position: relative;
}
.bubble.in  { background: var(--bubble-in); border-bottom-left-radius: 4px; align-self: flex-start; }
.bubble.out { background: var(--bubble-out); border-bottom-right-radius: 4px; align-self: flex-end; }
.bubble .time { display: block; font-size: .68rem; color: var(--text-muted); margin-top: .25rem; text-align: right; }
.bubble .media { font-style: italic; color: var(--text-2); }

/* citacao dentro do balao (responder) */
.bubble .quote {
    display: flex; flex-direction: column; gap: 1px; cursor: pointer;
    border-left: 3px solid var(--accent); padding: .25rem .5rem; margin-bottom: .35rem;
    background: color-mix(in srgb, var(--accent) 9%, transparent);
    border-radius: 5px; font-size: .78rem; line-height: 1.25;
}
.bubble .quote .quote-who { font-weight: 700; color: var(--accent-text); font-size: .68rem; }
.bubble .quote .quote-text { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* acoes por mensagem (aparecem no hover do balao recebido) */
.bubble .msg-acts {
    position: absolute; top: -10px; right: 6px; display: none; gap: 2px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
    box-shadow: var(--shadow-sm); padding: 1px;
}
.bubble:hover .msg-acts { display: flex; }
.bubble .msg-acts button {
    border: 0; background: transparent; cursor: pointer; font-size: .82rem;
    line-height: 1; padding: .2rem .34rem; border-radius: 999px; color: var(--text-2);
}
.bubble .msg-acts button:hover { background: var(--accent-soft); }

/* destaque ao pular para a mensagem citada */
@keyframes bubbleFlash { 0%,100% { box-shadow: var(--shadow-sm); } 30% { box-shadow: 0 0 0 3px var(--accent); } }
.bubble-flash { animation: bubbleFlash 1.3s ease; }

/* banner de "respondendo" acima do campo de resposta */
.reply-banner {
    display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem;
    padding: .4rem .55rem; border-radius: var(--radius-sm);
    background: var(--accent-soft); border: 1px solid var(--border);
}
.reply-banner .reply-bar { width: 3px; align-self: stretch; background: var(--accent); border-radius: 3px; }
.reply-banner .reply-title { font-size: .68rem; font-weight: 700; color: var(--accent-text); }
.reply-banner .reply-snippet { font-size: .8rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-banner .reply-x { border: 0; background: transparent; cursor: pointer; font-size: 1.1rem; line-height: 1; color: var(--text-muted); padding: 0 .25rem; }
.reply-banner .reply-x:hover { color: var(--danger); }

/* ---------- Alerts ---------- */
.alert { padding: .65rem .85rem; border-radius: var(--radius-sm); margin-bottom: .85rem; font-size: .88rem; border: 1px solid transparent; }
.alert-info { background: var(--accent-soft); color: var(--accent-text); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-success { background: var(--accent-soft); color: var(--accent-text); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Utilitarios ---------- */
.muted { color: var(--text-muted); }
.text-2 { color: var(--text-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.gap-sm { gap: .5rem; }
.flex { display: flex; align-items: center; }
.empty { text-align: center; color: var(--text-muted); padding: 2.5rem 1rem; }
.page-title { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.1rem; }

/* scrollbar discreta */
.chat-body::-webkit-scrollbar, .scroll::-webkit-scrollbar { width: 8px; }
.chat-body::-webkit-scrollbar-thumb, .scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

/* ---------- IA: balao, badges e bot ---------- */
.bubble.ia { background: var(--ia-bubble); border-bottom-right-radius: 4px; align-self: flex-end; border-color: color-mix(in srgb, var(--ia) 22%, transparent); }
.bubble .who { display: block; font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .15rem; }
.bubble.ia .who { color: var(--ia); }
.bubble.out .who { color: var(--accent-text); }
.badge-ia { background: var(--ia-soft); color: var(--ia); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.avatar.bot { background: linear-gradient(135deg, var(--ia), var(--ia-strong)); }

/* ---------- Interruptor da IA por conversa (verde on / vermelho off) ---------- */
.conv-item { display: flex; align-items: center; gap: .5rem; padding: .5rem .55rem; border-radius: 10px;
  position: relative; transition: background .12s; }
.conv-item:hover { background: var(--surface-2); }
.conv-item .conv { flex: 1; min-width: 0; padding: .3rem .15rem; border: 0; }
.conv-item .conv:hover { background: transparent; }
.conv-item .conv-meta { min-width: 76px; }
/* Etapa: fundo VIVO na cor da etapa + barra lateral grossa (reuniao 05/08: chamativo, cor viva). */
.conv-item.has-cor { background: color-mix(in srgb, var(--etapa-cor) 30%, transparent); }
.conv-item.has-cor::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 5px; border-radius: 0 4px 4px 0; background: var(--etapa-cor); }
.conv-item.has-cor:hover { background: color-mix(in srgb, var(--etapa-cor) 38%, transparent); }
/* Tag chamativa 'DESQUALIFICADO' — SO nas etapas de desqualificacao. Fundo na cor da etapa
   (vermelhos parecidos: atendente #f56042 x IA #e11d48) -> diferencia quem desqualificou pela cor. */
.conv-badges { display: inline-flex; align-items: center; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.etapa-tag { display: inline-flex; align-items: center; padding: .14rem .55rem; border-radius: 999px;
  font-size: .64rem; font-weight: 800; letter-spacing: .03em; white-space: nowrap;
  background: var(--etapa-cor); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.28); }
/* Controles a direita: MESMA altura e largura alinhada (simetrico e clean) */
.conv-item .conv-ia { padding: 0; margin: 0; }
/* slot fixo p/ a pilula da IA: reservado mesmo quando a linha nao esta em modo IA (sem pilula),
   pra as colunas seguintes (horario, etapa, editar) ficarem TODAS no esquadro entre as linhas. */
.conv-item .conv-pill { flex: none; width: 82px; display: inline-flex; align-items: center; }
.conv-item .ia-pill { height: 30px; box-sizing: border-box; }
.conv-item .conv-etapa-sel { height: 30px; box-sizing: border-box; width: 150px;
  padding: 0 1.4rem 0 .55rem; font-size: .78rem; border-radius: 8px; }
.conv-item > .btn { height: 30px; box-sizing: border-box; display: inline-flex; align-items: center;
  padding: 0 .5rem; border-radius: 8px; }
.conv-ia { display: flex; align-items: center; padding: 0 .5rem 0 .25rem; margin: 0; flex: none; }
.ia-pill { display: inline-flex; align-items: center; gap: .25rem; padding: .28rem .55rem; border-radius: 999px;
    font-size: .72rem; font-weight: 700; line-height: 1; border: 1px solid transparent; font-family: inherit; white-space: nowrap; }
.ia-pill.on  { background: var(--accent-soft); color: var(--accent-text); }
.ia-pill.off { background: var(--danger-soft); color: var(--danger); }
.ia-pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.ia-pill.on .dot  { background: var(--accent); }
.ia-pill.off .dot { background: var(--danger); }
button.ia-pill { cursor: pointer; transition: filter .12s; }
button.ia-pill:hover { filter: brightness(.96); }

/* ---------- Ficha do lead (dados da IA) ---------- */
.ficha { display: flex; flex-direction: column; }
.ficha-row { display: flex; justify-content: space-between; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .85rem; }
.ficha-row:last-child { border-bottom: none; }
.ficha-row .k { color: var(--text-muted); flex: none; }
.ficha-row .v { color: var(--text); font-weight: 600; text-align: right; word-break: break-word; }
.ficha-row .v.vazio { color: var(--text-muted); font-weight: 400; font-style: italic; }
.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); transition: width .3s ease; }

/* ---------- Logs / auditoria ---------- */
.log-list { display: flex; flex-direction: column; max-height: 340px; overflow-y: auto; }
.log-item { display: flex; gap: .5rem; padding: .4rem .1rem; border-bottom: 1px solid var(--border); font-size: .78rem; }
.log-item:last-child { border-bottom: none; }
.log-item .when { color: var(--text-muted); white-space: nowrap; flex: none; }
.log-item .ator { font-weight: 700; flex: none; }
.log-item .ator.ia { color: var(--ia); }
.log-item .ator.lead { color: var(--accent-text); }
.log-item .ator.atendente { color: var(--text); }
.log-item .ator.sistema, .log-item .ator.admin { color: var(--text-muted); }
.log-item .det { color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Simulador (lab) ---------- */
.lab-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1.25rem; align-items: start; }
.lab-side { display: flex; flex-direction: column; gap: 1.25rem; }
.lab-chat { display: flex; flex-direction: column; height: calc(100vh - 200px); min-height: 420px; }

/* responsivo */
@media (max-width: 820px) {
    .chat-wrap { grid-template-columns: 1fr; }
    .chat-wrap .side:not(.side-right) { display: none; }
    .chat { height: calc(100vh - 120px); }
}
@media (max-width: 900px) {
    .lab-grid { grid-template-columns: 1fr; }
}

/* ---------- Ficha: principais + edicao manual ---------- */
.ficha-principal { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 0 .55rem; margin-bottom: .35rem; }
.ficha-principal .ficha-row { border-bottom-color: color-mix(in srgb, var(--accent) 20%, transparent); }
.ficha-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem .6rem; }
.ficha-edit-grid .campo { display: flex; flex-direction: column; gap: .22rem; font-size: .72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.ficha-edit-grid .campo.full { grid-column: 1 / -1; }
.ficha-edit-grid .campo.principal > span::after { content: " ★"; color: var(--accent); }
.ficha-edit-grid .input { padding: .42rem .55rem; font-size: .85rem; text-transform: none; font-weight: 500; }
.ficha-edit-grid select.input { height: 34px; }

/* atribuicao manual (responsavel) */
.assign { display: flex; align-items: center; gap: .4rem; margin: 0; }
.assign select.input { flex: 1; padding: .35rem .5rem; font-size: .82rem; }

/* ---------- Painel admin (hub) ---------- */
.hub-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem; margin-bottom: 1.1rem; }
.hub-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: .9rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; }
.hub-stat .n { font-size: 1.6rem; font-weight: 750; color: var(--text); line-height: 1; }
.hub-stat .l { font-size: .78rem; color: var(--text-muted); font-weight: 600; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.hub-card { display: flex; flex-direction: column; gap: .35rem; padding: 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: inherit; transition: transform .08s, border-color .12s, box-shadow .12s; }
.hub-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-lg); }
.hub-card .ic { font-size: 1.7rem; line-height: 1; }
.hub-card .t { font-weight: 700; color: var(--text); font-size: 1rem; }
.hub-card .d { font-size: .82rem; color: var(--text-muted); line-height: 1.4; }

/* tabela generica */
.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th { text-align: left; padding: .6rem .7rem; color: var(--text-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border); }
.tbl td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--surface-2); }

@media (max-width: 720px) { .hub-stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Filtros / logs ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.fbox { display: flex; flex-direction: column; gap: .2rem; font-size: .7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.fbox .input { font-size: .85rem; font-weight: 500; text-transform: none; padding: .4rem .55rem; }
.logator { font-weight: 700; font-size: .78rem; }
.logator.ia { color: var(--ia); }
.logator.lead { color: var(--accent-text); }
.logator.atendente { color: var(--text); }
.logator.admin, .logator.sistema { color: var(--text-muted); }
code.acao { background: var(--surface-3); padding: .12rem .4rem; border-radius: 6px; font-size: .76rem; color: var(--text-2); }
.det-json { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .4rem .55rem; font-size: .72rem; white-space: pre-wrap; word-break: break-word; margin: .25rem 0 0; max-width: 520px; }

/* duas colunas (GPT/custos etc.) */
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 820px) { .cols-2 { grid-template-columns: 1fr; } }

/* indicador "digitando..." (bolha com pontinhos animados) */
.bubble.typing { padding: .7rem .9rem; }
.bubble.typing .dots { display: inline-flex; gap: 4px; align-items: center; }
.bubble.typing .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); display: inline-block; animation: lab-blink 1.2s infinite both; }
.bubble.typing .dots i:nth-child(2) { animation-delay: .2s; }
.bubble.typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes lab-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.lab-lendo { align-self: center; color: var(--text-muted); font-size: .78rem; font-style: italic; padding: .35rem .6rem; }

/* status de ENVIO — pill somente leitura na topbar */
.envio-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .7rem; border-radius: 999px; font-weight: 700; font-size: .78rem; border: 1px solid transparent; white-space: nowrap; }
.envio-pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.envio-pill.on { background: var(--accent-soft); color: var(--accent-text); }
.envio-pill.on .dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.envio-pill.off { background: var(--danger-soft); color: var(--danger); }
.envio-pill.off .dot { background: var(--danger); }
/* status grande na sub-aba de envio */
.envio-status { display: inline-flex; align-items: center; gap: .6rem; padding: .7rem 1.2rem; border-radius: 999px; font-weight: 800; font-size: 1.05rem; border: 1px solid transparent; }
.envio-status .dot { width: 12px; height: 12px; border-radius: 50%; }
.envio-status.on { background: var(--accent-soft); color: var(--accent-text); }
.envio-status.on .dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.envio-status.off { background: var(--danger-soft); color: var(--danger); }
.envio-status.off .dot { background: var(--danger); }

/* distribuicao: uma linha (form) por atendente */
.dist-row { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; padding: .65rem .2rem; border-bottom: 1px solid var(--border); margin: 0; }
.dist-row:last-child { border-bottom: none; }
.dist-row .dist-name { flex: 1; min-width: 160px; }
.dist-row .dist-chk { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--text-2); white-space: nowrap; }
