/* modules/courier/styles/courier.css · estilos do Blanes Courier (prefixo .cr-).
   Layout 2 painéis (LISTA + LEITURA) mobile-first — as PASTAS vivem no MENU lateral do produto
   (manifest.dynamicNav). Cabeçalhos/botões herdam --product-accent (a product-bar seta a cor do
   produto = azul Outlook #0078D4). Densidade via [data-density]. */

:root { --cr-accent: var(--product-accent, #0078D4); }

/* ====== Shell: LINHA 1 = toolbar de topo (largura total) · LINHA 2 = 2 painéis (lista | leitura) ====== */
.cr-shell {
  display: grid;
  grid-template-rows: auto 1fr;     /* row1 = toolbar de topo · row2 = painéis */
  grid-template-columns: 1fr;
  height: calc(100vh - 120px);
  min-height: 480px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  font-size: 14px;
}
/* Linha 2: os DOIS painéis (lista | leitura), abaixo da toolbar de topo. */
.cr-panes {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  min-height: 0;        /* permite que os painéis rolem dentro do grid */
  overflow: hidden;
}
.cr-shell[data-preview="bottom"] .cr-panes {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
}
.cr-shell[data-preview="off"] .cr-panes { grid-template-columns: 1fr; }
.cr-shell[data-preview="off"] .cr-read-pane { display: none; }

/* ====== Toolbar de TOPO (largura total, acima dos dois painéis) ====== */
.cr-topbar { position: relative; display: flex; flex-direction: column; gap: 0; border-bottom: 1px solid #e2e8f0; background: #fff; }
.cr-topbar-main { display: flex; align-items: center; gap: 8px; padding: 10px 12px; flex-wrap: wrap; }
.cr-topbar .cr-search-box { flex: 1 1 240px; }
.cr-topbar .cr-account-select { flex: 0 0 auto; }
/* toggle semântico na toolbar de topo (rótulo some cedo em telas estreitas; o switch permanece) */
.cr-topbar-semantic { flex: 0 0 auto; }
.cr-semantic-hint { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: #475569; }
.cr-semantic-hint svg { width: 14px; height: 14px; color: #b45309; }
/* chips ativos + segmentado de histórico, em linha no topo (full-width). */
.cr-topbar .cr-active-chips { border-bottom: none; padding: 0 12px 10px; }
.cr-topbar .cr-flow-seg { border-bottom: none; padding: 0 12px 10px; }
/* CRÍTICO: respeitar o atributo `hidden` (a CSS de display dos elementos vencia o [hidden] do UA,
   deixando o painel/segmentado/chips SEMPRE visíveis e sobrepondo os e-mails). */
.cr-shell [hidden] { display: none !important; }

/* Painel de filtros = POPOVER COMPACTO ancorado ao botão (card flutuante estreito, NÃO largura total).
   Minimalista: ~360px, à direita, com rolagem interna e sombra suave; nunca cobre a lista inteira. */
.cr-topbar .cr-filters {
  position: absolute; top: 100%; right: 12px; left: auto; z-index: 30;
  width: min(360px, calc(100vw - 24px));
  max-height: min(72vh, 560px); overflow-y: auto;
  margin-top: 8px; padding: 14px; gap: 12px;
  border: 1px solid #e6eaf0; border-radius: 14px; background: #fff;
  box-shadow: 0 16px 40px -8px rgba(15,23,42,.22), 0 2px 8px rgba(15,23,42,.08);
}
/* No card estreito os campos ficam em COLUNA ÚNICA (arejado, sem espremer). */
.cr-topbar .cr-filters .cr-filters-grid { grid-template-columns: 1fr; gap: 10px; }
.cr-topbar .cr-filters .cr-filters-foot { margin-top: 4px; padding-top: 12px; }

.cr-loading-full, .cr-offline-page { padding: 48px; text-align: center; color: #64748b; }
.cr-offline-page svg { width: 40px; height: 40px; color: #cbd5e1; margin-bottom: 12px; }

.cr-soon-pill { font-size: 10px; background: #fef3c7; color: #92400e; border-radius: 6px; padding: 1px 6px; font-weight: 600; }

/* ====== Lista ====== */
.cr-list-pane { display: flex; flex-direction: column; border-right: 1px solid #e2e8f0; min-width: 0; min-height: 0; overflow: hidden; }
/* Cabeçalho da lista: título = pasta atual (a busca/filtros/conta vivem na TOOLBAR DE TOPO). */
.cr-list-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; border-bottom: 1px solid #eef2f6; }
.cr-list-title { font-size: 15px; font-weight: 700; color: #0f172a; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-account-select { max-width: 220px; }
/* ---- Caixa de busca (na toolbar de topo) ---- */
.cr-search-box { display: flex; align-items: center; gap: 8px; background: #f1f5f9; border-radius: 10px; padding: 8px 12px; min-width: 0; transition: box-shadow .15s, background .15s; }
.cr-search-box:focus-within { background: #fff; box-shadow: 0 0 0 2px var(--cr-accent); }
.cr-search-box svg { width: 16px; height: 16px; color: #94a3b8; flex: 0 0 16px; }
.cr-search-input { flex: 1; border: none; background: none; outline: none; font-size: 14px; min-width: 0; color: #0f172a; }

/* Botão "Filtros" (disclosure) com contador de filtros ativos. */
.cr-filters-btn { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; height: 36px; padding: 0 12px; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; font-size: 13px; font-weight: 600; color: #475569; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.cr-filters-btn svg { width: 16px; height: 16px; }
.cr-filters-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.cr-filters-btn.open { background: color-mix(in srgb, var(--cr-accent) 10%, #fff); border-color: var(--cr-accent); color: var(--cr-accent); }
.cr-filters-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--cr-accent); color: #fff; font-size: 11px; font-weight: 700; }

/* ---- Chips dos filtros ATIVOS (removíveis) ---- */
.cr-active-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-bottom: 1px solid #eef2f6; }
.cr-active-chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: 13px; background: color-mix(in srgb, var(--cr-accent) 10%, #fff); border: 1px solid color-mix(in srgb, var(--cr-accent) 30%, #fff); color: var(--cr-accent); font-size: 12px; font-weight: 600; max-width: 100%; }
.cr-active-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.cr-active-chip-x { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; padding: 0; border: none; border-radius: 50%; background: none; color: inherit; cursor: pointer; opacity: .8; }
.cr-active-chip-x:hover { background: color-mix(in srgb, var(--cr-accent) 20%, #fff); opacity: 1; }
.cr-active-chip-x svg { width: 12px; height: 12px; }

/* ---- Painel de filtros (disclosure) ---- */
.cr-filters { display: flex; flex-direction: column; gap: 14px; padding: 14px 12px 12px; border-bottom: 1px solid #eef2f6; background: #fafbfc; }
.cr-filters-section { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Pills toggláveis (booleanos). */
.cr-pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cr-pill { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px; border: 1px solid #e2e8f0; border-radius: 15px; background: #fff; font-size: 13px; font-weight: 600; color: #475569; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.cr-pill svg { width: 14px; height: 14px; }
.cr-pill:hover { border-color: #cbd5e1; background: #f8fafc; }
.cr-pill.on { background: var(--cr-accent); border-color: var(--cr-accent); color: #fff; }

/* Campos compactos rotulados (De / Assunto / Período), em grade arejada. */
.cr-filters-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cr-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cr-field-label { font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: #94a3b8; }
.cr-field-period { grid-column: 1 / -1; }
.cr-input-sm { padding: 7px 10px; font-size: 13px; }
.cr-period-row { display: flex; align-items: center; gap: 8px; }
.cr-period-row .cr-input-sm { flex: 1; min-width: 0; }
.cr-period-sep { color: #94a3b8; flex: 0 0 auto; }

/* Toggle de busca semântica (switch) + selo "em breve". */
.cr-semantic-row { justify-content: space-between; }
.cr-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: #475569; }
.cr-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.cr-switch-track { position: relative; width: 36px; height: 20px; border-radius: 10px; background: #cbd5e1; transition: background .15s; flex: 0 0 auto; }
.cr-switch-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.cr-switch input:checked + .cr-switch-track { background: var(--cr-accent); }
.cr-switch input:checked + .cr-switch-track .cr-switch-thumb { transform: translateX(16px); }
.cr-switch input:focus-visible + .cr-switch-track { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--cr-accent); }
.cr-switch-label { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.cr-switch-label svg { width: 14px; height: 14px; color: #b45309; }

/* Rodapé do painel: Limpar / Aplicar. */
.cr-filters-foot { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid #eef2f6; margin-top: 2px; padding-top: 12px; }

/* Foco acessível em controles do painel. */
.cr-filters-btn:focus-visible, .cr-pill:focus-visible, .cr-active-chip-x:focus-visible { outline: 2px solid var(--cr-accent); outline-offset: 2px; }

.cr-bulk-bar { display: flex; align-items: center; gap: 4px; padding: 6px 10px; background: #e6f4f1; border-bottom: 1px solid #cdeae3; }

.cr-list { flex: 1; overflow-y: auto; }
.cr-list-loading, .cr-list-empty, .cr-reading-empty { padding: 40px 20px; text-align: center; color: #94a3b8; font-size: 14px; }

.cr-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer; position: relative;
}
.cr-row:hover { background: #f8fafc; }
.cr-row.active { background: #e6f4f1; }
.cr-row.selected { background: #eff6ff; }
.cr-row.unread { background: #fff; }
.cr-row.unread .cr-row-from, .cr-row.unread .cr-row-subject { font-weight: 700; color: #0f172a; }
.cr-row.unread::before { content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--cr-accent); }
.cr-row-check { margin-top: 4px; }
.cr-row-star { background: none; border: none; cursor: pointer; padding: 2px; color: #cbd5e1; }
.cr-row-star svg { width: 16px; height: 16px; }
.cr-row-star.on { color: #f59e0b; }
.cr-row-star.on svg { fill: #f59e0b; }
.cr-avatar { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; flex: 0 0 34px; }
.cr-avatar-sm { width: 26px; height: 26px; font-size: 10px; flex: 0 0 26px; }
.cr-row-main { flex: 1; min-width: 0; }
.cr-row-line1 { display: flex; justify-content: space-between; gap: 8px; }
.cr-row-from { font-size: 14px; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-row-date { font-size: 12px; color: #94a3b8; flex: 0 0 auto; }
.cr-row-line2 { display: flex; align-items: center; gap: 6px; }
.cr-row-subject { font-size: 13.5px; color: #334155; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-row-line3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cr-row-preview { font-size: 12.5px; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.cr-mini { display: inline-flex; align-items: center; color: #94a3b8; }
.cr-mini svg { width: 13px; height: 13px; }
.cr-mini-high { color: #dc2626; font-weight: 800; }
.cr-label-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cr-badge-spam { font-size: 10px; background: #fee2e2; color: #b91c1c; border-radius: 6px; padding: 1px 6px; font-weight: 700; white-space: nowrap; }
.cr-load-more { display: block; width: 100%; padding: 12px; background: none; border: none; color: var(--cr-accent); font-weight: 600; cursor: pointer; }

/* === Histórico (Archive): segmentado de direção + TIMELINE de fluxo ====================== */
/* Segmentado Tudo · Recebidos · Enviados (no topo da lista, só na pasta Histórico). */
.cr-flow-seg { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid #eef2f6; }
.cr-flow-seg-btn { display: inline-flex; align-items: center; gap: 5px; flex: 1; justify-content: center; height: 30px; padding: 0 8px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; font-size: 12.5px; font-weight: 600; color: #475569; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.cr-flow-seg-btn svg { width: 14px; height: 14px; }
.cr-flow-seg-btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.cr-flow-seg-btn.on { background: var(--cr-accent); border-color: var(--cr-accent); color: #fff; }
.cr-flow-seg-btn:focus-visible { outline: 2px solid var(--cr-accent); outline-offset: 2px; }

/* Timeline: grupos por dia, trilho vertical, nós e itens com badge de direção. */
.cr-flow { padding: 4px 0 8px; }
.cr-flow-group { padding: 0; }
.cr-flow-day { position: sticky; top: 0; z-index: 1; padding: 8px 12px 4px; background: linear-gradient(#fff 70%, rgba(255,255,255,0)); }
.cr-flow-day-label { font-size: 11.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: #94a3b8; }
/* Trilho = linha vertical à esquerda dos itens do grupo. */
.cr-flow-rail { position: relative; padding-left: 4px; }
.cr-flow-rail::before { content: ""; position: absolute; left: 26px; top: 4px; bottom: 4px; width: 2px; background: #eef2f6; }
.cr-flow-item { position: relative; display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px 8px 12px; cursor: pointer; border-radius: 8px; transition: background .12s; }
.cr-flow-item:hover { background: #f8fafc; }
.cr-flow-item.active { background: #e6f4f1; }
.cr-flow-item:focus-visible { outline: 2px solid var(--cr-accent); outline-offset: -2px; }
/* Nó do trilho (alinhado à linha vertical). */
.cr-flow-node { position: absolute; left: 21px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #cbd5e1; box-sizing: border-box; }
.cr-flow-in .cr-flow-node { border-color: var(--cr-accent); }
.cr-flow-out .cr-flow-node { border-color: #94a3b8; }
.cr-flow-item.unread .cr-flow-node { background: var(--cr-accent); border-color: var(--cr-accent); }
/* Badge de direção (seta entrada/saída). */
.cr-flow-dir { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px; margin-left: 24px; }
.cr-flow-dir svg { width: 15px; height: 15px; }
.cr-flow-in .cr-flow-dir { background: color-mix(in srgb, var(--cr-accent) 12%, #fff); color: var(--cr-accent); }
.cr-flow-out .cr-flow-dir { background: #f1f5f9; color: #64748b; }
.cr-flow-body { flex: 1; min-width: 0; }
.cr-flow-line1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.cr-flow-party { font-size: 13.5px; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-flow-rel { font-size: 11px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: .02em; }
.cr-flow-time { font-size: 12px; color: #94a3b8; flex: 0 0 auto; }
.cr-flow-line2 { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.cr-flow-subject { font-size: 13px; color: #475569; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-flow-item.unread .cr-flow-party, .cr-flow-item.unread .cr-flow-subject { font-weight: 700; color: #0f172a; }

/* densidade */
.cr-shell[data-density="cozy"] .cr-row { padding: 7px 12px; }
.cr-shell[data-density="cozy"] .cr-row-line3 { display: none; }
.cr-shell[data-density="compact"] .cr-row { padding: 5px 12px; }
.cr-shell[data-density="compact"] .cr-row-line3 { display: none; }
.cr-shell[data-density="compact"] .cr-row-avatar { display: none; }

/* ====== Leitura ====== */
.cr-read-pane { overflow-y: auto; min-width: 0; min-height: 0; }
.cr-reading { padding: 18px 22px; }
.cr-reading-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cr-reading-subject { font-size: 19px; font-weight: 700; color: #0f172a; flex: 1; min-width: 200px; }
.cr-reading-actions { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.cr-action-sep { width: 1px; height: 22px; background: #e2e8f0; margin: 0 4px; }
.cr-thread-info { font-size: 12px; color: #64748b; display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.cr-thread-info svg { width: 14px; height: 14px; }

.cr-msg { border: 1px solid #eef2f6; border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.cr-msg.collapsed .cr-msg-body, .cr-msg.collapsed .cr-att-zone, .cr-msg.collapsed .cr-ai-row, .cr-msg.collapsed .cr-msg-to { display: none; }
.cr-msg.collapsed .cr-msg-collapsed-preview { display: block; }
.cr-msg-collapsed-preview { display: none; font-size: 13px; color: #94a3b8; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-msg-head { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.cr-msg-meta { flex: 1; min-width: 0; }
.cr-msg-from { display: block; font-size: 14px; font-weight: 600; color: #1e293b; }
.cr-msg-from small { font-weight: 400; color: #94a3b8; }
.cr-msg-to { display: block; font-size: 12px; color: #94a3b8; margin-top: 2px; }
.cr-msg-flags { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.cr-flag { display: inline-flex; align-items: center; }
.cr-flag svg { width: 15px; height: 15px; }
.cr-flag-signed { color: #16a34a; }
.cr-flag-enc { color: #2563eb; }
.cr-flag-high { color: #dc2626; font-weight: 800; }
.cr-msg-date { font-size: 12px; color: #94a3b8; }

.cr-ai-row { display: flex; align-items: center; gap: 8px; margin: 12px 0 6px; flex-wrap: wrap; }
.cr-ai-btn { display: inline-flex; align-items: center; gap: 5px; background: #f0fdfa; color: var(--cr-accent); border: 1px solid #ccece4; border-radius: 8px; padding: 5px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.cr-ai-btn svg { width: 14px; height: 14px; }
.cr-ai-btn:hover { background: #e6f4f1; }
.cr-ai-soon-hint { font-size: 11px; color: #b45309; background: #fef3c7; border-radius: 6px; padding: 2px 7px; }
.cr-ai-out, .cr-smart-out { margin: 6px 0 4px; }
.cr-ai-panel { background: #f0fdfa; border: 1px solid #ccece4; border-radius: 8px; padding: 10px 12px; }
.cr-ai-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--cr-accent); margin-bottom: 4px; }
.cr-ai-head svg { width: 15px; height: 15px; }
.cr-ai-body { font-size: 13px; color: #475569; line-height: 1.5; }
.cr-ai-pending-tag { background: #fef3c7; color: #92400e; border-radius: 6px; padding: 1px 7px; font-size: 11px; font-weight: 700; }
.cr-ai-pending-note { font-size: 12.5px; color: #64748b; }
.cr-smart-chip { display: inline-flex; align-items: center; gap: 5px; background: #fff; border: 1px solid #cbd5e1; border-radius: 16px; padding: 5px 12px; font-size: 13px; cursor: pointer; margin: 0 6px 6px 0; }
.cr-smart-chip svg { width: 13px; height: 13px; color: #b45309; }

.cr-msg-body { margin-top: 12px; font-size: 14px; color: #1e293b; line-height: 1.6; }
.cr-html { overflow-x: auto; }
.cr-html img { max-width: 100%; }
.cr-show-images { display: block; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 7px; padding: 5px 10px; font-size: 12.5px; cursor: pointer; margin-bottom: 8px; }
.cr-text { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 14px; color: #1e293b; margin: 0; }

.cr-att-zone { margin-top: 14px; border-top: 1px solid #eef2f6; padding-top: 10px; }
.cr-att-zone-head { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 8px; }
.cr-att-zone-head svg { width: 15px; height: 15px; }
.cr-att-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.cr-att-card { display: flex; flex-direction: column; gap: 2px; width: 150px; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px; text-decoration: none; color: #334155; }
.cr-att-card:hover { border-color: var(--cr-accent); background: #f8fafc; }
.cr-att-ico svg { width: 18px; height: 18px; color: var(--cr-accent); }
.cr-att-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-att-size { font-size: 11px; color: #94a3b8; }

.cr-read-back { display: none; }

/* ====== Botões / inputs comuns ====== */
.cr-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: none; border: none; border-radius: 8px; color: #475569; cursor: pointer; }
.cr-icon-btn:hover { background: #f1f5f9; }
.cr-icon-btn svg { width: 18px; height: 18px; }
.cr-icon-btn.cr-danger:hover { background: #fee2e2; color: #b91c1c; }
.cr-btn { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 14px; font-size: 14px; font-weight: 600; color: #334155; cursor: pointer; }
.cr-btn:hover { background: #f8fafc; }
.cr-btn-primary { background: var(--cr-accent); border-color: var(--cr-accent); color: #fff; }
.cr-btn-primary:hover { filter: brightness(1.06); background: var(--cr-accent); }
.cr-btn-primary svg { width: 16px; height: 16px; }
.cr-btn-sm { padding: 5px 10px; font-size: 13px; }
.cr-btn-ghost { background: none; border-color: transparent; }
.cr-btn-danger { background: none; border-color: #fca5a5; color: #b91c1c; margin-right: auto; }
.cr-btn-danger:hover { background: #fee2e2; }
/* Indicador discreto: botão de calendário "aceso" quando a mensagem já tem lembrete. */
.cr-icon-btn.cr-has-reminder { color: var(--cr-accent); }
.cr-icon-btn.cr-has-reminder::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--cr-accent); }
.cr-act-labeled.cr-has-reminder { position: relative; }
.cr-link-btn { background: none; border: none; color: var(--cr-accent); font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 0; }
.cr-input { width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; font-size: 14px; outline: none; box-sizing: border-box; }
.cr-input:focus { border-color: var(--cr-accent); }
.cr-textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.cr-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #475569; }
.cr-check-lg { display: flex; font-size: 14px; margin: 8px 0; }
.cr-radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.cr-radio { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; color: #475569; }
.cr-pill { font-size: 11px; background: #f1f5f9; color: #64748b; border-radius: 6px; padding: 2px 8px; font-weight: 600; }
.cr-pill-on { background: #dcfce7; color: #15803d; }

/* ====== Páginas simples (contatos/regras/config) ====== */
.cr-page { padding: 20px 24px; max-width: 980px; }
.cr-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.cr-page-title { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; color: #0f172a; margin: 0; }
.cr-page-title svg { width: 22px; height: 22px; color: var(--cr-accent); }
.cr-page-search { max-width: 420px; margin-bottom: 8px; }
.cr-note { font-size: 12.5px; color: #94a3b8; margin: 4px 0 14px; }
.cr-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cr-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #94a3b8; padding: 8px 10px; border-bottom: 2px solid #eef2f6; }
.cr-table td { padding: 10px; border-bottom: 1px solid #f1f5f9; color: #334155; vertical-align: middle; }
.cr-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.cr-card-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; color: #0f172a; margin: 0 0 12px; }
.cr-card-title svg { width: 18px; height: 18px; color: var(--cr-accent); }
.cr-field { margin-bottom: 14px; }
.cr-field-label { display: block; font-size: 12.5px; font-weight: 600; color: #64748b; margin-bottom: 5px; }
.cr-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cr-id-row, .cr-sig-row { border: 1px solid #eef2f6; border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.cr-id-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.cr-sig-row-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.cr-rule-cond, .cr-rule-act { display: grid; grid-template-columns: 1fr 1fr 2fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.cr-ai-status-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; color: #475569; }

/* ====== Compositor (modal) ====== */
.cr-compose-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: flex; align-items: flex-end; justify-content: flex-end; z-index: 9998; padding: 0; opacity: 0; transition: opacity .15s; }
.cr-compose-overlay.open { opacity: 1; }
.cr-compose { background: #fff; width: 640px; max-width: 100%; max-height: 92vh; display: flex; flex-direction: column; border-radius: 12px 12px 0 0; box-shadow: 0 -8px 40px rgba(0,0,0,.25); margin: 0 28px 0 0; transform: translateY(12px); transition: transform .15s; }
.cr-compose-overlay.open .cr-compose { transform: none; }
.cr-compose-head { display: flex; align-items: center; gap: 10px; background: var(--cr-accent); color: #fff; padding: 10px 14px; border-radius: 12px 12px 0 0; }
.cr-compose-title { flex: 1; font-weight: 700; font-size: 15px; }
.cr-compose-head .cr-icon-btn { color: #fff; }
.cr-compose-head .cr-icon-btn:hover { background: rgba(255,255,255,.2); }
.cr-compose-autosave { font-size: 11px; opacity: .85; }
.cr-compose-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.cr-recip { position: relative; }
.cr-chips { display: flex; flex-wrap: wrap; gap: 5px; border: 1px solid #cbd5e1; border-radius: 8px; padding: 5px 8px; min-height: 36px; align-items: center; }
.cr-chips:focus-within { border-color: var(--cr-accent); }
.cr-chip { display: inline-flex; align-items: center; gap: 4px; background: #e6f4f1; color: #0f5e54; border-radius: 14px; padding: 2px 4px 2px 10px; font-size: 13px; }
.cr-chip-x { background: none; border: none; cursor: pointer; color: #0f5e54; font-size: 15px; line-height: 1; padding: 0 4px; }
.cr-chip-input { flex: 1; min-width: 100px; border: none; outline: none; font-size: 14px; padding: 4px; }
.cr-autocomplete { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 5; overflow: hidden; }
.cr-ac-item { display: flex; flex-direction: column; width: 100%; text-align: left; background: none; border: none; padding: 8px 12px; cursor: pointer; }
.cr-ac-item:hover { background: #f1f5f9; }
.cr-ac-item strong { font-size: 13.5px; color: #1e293b; }
.cr-ac-item span { font-size: 12px; color: #94a3b8; }
.cr-rt-toolbar { display: flex; align-items: center; gap: 2px; border: 1px solid #e2e8f0; border-bottom: none; border-radius: 8px 8px 0 0; padding: 4px 6px; background: #f8fafc; }
.cr-rt-btn { width: 28px; height: 28px; background: none; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; color: #475569; }
.cr-rt-btn:hover { background: #e2e8f0; }
.cr-rt-sep { width: 1px; height: 18px; background: #cbd5e1; margin: 0 4px; }
.cr-rt-editor { border: 1px solid #cbd5e1; border-radius: 0 0 8px 8px; min-height: 200px; padding: 12px; font-size: 14px; line-height: 1.6; outline: none; overflow-y: auto; }
.cr-rt-editor:focus { border-color: var(--cr-accent); }
.cr-rt-editor [data-ph] { color: #94a3b8; }
.cr-quote { border-left: 3px solid #cbd5e1; padding-left: 12px; margin-top: 12px; color: #64748b; font-size: 13px; }
.cr-quote blockquote { margin: 6px 0 0; }
.cr-sig-block { color: #64748b; margin-top: 10px; }
.cr-attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cr-attach-item { display: inline-flex; align-items: center; gap: 5px; background: #f1f5f9; border-radius: 7px; padding: 4px 6px 4px 10px; font-size: 12.5px; color: #334155; }
.cr-attach-item svg { width: 13px; height: 13px; color: #64748b; }
.cr-attach-x { background: none; border: none; cursor: pointer; color: #94a3b8; font-size: 15px; line-height: 1; }
.cr-compose-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid #eef2f6; flex-wrap: wrap; }
.cr-attach-btn { cursor: pointer; }
.cr-foot-select { width: auto; min-width: 120px; padding: 5px 8px; font-size: 13px; }
.cr-foot-spacer { flex: 1; }

.cr-shortcuts { background: #fff; border-radius: 12px; width: 360px; max-width: 92%; margin: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3); overflow: hidden; }
.cr-compose-overlay:has(.cr-shortcuts) { align-items: center; justify-content: center; }
.cr-sc-list { list-style: none; margin: 0; padding: 12px 18px 18px; }
.cr-sc-list li { display: flex; align-items: center; gap: 12px; padding: 7px 0; font-size: 14px; color: #334155; }
.cr-sc-list kbd { background: #f1f5f9; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: 6px; padding: 2px 9px; font-size: 13px; font-family: monospace; min-width: 22px; text-align: center; }

/* ====== Mobile-first (toolbar de topo quebra/colapsa · 2 painéis colapsam: lista→leitura) ====== */
@media (max-width: 900px) {
  .cr-shell { height: calc(100vh - 100px); }
  /* Painéis: 1 coluna (lista→leitura), independentemente do modo de preview. */
  .cr-panes, .cr-shell[data-preview="bottom"] .cr-panes, .cr-shell[data-preview="off"] .cr-panes {
    grid-template-columns: 1fr; grid-template-rows: 1fr;
  }
  .cr-read-pane { display: none; }
  .cr-shell[data-preview="off"] .cr-read-pane { display: none; }
  .cr-shell.reading-open .cr-list-pane { display: none; }
  .cr-shell.reading-open .cr-read-pane { display: block; }
  .cr-read-back { display: inline-flex; }
  .cr-compose { width: 100%; max-height: 100vh; height: 100vh; border-radius: 0; margin: 0; }
  .cr-compose-overlay { align-items: stretch; }
  .cr-id-row { grid-template-columns: 1fr; }
  .cr-grid-2 { grid-template-columns: 1fr; }
  .cr-rule-cond, .cr-rule-act { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  /* Filtros viram coluna única; o painel se comporta como drawer expansível. */
  .cr-filters-grid { grid-template-columns: 1fr; }
  .cr-filters-btn-label { display: none; }
  .cr-active-chip-label { max-width: 120px; }
  .cr-reading { padding: 14px; }
  .cr-page { padding: 14px; }
  /* Toolbar de topo: rótulo do toggle semântico some (o switch permanece); chips/segmentado quebram. */
  .cr-topbar-semantic .cr-switch-text { display: none; }
  /* Histórico: segmentado compacto + trilho mais justo no mobile. */
  .cr-flow-seg, .cr-topbar .cr-flow-seg { padding: 6px 8px; gap: 3px; }
  .cr-flow-seg-btn { font-size: 12px; padding: 0 4px; height: 28px; }
  .cr-flow-dir { margin-left: 18px; }
  .cr-flow-rail::before { left: 20px; }
  .cr-flow-node { left: 15px; }
}

/* === ETIQUETAS coloridas (tags) + popovers de etiqueta/calendário ====================== */
/* Chips completos no painel de leitura (cor de fundo do catálogo + texto legível via JS). */
.cr-reading-chips { margin: 0 0 12px; }
.cr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cr-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: 11px; font-size: 12px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Botão de ação com rótulo (Etiquetas / Calendário) no cabeçalho de leitura. */
.cr-act-labeled { width: auto; gap: 5px; padding: 0 10px; font-size: 12.5px; font-weight: 600; color: #475569; }
.cr-act-labeled .cr-act-text { white-space: nowrap; }
.cr-act-labeled[aria-expanded="true"] { background: color-mix(in srgb, var(--cr-accent) 12%, #fff); color: var(--cr-accent); }

/* Âncora de popover (o popover absoluto se posiciona em relação a ela). */
.cr-pop-anchor { position: relative; display: inline-flex; }

/* Popover compacto (disclosure, não modal) — mesmo idioma do popover de filtros. */
.cr-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; min-width: 240px; max-width: 320px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.16);
  padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.cr-pop-cal { min-width: 260px; }
.cr-pop-head { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: #1e293b; padding: 2px 2px 6px; border-bottom: 1px solid #eef2f6; }
.cr-pop-head svg { width: 15px; height: 15px; color: var(--cr-accent); }
.cr-pop-head .cr-pop-x { margin-left: auto; width: 26px; height: 26px; }
.cr-pop-loading, .cr-pop-empty { padding: 10px 4px; font-size: 13px; color: #94a3b8; text-align: center; }

/* Lista de tags com checkbox + cor. */
.cr-tag-list { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.cr-tag-opt { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: #334155; }
.cr-tag-opt:hover { background: #f8fafc; }
.cr-tag-opt input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--cr-accent); flex: 0 0 auto; }
.cr-tag-swatch { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.cr-tag-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Mini-form "nova etiqueta". */
.cr-tag-new { display: flex; align-items: center; gap: 6px; padding-top: 6px; border-top: 1px solid #eef2f6; }
.cr-tag-color { width: 30px; height: 30px; padding: 0; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; cursor: pointer; flex: 0 0 auto; }
.cr-tag-newname { flex: 1; min-width: 0; }
.cr-tag-add { flex: 0 0 auto; color: var(--cr-accent); }

/* Rodapé / link "Gerenciar etiquetas". */
.cr-pop-foot { display: flex; align-items: center; padding-top: 4px; }
.cr-link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; padding: 4px 2px; font-size: 12.5px; font-weight: 600; color: var(--cr-accent); cursor: pointer; }
.cr-link-btn svg { width: 14px; height: 14px; }
.cr-tag-manage-row { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 8px; font-size: 13.5px; color: #334155; }
.cr-tag-manage-row:hover { background: #f8fafc; }
.cr-tag-manage-row .cr-tag-name { flex: 1; }
.cr-tag-del { width: 28px; height: 28px; }

/* Popover de calendário (form compacto). */
.cr-cal-form { display: flex; flex-direction: column; gap: 8px; }
.cr-cal-allday { display: flex; align-items: center; gap: 7px; font-size: 13px; color: #334155; cursor: pointer; }
.cr-cal-allday input { accent-color: var(--cr-accent); }
.cr-cal-times { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cr-cal-tz { font-size: 11px; color: #94a3b8; }
.cr-cal-foot { justify-content: flex-end; gap: 8px; }

/* Bolinha colorida da etiqueta no MENU lateral (item-filtro). */
.cr-nav-tag-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }

@media (max-width: 560px) {
  /* No mobile, os popovers ocupam a largura útil ancorados à direita. */
  .cr-pop { right: 0; left: auto; max-width: calc(100vw - 28px); }
  .cr-act-labeled .cr-act-text { display: none; }
}

/* Drag-and-drop de anexos no corpo do compose (arrastar arquivos sobre o editor) */
.cr-rt-editor.cr-dragover { outline: 2px dashed var(--product-accent, #2563eb); outline-offset: -4px; background: color-mix(in srgb, var(--product-accent, #2563eb) 6%, #fff); }
