:root {
  --red:#d44d4d; --red-dark:#c13e3e; --red-tint:#fdeeee; --dark:#0f172a; --muted:#64748b; --line:#e2e8f0;
  --bg:#f6f7f9; --card:#fff; --track:#f1f5f9;
  /* Categorias: vermelho, âmbar, cinza-azulado, laranja, vinho e cinza claro; ordem validada para daltonismo e visão normal */
  --s1:#d44d4d; --s2:#eda100; --s3:#5c6986; --s4:#eb6834; --s5:#8e2f2f; --s6:#a3a9b5; --slate:#5c6986; --slate-tint:#eceef3;
  --seq:#5c6986;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Plus Jakarta Sans", system-ui, sans-serif; background: var(--bg); color: var(--dark); font-size: 15px; line-height: 1.55; }
a { color: inherit; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px 64px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Cabeçalho e menu sanduíche */
.topbar { position: sticky; top: 0; z-index: 20; background: rgb(246 247 249 / .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.topbar .in { max-width: 1160px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar img { height: 40px; width: auto; display: block; }
.burger { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; border: 0; background: none; color: var(--red); cursor: pointer; padding: 0; }
.burger:hover { color: var(--red-dark); }
.burger svg { width: 22px; height: 22px; }
.burger { position: relative; }
.burger-dot { position: absolute; top: 0; right: 0; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--bg); }
.nav-count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.notif-drawer { width: min(400px, 92vw); }
.notif-top { padding: 22px 20px 14px; border-bottom: 1px solid var(--line); }
.notif-top h2 { margin: 0 0 2px; }
.notif-top .muted { font-size: 13px; }
.notif-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 8px 12px 24px; }
.notif-item { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; text-decoration: none; }
.notif-item:hover { background: var(--track); }
.notif-item .ni { width: 32px; height: 32px; border-radius: 10px; background: var(--red-tint); color: var(--red); display: grid; place-items: center; flex-shrink: 0; }
.notif-item .ni svg { width: 16px; height: 16px; }
.notif-item .nt { display: grid; min-width: 0; }
.notif-item b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item small { font-size: 12px; color: var(--muted); }
.notif-item .ns { font-size: 12.5px; color: var(--dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item + .notif-item { border-top: 1px solid var(--track); }
.notif-sec { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 14px 8px 6px; }
.notif-item.new { background: #fff7f6; }
.notif-item.new:hover { background: var(--red-tint); }
.notif-item.new b { font-weight: 800; }
.notif-item .nd { width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-left: auto; flex-shrink: 0; }
.notif-item.seen .ni { background: var(--track); color: var(--muted); }
.notif-item.seen b { font-weight: 500; color: var(--muted); }
.notif-item.seen .ns { color: var(--muted); }
/* Selo de novidade (Início) */
.flag { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; color: #fff; background: var(--red); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.flag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: flag-pulse 1.6s ease-in-out infinite; }
@keyframes flag-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .flag::before { animation: none; } }
.backdrop { position: fixed; inset: 0; background: rgb(15 23 42 / .35); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .25s; }
.backdrop.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(340px, 88vw); background: #fff; box-shadow: -10px 0 40px -10px rgb(15 23 42 / .2); transform: translateX(100%); transition: transform .25s; display: flex; flex-direction: column; visibility: hidden; }
.drawer.open { transform: none; visibility: visible; }
.drawer .who { padding: 24px 20px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
img.avatar { object-fit: cover; background: var(--track); }
.who .n { font-weight: 700; }
.who .e { font-size: 13px; color: var(--muted); word-break: break-all; }
.drawer nav { padding: 12px; display: grid; gap: 4px; flex: 1; align-content: start; }
.drawer nav a, .drawer .logout { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; text-decoration: none; font-weight: 600; color: var(--dark); }
.drawer nav a:hover { background: var(--track); }
.drawer nav a[aria-current=page] { background: var(--red-tint); color: var(--red); }
.drawer svg { width: 20px; height: 20px; flex-shrink: 0; }
.drawer .foot { padding: 12px; border-top: 1px solid var(--line); }
.drawer .logout { width: 100%; background: none; border: 0; cursor: pointer; font: inherit; font-weight: 600; color: var(--muted); }
.drawer .logout:hover { background: var(--track); color: var(--red); }
.drawer .close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; background: none; border-radius: 10px; cursor: pointer; color: var(--muted); }
.drawer .close:hover { background: var(--track); color: var(--dark); }

/* Tipografia e blocos */
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--red); background: var(--red-tint); border-radius: 999px; padding: 4px 12px; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 10px 0 4px; line-height: 1.2; }
h2 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; margin: 0; }
h3 { font-size: 14px; font-weight: 700; margin: 0 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; margin-bottom: 8px; }
.back:hover { color: var(--red); }
.msg { font-size: 13px; margin-top: 12px; }
.msg.err { color: var(--red); }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }

/* Login */
.login { max-width: 440px; margin: 48px auto; }
label.l { display: block; font-size: 13px; font-weight: 600; margin: 16px 0 6px; }
input[type=email], input[type=password], input[type=search], select { width: 100%; font: inherit; font-size: 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; color: var(--dark); outline: none; }
input:focus, select:focus { border-color: var(--red); background: #fff; box-shadow: 0 0 0 3px rgb(212 77 77 / .15); }
button { font: inherit; font-weight: 600; cursor: pointer; border-radius: 999px; border: 1px solid transparent; padding: 10px 20px; }
.btn-primary { background: var(--red); color: #fff; width: 100%; margin-top: 14px; border-radius: 999px; padding: 12px; }
.btn-primary:hover { background: var(--red-dark); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
label.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--red); margin: 0; }
.link { display: block; margin: 14px auto 0; background: none; border: 0; padding: 4px; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: underline; }
.link:hover { color: var(--red); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--dark); font-size: 13px; padding: 8px 16px; }
.btn-ghost:hover { border-color: var(--red); color: var(--red); }

/* Listas clicáveis */
.rows { display: grid; }
.rowlink { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 12px 10px; border-radius: 12px; text-decoration: none; }
.rowlink + .rowlink { border-top: 1px solid var(--track); }
.rowlink:hover { background: var(--track); }
.rowlink .ini { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--red-tint); color: var(--red); grid-row: span 2; }
.rowlink .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowlink .d { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ini.mail svg { width: 20px; height: 20px; }
/* Mensagem respondida: verde */
.rowlink.answered.seen .ini, .entry.answered.seen .ini { background: #e6f4ea; color: #1e7b45; }
.rowlink.answered.seen .t, .entry.answered.seen .t { color: #1e7b45; }
/* Reunião agendada: azul */
.rowlink.meeting.seen .ini, .entry.meeting.seen .ini { background: #e8f0fe; color: #1a56c4; }
.rowlink.meeting.seen .t, .entry.meeting.seen .t { color: #1a56c4; }
/* Já visualizado: cinza, mas continua clicável */
.rowlink.seen .ini, .entry.seen .ini { background: var(--track); color: var(--muted); }
.rowlink.seen .t, .entry.seen .t { color: var(--muted); font-weight: 600; }
.entry.seen .f, .entry.seen .when b, .rowlink.seen .d { color: var(--muted); }
.rowlink.seen .s, .entry.seen .f span { color: #94a3b8; }
.rowlink .s { grid-column: 2 / -1; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Detalhe (todas as respostas) */
.sec { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--red); margin: 24px 0 4px; }
.sec:first-child { margin-top: 0; }
dl { margin: 0; }
.row { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.row:last-child { border-bottom: 0; }
dt { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
dd a { color: var(--red); }
.detail-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.detail-head .ini { width: 52px; height: 52px; font-size: 18px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--red); color: #fff; flex-shrink: 0; }
.detail-head .meta { font-size: 13px; color: var(--muted); }

/* Situação da mensagem de contato */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pend { background: #fdf3dc; color: #a06d00; }
.badge.ok { background: var(--slate-tint); color: var(--slate); }
.badge.meet { background: #e8f0fe; color: #1a56c4; }
.status-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.status-bar .when { font-size: 13px; color: var(--muted); }
.btn-ok { background: var(--red); color: #fff; border-radius: 999px; padding: 10px 18px; font-size: 14px; }
.btn-ok:hover { background: var(--red-dark); }
.btn-ok:disabled { opacity: .6; cursor: wait; }

/* Celular: campos com 16px evitam o zoom automático do iPhone ao tocar no campo; sem rolagem lateral. */
html { overflow-x: clip; }
@media (max-width: 767px) { input, select, textarea { font-size: 16px !important; } }

/* Com menu ou notificações abertos, a página atrás fica travada. */
body.scroll-lock { position: fixed; left: 0; right: 0; overflow: hidden; }
.backdrop { touch-action: none; }
/* Padrão dos campos de busca: lupa dentro do campo, à esquerda. */
input[type=search] { padding-left: 40px; background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center / 18px; }
/* Janela de confirmação */
.confirm-dlg { width: min(420px, 92vw); border: 0; border-radius: 18px; padding: 22px; box-shadow: 0 20px 60px -10px rgb(15 23 42 / .35); }
.confirm-dlg::backdrop { background: rgb(15 23 42 / .45); }
.confirm-dlg h2 { margin: 0 0 8px; font-size: 18px; }
.confirm-dlg p { margin: 0 0 18px; font-size: 14px; line-height: 1.5; }
.cd-acts { display: flex; justify-content: flex-end; gap: 8px; }
.cd-field { display: grid; gap: 6px; margin: -4px 0 18px; }
.cd-field span { font-size: 13px; font-weight: 600; }
.cd-field textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; resize: vertical; }
.cd-field textarea:focus { outline: none; border-color: var(--red); }
.cd-err { font-style: normal; font-size: 13px; color: var(--red); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translate(-50%, 16px); opacity: 0; transition: opacity .25s, transform .25s; background: #0f172a; color: #fff; font-size: 14px; font-weight: 600; padding: 12px 18px; border-radius: 12px; box-shadow: 0 12px 30px -10px rgb(15 23 42 / .5); width: max-content; max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 8px; }
.toast::before { content: ""; width: 18px; height: 18px; flex-shrink: 0; border-radius: 50%; background: #22c55e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 12px no-repeat; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.btn-danger-solid { background: #c0392b; color: #fff; border: 0; border-radius: 999px; padding: 10px 18px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.btn-danger-solid:hover { background: #a93226; }
