/* AlcureSys — CSS customizado (mínimo). Tailwind cuida de 95%. */

/* Reset mínimo pra páginas standalone (fullscreen) que não herdam do base.html */
html, body { margin: 0; padding: 0; width: 100%; }

/* Crossfade nativo nas navegações de página inteira que restarem. */
@view-transition { navigation: auto; }

/* PWA standalone e popup ?janela=1: some o chrome do sistema. */
html.modo-janela #chrome-sidebar,
html.modo-janela #chrome-topbar,
html.modo-janela #chrome-rodape,
html.modo-janela #trilha,
html.modo-janela .so-navegador { display: none !important; }
html.modo-janela main { padding: 0.75rem; }

/* Painel direito da conversa (recorte, cliente, relatório). */
#conversa-shell.painel-fechado #painel-conversa-coluna { display: none !important; }



/* Esconde elementos até Alpine inicializar */
[x-cloak] { display: none !important; }

/* HTMX indicator */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* Pequena animação pra deleção */
.htmx-swapping { opacity: 0; transition: opacity 200ms ease-out; }

/* Cards com hover sutil */
.card-hover { transition: box-shadow 200ms ease, transform 200ms ease; }
.card-hover:hover { box-shadow: 0 4px 14px -2px rgba(0,0,0,0.08); }

/* Truncamento em uma linha */
.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* =================================================================
   Editor rico (Tiptap) — partial _editor_rico.html
   Movido do `<style type="text/tailwindcss">` inline porque o Play
   CDN do Tailwind não processa @apply de forma confiável. CSS
   regular sempre funciona.
   ================================================================= */
/* .editor-topbar = abas + toolbars. No modo contraído NÃO é sticky: o
   .ProseMirror tem scroll próprio (max-height: 70vh), então a toolbar já
   fica sempre visível sem brigar com a topbar do app. No fullscreen o
   topbar inteiro vira um bloco sticky único (ver regra body.tela-cheia). */
.editor-topbar { margin-bottom: 0; }

