/* ============================================================
   Design System — Imediato Nexway
   Verde institucional #43BA95 · Navy #001F40 · Fonte Prompt
   ============================================================ */
:root {
  --verde: #43ba95;
  --verde-escuro: #339a7a;
  --verde-suave: #e2f5ee;
  --navy: #001f40;
  --navy-claro: #0b3560;
  --bg: #f9f9f9;
  --card: #ffffff;
  --text: #3c3c3c;
  --muted: #7b8a9c;
  --border: #e1e5eb;
  --green: #2e9e5b;
  --red: #d64545;
  --amber: #b97a12;
  --yellow-bg: #fff8e1;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { min-height: 100%; }
body { font-family: 'Prompt', 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; width: 100%; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(67, 186, 149, .35); border-color: var(--verde); }
input:disabled { background: #f2f5f8; color: var(--muted); }

/* ===== Shell / Sidebar ===== */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 276px minmax(0, 1fr); background: var(--bg); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--navy); color: #fff; border-right: 1px solid rgba(255,255,255,.08); overflow: hidden; z-index: 20; }
.side-brand { min-height: 82px; display: grid; grid-template-columns: 42px 1fr 32px; align-items: center; gap: 12px; padding: 18px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.09); }
.side-brand img { width: 42px; height: 42px; object-fit: contain; display: block; }
.brand-copy b { display: block; font-size: 13px; font-weight: 600; letter-spacing: .2px; line-height: 1.25; }
.brand-copy span { display: block; margin-top: 2px; color: #9fb3c8; font-size: 11.5px; }
.side-toggle { width: 32px; height: 32px; border: 1px solid rgba(255,255,255,.14); border-radius: 9px; background: rgba(255,255,255,.07); color: #d9e4ef; font-size: 20px; line-height: 1; }
.side-toggle:hover { background: rgba(255,255,255,.13); color: #fff; }
.side-nav { display: flex; flex-direction: column; gap: 4px; padding: 14px 12px; flex: 1; }
.side-nav a, .side-status, .side-user, .side-logout { min-height: 42px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 10px; padding: 10px 12px; background: transparent; color: #b7c8da; text-decoration: none; font-size: 13px; text-align: left; width: 100%; }
.side-nav a:hover, .side-status:hover, .side-user:hover, .side-logout:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav a.active { background: rgba(67,186,149,.18); color: #fff; box-shadow: inset 3px 0 0 var(--verde); }
.nav-ico { width: 22px; min-width: 22px; display: inline-flex; justify-content: center; align-items: center; font-size: 16px; }
.nav-ico svg { width: 18px; height: 18px; display: block; }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.09); display: flex; flex-direction: column; gap: 6px; }
.side-user .nav-label { display: flex; flex-direction: column; gap: 1px; }
.side-user b { font-size: 12.5px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; }
.side-user small { color: #9fb3c8; font-size: 11px; text-transform: capitalize; }
.side-logout { color: #ffd7d7; }
.workspace { min-width: 0; }
.mobile-topbar { display: none; align-items: center; gap: 10px; background: var(--navy); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 15; }
.mobile-topbar img { height: 30px; }
.mobile-topbar span { font-size: 12.5px; font-weight: 500; color: #d9e4ef; }
.sidebar-collapsed { grid-template-columns: 84px minmax(0, 1fr); }
.sidebar-collapsed .side-brand { grid-template-columns: 1fr; justify-items: center; padding: 16px 12px; gap: 10px; }
.sidebar-collapsed .side-brand img { width: 38px; height: 38px; }
.sidebar-collapsed .brand-copy, .sidebar-collapsed .nav-label { display: none; }
.sidebar-collapsed .side-toggle { width: 36px; }
.sidebar-collapsed .side-nav a, .sidebar-collapsed .side-status, .sidebar-collapsed .side-user, .sidebar-collapsed .side-logout { justify-content: center; padding: 10px; }
.sidebar-collapsed .side-nav a.active { box-shadow: inset 0 -3px 0 var(--verde); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--verde); display: flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; flex-shrink: 0; }
.wa-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.wa-dot.on { background: var(--verde); } .wa-dot.off { background: #e05a4e; } .wa-dot.qr { background: #f5b940; }

/* ===== Layout ===== */
main { padding: 24px 28px; max-width: 1440px; margin: 0 auto; }
h1.page { font-size: 21px; margin-bottom: 16px; font-weight: 600; color: var(--navy); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.btn { background: var(--verde); border: none; color: #fff; padding: 9px 16px; border-radius: 7px; font-weight: 500; font-size: 13px; white-space: nowrap; }
.btn:hover { background: var(--verde-escuro); }
.btn.sec { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.sec:hover { background: #f5f8fa; }
.btn.navy { background: var(--navy); }
.btn.navy:hover { background: var(--navy-claro); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #f0caca; }
.btn.danger:hover { background: #fdf1f1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; }
.spacer { flex: 1; }

/* ===== Tabelas ===== */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #fafbfc; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
tr.click { cursor: pointer; }
tr.click:hover { background: #f4faf8; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 500; }
.badge.aguardando { background: #eef2f6; color: #56718c; }
.badge.em_atendimento { background: #fff4e0; color: var(--amber); }
.badge.aprovado { background: var(--verde-suave); color: var(--verde-escuro); }
.badge.contratado { background: var(--verde); color: #fff; }
.badge.cancelado { background: #fdeaea; color: var(--red); }
.badge.ativo { background: var(--verde-suave); color: var(--verde-escuro); }
.badge.suspenso { background: var(--yellow-bg); color: var(--amber); }
.badge.desligado { background: #eef2f6; color: #56718c; }
.badge.agendado { background: #eaf3fd; color: #2c6ca8; }
.badge.em_rota { background: #fff4e0; color: var(--amber); }
.badge.concluido { background: var(--verde-suave); color: var(--verde-escuro); }
.badge.alerta { background: #fdeaea; color: var(--red); font-weight: 500; }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(140deg, var(--navy) 0%, #012c58 60%, #0a4a45 100%); }
.login-card { background: #fff; padding: 38px; border-radius: 14px; width: 380px; box-shadow: 0 18px 60px rgba(0, 15, 32, .45); text-align: center; }
.login-card img.lg-logo { width: 210px; margin: 0 auto 10px; display: block; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card .field { text-align: left; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.erro { color: var(--red); font-size: 12.5px; margin-top: 8px; }

/* ===== Conversas ===== */
.conv-layout { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
.conv-layout.com-ficha { grid-template-columns: 420px 1fr; }
.conv-list-card .tabs2 { display: flex; border-bottom: 1px solid var(--border); }
.tabs2 button { flex: 1; background: none; border: none; padding: 12px 4px; font-size: 12px; font-weight: 500; color: var(--muted); border-bottom: 2.5px solid transparent; text-transform: uppercase; letter-spacing: .3px; }
.tabs2 button.active { color: var(--verde-escuro); border-bottom-color: var(--verde); }
.tabs2 .cnt { background: var(--verde); color: #fff; border-radius: 12px; padding: 1px 7px; font-size: 10.5px; margin-left: 4px; }
.conv-list { max-height: calc(100vh - 260px); overflow-y: auto; }
.conv-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.conv-item:hover, .conv-item.sel { background: #f2faf7; }
.conv-item.parada { border-left: 3px solid var(--amber); background: #fffaf0; }
.conv-item.parada:hover, .conv-item.parada.sel { background: #fdf3df; }
.conv-item .nome { font-weight: 500; font-size: 13.5px; }
.conv-item .prev { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.conv-item .hora { font-size: 11px; color: var(--muted); margin-left: auto; text-align: right; }
.vazio { padding: 46px 20px; text-align: center; color: var(--muted); font-size: 13px; }

.chat-card { display: flex; flex-direction: column; height: calc(100vh - 200px); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.chat-head .nome { font-weight: 600; font-size: 14.5px; }
.chat-head .st { font-size: 12px; color: var(--muted); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: #f5f8f7; }
.msg { max-width: 62%; padding: 10px 13px; border-radius: 10px; font-size: 13px; line-height: 1.45; word-break: break-word; }
.msg .tx { white-space: pre-wrap; }
.msg .meta { font-size: 10.5px; margin-top: 5px; opacity: .75; }
.msg.agregado { background: #fff; border: 1px solid var(--border); align-self: flex-start; }
.msg.copiloto, .msg.captador { background: var(--verde); color: #fff; align-self: flex-end; }
.msg.captador { background: var(--navy-claro); }
.msg .doc { display: flex; gap: 8px; align-items: center; background: rgba(255,255,255,.92); color: var(--navy); border-radius: 8px; padding: 9px 11px; font-weight: 500; text-decoration: none; font-size: 12.5px; margin-bottom: 4px; }
.msg.agregado .doc { background: var(--verde-suave); color: var(--verde-escuro); }
.audio-play-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; border: none; background: var(--navy); color: #fff; cursor: pointer; flex-shrink: 0; padding: 0; }
.audio-play-btn:hover { background: var(--navy-claro); }
.audio-play-btn svg { display: block; margin-left: 1px; }
.msg .transc { font-size: 12px; font-style: italic; opacity: .85; border-top: 1px dashed rgba(0,0,0,.15); margin-top: 6px; padding-top: 6px; }
.chat-foot { padding: 12px 14px; border-top: 1px solid var(--border); }
.chat-foot .aviso { text-align: center; color: var(--muted); font-size: 12.5px; padding: 4px; }
.chat-compose { display: flex; gap: 8px; }
.chat-compose input { flex: 1; }
.tools-pop { position: absolute; bottom: 52px; left: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.14); width: 300px; max-height: 280px; overflow-y: auto; z-index: 30; }
.tools-pop .item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.tools-pop .item:hover { background: #f2faf7; }
.tools-pop .item .t { font-weight: 500; font-size: 12.5px; }
.tools-pop .item .x { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Ficha ===== */
.ficha { max-height: calc(100vh - 200px); overflow-y: auto; padding: 16px; }
.ficha h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--navy); margin: 20px 0 10px; font-weight: 600; }
.ficha h3:first-child { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .full { grid-column: 1 / -1; }
.fnote { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.pend { background: var(--yellow-bg); border: 1px solid #f0dfa8; border-radius: 8px; padding: 10px 13px; margin-bottom: 12px; }
.pend .t { font-weight: 600; font-size: 11.5px; color: #8a6d1a; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
.pend div.i { font-size: 12.5px; color: #7a6015; padding: 2px 0; }
.pend.vermelho { background: #fdf1f1; border-color: #f0caca; }
.pend.vermelho .t { color: var(--red); }
.pend.vermelho div.i { color: #a03636; }
.flagline { background: #eaf6f2; border: 1px solid #c9e8dd; padding: 8px 12px; border-radius: 7px; font-size: 12.5px; margin-bottom: 12px; display: flex; gap: 8px; align-items: center; }
.aprovacoes { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.aprov { border: 1px solid var(--border); border-radius: 9px; padding: 12px; text-align: center; }
.aprov .nm { font-size: 12.5px; font-weight: 500; margin-bottom: 8px; }
.aprov .stx { font-size: 12px; margin-bottom: 8px; }
.aprov .ok { color: var(--green); font-weight: 600; }
.contrato-info { margin-top: 10px; font-size: 12.5px; }
.contrato-info.ok { color: var(--green); font-weight: 500; }
.contrato-bloq { background: var(--yellow-bg); border: 1px solid #f0dfa8; border-radius: 8px; padding: 10px 13px; margin-top: 10px; font-size: 12.5px; color: #7a6015; }
.doclist a { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; text-decoration: none; color: var(--text); font-size: 12.5px; }
.doclist a:hover { background: #f2faf7; }
.hist-list { max-height: 260px; overflow-y: auto; }
.hist-item { font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.hist-data { color: var(--muted); margin-right: 6px; }

/* ===== Mapa ===== */
.mapa-card { height: calc(100vh - 220px); overflow: hidden; }

/* ===== Painel / Gestão ===== */
.cards-funil { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.cards-funil.seis { grid-template-columns: repeat(6, 1fr); }
.cfunil { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.cfunil .n { font-size: 30px; font-weight: 600; color: var(--verde); }
.cfunil .n.navy { color: var(--navy); }
.cfunil .n.vermelho { color: var(--red); }
.cfunil .l { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.indicadores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.indic { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.indic .t { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.indic .v { font-size: 21px; font-weight: 600; color: var(--navy); }
.indic .sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.periodo { display: flex; gap: 10px; align-items: end; margin-bottom: 18px; }
.periodo .field { margin: 0; width: 160px; }
.alerta-chip { display: inline-block; background: #fdf1f1; color: #a03636; border: 1px solid #f0caca; border-radius: 6px; padding: 2px 8px; font-size: 11px; margin: 1px 3px 1px 0; }

/* ===== Config / cards genéricos ===== */
.cfg-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 16px; max-width: 640px; }
.cfg-card h3 { font-size: 14.5px; margin-bottom: 8px; color: var(--navy); }
.cfg-card p { font-size: 13px; color: var(--muted); line-height: 1.5; }
.cfg-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl { position: absolute; inset: 0; background: #cfd8e2; border-radius: 24px; transition: .2s; cursor: pointer; }
.switch .sl:before { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + .sl { background: var(--verde); }
.switch input:checked + .sl:before { transform: translateX(20px); }
.rr-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
code.var { background: var(--navy); color: #fff; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ===== QR / conexão ===== */
.qr-box { text-align: center; padding: 30px; }
.qr-box img { border: 1px solid var(--border); border-radius: 10px; }
.qr-box .st { margin-top: 14px; font-size: 13.5px; }

/* ===== Modal ===== */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 31, 64, .55); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 440px; max-height: 85vh; overflow-y: auto; }
.modal h3 { margin-bottom: 16px; color: var(--navy); }
.modal .acts { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 200; }
.toast.err { background: var(--red); }
.search-inp { max-width: 100%; margin-bottom: 14px; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 84px minmax(0, 1fr); }
  .app-shell .side-brand { grid-template-columns: 1fr; justify-items: center; padding: 16px 12px; gap: 10px; }
  .app-shell .side-brand img { width: 38px; height: 38px; }
  .app-shell .brand-copy, .app-shell .nav-label { display: none; }
  .app-shell .side-toggle { width: 36px; }
  .app-shell .side-nav a, .app-shell .side-status, .app-shell .side-user, .app-shell .side-logout { justify-content: center; padding: 10px; }
  .conv-layout, .conv-layout.com-ficha { grid-template-columns: 340px 1fr; }
  .cards-funil, .cards-funil.seis, .indicadores { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app-shell, .sidebar-collapsed { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: 84px; transform: translateX(-84px); transition: transform .18s ease; box-shadow: 10px 0 30px rgba(0,0,0,.2); }
  .app-shell:not(.sidebar-collapsed) .sidebar { transform: translateX(0); }
  .app-shell:not(.sidebar-collapsed) .workspace { margin-left: 84px; }
  .mobile-topbar { display: flex; }
  main { padding: 18px 16px; }
  .conv-layout, .conv-layout.com-ficha { display: block; }
  .conv-list-card { margin-bottom: 14px; }
  .conv-list { max-height: 320px; }
  .chat-card { height: 70vh; min-height: 520px; }
  .ficha { max-height: none; }
  .card { overflow-x: auto; }
  .periodo, .row { flex-wrap: wrap; }
  .periodo .field { width: min(100%, 180px); }
  .grid2, .aprovacoes, .cards-funil, .cards-funil.seis, .indicadores { grid-template-columns: 1fr; }
  .msg { max-width: 86%; }
  .modal { width: calc(100vw - 28px); }
}
