@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
  --fonte: 'Montserrat', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --bg: #16232f;          /* marinho profundo (sidebar) */
  --bg-soft: #223648;     /* hover no menu */
  --panel: #ffffff;
  --panel-soft: #faf7f0;  /* creme quente (fundo) */
  --border: #e8e1d3;      /* borda quente */
  --text: #1e2b38;        /* tinta marinho */
  --text-soft: #77808c;
  --primary: #1e3a52;     /* marinho (botoes/links) */
  --primary-soft: #e9eff4;
  --gold: #b8912f;        /* dourado (acentos) */
  --gold-2: #d9b866;      /* dourado claro */
  --gold-soft: #f5edd8;
  --accent: #1f7a5a;      /* verde discreto (sucesso) */
  --danger: #b3402f;
  --warn: #b5791f;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(20, 30, 45, 0.06);
  --serif: Georgia, "Times New Roman", "Playfair Display", serif;
  --topbar-h: 58px;
  --sidebar-w: 244px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--fonte);
  color: var(--text);
  background: var(--panel-soft);
  -webkit-font-smoothing: antialiased;
}

/* Foco visível em campos e botões (acessibilidade — Bloco A.3) */
:focus-visible { outline: 2px solid var(--gold-2, #d9b866); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-color: var(--primary); }

button {
  font-family: inherit; cursor: pointer; border: none; border-radius: 9px;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  background: var(--primary); color: #fff; transition: all 0.15s; letter-spacing: 0.2px;
}
button:hover { filter: brightness(1.1); box-shadow: 0 3px 10px rgba(30,58,82,0.18); }
button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
button.ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); box-shadow: none; }
button.ghost:hover { background: var(--panel-soft); border-color: var(--gold); color: var(--gold); }
button.gold { background: linear-gradient(135deg, #d9b866, #b8912f); color: #16232f; font-weight: 700; }
button.danger { background: var(--danger); }
button.small { padding: 6px 11px; font-size: 13px; }

input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; width: 100%;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
label { font-size: 13px; font-weight: 600; color: var(--text-soft); display: block; margin-bottom: 5px; }

.muted { color: var(--text-soft); font-size: 13px; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.tag.admin { background: #ede9fe; color: #6d28d9; }
.tag.atendente { background: #dbeafe; color: #1e40af; }
.tag.ok { background: #dcfce7; color: #15803d; }
.tag.off { background: #fee2e2; color: #b91c1c; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.row { display: flex; gap: 12px; align-items: center; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 14px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.login-wrap {
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(217,184,102,0.10), transparent),
    linear-gradient(160deg, #16232f, #0f1a24);
}
.login-card { width: 380px; max-width: 100%; padding: 38px 34px; border: none; border-top: 3px solid var(--gold); }
.login-logo { width: 220px; max-width: 80%; height: auto; display: block; margin: 0 auto 6px; }
.brand-big { text-align: center; font-family: var(--serif); font-size: 25px; font-weight: 700; letter-spacing: 2px; color: var(--text); }
.brand-big .s { display: block; font-size: 12px; letter-spacing: 4px; color: var(--gold); text-transform: uppercase; margin-top: 4px; font-weight: 600; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }

.topbar {
  display: none; align-items: center; gap: 12px; height: var(--topbar-h);
  background: var(--bg); color: #fff; padding: 0 16px; position: sticky; top: 0; z-index: 30;
}
.topbar .hamburger { background: transparent; font-size: 22px; padding: 4px 8px; }
.topbar .title { font-family: var(--serif); font-weight: 700; font-size: 18px; letter-spacing: 1.5px; display: flex; align-items: center; gap: 9px; }
.topbar .title img { width: 30px; height: 30px; }
.topbar .title span { color: var(--gold-2); }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1a2937, #131f2a);
  color: #c3ccd6;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar .brand {
  padding: 16px 16px 18px;
  border-bottom: 1px solid rgba(217, 184, 102, 0.18);
}
.sidebar .brand img {
  display: block; width: 100%; max-width: 172px; height: auto; margin: 0 auto;
  background: #fff; border-radius: 10px; padding: 14px 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-secao { font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; color: #6b7686; padding: 14px 14px 5px; text-transform: uppercase; }
.nav-secao:first-child { padding-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 14px;
  border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px;
  color: #c3ccd6; margin-bottom: 3px; transition: all 0.15s;
}
.nav-item .nav-lbl { flex: 1; min-width: 0; }
.nav-badge { background: var(--gold); color: #16232f; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.nav-item.active .nav-badge { background: #16232f; color: var(--gold-2); }
.nav-item:hover { background: var(--bg-soft); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, #d9b866, #b8912f);
  color: #16232f; font-weight: 700; box-shadow: 0 2px 8px rgba(184, 145, 47, 0.3);
}
.userbox { padding: 16px 20px; border-top: 1px solid rgba(217, 184, 102, 0.18); font-size: 13px; color: #9aa4b0; }

.main { flex: 1; padding: 30px 34px; overflow-x: hidden; }
.page-title {
  font-family: var(--fonte); font-size: 27px; font-weight: 700; margin: 0 0 6px;
  color: var(--text); letter-spacing: 0.2px;
}
.page-title::after {
  content: ""; display: block; width: 42px; height: 3px; margin-top: 8px;
  background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 2px;
}
.page-sub { color: var(--text-soft); margin: 10px 0 24px; font-size: 14px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { font-size: 12px; text-transform: uppercase; color: var(--text-soft); letter-spacing: 0.5px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; width: 440px; max-width: 100%; max-height: 90vh; overflow-y: auto; }

.scrim { display: none; }
.error-msg { color: var(--danger); font-size: 13px; margin: 8px 0; }
.ok-msg { color: var(--accent); font-size: 13px; margin: 8px 0; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-soft); }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 140px; }
.stat .big { font-size: 30px; font-weight: 800; }

/* ---------- Chat / Inbox ---------- */
.chat-layout {
  display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr);
  height: calc(100dvh - 150px); min-height: 420px;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff;
}
/* 3a coluna: detalhes do atendimento (desktop). Vira gaveta no mobile. */
.det-col { display: flex; flex-direction: column; border-left: 1px solid var(--border); overflow-y: auto; padding: 14px; background: var(--panel-soft); min-height: 0; }
.det-titulo { font-weight: 700; margin-bottom: 12px; }
.det-vazio { padding: 20px 6px; font-size: 13px; }
.det-col label { display: block; font-size: 12px; font-weight: 600; color: var(--text-soft); margin-bottom: 4px; }
.det-col select, .det-col textarea { width: 100%; }
/* Telas medias: esconde a 3a coluna e mantem o botao Detalhes (gaveta). */
@media (max-width: 1100px) and (min-width: 821px) {
  .chat-layout { grid-template-columns: 320px minmax(0, 1fr); }
  .det-col { display: none; }
}
.conv-col { display: flex; flex-direction: column; border-right: 1px solid var(--border); overflow: hidden; min-height: 0; }
.conv-list { overflow-y: auto; flex: 1 1 0%; min-height: 0; }
/* Barra de filtros do inbox */
.inbox-filtros { padding: 10px; border-bottom: 1px solid var(--border); background: var(--panel-soft); display: flex; flex-direction: column; gap: 8px; }
.inbox-filtros .f-busca { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.inbox-filtros .f-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.inbox-filtros .f-chips button { font-size: 11px; padding: 3px 9px; border: 1px solid var(--border); background: #fff; border-radius: 14px; cursor: pointer; color: var(--text-soft); }
.inbox-filtros .f-chips button.ativo { background: var(--gold, #b8912f); color: #fff; border-color: var(--gold, #b8912f); font-weight: 700; }
.inbox-filtros .f-linha { display: flex; align-items: center; gap: 8px; }
.inbox-filtros .f-sel { flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; background: #fff; }
.inbox-filtros .f-canal { font-size: 12px; color: var(--text-soft); white-space: nowrap; }
/* Cartao da conversa */
.conv-item { padding: 10px 14px 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.conv-item:hover { background: var(--panel-soft); }
.conv-item.active { background: var(--primary-soft); }
.conv-item.aguardando { border-left: 4px solid var(--gold, #b8912f); padding-left: 12px; background: #fffdf5; }
.conv-item .conv-top { display: flex; align-items: baseline; gap: 6px; }
.conv-item .canal-dot { font-size: 9px; }
.conv-item .name { font-weight: 700; font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .conv-data { font-size: 11px; color: var(--text-soft); white-space: nowrap; }
.conv-item .preview { color: var(--text-soft); font-size: 13px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.conv-item .conv-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.conv-item .conv-foot .muted { font-size: 11px; }
.conv-item .sla { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.conv-item .sla.aguardando { background: #fef3c7; color: #92400e; }
.conv-item .sla.ok { background: #dcfce7; color: #166534; }
.conv-item .unread { background: #22c55e; color: #fff; font-size: 11px; padding: 0 7px; border-radius: 10px; margin-left: 6px; }
.chat-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; position: relative; }
.chat-header { flex: 0 0 auto; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.chat-body { flex: 1 1 0%; min-height: 0; overflow-y: auto; padding: 16px; background: #f0f2f5; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 70%; padding: 8px 12px; border-radius: 10px; font-size: 14px; line-height: 1.4; box-shadow: var(--shadow); word-wrap: break-word; }
.bubble.in { background: #fff; align-self: flex-start; border-top-left-radius: 2px; }
.bubble.out { background: #d9fdd3; align-self: flex-end; border-top-right-radius: 2px; }
.bubble .time { display: block; font-size: 10px; color: var(--text-soft); margin-top: 3px; text-align: right; }
.bubble .media-ph { font-style: italic; color: #4b5563; }
.bubble .bubble-cap { margin-top: 4px; }
.bubble .bubble-trans { margin-top: 5px; padding-top: 5px; border-top: 1px dashed rgba(0,0,0,.12); font-size: 13px; }
.bubble .ia-selo { display: inline-block; font-size: 9px; font-weight: 700; background: var(--gold, #b8912f); color: #fff; padding: 1px 5px; border-radius: 8px; vertical-align: middle; }
.bubble .audio-wrap audio { width: 240px; max-width: 60vw; height: 38px; }
.bubble .audio-tools { display: flex; align-items: center; gap: 10px; margin-top: 3px; }
.bubble .audio-speed { cursor: pointer; font-size: 11px; font-weight: 700; background: rgba(0,0,0,.06); padding: 1px 7px; border-radius: 10px; user-select: none; }
.bubble .btn-transcrever { cursor: pointer; font-size: 11px; border: 1px solid var(--border); background: #fff; padding: 2px 8px; border-radius: 10px; }
.bubble .chat-img { max-width: 240px; max-height: 280px; border-radius: 8px; cursor: pointer; display: block; }
.bubble .chat-img.sticker { max-width: 120px; cursor: default; }
.bubble .chat-video { max-width: 260px; border-radius: 8px; display: block; }
.bubble .doc-link { display: inline-flex; align-items: center; gap: 6px; color: var(--primary, #1e40af); text-decoration: none; font-weight: 600; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 9999; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 6px; }
/* Separador de data + status + autor nos baloes */
.dia-sep { text-align: center; margin: 10px 0; }
.dia-sep span { background: rgba(0,0,0,.06); color: #4b5563; font-size: 11px; padding: 2px 10px; border-radius: 10px; }
.bubble .ack { font-size: 10px; }
.bubble .ack.lido { color: #2563eb; }
/* Badges do cabecalho e etiquetas do cartao */
.ia-badge { font-size: 10px; background: #ede9fe; color: #6d28d9; padding: 1px 6px; border-radius: 8px; margin-left: 6px; }
.fin-badge { font-size: 10px; background: #dcfce7; color: #166534; padding: 1px 6px; border-radius: 8px; margin-left: 6px; }
.conv-etqs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.etq-chip { font-size: 10px; color: #fff; padding: 1px 7px; border-radius: 8px; }
/* Compositor com textarea */
.chat-input textarea { flex: 1 1 200px; min-width: 180px; resize: none; min-height: 44px; max-height: min(45vh, 420px); padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px; font: inherit; font-size: 14.5px; line-height: 1.5; }

/* Bloco B: dica, estado de envio, arrastar-soltar, prévia e editor em tela cheia */
.chat-dica { font-size: 11.5px; color: var(--text-soft); padding: 0 12px 8px; flex: 0 0 auto; width: 100%; text-align: center; }
.chat-input .comp-send.enviando { opacity: .5; }
.chat-body.arrastando { outline: 3px dashed var(--primary); outline-offset: -8px; background: rgba(37,99,235,.04); }
.previa-fundo { background: #e5ddd5; border-radius: 12px; padding: 18px; }
.previa-bolha { position: relative; background: #dcf8c6; color: #111; padding: 9px 12px 20px; border-radius: 10px; max-width: 85%; margin-left: auto; font-size: 14.5px; line-height: 1.5; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.previa-bolha code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 13px; }
.previa-hora { position: absolute; right: 10px; bottom: 4px; font-size: 10.5px; color: #667781; }
.expandir-modal { max-width: 780px; width: 92vw; }
.expandir-area { width: 100%; height: 62vh; resize: none; padding: 14px; border: 1px solid var(--border); border-radius: 12px; font: inherit; font-size: 15px; line-height: 1.55; }

/* Bloco C: mensagens salvas */
.ms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-height: 52vh; overflow-y: auto; }
.ms-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; background: #fff; transition: box-shadow .15s, border-color .15s; display: flex; flex-direction: column; gap: 6px; }
.ms-card:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(31,42,68,.08); }
.ms-card-top { display: flex; justify-content: space-between; align-items: center; }
.ms-tipo { font-size: 18px; }
.ms-fav { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--warn); line-height: 1; }
.ms-titulo { font-weight: 700; font-size: 13.5px; color: var(--tinta, var(--text)); }
.ms-preview { font-size: 12.5px; color: var(--text-soft); line-height: 1.4; max-height: 3.6em; overflow: hidden; }
.ms-rodape { display: flex; justify-content: space-between; align-items: center; font-size: 11px; margin-top: 2px; }
.ms-acoes { display: flex; gap: 4px; }
.ms-mini { background: none; border: none; cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 5px; }
.ms-mini:hover { background: var(--panel-soft); }
.ms-vars { font-size: 11.5px; color: var(--text-soft); margin: 6px 0; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.ms-var { background: var(--panel-soft); border: 1px solid var(--border); border-radius: 20px; padding: 2px 9px; font-size: 11px; cursor: pointer; color: var(--primary); font-weight: 600; }
.ms-var:hover { background: var(--primary); color: #fff; }
@media (max-width: 560px) { .ms-grid { grid-template-columns: 1fr; } }

/* Bloco D: gravação de áudio e prévia de anexo */
.rec-bar { position: absolute; left: 12px; right: 12px; bottom: 68px; z-index: 6; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; box-shadow: 0 8px 26px rgba(31,42,68,.14); }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; flex: 0 0 auto; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; }
.rec-limite { font-size: 11px; }
.rec-wave { display: flex; align-items: center; gap: 3px; height: 20px; flex: 1; min-width: 40px; }
.rec-wave span { width: 3px; background: var(--primary); border-radius: 3px; animation: recwave 1s ease-in-out infinite; height: 40%; }
.rec-wave span:nth-child(2) { animation-delay: .15s; } .rec-wave span:nth-child(3) { animation-delay: .3s; } .rec-wave span:nth-child(4) { animation-delay: .45s; }
@keyframes recwave { 0%,100% { height: 30%; } 50% { height: 95%; } }
.rec-player { height: 34px; flex: 1; min-width: 140px; }
.anexo-box { display: flex; align-items: center; justify-content: center; background: var(--panel-soft); border-radius: 12px; padding: 12px; min-height: 120px; }
.anexo-previa { max-width: 100%; max-height: 260px; border-radius: 8px; }
.anexo-icone { font-size: 56px; }
.video-modal { max-width: 560px; width: 94vw; }
.video-palco { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; }
.video-palco video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-timer { position: absolute; top: 10px; left: 12px; background: rgba(0,0,0,.55); color: #fff; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; padding: 3px 9px; border-radius: 20px; display: flex; align-items: center; gap: 6px; }
.video-timer::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }

/* Bloco E: sincronização do histórico */
.sync-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.sync-label { font-size: 12px; }
.sync-prog { flex: 1 1 100%; margin-top: 4px; }
.sync-bar { height: 8px; background: var(--panel-soft); border-radius: 6px; overflow: hidden; margin-bottom: 4px; }
.sync-bar span { display: block; height: 100%; background: var(--primary); border-radius: 6px; transition: width .4s; }
.sync-status { font-size: 12px; }

/* Bloco A.3: skeleton de carregamento */
.skel { background: linear-gradient(90deg, var(--panel-soft) 25%, #efe8d8 37%, var(--panel-soft) 63%); background-size: 400% 100%; animation: skel 1.4s ease infinite; border-radius: 8px; }
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skel-wrap { display: flex; flex-direction: column; gap: 10px; padding: 10px 0; }
.skel-linha { height: 46px; }

/* Bloco A.3: estado vazio com ação */
.vazio-box { text-align: center; padding: 40px 18px; color: var(--text-soft); }
.vazio-ico { font-size: 44px; margin-bottom: 10px; opacity: .7; }
.vazio-txt { font-size: 14px; margin-bottom: 14px; }

/* Bloco A.2: cabeçalho padrão de página */
.pg-cab { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.pg-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-soft); margin-bottom: 2px; }
.pg-destaque { color: var(--gold); font-style: italic; font-weight: 600; }
.pg-cab-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.pg-cab .page-title, .pg-cab .page-sub { margin-top: 0; }

/* Bloco F: badges de tipo e atraso nos contratos */
.badge-dourado { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-2); font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; letter-spacing: 0.03em; white-space: nowrap; }
.badge-atraso { background: #fde8e4; color: var(--danger); font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 12px; }
.badge { background: var(--panel-soft); color: var(--text-soft); border: 1px solid var(--border); font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 12px; }
.ct-tabela tr:nth-child(even) td { background: rgba(0,0,0,.012); }
.ct-tabela tbody tr:hover td { background: var(--panel-soft); }

/* Financeiro: abas */
.fin-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.fin-tab { background: none; border: none; padding: 9px 14px; font-weight: 600; font-size: 13.5px; color: var(--text-soft); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.fin-tab.active { color: var(--primary); border-bottom-color: var(--gold); }
.fin-tab:hover { color: var(--text); }
.fin-subtabs { display: flex; gap: 4px; flex-wrap: wrap; }

/* Acordos: kanban e cronograma */
.kanban-acordos { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kb-col { flex: 0 0 240px; background: var(--panel-soft); border-radius: 12px; padding: 10px; }
.kb-col-tit { font-weight: 700; font-size: 13px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.kb-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer; transition: box-shadow .15s; }
.kb-card:hover { box-shadow: 0 4px 12px rgba(31,42,68,.1); border-color: var(--primary); }
.parc-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.parc-row.paga { opacity: .8; }

/* DRE */
.dre-tabela { width: 100%; border-collapse: collapse; }
.dre-tabela th { font-size: 12px; color: var(--text-soft); padding: 8px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.dre-tabela td { padding: 8px 14px; font-size: 13.5px; border-bottom: 1px solid var(--panel-soft); }
.dre-tabela tr.dre-sub td { background: var(--panel-soft); font-weight: 600; }
.dre-tabela tr.dre-forte td { background: var(--gold-soft); font-weight: 800; font-size: 14.5px; }
/* Painel lateral (drawer) do atendimento */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; display: flex; justify-content: flex-end; }
.drawer { width: 340px; max-width: 90vw; height: 100%; background: #fff; padding: 18px; overflow-y: auto; box-shadow: -4px 0 20px rgba(0,0,0,.15); }
.drawer label { display: block; font-size: 12px; font-weight: 700; color: var(--text-soft); margin-bottom: 4px; }
.drawer select, .drawer textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 13px; }
.etq-lista { display: flex; flex-wrap: wrap; gap: 6px; }
.etq-toggle { font-size: 12px; padding: 3px 10px; border: 1.5px solid var(--c, #64748b); border-radius: 14px; cursor: pointer; color: var(--text); user-select: none; }
.etq-toggle.on { background: var(--c, #64748b); color: #fff; }
/* Compositor (1.9) */
.chat-input { align-items: flex-end; flex-wrap: wrap; }
.chat-input .comp-btn { background: none; border: none; font-size: 18px; cursor: pointer; padding: 5px 6px; border-radius: 6px; line-height: 1; }
.chat-input .comp-btn:hover { background: var(--panel-soft); }
.chat-input .comp-btn.gravando { background: #fee2e2; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.chat-input .comp-send { flex: 0 0 auto; }
.comp-pop { position: fixed; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); z-index: 2000; padding: 6px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 190px; overflow-y: auto; width: 268px; }
.emoji-grid span { font-size: 20px; cursor: pointer; text-align: center; padding: 3px; border-radius: 6px; }
.emoji-grid span:hover { background: var(--panel-soft); }
.resp-lista { max-height: 240px; overflow-y: auto; min-width: 250px; }
.resp-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; }
.resp-item:hover { background: var(--panel-soft); }
.resp-txt { flex: 1; font-size: 13px; cursor: pointer; }
.resp-del { border: none; background: none; color: #dc2626; cursor: pointer; font-size: 13px; }
.resp-nova { width: 100%; margin-top: 6px; font-size: 13px; padding: 7px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #16232f; color: #fff; padding: 10px 18px; border-radius: 20px; z-index: 3000; font-size: 13px; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 90vw; }
.toast.erro { background: #dc2626; }
/* Campos de textarea/select nas Configuracoes (Bloco 9) */
#cfgWrap textarea, #cfgWrap select { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; }
#cfgWrap textarea { resize: vertical; min-height: 90px; }
/* Linha de cartoes de estatistica (Inicio / Dashboard) */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-row .card.stat { cursor: default; }
.stat-row .card.stat.clicavel { cursor: pointer; }
.stat-row .card.stat.clicavel:hover { border-color: var(--gold, #b8912f); }
/* Alerta de lead parado (Bloco 2) */
.kcard.parado { border-left: 3px solid #d97706; }
.lead-alerta { font-size: 10px; font-weight: 700; background: #fef3c7; color: #92400e; padding: 1px 6px; border-radius: 8px; }
.chat-input { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); flex: 0 0 auto; }
.novas-pilula { position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%); background: #16232f; color: #fff; padding: 7px 14px; border-radius: 20px; font-size: 13px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.3); z-index: 5; display: flex; gap: 10px; align-items: center; }
.novas-pilula .pilula-x { opacity: .7; }
.btn-descer { position: absolute; bottom: 80px; right: 16px; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: #fff; box-shadow: 0 3px 10px rgba(0,0,0,.2); cursor: pointer; font-size: 18px; display: none; align-items: center; justify-content: center; z-index: 5; }
/* Busca dentro da conversa (PARTE 3) */
.busca-conv { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel-soft); }
.busca-conv input { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.busca-conv .bc-contador { font-size: 12px; color: var(--text-soft); white-space: nowrap; }
mark.busca { background: #fde68a; color: inherit; border-radius: 2px; }
mark.busca.atual { background: #f59e0b; color: #fff; }
/* Botao voltar (mobile) */
.chat-voltar { display: none; border: none; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--text); padding: 0 4px; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-soft); }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kcol { background: var(--panel-soft); border: 1px solid var(--border); border-radius: var(--radius); flex: 1 1 180px; min-width: 172px; max-width: 340px; display: flex; flex-direction: column; max-height: calc(100vh - 160px); }
.kcol-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 7px 9px; font-weight: 700; font-size: 12px; color: #fff; border-radius: var(--radius) var(--radius) 0 0; }
.kcol-count { background: rgba(255,255,255,.28); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }
.kcol-sum { padding: 2px 9px 4px; font-size: 10.5px; font-weight: 600; }
.kcol-body { padding: 7px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 50px; flex: 1; }
.kcol-body.dragover { background: var(--primary-soft); border-radius: 8px; }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; cursor: pointer; box-shadow: var(--shadow); }
.kcard:hover { border-color: var(--primary); }
.kcard.dragging { opacity: 0.4; }
.kcard-nome { font-weight: 700; font-size: 12px; line-height: 1.25; }
.kcard-tags { display: flex; gap: 4px; margin: 4px 0; flex-wrap: wrap; }
.kcard-coment { font-size: 10.5px; color: var(--muted, #64748b); line-height: 1.3; margin: 3px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lista-pipe { width: 100%; border-collapse: collapse; font-size: 13px; }
.lista-pipe th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border, #e2e8f0); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted, #64748b); white-space: nowrap; }
.lista-pipe td { padding: 7px 10px; border-bottom: 1px solid var(--border, #eef1f5); }
.lista-pipe tbody tr:hover { background: var(--panel-soft, #f3f6fa); }
.pipe-alerta { background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; border-radius: 8px; padding: 9px 14px; margin-bottom: 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.pipe-alerta:hover { background: #ffedd5; }
.fila-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-top: 1px solid var(--border, #eef1f5); cursor: pointer; }
.fila-row:first-of-type { border-top: 0; }
.fila-row:hover { background: var(--panel-soft, #f3f6fa); }
.dot-tag { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.kcard-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 10.5px; margin-top: 3px; }

.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.ev-linha { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }

/* ---------- Dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dash-titulo { font-weight: 700; margin-bottom: 14px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-label { font-size: 13px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--panel-soft); border-radius: 6px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; min-width: 2px; transition: width 0.3s; }
.bar-val { font-size: 13px; font-weight: 700; text-align: right; }

@media (max-width: 820px) { .dash-grid { grid-template-columns: 1fr; } }

/* ---------- Filtros e acoes genericas ---------- */
.f-sel { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff; color: var(--text); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; font-size: 13.5px; font-weight: 600; font-family: inherit; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text); cursor: pointer; }
.btn:hover { background: var(--panel-soft); }
.btn-primario { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primario:hover { filter: brightness(1.05); background: var(--primary); }
.btn-mini {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--primary); cursor: pointer; text-decoration: none;
}
.btn-mini:hover { background: var(--panel-soft); }
.btn-mini.danger { color: var(--danger); border-color: #f3c6c6; }
.ghost.small { padding: 6px 10px; font-size: 12px; }

/* ---------- Contratos: tabela vira cards no mobile ---------- */
@media (max-width: 720px) {
  .ct-tabela thead { display: none; }
  .ct-tabela, .ct-tabela tbody, .ct-tabela tr, .ct-tabela td { display: block; width: 100%; }
  .ct-tabela tr { border-bottom: 8px solid var(--panel-soft); padding: 6px 4px; }
  .ct-tabela td { border: none; padding: 5px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .ct-tabela td::before { content: attr(data-label); font-weight: 600; color: var(--text-soft); text-align: left; }
}

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .topbar { display: flex; }
  .shell { flex-direction: column; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 250px; z-index: 50;
    transform: translateX(-100%); transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .main { padding: 18px 16px; }
  /* Mobile: uma coluna por vez (lista -> conversa em tela cheia) */
  .chat-layout { display: block; grid-template-columns: none; grid-template-rows: none; height: calc(100dvh - 150px); position: relative; }
  .conv-col { height: 100%; border-right: none; border-bottom: none; }
  .chat-panel { display: none; }
  .det-col { display: none; }
  .chat-layout.mostrando-chat .conv-col { display: none; }
  .chat-layout.mostrando-chat .chat-panel { display: flex; height: 100%; }
  .chat-voltar { display: inline-flex; align-items: center; }
}