.editor-tabs {
  display: flex; gap: 4px;
  padding: 0 0 0 4px;
}
.editor-tab {
  padding: 6px 12px; border-top-left-radius: 8px; border-top-right-radius: 8px;
  font-size: 12px; font-weight: 600; color: #6b7280;
  border: 1px solid #d1d5db; border-bottom: 0;
  background: #eef1f5; cursor: pointer;
  transition: color 120ms, background-color 120ms;
}
.editor-tab:hover { color: #1f2937; }
/* Aba ativa "merges" com o container da toolbar (mesma cor + cobre a borda) */
.editor-tab.ativo {
  background: #f9fafb; color: #1f3c66;
  position: relative; top: 1px;
  padding-bottom: 7px;
}
.editor-tab:focus { outline: none; }

.editor-toolbars {
  display: flex; flex-direction: column;
  border: 1px solid #d1d5db; border-radius: 0 8px 8px 8px;
  background: #f9fafb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.editor-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px;
  padding: 5px 8px;
}
.editor-toolbar + .editor-toolbar { border-top: 1px solid #e5e7eb; }

.editor-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 30px; padding: 0 10px;
  border-radius: 6px;
  font-size: 13px; font-weight: 500; color: #4b5563;
  background: transparent; border: 0; cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms, color 120ms;
}
.editor-btn:hover { background: #e5e7eb; }
.editor-btn.ativo { background: #d9e6f5; color: #1f3c66; }
.editor-btn:focus { outline: none; box-shadow: 0 0 0 2px rgba(53, 109, 180, 0.3); }

.editor-select {
  height: 30px; border-radius: 6px; border: 1px solid #d1d5db;
  font-size: 12px; color: #374151; padding: 0 8px; background: #fff;
  cursor: pointer;
}
.editor-select:focus { outline: none; border-color: #356db4; box-shadow: 0 0 0 2px rgba(53, 109, 180, 0.3); }

.editor-color {
  height: 30px; width: 34px; border-radius: 6px;
  border: 1px solid #d1d5db; background: #fff;
  padding: 2px; cursor: pointer;
}

.editor-sep { width: 1px; height: 22px; background: #d1d5db; margin: 0 4px; flex-shrink: 0; }

/* Ícones SVG dos botões da toolbar */
.editor-ico { width: 15px; height: 15px; display: block; }
.editor-btn-ico { min-width: 30px; padding: 0 7px; }

.editor-area { min-height: 380px; display: flex; flex-direction: column; }
/* O textarea cru (aba "Código HTML" / fallback sem JS) some via [hidden] —
   o !important vence classes de form (.input) com display: block. */
[data-editor-config-url] textarea[hidden] { display: none !important; }
.editor-area .ProseMirror {
  min-height: 380px; max-height: 70vh; overflow-y: auto;
  border: 1px solid #d1d5db; border-top: 0;
  background: #fff; padding: 24px 32px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 15px; line-height: 1.7; color: #111827;
  outline: none; flex: 1 1 auto;
}
.editor-area .ProseMirror p { margin-bottom: 12px; }
.editor-area .ProseMirror ul { list-style: disc; padding-left: 24px; margin-bottom: 12px; }
.editor-area .ProseMirror ol { list-style: decimal; padding-left: 24px; margin-bottom: 12px; }
.editor-area .ProseMirror blockquote { border-left: 4px solid #d1d5db; padding-left: 16px; font-style: italic; margin-bottom: 12px; }
.editor-area .ProseMirror h2 { font-size: 1.125rem; font-weight: 700; margin-bottom: 12px; }
.editor-area .ProseMirror h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.editor-area .ProseMirror hr { margin: 16px 0; border-color: #d1d5db; }
.editor-area .ProseMirror table { border-collapse: collapse; width: 100%; margin-bottom: 12px; }
.editor-area .ProseMirror td, .editor-area .ProseMirror th {
  border: 1px solid #9ca3af; padding: 4px 8px; vertical-align: top; min-width: 32px;
}
.editor-area .ProseMirror th { background: #f3f4f6; font-weight: 600; }
.editor-area .ProseMirror .selectedCell { background: #eef4fb; }

/* Menu "⋯" (details nativo) — dropdown com opções menos usadas */
.editor-menu { position: relative; }
.editor-menu[open] > summary { background: #e5e7eb; }
.editor-menu-body {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 50;
  min-width: 190px; border-radius: 8px;
  border: 1px solid #e5e7eb; background: #fff;
  box-shadow: 0 8px 24px -6px rgba(16, 24, 40, 0.16);
  padding: 4px; display: flex; flex-direction: column;
}
.editor-menu-body .editor-btn { justify-content: flex-start; width: 100%; height: 30px; padding: 0 8px; font-weight: 400; font-size: 12.5px; }
.editor-menu-sep { height: 1px; background: #e5e7eb; margin: 4px 6px; }

/* details > summary nativo (sem markers do Chrome) */
.editor-toolbar details { position: relative; }
.editor-toolbar details > summary { list-style: none; cursor: pointer; }
.editor-toolbar details > summary::-webkit-details-marker { display: none; }
.editor-toolbar details > summary::marker { display: none; content: ''; }
.editor-toolbar details > summary > * { display: inline-block; vertical-align: middle; }

/* Grupo de botões contextuais de tabela (visível só quando o cursor está numa tabela).
   Usa display: inline-flex em vez de attribute hidden (que tem prioridade
   menor que style="display:..." inline). O JS toggle via .hidden = true/false. */
.editor-table-tools {
  display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap;
}
.editor-table-tools[hidden] { display: none; }

/* Imagens inseridas no editor */
.editor-area .ProseMirror .editor-img {
  max-width: 100%; height: auto;
  border-radius: 6px; border: 1px solid #e5e7eb;
}
.editor-area .ProseMirror img.ProseMirror-selected,
.editor-area .ProseMirror .editor-img.ProseMirror-selected {
  outline: 2px solid #356db4; outline-offset: 2px;
}

/* Links no editor */
.editor-area .ProseMirror a { color: #265697; text-decoration: underline; }
.editor-area .ProseMirror a:hover { color: #1f3c66; }

/* Code inline e code block */
.editor-area .ProseMirror code {
  background: #f3f4f6; padding: 1px 5px; border-radius: 3px;
  font-family: 'Courier New', ui-monospace, monospace; font-size: 0.92em;
}
.editor-area .ProseMirror pre {
  background: #0f172a; color: #f1f5f9;
  padding: 14px 18px; border-radius: 8px;
  font-family: 'Courier New', ui-monospace, monospace; font-size: 13px;
  line-height: 1.5; overflow-x: auto;
}
.editor-area .ProseMirror pre code { background: transparent; padding: 0; color: inherit; }

/* Task list (lista de tarefas com checkbox) */
.editor-area .ProseMirror ul[data-type="taskList"] {
  list-style: none; padding-left: 0; margin-bottom: 12px;
}
.editor-area .ProseMirror ul[data-type="taskList"] li {
  display: flex; align-items: flex-start; gap: 8px; margin-bottom: 4px;
}
.editor-area .ProseMirror ul[data-type="taskList"] li > label {
  margin-top: 3px; flex-shrink: 0;
}
.editor-area .ProseMirror ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.editor-area .ProseMirror ul[data-type="taskList"] input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer; accent-color: #265697;
}
.editor-area .ProseMirror ul[data-type="taskList"] li[data-checked="true"] > div {
  text-decoration: line-through; color: #6b7280;
}

/* Headings 1, 4, 5 (só 2 e 3 estavam antes) */
.editor-area .ProseMirror h1 {
  font-size: 1.5rem; font-weight: 700; margin: 16px 0 12px 0;
  border-bottom: 2px solid #1f3c66; padding-bottom: 6px;
}
.editor-area .ProseMirror h4 { font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; color: #1f3c66; }
.editor-area .ProseMirror h5 { font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; color: #4b5563; text-transform: uppercase; letter-spacing: 0.05em; }

/* Sup/Sub */
.editor-area .ProseMirror sup, .editor-area .ProseMirror sub { font-size: 0.75em; line-height: 0; }

/* Zoom: usa a propriedade CSS `zoom` (definida inline pelo JS), que reflui
   o layout — sem transform: scale (que quebrava overflow, sticky e a
   seleção de texto). */
.editor-area .ProseMirror { min-height: 380px; }

/* =================================================================
   Configurador de página (modelo_form_fullscreen.html)
   ================================================================= */
.fs-page-panel {
  border-left: 1px solid #e5e7eb;
  background: #fff;
  display: flex; flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.fs-page-panel-header {
  padding: 12px 16px; border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.fs-page-panel-header h2 { font-size: 13px; font-weight: 600; color: #111827; }
.fs-page-panel-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.fs-page-panel-body section { margin-bottom: 18px; }
.fs-page-panel-body section > h3 {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: #6b7280; margin: 0 0 8px 0;
}
.fs-page-panel-body label {
  display: block; font-size: 12px; color: #374151; margin-bottom: 4px;
}
.fs-page-panel-body select,
.fs-page-panel-body input[type="text"],
.fs-page-panel-body input[type="number"] {
  width: 100%; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 13px; background: #fff;
}
.fs-page-panel-body input[type="color"] {
  width: 100%; height: 32px; border: 1px solid #d1d5db; border-radius: 6px;
  padding: 2px; cursor: pointer; background: #fff;
}
.fs-page-panel-body .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fs-page-panel-body .row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; }
.fs-page-panel-body .help { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.fs-page-panel-body input[type="range"] { width: 100%; }

/* Painéis laterais do fullscreen (Variáveis / Página / Identificação)
   compartilham .fs-aside mas cada um tem largura diferente via grid-template. */
.fs-aside-variaveis { /* largura padrão 360px, controlada por .no-variaveis */ }
.fs-aside-page { /* 280px quando .com-pagina */ }
.fs-aside-id { /* 240px quando .com-id */ }
.fs-aside-body {
  flex: 1; overflow-y: auto; padding: 12px 16px;
}
.fs-aside-body section { margin-bottom: 18px; }
.fs-aside-body section > h3 {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: #6b7280; margin: 0 0 8px 0;
}
.fs-aside-body label {
  display: block; font-size: 12px; color: #374151; margin-bottom: 4px;
}
.fs-aside-body select,
.fs-aside-body input[type="text"],
.fs-aside-body input[type="number"] {
  width: 100%; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 13px; background: #fff;
}
.fs-aside-body input[type="color"] {
  width: 100%; height: 32px; border: 1px solid #d1d5db; border-radius: 6px;
  padding: 2px; cursor: pointer; background: #fff;
}
.fs-aside-body .row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; }
.fs-aside-body .help { font-size: 11px; color: #9ca3af; margin-top: 4px; }

/* A4, A5, Carta, Ofício — tamanhos em mm. Ajustados ao aspect ratio do
   container, mantendo proporção real. */
.fs-page-preview {
  position: relative;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #d1d5db;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  background-size: 8px 8px;
  background-image:
    linear-gradient(to right, rgba(0,0,0,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.04) 1px, transparent 1px);
  transition: width 200ms, height 200ms, padding 200ms, background-color 200ms;
}

/* =================================================================
   Página dentro do editor fullscreen (papel real visualizado)
   ================================================================= */
.fs-paper {
  background: #fff;
  margin: 24px auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border: 1px solid #d1d5db;
  position: relative;
  overflow: hidden;
  transition: width 200ms ease, min-height 200ms ease, padding 200ms ease, background-color 200ms ease;
}
.fs-paper .ProseMirror {
  border: 0; padding: 0; min-height: 0; max-height: none;
  background: transparent;
}
.fs-paper-watermark {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; user-select: none;
  font-size: 96px; font-weight: 800; letter-spacing: 0.05em;
  color: #000;
  transform: rotate(-30deg);
  z-index: 0;
}
.fs-paper-watermark img {
  width: 50%; max-width: 400px; opacity: 0.15;
  transform: rotate(-30deg);
}
.fs-paper .ProseMirror { position: relative; z-index: 1; }
.fs-paper-watermark-text { z-index: 0; }

/* Quando o formulário fullscreen NÃO usa a "página" (modo contínuo), o
   .fs-paper pode ser escondido — basta remover a classe do .fs-form. */
.fs-form.papel-continuo .fs-paper { display: none; }

/* =================================================================
   Editor fullscreen — modelo_form_fullscreen.html
   Grid com 4 colunas: form | variáveis | página | identificação.
   Cada painel é toggable. O JS (setPanel) aplica grid-template-columns
   via inline style pra evitar conflito de especificidade com o Tailwind
   via Play CDN. Aqui só definimos o fallback inicial.
   IMPORTANTE: cada <aside> tem grid-column: N explícito no HTML,
   senão um display:none num painel intermediário faz o próximo
   "escorregar" pra coluna errada.
   ================================================================= */
.fs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px 0px 0px;  /* form | variaveis | page | id */
  height: 100vh;
  width: 100vw;
  background: #f8fafc;
}

.fs-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  min-width: 0;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.fs-header h1 { font-size: 14px; font-weight: 600; color: #111827; }
.fs-header .btn-back {
  font-size: 13px; color: #6b7280; text-decoration: none;
  white-space: nowrap; flex-shrink: 0;
}
.fs-header .btn-back:hover { color: #265697; }

/* Botão "Sair da tela cheia" no header — só em .tela-cheia, com X + texto claro */
body.tela-cheia .fs-header .btn-sair-tela-cheia {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: #991b1b;
  background: #fff; border: 1px solid #fecaca;
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
  transition: background-color 120ms, border-color 120ms;
}
body.tela-cheia .fs-header .btn-sair-tela-cheia:hover {
  background: #fee2e2; border-color: #fca5a5; color: #7f1d1d;
}

/* Botão "Protocolo" no header — sai da tela cheia E volta ao protocolo.
   Visual neutro/discreto, pra não competir com "Salvar" nem com o botão vermelho. */
body.tela-cheia .fs-header .btn-voltar-protocolo {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: #374151;
  background: #fff; border: 1px solid #d1d5db;
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}
body.tela-cheia .fs-header .btn-voltar-protocolo:hover {
  background: #f9fafb; border-color: #9ca3af; color: #111827;
}

/* Edição inline do título do documento (lápis + input) — usado no editor
   fullscreen e no editor normal. Afordância discreta. */
.titulo-edit-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px; border: 0; background: transparent;
  color: #9ca3af; cursor: pointer; border-radius: 4px;
  flex-shrink: 0; opacity: 0; transition: opacity 120ms, color 120ms, background-color 120ms;
}
h1:hover > .titulo-edit-btn,
.card:hover .titulo-edit-btn,
.titulo-edit-btn:focus-visible { opacity: 1; }
.titulo-edit-btn:hover { color: #265697; background: #eef4fb; }
.titulo-edit-input {
  font: inherit; color: #111827;
  padding: 2px 6px; border: 1px solid #356db4; border-radius: 6px;
  box-shadow: 0 0 0 2px rgba(53, 109, 180, 0.25);
  outline: none; min-width: 0; max-width: 100%; width: 22ch;
}

.fs-toggle-sidebar {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 6px;
  font-size: 13px; color: #4b5563; font-weight: 500;
  background: transparent; border: 1px solid transparent;
  cursor: pointer; transition: background-color 120ms, border-color 120ms;
  white-space: nowrap; flex-shrink: 0;
}
.fs-toggle-sidebar:hover { background: #f3f4f6; border-color: #e5e7eb; color: #265697; }

.fs-form {
  flex: 1; overflow-y: auto;
  /* Sem padding-top em fullscreen: as toolbars são sticky no topo do scroll
     e ocupam esse espaço. Adiciona padding-top só quando NÃO tem toolbar
     sticky (modo normal). */
  padding: 24px 32px;
  background: #f8fafc;
  min-width: 0;
}
body.tela-cheia .fs-form {
  padding: 0 32px 24px 32px;  /* sem top — ocupado pelas toolbars sticky */
}
/* Fullscreen: o topbar (abas + toolbar) é movido pelo JS pra dentro do form,
   como irmão do .fs-paper, e vira UM bloco sticky único no topo do scroll —
   sem offsets mágicos por fileira. */
body.tela-cheia .fs-form > .editor-topbar {
  position: sticky; top: 0; z-index: 40;
  background: #f8fafc;
  padding-top: 10px; padding-bottom: 6px;
}

.fs-aside {
  border-left: 1px solid #e5e7eb;
  background: #fff;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.fs-aside-header {
  padding: 16px; border-bottom: 1px solid #e5e7eb;
}
.fs-aside-header h2 { font-size: 14px; font-weight: 600; color: #111827; }
.fs-aside-header .hint { font-size: 12px; color: #6b7280; margin-top: 2px; }
.fs-aside-search { margin-top: 12px; position: relative; }
.fs-aside-search input {
  width: 100%; padding: 8px 12px 8px 32px;
  border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 13px; background: #fff;
}
.fs-aside-search input:focus { outline: none; border-color: #356db4; box-shadow: 0 0 0 2px rgba(53, 109, 180, 0.3); }
.fs-aside-search svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: #9ca3af; pointer-events: none;
}
.fs-aside-list { flex: 1; overflow-y: auto; padding: 12px; }
.fs-aside-list > section { margin-bottom: 16px; }
.fs-aside-list > section > h3 {
  padding: 4px 8px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280;
  margin: 0 0 6px 0;
}
.fs-aside-list .var-group { display: flex; flex-direction: column; gap: 6px; }

/* Card de variável (drag & drop) */
.var-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 10px; cursor: grab;
  transition: background-color 120ms, box-shadow 120ms, border-color 120ms;
}
.var-card:hover { border-color: #b7cfec; box-shadow: 0 2px 8px -2px rgba(16, 24, 40, 0.08); }
.var-card.dragging { opacity: 0.5; cursor: grabbing; }
.var-card.drag-over { background-color: #eef4fb; border-color: #356db4; }

/* Botão "×" de remover parte/imóvel no card — discreto, aparece no hover */
.var-card { position: relative; }
.card-remove-form { position: absolute; top: 4px; right: 4px; margin: 0; line-height: 0; }
.card-remove {
  width: 20px; height: 20px; padding: 0; border: 0; border-radius: 5px;
  background: transparent; color: #9ca3af; cursor: pointer;
  font-size: 16px; line-height: 18px; text-align: center;
  opacity: 0; transition: opacity 120ms, background-color 120ms, color 120ms;
}
.var-card:hover .card-remove, .card-remove:focus-visible { opacity: 1; }
.card-remove:hover { background: #fee2e2; color: #b91c1c; }

/* Formulários "Adicionar parte / Vincular imóvel" dentro do painel (360px) */
.painel-add { margin-top: 8px; }
.painel-add > summary {
  list-style: none; cursor: pointer;
  font-size: 12px; font-weight: 600; color: #265697;
  padding: 6px 8px; border-radius: 6px; border: 1px dashed #cbd5e1;
  text-align: center; transition: background-color 120ms, border-color 120ms;
}
.painel-add > summary::-webkit-details-marker { display: none; }
.painel-add > summary:hover { background: #eef4fb; border-color: #93b4dd; }
.painel-add[open] > summary { border-style: solid; margin-bottom: 8px; }
.painel-add-form { display: flex; flex-direction: column; gap: 6px; }
.painel-busca { position: relative; }
.painel-add-form .painel-input {
  width: 100%; padding: 6px 8px; font-size: 12px;
  border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #1f2937;
}
.painel-add-form .painel-input:focus { outline: none; border-color: #356db4; box-shadow: 0 0 0 2px rgba(53, 109, 180, 0.25); }
.painel-resultados { position: absolute; left: 0; right: 0; z-index: 30; }
.painel-selecionado { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.painel-selecionado button { font-size: 11px; color: #b91c1c; background: none; border: 0; cursor: pointer; }
.painel-selecionado button:hover { text-decoration: underline; }
.painel-add-btn {
  padding: 6px 10px; border-radius: 6px; border: 0; cursor: pointer;
  font-size: 12px; font-weight: 600; color: #fff; background: #265697;
  transition: background-color 120ms;
}
.painel-add-btn:hover { background: #1f3c66; }
.painel-add-btn:disabled { background: #cbd5e1; cursor: not-allowed; }
.painel-linha { display: flex; gap: 6px; }
.painel-linha .painel-input { flex: 1; min-width: 0; }
.painel-uf { flex: 0 0 78px !important; }
.var-card .var-label { font-size: 12px; font-weight: 600; color: #1f2937; line-height: 1.3; }
.var-card .var-token { font-size: 10.5px; color: #265697; font-family: ui-monospace, SFMono-Regular, monospace; word-break: break-all; display: block; margin-top: 2px; }
.var-card .var-desc { font-size: 11px; color: #6b7280; line-height: 1.4; margin-top: 4px; }
.var-card .var-exemplo { font-size: 10.5px; color: #9ca3af; font-style: italic; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.var-card .var-inserir {
  font-size: 10.5px; font-weight: 600; color: #265697;
  padding: 2px 8px; border-radius: 4px; cursor: pointer;
  transition: background-color 120ms, color 120ms;
  background: transparent; border: 0;
}
.var-card .var-inserir:hover { background: #eef4fb; color: #1f3c66; }
.var-card .var-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.var-card .var-row > div { min-width: 0; flex: 1; }

/* Indicador de auto-salvamento (editor) */
.autosave-status { font-size: 12px; color: #9ca3af; white-space: nowrap; flex-shrink: 0; }

/* =================================================================
   Multi-colunas de texto (CSS columns) — botão "Colunas" na toolbar
   ================================================================= */
.editor-area .ProseMirror .multi-col {
  column-count: 2; column-gap: 24px; column-rule: 1px solid #e5e7eb;
  padding: 8px 12px; border: 1px dashed #d1d5db; border-radius: 4px;
  background: #fafbfc; margin: 8px 0;
}
.editor-area .ProseMirror .multi-col[data-cols="3"] { column-count: 3; }
.editor-area .ProseMirror .multi-col[data-cols="4"] { column-count: 4; }

/* =================================================================
   Picker de tamanho de tabela (grid 8x8) — aparece ao clicar no botão
   Tabela. position: fixed (coordenadas de viewport via JS) pra funcionar
   dentro de qualquer container rolável (form fullscreen, cards, etc).
   ================================================================= */
.editor-table-picker {
  position: fixed; z-index: 60;
  background: #fff; border: 1px solid #d1d5db; border-radius: 8px;
  box-shadow: 0 12px 32px -8px rgba(16, 24, 40, 0.22);
  padding: 14px;
  display: none;
}
.editor-table-picker.aberto { display: block; }
.editor-table-picker .picker-grid {
  display: grid; grid-template-columns: repeat(8, 22px); grid-template-rows: repeat(8, 22px);
  gap: 3px;
  padding: 3px;
  background: #f3f4f6; border-radius: 4px;
}
.editor-table-picker .picker-cell {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 2px;
  cursor: pointer; transition: background-color 80ms, border-color 80ms;
}
.editor-table-picker .picker-cell.ativo {
  background: #265697; border-color: #1f3c66;
  box-shadow: inset 0 0 0 1px #1f3c66;
}
.editor-table-picker .picker-cell:hover { border-color: #356db4; }
.editor-table-picker .picker-cell.ativo:hover { border-color: #1f3c66; }
.editor-table-picker .picker-info {
  margin-top: 10px; font-size: 12px; color: #4b5563; text-align: center; min-height: 18px; font-weight: 500;
}
.editor-table-picker .picker-hint {
  font-size: 10.5px; color: #9ca3af; text-align: center; margin-top: 2px;
}


/* Estado do card expansível sem depender de variantes geradas pelo Tailwind. */
.modelos-details > summary::-webkit-details-marker { display: none; }
.modelos-details .modelos-recolher { display: none; }
.modelos-details[open] .modelos-expandir { display: none; }
.modelos-details[open] .modelos-recolher { display: inline; }
.modelos-details[open] .modelos-chevron { transform: rotate(180deg); }

/* Cards compactos de modelo e prévia em formato de documento. */
.modelo-page-icon {
  width: 34px;
  height: 46px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 7px 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.08);
  cursor: zoom-in;
}
.modelo-page-icon span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: #dbe3ee;
}
.modelo-page-icon span:nth-child(2) { width: 78%; }
.modelo-page-icon span:nth-child(4) { width: 62%; }
.modelo-card:hover .modelo-page-icon,
.modelo-card:focus-within .modelo-page-icon {
  border-color: #356db4;
  box-shadow: 0 3px 8px rgba(38, 86, 151, 0.16);
}
.modelo-preview-popover {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  left: 50%;
  width: min(360px, calc(100vw - 2rem));
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 22px 50px -16px rgba(15, 23, 42, 0.38);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -5px);
  transition: opacity 120ms ease, transform 120ms ease;
}
.modelo-card:hover .modelo-preview-popover,
.modelo-card:focus-within .modelo-preview-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
.modelo-preview-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
}
.modelo-preview-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 999px;
  background: #265697;
  box-shadow: 14px 0 #d5a94e, 28px 0 #94a3b8;
  margin-right: 28px;
}
.modelo-preview-canvas {
  display: flex;
  justify-content: center;
  max-height: 470px;
  overflow: hidden;
  padding: 16px;
  background: #e9edf3;
}
.modelo-thumb {
  position: relative;
  width: 286px;
  aspect-ratio: 210 / 297;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  background: #fff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.14);
}
.modelo-thumb-inner {
  width: 794px;
  padding: 48px 40px;
  color: #111827;
  font-size: 12pt;
  line-height: 1.5;
  pointer-events: none;
  user-select: none;
  transform: scale(0.36);
  transform-origin: top left;
}
.modelo-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 83%, rgba(255, 255, 255, 0.96));
  pointer-events: none;
}

/* =========================================================================
   Anexos do protocolo — estados de arrastar-e-soltar
   =========================================================================
   CSS de verdade (e não classe utilitária no template) porque quem liga e
   desliga estas classes é o JS de `_anexos_js.html`, a cada dragover: o
   estado é de interação, não de renderização.
   ------------------------------------------------------------------------ */
#anexos-raiz.solta-aqui {
  outline: 2px dashed #7c3aed;
  outline-offset: 4px;
  border-radius: 12px;
  background: rgba(124, 58, 237, 0.03);
}
.anexo-item {
  cursor: grab;
}
.anexo-item.arrastando {
  opacity: 0.45;
}
.anexo-pasta.solta-aqui {
  border-color: #7c3aed;
  box-shadow: inset 0 0 0 1px #7c3aed;
  background: rgba(124, 58, 237, 0.06);
}
[data-anexos-lixeira].solta-aqui {
  border-color: #b91c1c;
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.06);
}
[data-anexos-lixeira].solta-aqui svg,
[data-anexos-lixeira].solta-aqui p {
  color: #b91c1c;
}


/* Cortina do assistente do protocolo: fora do main (overflow-x-auto). */
.assistente-aba {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #b7cfec;
  background: #fff;
  color: #21457b;
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: 0 8px 24px -6px rgb(16 24 40 / 0.16);
}
.assistente-aba:hover { background: #eef4fb; }
.assistente-cortina { display: none; }
.assistente-dock.is-open .assistente-aba { display: none; }
.assistente-dock.is-open .assistente-cortina {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 24rem;
  max-width: 100vw;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -12px 0 32px -16px rgb(16 24 40 / 0.28);
}
.assistente-dock.is-open.is-largo .assistente-cortina { width: min(42rem, 100vw); }
.assistente-barra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}
.assistente-janela { display: flex; align-items: center; gap: 0.2rem; }
.assistente-btn {
  display: inline-grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 0.3rem;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: 0.85rem;
  line-height: 1;
  text-decoration: none;
}
.assistente-btn:hover { background: #eef4fb; border-color: #8ab0de; color: #21457b; }
.assistente-corpo { min-height: 0; flex: 1; overflow: hidden; }
