:root {
  --azul: #00246c;
  --azul-link: #0044b0;
  --azul-claro: #edf2f8;
  --azul-sel: #dbe5f2;
  --rosa: #d62e72;
  --rosa-escuro: #b82060;
  --rosa-claro: #fdf0f6;
  --tinta: #14171c;
  --cinza: #5a6068;
  --cinza-claro: #949aa3;
  --linha: #e3e5e9;
  --fundo: #f5f7fa;
  --branco: #ffffff;
  --erro: #c0342b;
  --estrela: #e3a008;
  --sombra: 0 1px 2px rgba(20, 23, 28, .12), 0 2px 6px rgba(20, 23, 28, .08);
  --sombra-forte: 0 8px 30px rgba(20, 23, 28, .22);
  --raio: 16px;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--tinta);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--fundo); font-size: 14px; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.icone { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--cinza); flex: none; }
.icone:hover { background: rgba(20, 23, 28, .07); color: var(--tinta); }
.icone.pequeno { width: 28px; height: 28px; }
.icone.pequeno svg { width: 16px; height: 16px; }
.link { border: 0; background: none; color: var(--cinza); padding: 4px 6px; }
.link:hover { color: var(--tinta); text-decoration: underline; }
.btn-primario { border: 0; background: var(--rosa); color: #fff; font-weight: 600; padding: 10px 22px; border-radius: 999px; }
.btn-primario:hover { background: var(--rosa-escuro); }
.btn-primario:disabled { opacity: .6; cursor: default; }
.erro { color: var(--erro); margin: 0; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--azul-claro), #fff 60%); }
.login-cartao { width: min(400px, 100%); background: #fff; border: 1px solid var(--linha); border-radius: 24px; padding: 40px 32px; display: grid; gap: 14px; box-shadow: var(--sombra); }
.login-logo { height: 72px; justify-self: center; }
.login h1 { margin: 8px 0 0; text-align: center; font-size: 22px; font-weight: 600; color: var(--azul); }
.login-sub { margin: 0 0 8px; text-align: center; color: var(--cinza); }
.login label { display: grid; gap: 6px; font-weight: 500; color: var(--cinza); font-size: 13px; }
.login input { border: 1px solid var(--linha); border-radius: 10px; padding: 12px 14px; font-size: 15px; outline: none; }
.login input:focus { border-color: var(--azul-link); box-shadow: 0 0 0 3px var(--azul-claro); }
.login .btn-primario { margin-top: 8px; padding: 12px; font-size: 15px; }

/* ---------- Estrutura ---------- */
.app { display: grid; grid-template-columns: 256px 1fr; grid-template-rows: 64px 1fr; height: 100vh; height: 100dvh; }
.topo { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; padding: 0 16px 0 12px; }
.marca { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--cinza); width: 232px; padding-left: 12px; flex: none; }
.marca img { height: 32px; }
.marca b { color: var(--azul); font-weight: 600; }
.marca span { font-size: 20px; font-weight: 400; }
.busca { flex: 1; max-width: 720px; display: flex; align-items: center; background: #e9eef6; border-radius: 999px; height: 48px; padding: 0 6px 0 16px; gap: 8px; }
.busca:focus-within { background: #fff; box-shadow: var(--sombra); }
.busca .lupa { color: var(--cinza); flex: none; }
.busca input { flex: 1; border: 0; background: transparent; outline: none; font-size: 16px; min-width: 0; }
.busca input::-webkit-search-cancel-button { display: none; }
.conta { margin-left: auto; position: relative; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--azul); color: #fff; font-weight: 600; font-size: 15px; }
.menu-conta { position: absolute; right: 0; top: 44px; background: #fff; border-radius: 16px; box-shadow: var(--sombra-forte); padding: 16px; min-width: 240px; z-index: 30; display: grid; gap: 12px; }
.menu-conta-email { color: var(--cinza); word-break: break-all; }
.menu-conta button { border: 1px solid var(--linha); background: #fff; border-radius: 999px; padding: 8px; }
.menu-conta button:hover { background: var(--fundo); }

.lateral { padding: 8px 16px 16px 8px; overflow-y: auto; }
.btn-escrever { display: inline-flex; align-items: center; gap: 12px; border: 0; background: var(--rosa-claro); color: var(--rosa-escuro); border-radius: var(--raio); padding: 18px 24px 18px 20px; font-weight: 600; font-size: 15px; margin: 0 0 16px 8px; box-shadow: var(--sombra); transition: box-shadow .15s; }
.btn-escrever:hover { box-shadow: var(--sombra-forte); }
.pasta { display: flex; align-items: center; gap: 16px; height: 34px; padding: 0 12px 0 24px; border-radius: 0 999px 999px 0; text-decoration: none; color: var(--tinta); }
.pasta:hover { background: rgba(20, 23, 28, .06); }
.pasta.ativa { background: var(--azul-sel); font-weight: 700; color: var(--azul); }
.pasta .nome { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pasta .conta-nl { font-size: 12px; font-weight: 700; }
.pasta svg { width: 18px; height: 18px; flex: none; }

.principal { background: #fff; border-radius: var(--raio) 0 0 0; overflow: hidden; display: flex; flex-direction: column; margin-right: 16px; border-radius: var(--raio); margin-bottom: 16px; }
.vista { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.barra { display: flex; align-items: center; gap: 2px; height: 48px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--linha); flex: none; }
.caixa-sel { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; }
.caixa-sel:hover { background: rgba(20, 23, 28, .07); }
.caixa-sel input, .linha-msg input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--azul); cursor: pointer; margin: 0; }
.acoes-lote { display: flex; }
.paginacao { margin-left: auto; color: var(--cinza); font-size: 12px; padding: 0 8px; white-space: nowrap; }

/* ---------- Lista ---------- */
.lista { overflow-y: auto; flex: 1; }
.linha-msg { display: grid; grid-template-columns: 32px 28px 200px 1fr auto; align-items: center; gap: 4px; height: 40px; padding: 0 16px 0 12px; border-bottom: 1px solid var(--linha); cursor: pointer; background: #f2f6fc; position: relative; }
.linha-msg.nao-lida { background: #fff; font-weight: 700; }
.linha-msg:hover { box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px rgba(60, 64, 67, .3); z-index: 1; }
.linha-msg.selecionada { background: var(--azul-sel); }
.linha-msg .sel { display: grid; place-items: center; }
.estrela { border: 0; background: none; padding: 0; width: 24px; height: 24px; display: grid; place-items: center; color: var(--cinza-claro); }
.estrela.on { color: var(--estrela); }
.estrela.on svg { fill: var(--estrela); }
.estrela svg { width: 18px; height: 18px; }
.linha-msg .quem { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 12px; }
.linha-msg .quem .n { font-weight: 400; color: var(--cinza); font-size: 12px; margin-left: 4px; }
.linha-msg .resumo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tinta); min-width: 0; }
.linha-msg .resumo .trecho { color: var(--cinza); font-weight: 400; }
.linha-msg .clipe { display: inline-block; vertical-align: -4px; margin-right: 4px; color: var(--cinza); }
.linha-msg .clipe svg { width: 16px; height: 16px; }
.linha-msg .quando { font-size: 12px; color: var(--cinza); white-space: nowrap; padding-left: 12px; }
.linha-msg.nao-lida .quando { color: var(--tinta); }
.vazio { padding: 64px 24px; text-align: center; color: var(--cinza); }
.vazio strong { display: block; color: var(--tinta); font-size: 16px; margin-bottom: 4px; }
.carregando { height: 3px; background: linear-gradient(90deg, transparent, var(--rosa), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: faixa 1s linear infinite; }
@keyframes faixa { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* ---------- Conversa ---------- */
.conversa { overflow-y: auto; flex: 1; padding: 20px 24px 40px 72px; }
.conversa h2 { font-size: 22px; font-weight: 400; margin: 0 0 20px; word-break: break-word; }
.msg { border-bottom: 1px solid var(--linha); padding: 16px 0; }
.msg-cab { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: start; cursor: pointer; }
.msg-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--azul-link); color: #fff; display: grid; place-items: center; font-weight: 600; margin-left: -56px; }
.msg-cab { margin-left: 0; }
.msg-de strong { font-weight: 700; }
.msg-de .email { color: var(--cinza); font-size: 12px; }
.msg-para { color: var(--cinza); font-size: 12px; margin-top: 2px; }
.msg-data { color: var(--cinza); font-size: 12px; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.msg-trecho { color: var(--cinza); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.fechada .msg-corpo, .msg.fechada .msg-anexos, .msg.fechada .msg-acoes { display: none; }
.msg:not(.fechada) .msg-trecho { display: none; }
.msg-corpo { margin-top: 16px; }
.msg-corpo iframe { width: 100%; border: 0; display: block; min-height: 60px; }
.msg-corpo pre { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; line-height: 1.5; }
.msg-anexos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.anexo { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--linha); border-radius: 8px; padding: 8px 12px; text-decoration: none; color: var(--tinta); max-width: 260px; }
.anexo:hover { background: var(--fundo); }
.anexo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anexo small { color: var(--cinza); flex: none; }
.msg-acoes { display: flex; gap: 8px; margin-top: 20px; }
.btn-contorno { border: 1px solid var(--cinza-claro); background: #fff; border-radius: 999px; padding: 8px 20px; display: inline-flex; align-items: center; gap: 8px; color: var(--cinza); font-weight: 500; }
.btn-contorno:hover { background: var(--fundo); color: var(--tinta); }
.btn-contorno svg { width: 18px; height: 18px; }

/* ---------- Escrever ---------- */
.escrever { position: fixed; right: 24px; bottom: 0; width: 540px; max-width: calc(100vw - 32px); background: #fff; border-radius: 12px 12px 0 0; box-shadow: var(--sombra-forte); z-index: 40; display: flex; flex-direction: column; max-height: calc(100vh - 80px); }
.escrever.minimizada .escrever-corpo { display: none; }
.escrever.minimizada { width: 280px; }
.escrever-topo { background: var(--azul-claro); border-radius: 12px 12px 0 0; display: flex; align-items: center; padding: 6px 8px 6px 16px; font-weight: 500; cursor: pointer; }
.escrever-topo span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.escrever-corpo { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.linha-campo { display: flex; align-items: center; border-bottom: 1px solid var(--linha); margin: 0 16px; gap: 8px; }
.linha-campo label { color: var(--cinza); }
.linha-campo input { flex: 1; border: 0; outline: none; padding: 10px 0; min-width: 0; }
.editor { flex: 1; min-height: 260px; overflow-y: auto; padding: 12px 16px; outline: none; line-height: 1.5; word-break: break-word; }
.editor blockquote { margin: 8px 0 0 4px; padding-left: 12px; border-left: 2px solid var(--linha); color: var(--cinza); }
.anexos-escrever { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; }
.anexos-escrever .anexo { background: var(--fundo); padding: 6px 10px; }
.anexos-escrever .anexo button { border: 0; background: none; padding: 0 2px; color: var(--cinza); }
.escrever-rodape { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.escrever-rodape label.icone { cursor: pointer; }
.aviso-escrever { color: var(--cinza); font-size: 12px; flex: 1; }

.toast { position: fixed; left: 24px; bottom: 24px; background: #1f2329; color: #fff; padding: 14px 20px; border-radius: 8px; box-shadow: var(--sombra-forte); z-index: 50; display: flex; gap: 16px; align-items: center; max-width: calc(100vw - 48px); }
.toast button { border: 0; background: none; color: #a8c7fa; font-weight: 600; }

.so-celular { display: none; }
.veu { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 19; }

/* ---------- Celular ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 60px 1fr; }
  .so-celular { display: inline-grid; }
  .topo { padding: 0 8px; gap: 4px; }
  .marca { width: auto; padding-left: 0; }
  .marca span { display: none; }
  .marca img { height: 24px; }
  .busca { height: 44px; }
  .lateral { position: fixed; top: 0; left: 0; bottom: 0; width: 280px; background: #fff; z-index: 20; transform: translateX(-100%); transition: transform .2s; padding-top: 16px; box-shadow: var(--sombra-forte); }
  .lateral.aberta { transform: none; }
  .btn-escrever { position: fixed; right: 16px; bottom: 20px; z-index: 15; margin: 0; }
  .lateral .btn-escrever { position: static; }
  .principal { margin: 0; border-radius: 0; }
  .linha-msg { grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; height: auto; padding: 10px 16px; gap: 2px 8px; }
  .linha-msg .sel { display: none; }
  .linha-msg .estrela { grid-column: 2; grid-row: 2 / 4; justify-self: end; }
  .linha-msg .quem { grid-column: 1; grid-row: 1; font-size: 15px; }
  .linha-msg .quando { grid-column: 2; grid-row: 1; }
  .linha-msg .resumo { grid-column: 1; grid-row: 2 / 4; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .linha-msg .resumo .trecho::before { content: ''; display: block; }
  .conversa { padding: 16px; }
  .msg-cab { grid-template-columns: 1fr auto; }
  .msg-avatar { display: none; }
  .escrever { inset: 0; width: auto; max-width: none; max-height: none; border-radius: 0; right: 0; }
  .escrever-topo { border-radius: 0; padding-top: max(6px, env(safe-area-inset-top)); }
  .escrever.minimizada { inset: auto 0 0 auto; width: 100%; }
  .toast { left: 16px; right: 16px; bottom: 88px; }
}
