/* Editor de documentos do Linot (inspirado no Publisher): cabeçalho, faixa de opções com abas,
   folhas A4, objetos livres, painel lateral, barra de status, escolha de modelo e impressão. */

/* ---------- Área de trabalho ---------- */
.editing-report{max-width:none!important;width:100%!important;padding:0!important;margin:0!important}
.pub-editor{--pe-line:#dde7ec;--pe-soft:#f3f7f9;--pe-ink:#20394a;--pe-muted:#6f8592;--pe-accent:#137b98;--pe-accent-soft:#e3f2f6;--pe-warn:#b4730f;
  display:flex;flex-direction:column;min-height:calc(100vh - 64px);background:#e7edf1;background:hsl(from var(--primary) h calc(s * 0.34) 92.5);color:var(--pe-ink);font-family:Inter,"Segoe UI",Arial,sans-serif}
.pub-editor svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:none}

/* ---------- Cabeçalho ---------- */
.pub-header{display:flex;align-items:center;gap:16px;padding:10px 20px;background:#fff;border-bottom:1px solid var(--pe-line)}
.pub-title{flex:1;min-width:0;display:grid;gap:3px}
.pub-title input{width:100%;max-width:560px;height:32px;padding:4px 8px;margin-left:-8px;border:1px solid transparent;border-radius:6px;background:transparent;font:600 16px/1.2 inherit;font-family:inherit;color:var(--pe-ink)}
.pub-title input:hover{border-color:var(--pe-line)}
.pub-title input:focus{outline:0;border-color:var(--pe-accent);background:#fbfdfe}
.pub-meta{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--pe-muted);min-width:0}
.pub-meta>span:not(.pub-chip){white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pub-meta select{width:auto!important;max-width:220px;height:24px;min-height:24px;padding:0 6px;border:1px solid var(--pe-line);border-radius:5px;font-size:12px;background:#fff;color:var(--pe-ink)}
.pub-chip{display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;background:var(--pe-accent-soft);color:#0f6b84;color:hsl(from var(--primary) h calc(s * 1.03) 28.8);font-size:11px;font-weight:600;white-space:nowrap}
.pub-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.pub-btn{display:inline-flex;align-items:center;gap:6px;height:34px;padding:0 12px;border:1px solid var(--pe-line,#dde7ec);border:1px solid var(--pe-line,hsl(from var(--primary) h calc(s * 0.37) 89.6));border-radius:7px;background:#fff;color:#2c5266;color:hsl(from var(--primary) h calc(s * 0.52) 28.6);font:500 12.5px/1 inherit;font-family:inherit;cursor:pointer;white-space:nowrap;transition:background .12s,border-color .12s}
.pub-btn:hover{background:#f2f8fa;background:hsl(from var(--primary) h calc(s * 0.58) 96.5);border-color:#b9d5df;border-color:hsl(from var(--primary) h calc(s * 0.48) 80)}
.pub-btn.ghost{border-color:transparent;background:transparent;color:#4c6d7d;color:hsl(from var(--primary) h calc(s * 0.32) 39.4)}
.pub-btn.ghost:hover{background:#eef5f8;background:hsl(from var(--primary) h calc(s * 0.54) 95.3)}
.pub-btn.ghost.active{background:#eef5f8;background:hsl(from var(--primary) h calc(s * 0.54) 95.3);color:#0f6b84;color:hsl(from var(--primary) h calc(s * 1.03) 28.8)}
.pub-btn.primary{background:#137b98;background:hsl(from var(--primary) h calc(s * 1.01) 33.5);border-color:#137b98;border-color:hsl(from var(--primary) h calc(s * 1.01) 33.5);color:#fff;font-weight:600}
.pub-btn.primary:hover{background:#0c6a84;background:hsl(from var(--primary) h calc(s * 1.08) 28.2)}
.pub-btn:disabled{opacity:.6;cursor:wait}
.pub-btn svg{width:16px;height:16px}
/* Ponto no botão Salvar quando há alterações não salvas */
.pub-editor.is-dirty .pub-save{position:relative}
.pub-editor.is-dirty .pub-save::after{content:"";position:absolute;top:-3px;right:-3px;width:9px;height:9px;border-radius:50%;background:#f0a640;border:2px solid #fff}

/* ---------- Faixa de opções ---------- */
.pub-ribbon-wrap{background:#fff;border-bottom:1px solid var(--pe-line);box-shadow:0 2px 6px #1f3d4f0a;box-shadow:0 2px 6px hsl(from var(--primary) h calc(s * 0.57) 21.6 / 0.039);position:relative;z-index:5}
.pub-tabs{display:flex;align-items:flex-end;gap:2px;padding:0 16px;border-bottom:1px solid #edf2f5;border-bottom:1px solid hsl(from var(--primary) h calc(s * 0.37) 94.5);background:#f7fafb}
.pub-tab{position:relative;height:36px;padding:0 14px;border:0;background:transparent;font:500 13px/1 inherit;font-family:inherit;color:#5b7685;color:hsl(from var(--primary) h calc(s * 0.24) 43.9);cursor:pointer;border-radius:7px 7px 0 0}
.pub-tab:hover{color:var(--pe-ink);background:#eef4f6;background:hsl(from var(--primary) h calc(s * 0.4) 94.9)}
.pub-tab.active{background:#fff;color:#0f6b84;color:hsl(from var(--primary) h calc(s * 1.03) 28.8);font-weight:600;box-shadow:0 -1px 0 var(--pe-line) inset}
.pub-tab.active::after{content:"";position:absolute;left:12px;right:12px;bottom:0;height:2px;border-radius:2px;background:var(--pe-accent)}
.pub-tab.contextual{color:#9a5a12}
.pub-tab.contextual::before{content:"";position:absolute;left:8px;right:8px;top:4px;height:3px;border-radius:2px;background:#f0b25a}
.pub-tab.contextual.active{color:#8a4f0c}
.pub-tab.contextual.active::after{background:#e39b38}
.pub-ribbon{display:flex;align-items:stretch;gap:0;min-height:96px;padding:8px 12px 4px;overflow-x:auto;scrollbar-width:thin}
.rb-group{display:flex;flex-direction:column;padding:0 12px;border-right:1px solid #e8eef1;border-right:1px solid hsl(from var(--primary) h calc(s * 0.32) 92.7);flex:none}
.rb-group:last-child{border-right:0}
.rb-group.rb-off{display:none}
.rb-body{display:flex;align-items:center;gap:6px;flex:1;flex-wrap:nowrap}
.rb-body:has(> .rb-row){flex-direction:column;align-items:flex-start;justify-content:center;gap:5px}
.rb-caption{display:block;margin-top:4px;text-align:center;font-size:10.5px;color:#8a9ea9;color:hsl(from var(--primary) h calc(s * 0.2) 60.2);letter-spacing:.2px;white-space:nowrap}
.rb-row{display:flex;align-items:center;gap:3px}
.rb-stack{display:flex;flex-direction:column;justify-content:center;gap:2px}
.rb-big,.rb-small{display:inline-flex;align-items:center;border:1px solid transparent;background:transparent;color:#2f5669;color:hsl(from var(--primary) h calc(s * 0.5) 29.8);font:500 12px/1.15 inherit;font-family:inherit;cursor:pointer;border-radius:6px;transition:background .12s,border-color .12s;white-space:nowrap}
.rb-big{flex-direction:column;justify-content:center;gap:5px;min-width:64px;max-width:96px;height:64px;padding:6px 8px;white-space:normal;text-align:center;font-size:11.5px}
.rb-big svg{width:26px;height:26px;stroke-width:1.5;color:#147f9b;color:hsl(from var(--primary) h calc(s * 1.0) 34.3)}
.rb-small{gap:7px;height:26px;padding:0 8px;font-size:12px}
.rb-small svg{width:16px;height:16px;color:#3f7489;color:hsl(from var(--primary) h calc(s * 0.48) 39.2)}
.rb-small.icon-only{width:28px;height:28px;padding:0;justify-content:center}
.rb-mark{font:700 13px/1 Georgia,"Times New Roman",serif;color:#2f5669;color:hsl(from var(--primary) h calc(s * 0.5) 29.8)}
.rb-mark[data-cmd=italic]{font-style:italic}
.rb-mark[data-cmd=underline]{text-decoration:underline}
.rb-mark[data-cmd=strikeThrough]{text-decoration:line-through;font-size:11px}
.rb-mark[data-cmd=subscript],.rb-mark[data-cmd=superscript],.rb-mark[data-cmd=removeFormat]{font:600 11px/1 inherit;font-family:inherit}
.rb-big:hover,.rb-small:hover{background:#eaf4f7;background:hsl(from var(--primary) h calc(s * 0.58) 94.3);border-color:#cfe4eb;border-color:hsl(from var(--primary) h calc(s * 0.53) 86.7)}
.rb-big:active,.rb-small:active{background:#dceef3;background:hsl(from var(--primary) h calc(s * 0.64) 90.8)}
.rb-small.danger,.rb-small.danger svg{color:#b5473f}
.rb-small.danger:hover{background:#fbeeed;border-color:#f0cfcc}
.rb-select{height:28px;min-height:28px;padding:0 4px 0 6px;border:1px solid #d6e3e9;border:1px solid hsl(from var(--primary) h calc(s * 0.39) 87.6);border-radius:6px;background-color:#fff;color:var(--pe-ink);font:13px/1 inherit;font-family:inherit;cursor:pointer;width:auto}
.rb-select:hover{border-color:#b9d5df;border-color:hsl(from var(--primary) h calc(s * 0.48) 80)}
.rb-font{width:150px}
.rb-size{width:64px}
.rb-field{width:190px;margin-bottom:3px}
.rb-color{position:relative;display:inline-flex;align-items:center;justify-content:center;width:30px;height:28px;border-radius:6px;cursor:pointer}
.rb-color:hover{background:#eaf4f7;background:hsl(from var(--primary) h calc(s * 0.58) 94.3)}
.rb-color-mark{font:700 13px/1 Georgia,serif;color:#2f5669;color:hsl(from var(--primary) h calc(s * 0.5) 29.8);border-bottom:4px solid #243c4c;padding:0 3px 1px;line-height:1}
.rb-color input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;padding:0;border:0}
.rb-styles{display:grid;grid-template-columns:repeat(2,minmax(84px,auto));gap:4px}
.rb-style{height:30px;padding:0 10px;border:1px solid #e1eaef;border:1px solid hsl(from var(--primary) h calc(s * 0.4) 91);border-radius:6px;background:#fbfdfe;color:var(--pe-ink);cursor:pointer;text-align:left;font-family:Arial,sans-serif;font-size:12px}
.rb-style:hover{border-color:#9fcbd8;border-color:hsl(from var(--primary) h calc(s * 0.55) 73.5);background:#f0f8fa;background:hsl(from var(--primary) h calc(s * 0.65) 96.1)}
.rb-style-h1{font-size:15px;font-weight:700}
.rb-style-h2{font-size:13.5px;font-weight:700}
.rb-style-h3{font-size:12.5px;font-weight:700;color:#3f6577;color:hsl(from var(--primary) h calc(s * 0.4) 35.7)}
.rb-labeled{display:flex;align-items:center;gap:10px;padding:6px 10px;border:1px solid #e1eaef;border:1px solid hsl(from var(--primary) h calc(s * 0.4) 91);border-radius:8px;background:#fbfdfe}
.rb-labeled>svg{width:26px;height:26px;color:#147f9b;color:hsl(from var(--primary) h calc(s * 1.0) 34.3);stroke-width:1.5}
.rb-labeled>span{display:grid;gap:4px}
.rb-labeled small{font-size:11px;color:var(--pe-muted)}
.rb-check{display:flex;align-items:center;gap:7px;height:24px;font-size:12px;color:#33586b;color:hsl(from var(--primary) h calc(s * 0.46) 31);cursor:pointer;white-space:nowrap}
.rb-check input{width:15px;height:15px;margin:0;accent-color:#137b98;accent-color:hsl(from var(--primary) h calc(s * 1.01) 33.5)}
.rb-range{display:flex;align-items:center;gap:8px;font-size:12px;color:#33586b;color:hsl(from var(--primary) h calc(s * 0.46) 31)}
.rb-range input{width:96px;accent-color:#137b98;accent-color:hsl(from var(--primary) h calc(s * 1.01) 33.5)}

/* ---------- Corpo: folha + painel lateral ---------- */
.pub-body{flex:1;display:grid;grid-template-columns:minmax(0,1fr) 272px;gap:0;align-items:start;min-height:0}
.pub-body.side-hidden{grid-template-columns:minmax(0,1fr)}
.pub-canvas{min-width:0;overflow-x:auto;padding:22px 24px 48px!important;background:transparent!important}
.pub-canvas .word-ruler{width:794px;margin:0 auto 10px;border-radius:4px;background-color:#f8fafb;opacity:1;color:#98a9b2;color:hsl(from var(--primary) h calc(s * 0.19) 64.7)}
.pub-canvas .report-paper{margin:0 auto;flex:none}
.pub-side{position:sticky;top:0;align-self:start;max-height:calc(100vh - 40px);overflow-y:auto;padding:16px 14px 24px;background:#fff;border-left:1px solid var(--pe-line);min-height:calc(100vh - 220px);scrollbar-width:thin}
.pub-panel{border-bottom:1px solid #edf2f5;border-bottom:1px solid hsl(from var(--primary) h calc(s * 0.37) 94.5);padding:4px 0 12px;margin-bottom:6px}
.pub-panel:last-child{border-bottom:0}
.pub-panel>summary{display:flex;align-items:center;justify-content:space-between;padding:8px 2px;font-size:12px;font-weight:650;letter-spacing:.3px;text-transform:uppercase;color:#47697a;color:hsl(from var(--primary) h calc(s * 0.34) 37.8);cursor:pointer;list-style:none}
.pub-panel>summary::-webkit-details-marker{display:none}
.pub-panel>summary::after{content:"";width:7px;height:7px;border-right:1.6px solid #8aa1ad;border-right:1.6px solid hsl(from var(--primary) h calc(s * 0.23) 61);border-bottom:1.6px solid #8aa1ad;border-bottom:1.6px solid hsl(from var(--primary) h calc(s * 0.23) 61);transform:rotate(45deg);margin-right:4px;transition:transform .15s}
.pub-panel:not([open])>summary::after{transform:rotate(-45deg)}
.pub-info{display:grid;grid-template-columns:auto 1fr;gap:6px 12px;margin:4px 2px 0;font-size:12px}
.pub-info dt{color:var(--pe-muted)}
.pub-info dd{margin:0;color:var(--pe-ink);font-weight:500;text-align:right;overflow-wrap:anywhere}
.pub-chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:4px}
.pub-chip-btn{height:28px;padding:0 10px;border:1px solid #d6e6ec;border:1px solid hsl(from var(--primary) h calc(s * 0.48) 88.2);border-radius:999px;background:#f6fafb;color:#2f5669;color:hsl(from var(--primary) h calc(s * 0.5) 29.8);font:500 11.5px/1 inherit;font-family:inherit;cursor:pointer}
.pub-chip-btn:hover{background:var(--pe-accent-soft);border-color:#9fcbd8;border-color:hsl(from var(--primary) h calc(s * 0.55) 73.5);color:#0f6b84;color:hsl(from var(--primary) h calc(s * 1.03) 28.8)}
.pub-hint{margin:8px 2px 0;font-size:11.5px;line-height:1.45;color:var(--pe-muted)}
.objects-pane{display:grid;gap:6px;margin-top:4px}
.objects-pane-item{display:flex;align-items:center;gap:10px;width:100%;padding:8px 10px;border:1px solid #e1eaef;border:1px solid hsl(from var(--primary) h calc(s * 0.4) 91);border-radius:8px;background:#fff;font:inherit;text-align:left;cursor:pointer;color:var(--pe-ink)}
.objects-pane-item svg{width:18px;height:18px;color:#3f7489;color:hsl(from var(--primary) h calc(s * 0.48) 39.2)}
.objects-pane-item span{display:grid;gap:2px;min-width:0}
.objects-pane-item strong{font-size:12px;font-weight:550;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.objects-pane-item small{font-size:11px;color:var(--pe-muted)}
.objects-pane-item:hover,.objects-pane-item.selected{border-color:#7fbfd1;border-color:hsl(from var(--primary) h calc(s * 0.61) 65.9);background:#eef7fa;background:hsl(from var(--primary) h calc(s * 0.71) 95.7)}

/* ---------- Barra de status ---------- */
.pub-status{position:sticky;bottom:0;z-index:5;display:flex;align-items:center;gap:18px;height:30px;padding:0 20px;background:#fff;border-top:1px solid var(--pe-line);font-size:11.5px;color:var(--pe-muted)}
.pub-status-end{margin-left:auto}
.pub-save-state{display:inline-flex;align-items:center;gap:6px;color:#2d8a6e;font-weight:500}
.pub-save-state::before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor}
.pub-editor.is-dirty .pub-save-state{color:var(--pe-warn)}

/* ---------- Folhas A4 ---------- */
.report-paper.paged{background:transparent;border:0;box-shadow:none;overflow:visible;min-height:0}
.report-paper.paged:focus-within{border:0}
.report-paper.paged>.paper-background{display:none}
.paper-sheets{position:absolute;inset:0;pointer-events:none;z-index:0}
.paper-sheet{position:absolute;left:0;width:100%;height:1123px;background:#fff;border:1px solid #d3dce2;border:1px solid hsl(from var(--primary) h calc(s * 0.27) 85.7);box-shadow:0 8px 24px #20394a14,0 1px 3px #20394a12;overflow:hidden}
.paper-sheet .paper-background{position:absolute;inset:0;width:100%;height:100%;object-fit:fill}
.paper-page-number{position:absolute;right:22px;bottom:12px;font-size:10px;color:#9aabb5;color:hsl(from var(--primary) h calc(s * 0.2) 65.7)}
.report-paper.paged .rich-content{background:transparent;position:relative;z-index:400}
.rich-content span.page-gap,.rich-content div.page-gap{display:block;user-select:none;pointer-events:none}
.rich-content tr.page-gap td{border:0!important;padding:0!important;background:transparent!important}
.report-paper.paged .paper-sheet .paper-margin-guide{position:absolute;border:1px dashed #c7dce4;border:1px dashed hsl(from var(--primary) h calc(s * 0.45) 83.7);pointer-events:none}
.report-paper.paged.hide-guides .paper-margin-guide{display:none}
.report-paper.paged.show-grid .paper-sheet{background-image:linear-gradient(#ebf2f5 1px,transparent 1px),linear-gradient(90deg,#ebf2f5 1px,transparent 1px);background-image:linear-gradient(hsl(from var(--primary) h calc(s * 0.43) 94.1) 1px,transparent 1px),linear-gradient(90deg,hsl(from var(--primary) h calc(s * 0.43) 94.1) 1px,transparent 1px);background-size:8px 8px,8px 8px}
@media print{.paper-sheets{display:none!important}.print-document:not(.paged-print) .page-gap{display:none!important}}

/* ---------- Objetos livres ---------- */
.doc-objects{position:absolute;inset:0;pointer-events:none}
.doc-obj{position:absolute;box-sizing:border-box;pointer-events:auto;overflow:hidden}
.doc-obj[data-kind=image] img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;user-select:none}
.doc-obj[data-shape=ellipse]{border-radius:50%!important}
.doc-obj[data-shape=line]{height:0!important;border-left:0!important;border-right:0!important;border-bottom:0!important;background:transparent!important;overflow:visible}
.report-paper .doc-obj[data-shape=line]::before{content:"";position:absolute;left:0;right:0;top:-7px;height:14px}
.doc-obj-text{width:100%;min-height:100%;outline:0;font-family:Arial,sans-serif;font-size:12pt;line-height:1.3;overflow-wrap:anywhere}
.doc-obj-text p{margin:0}
.report-paper .doc-obj[data-kind=text]{outline:1px dashed #b7c9d3;outline:1px dashed hsl(from var(--primary) h calc(s * 0.31) 77.3);outline-offset:-1px}
.report-paper .doc-obj{cursor:move}
.report-paper .doc-obj.editing{z-index:950!important;cursor:text;outline:2px solid #16849c;outline:2px solid hsl(from var(--primary) h calc(s * 0.98) 34.9)}
.doc-selection{position:absolute;box-sizing:border-box;border:1.5px solid #16849c;border:1.5px solid hsl(from var(--primary) h calc(s * 0.98) 34.9);z-index:1000;cursor:move;touch-action:none}
.doc-selection.is-editing{pointer-events:none;border-style:dashed}
.doc-selection.is-editing .doc-handle{display:none}
.doc-handle{position:absolute;width:10px;height:10px;background:#fff;border:1.5px solid #16849c;border:1.5px solid hsl(from var(--primary) h calc(s * 0.98) 34.9);border-radius:2px;box-sizing:border-box}
.h-nw{left:-6px;top:-6px;cursor:nwse-resize}.h-n{left:calc(50% - 5px);top:-6px;cursor:ns-resize}.h-ne{right:-6px;top:-6px;cursor:nesw-resize}
.h-e{right:-6px;top:calc(50% - 5px);cursor:ew-resize}.h-se{right:-6px;bottom:-6px;cursor:nwse-resize}.h-s{left:calc(50% - 5px);bottom:-6px;cursor:ns-resize}
.h-sw{left:-6px;bottom:-6px;cursor:nesw-resize}.h-w{left:-6px;top:calc(50% - 5px);cursor:ew-resize}
.h-rotate{left:calc(50% - 6px);top:-30px;width:12px;height:12px;border-radius:50%;background:#16849c;background:hsl(from var(--primary) h calc(s * 0.98) 34.9);cursor:grab}
.h-rotate::after{content:"";position:absolute;left:4px;top:11px;width:1.5px;height:14px;background:#16849c;background:hsl(from var(--primary) h calc(s * 0.98) 34.9)}
.doc-selection.is-line{border-color:transparent}
.doc-selection.is-line .h-nw,.doc-selection.is-line .h-n,.doc-selection.is-line .h-ne,.doc-selection.is-line .h-se,.doc-selection.is-line .h-s,.doc-selection.is-line .h-sw{display:none}
.doc-selection.is-line .h-e,.doc-selection.is-line .h-w{top:-5px}
.doc-center-guide{position:absolute;top:0;bottom:0;left:396px;width:0;border-left:1px dashed #e5a03a;z-index:999;pointer-events:none}

/* ---------- Tabelas e blocos no texto ---------- */
.doc-table{width:100%;border-collapse:collapse;margin:8px 0}
.doc-table td,.doc-table th{border:1px solid #8fa3ad;border:1px solid hsl(from var(--primary) h calc(s * 0.2) 62);padding:4px 6px;vertical-align:top;min-width:30px}
.rich-content .doc-table.borderless td,.rich-content .doc-table.borderless th{border:1px dashed #dbe5ea;border:1px dashed hsl(from var(--primary) h calc(s * 0.34) 88.8)}
.print-document .doc-table.borderless td,.print-document .doc-table.borderless th{border-color:transparent}
.rich-content hr{border:0;border-top:1px solid #8fa3ad;border-top:1px solid hsl(from var(--primary) h calc(s * 0.2) 62);margin:12px 0}
.rich-content hr.doc-page-break{border-top:2px dashed #e5a03a;margin:16px 0 0;position:relative;overflow:visible}
.report-paper hr.doc-page-break::after{content:"Quebra de página";position:absolute;right:0;top:2px;font-size:10px;color:#b07a2a}

/* ---------- Diálogos pequenos (tabela, salvar como template) ---------- */
.pub-mini-dialog{width:min(380px,calc(100vw - 32px));padding:22px;border:0;border-radius:14px;box-shadow:0 24px 60px #10283a40;color:#20394a;font-family:Inter,"Segoe UI",Arial,sans-serif}
.pub-mini-dialog::backdrop{background:#10283a59}
.pub-mini-dialog h2{margin:0 0 14px;font-size:17px}
.pub-mini-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.pub-mini-grid.single{grid-template-columns:1fr}
.pub-mini-grid label{display:grid;gap:6px;font-size:12px;color:#5b7685;color:hsl(from var(--primary) h calc(s * 0.24) 43.9)}
.pub-mini-grid input,.pub-mini-grid select{height:36px;min-height:36px;padding:0 10px;border:1px solid #d6e3e9;border:1px solid hsl(from var(--primary) h calc(s * 0.39) 87.6);border-radius:7px;font:inherit;font-size:13px;color:#20394a}
.pub-mini-check{display:flex;align-items:center;gap:8px;margin:14px 0 4px;font-size:13px}
.pub-mini-check input{accent-color:#137b98;accent-color:hsl(from var(--primary) h calc(s * 1.01) 33.5)}
.pub-mini-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}

/* ---------- Editor de template em tela cheia ---------- */
.template-fullscreen{width:100vw;max-width:100vw;height:100vh;max-height:100vh;margin:0;padding:0;border:0;background:#e7edf1;background:hsl(from var(--primary) h calc(s * 0.34) 92.5);overflow:auto}
.template-fullscreen::backdrop{background:#10283a80}
.template-fullscreen-body{min-height:100%}
.template-fullscreen .pub-editor{min-height:100vh}

/* ---------- Novo documento: escolha do modelo ---------- */
.doc-chooser{width:min(920px,calc(100vw - 32px));max-height:calc(100vh - 48px);padding:0;border:0;border-radius:16px;box-shadow:0 30px 80px #10283a4d;color:#20394a;font-family:Inter,"Segoe UI",Arial,sans-serif;overflow:hidden;display:flex;flex-direction:column}
.doc-chooser[open]{display:flex}
.doc-chooser::backdrop{background:#10283a66;backdrop-filter:blur(2px)}
.doc-chooser-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:22px 26px 18px;background:linear-gradient(135deg,#eaf6f9,#f7fbfc 60%);background:linear-gradient(135deg,hsl(from var(--primary) h calc(s * 0.72) 94.7),#f7fbfc 60%);border-bottom:1px solid #e1ebef;border-bottom:1px solid hsl(from var(--primary) h calc(s * 0.4) 91)}
.doc-chooser-head h2{margin:0;font-size:20px;letter-spacing:-.3px}
.doc-chooser-head p{margin:5px 0 0;font-size:13px;color:#5f7a88;color:hsl(from var(--primary) h calc(s * 0.23) 45.3)}
.doc-chooser-close{width:34px;height:34px;border:0;border-radius:8px;background:transparent;font-size:24px;line-height:1;color:#6f8592;color:hsl(from var(--primary) h calc(s * 0.18) 50.4);cursor:pointer}
.doc-chooser-close:hover{background:#ffffffaa;color:#20394a}
.doc-chooser-body{padding:20px 26px 26px;overflow-y:auto}
.doc-chooser-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:16px}
.doc-chooser-section{margin-top:16px;border:1px solid #e1ebef;border:1px solid hsl(from var(--primary) h calc(s * 0.4) 91);border-radius:12px;background:#fbfdfe}
.doc-chooser-section>summary{display:flex;align-items:center;gap:10px;padding:14px 16px;cursor:pointer;list-style:none;font-weight:600;font-size:14px}
.doc-chooser-section>summary::-webkit-details-marker{display:none}
.doc-chooser-section>summary::before{content:"";width:8px;height:8px;border-right:2px solid #5f8a9b;border-right:2px solid hsl(from var(--primary) h calc(s * 0.31) 49);border-bottom:2px solid #5f8a9b;border-bottom:2px solid hsl(from var(--primary) h calc(s * 0.31) 49);transform:rotate(-45deg);transition:transform .15s;margin-right:2px}
.doc-chooser-section[open]>summary::before{transform:rotate(45deg)}
.doc-chooser-section>summary small{margin-left:auto;padding:3px 9px;border-radius:999px;background:#e8f3f6;background:hsl(from var(--primary) h calc(s * 0.57) 93.7);color:#2f6f84;color:hsl(from var(--primary) h calc(s * 0.62) 35.1);font-size:11px;font-weight:600}
.doc-chooser-section>summary:hover{background:#f2f8fa;background:hsl(from var(--primary) h calc(s * 0.58) 96.5);border-radius:12px}
.doc-chooser-section>.doc-chooser-grid{padding:4px 16px 18px}
.doc-chooser-section .muted{grid-column:1/-1;margin:0;font-size:12.5px;color:#6f8592;color:hsl(from var(--primary) h calc(s * 0.18) 50.4)}
.doc-chooser-type{grid-column:1/-1;margin:8px 0 -4px;font-size:11px;font-weight:650;letter-spacing:.6px;text-transform:uppercase;color:#7d97a3;color:hsl(from var(--primary) h calc(s * 0.22) 56.5)}
.doc-card{display:flex;flex-direction:column;gap:10px;padding:10px;border:1px solid #e1ebef;border:1px solid hsl(from var(--primary) h calc(s * 0.4) 91);border-radius:12px;background:#fff;font:inherit;text-align:left;cursor:pointer;transition:transform .12s,box-shadow .12s,border-color .12s}
.doc-card:hover,.doc-card:focus-visible{border-color:#7fbfd1;border-color:hsl(from var(--primary) h calc(s * 0.61) 65.9);box-shadow:0 10px 24px #137b981f;box-shadow:0 10px 24px hsl(from var(--primary) h calc(s * 1.01) 33.5 / 0.122);transform:translateY(-2px);outline:0}
.doc-card-info{display:grid;gap:3px;padding:0 2px 2px}
.doc-card-info strong{font-size:12.5px;font-weight:600;line-height:1.3;color:#20394a}
.doc-card-info small{font-size:11px;color:#7d97a3;color:hsl(from var(--primary) h calc(s * 0.22) 56.5)}
.doc-thumb{position:relative;width:100%;aspect-ratio:794/1123;overflow:hidden;border-radius:6px;border:1px solid #e3ebef;border:1px solid hsl(from var(--primary) h calc(s * 0.35) 91.4);background:#fff;box-shadow:0 2px 6px #20394a0f}
.doc-thumb-page{position:absolute;left:0;top:0;width:794px;height:1123px;transform-origin:0 0;transform:scale(var(--thumb-scale,.17));pointer-events:none}
.doc-thumb-page .rich-content{min-height:0!important;outline:0}
.doc-thumb-plus{position:absolute;inset:0;display:grid;place-items:center;font-size:260px;font-weight:200;color:#b9d3dc;color:hsl(from var(--primary) h calc(s * 0.43) 79.4)}

/* ---------- Telas menores ---------- */
@media(max-width:1100px){.pub-body{grid-template-columns:minmax(0,1fr) 240px}}
@media(max-width:820px){
  .pub-header{flex-wrap:wrap;padding:10px 12px}
  .pub-title{flex-basis:100%}
  .pub-actions{justify-content:flex-start}
  .pub-btn span{display:none}
  .pub-btn.primary span{display:inline}
  .pub-body{display:flex;flex-direction:column}
  .pub-side{position:static;max-height:none;min-height:0;width:100%;border-left:0;border-top:1px solid var(--pe-line);order:2}
  .pub-canvas{width:100%;padding:14px 10px 30px!important}
  .pub-status span:nth-child(n+3){display:none}
}

/* ---------- Impressão fiel ao editor (folha a folha) ---------- */
.print-sheet,.print-stage{display:none}
@media print{
  body>.print-document.paged-print{padding:0!important;min-height:0!important;position:static!important;font:inherit;color:#222;background:white}
  .paged-print .print-sheet{display:block;position:relative;width:210mm;height:297mm;overflow:hidden;break-after:page;page-break-after:always}
  .paged-print .print-sheet:last-child{break-after:auto;page-break-after:auto}
  .paged-print .print-sheet>.paper-background{position:absolute;inset:0;width:100%;height:100%;object-fit:fill;z-index:0}
  .paged-print .print-stage{display:block;position:absolute;left:0;width:794px}
  .paged-print .print-stage>.rich-content{position:relative;background:transparent;min-height:0}
  body>.print-document.paged-print .rich-content p{white-space:normal;line-height:inherit;margin:10px 0}
  body>.print-document.paged-print .doc-obj-text p{white-space:normal;line-height:inherit;margin:0}
  body>.print-document.paged-print .rich-content h1,body>.print-document.paged-print .rich-content h2,body>.print-document.paged-print .rich-content h3{text-align:start;line-height:1.3;margin:18px 0}
  body>.print-document.paged-print .rich-content h1{font-size:26pt}
  body>.print-document.paged-print .rich-content h2{font-size:20pt}
  body>.print-document.paged-print .rich-content h3{font-size:16pt}
  body>.print-document.paged-print li{line-height:inherit}
  .paged-print .doc-obj[data-kind=text]{outline:0}
  .paged-print hr.doc-page-break{visibility:hidden}
  .paged-print *{print-color-adjust:exact;-webkit-print-color-adjust:exact}
}
.rb-color.with-label{width:auto;gap:6px;padding:0 8px 0 6px}
.rb-color-label{font-size:12px;color:#2f5669;color:hsl(from var(--primary) h calc(s * 0.5) 29.8);white-space:nowrap}
.rb-small.no-fill{position:relative}
.rb-small.no-fill::after{content:"";position:absolute;left:7px;right:7px;top:50%;height:1.6px;background:#b5473f;transform:rotate(-35deg)}
.doc-chooser-close:focus:not(:focus-visible){outline:0;box-shadow:none}

/* ---------- Configurações › Templates ---------- */
.tpl-settings{padding:24px 26px!important;border-radius:16px!important}
.tpl-head{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;flex-wrap:wrap}
.tpl-head h2{margin:0;font-size:19px;letter-spacing:-.3px}
.tpl-sub{margin:6px 0 0;max-width:620px;font-size:13px;line-height:1.55;color:#6f8592}
.tpl-create{border-radius:9px!important;min-height:38px;padding:8px 16px!important}
.tpl-fields{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin:16px 0 4px;padding:10px 12px;border-radius:10px;background:color-mix(in srgb,var(--primary) 6%,#fff);border:1px solid color-mix(in srgb,var(--primary) 14%,#fff)}
.tpl-fields-label{font-size:12px;font-weight:600;color:color-mix(in srgb,var(--primary) 80%,#000);margin-right:4px}
.tpl-fields code{padding:3px 8px;border-radius:6px;background:#fff;border:1px solid color-mix(in srgb,var(--primary) 18%,#fff);font:500 11.5px/1.2 ui-monospace,Consolas,monospace;color:#33586b}
.tpl-fields-more{font-size:11.5px;color:#8a9ea9}
.tpl-filter{display:flex;flex-wrap:wrap;gap:6px;margin:18px 0 0;padding:4px;width:fit-content;max-width:100%;border-radius:999px;background:#f2f6f8}
.tpl-chip{display:inline-flex;align-items:center;gap:7px;height:32px;padding:0 14px;border:0;border-radius:999px;background:transparent;font:500 12.5px/1 inherit;font-family:inherit;color:#4c6d7d;cursor:pointer}
.tpl-chip small{padding:2px 7px;border-radius:999px;background:#e3ebef;font-size:11px;font-weight:600;color:#5f7a88}
.tpl-chip:hover{background:#e8eff2}
.tpl-chip.active{background:#fff;color:color-mix(in srgb,var(--primary) 85%,#000);font-weight:600;box-shadow:0 1px 3px #1f3d4f1f}
.tpl-chip.active small{background:color-mix(in srgb,var(--primary) 14%,#fff);color:color-mix(in srgb,var(--primary) 85%,#000)}
.tpl-section{margin-top:22px}
.tpl-section-head,.tpl-ready>summary{display:flex;align-items:baseline;gap:10px;margin-bottom:12px}
.tpl-section-head h3,.tpl-ready>summary span{margin:0;font-size:14.5px;font-weight:650;color:#26475a}
.tpl-section-head small,.tpl-ready>summary small{font-size:12px;color:#8a9ea9}
.tpl-ready{padding-top:18px;border-top:1px solid #edf2f5}
.tpl-ready>summary{cursor:pointer;list-style:none;padding:4px 0}
.tpl-ready>summary::-webkit-details-marker{display:none}
.tpl-ready>summary::before{content:"";align-self:center;width:8px;height:8px;border-right:2px solid #6f8f9d;border-bottom:2px solid #6f8f9d;transform:rotate(-45deg);transition:transform .15s;margin-right:2px}
.tpl-ready[open]>summary::before{transform:rotate(45deg)}
.tpl-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(184px,1fr));gap:16px}
.tpl-card{display:flex;flex-direction:column;border:1px solid #e3ebef;border-radius:14px;background:#fff;overflow:hidden;transition:box-shadow .15s,border-color .15s,transform .15s}
.tpl-card:hover{border-color:color-mix(in srgb,var(--primary) 35%,#fff);box-shadow:0 12px 28px #1f3d4f14;transform:translateY(-2px)}
.tpl-preview{position:relative;display:block;padding:14px 14px 0;border:0;background:linear-gradient(180deg,#f2f6f8,#e9eff2);cursor:pointer}
.tpl-preview .doc-thumb{border-radius:6px 6px 0 0;border-bottom:0;box-shadow:0 4px 14px #1f3d4f1a}
.tpl-preview-hint{position:absolute;left:50%;top:46%;transform:translate(-50%,-50%) scale(.96);padding:7px 14px;border-radius:999px;background:var(--primary);color:#fff;font-size:12px;font-weight:600;opacity:0;transition:opacity .15s,transform .15s;pointer-events:none;white-space:nowrap}
.tpl-card:hover .tpl-preview-hint,.tpl-preview:focus-visible .tpl-preview-hint{opacity:1;transform:translate(-50%,-50%) scale(1)}
.tpl-info{display:grid;gap:6px;padding:12px 14px 4px;border-top:1px solid #edf2f5}
.tpl-info strong{font-size:13px;font-weight:600;line-height:1.35;color:#20394a;overflow-wrap:anywhere}
.tpl-type{justify-self:start;padding:3px 9px;border-radius:999px;font-size:10.5px;font-weight:600;letter-spacing:.2px;background:color-mix(in srgb,var(--primary) 11%,#fff);color:color-mix(in srgb,var(--primary) 85%,#000)}
.tpl-type-atestado{background:#fdf1e3;color:#9a5a12}
.tpl-type-declaracao{background:#eef0fb;color:#4b4f9a}
.tpl-type-ficha{background:#eaf6f1;color:#2b7a5b}
.tpl-type-encaminhamento{background:#fbeef3;color:#9a3f62}
.tpl-actions{display:flex;align-items:center;gap:4px;margin-top:auto;padding:8px 10px 12px}
.tpl-edit{margin-left:auto;min-height:30px!important;padding:4px 12px!important;border-radius:8px!important;font-size:12px!important}
.tpl-actions .tpl-edit:only-child{margin-left:0;width:100%;justify-content:center}
.tpl-icon{display:grid;place-items:center;width:30px;height:30px;padding:0;border:1px solid transparent;border-radius:8px;background:transparent;color:#5f7a88;cursor:pointer}
.tpl-icon svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.tpl-icon:hover:not(:disabled){background:#eef4f6;color:#20394a}
.tpl-icon:disabled{opacity:.3;cursor:default}
.tpl-icon.danger:hover{background:#fcefee;color:#b5473f}
.tpl-new{align-items:center;justify-content:center;gap:6px;min-height:260px;padding:20px;border:1.5px dashed color-mix(in srgb,var(--primary) 30%,#d6e2e7);background:color-mix(in srgb,var(--primary) 3%,#fff);font:inherit;text-align:center;cursor:pointer}
.tpl-new:hover{background:color-mix(in srgb,var(--primary) 7%,#fff);transform:none}
.tpl-new-plus{display:grid;place-items:center;width:46px;height:46px;margin-bottom:6px;border-radius:50%;background:color-mix(in srgb,var(--primary) 12%,#fff);color:var(--primary);font-size:26px;font-weight:300}
.tpl-new strong{font-size:13.5px;color:#26475a}
.tpl-new small{font-size:12px;color:#8a9ea9}
.tpl-status{margin:14px 0 0;font-size:12.5px;color:#2d8a6e}
.tpl-status:empty{display:none}
@media(max-width:620px){.tpl-settings{padding:18px 16px!important}.tpl-grid{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px}.tpl-filter{border-radius:12px}}
/* Miniatura mostra a parte de cima da folha, onde fica o conteúdo, com o texto maior. */
.tpl-preview .doc-thumb{aspect-ratio:794/700}
.tpl-preview{padding:12px 12px 0}
.tpl-new{min-height:220px}

/* Caixas de marcar do documento (☐/☒): clicáveis no editor, iguais na impressão e no PDF. */
.doc-check{cursor:pointer;user-select:none;-webkit-user-select:none;font-family:"Segoe UI Symbol","Noto Sans Symbols 2","DejaVu Sans",sans-serif;font-size:1.15em;line-height:1;padding:0 .08em;border-radius:3px}
.pub-editor .doc-check:hover{background:rgba(20,126,151,.14)}
@media print{.doc-check{cursor:auto}}
/* Área de toque maior que o símbolo (a folha encolhe no celular); invisível, não sai na impressão nem no PDF. */
.pub-editor .doc-check{position:relative}
.pub-editor .doc-check::after{content:"";position:absolute;inset:-6px -4px}
@media (max-width:700px){.pub-editor .doc-check::after{inset:-18px -14px}}

/* Biblioteca de modelos em lista */
.tpl-settings .tpl-fields{display:block}.tpl-fields>summary{cursor:pointer}.tpl-fields[open]>summary{margin-bottom:8px}
.tpl-library-tabs{display:flex;gap:8px;margin:18px 0 12px;flex-wrap:wrap}.tpl-search{box-sizing:border-box;width:100%;max-width:100%;margin:0 0 10px;padding:10px 12px;border:1px solid var(--line,#d6e2e7);border-radius:9px;font:inherit}
.tpl-settings .tpl-grid{display:flex;flex-direction:column;gap:4px}.tpl-settings .tpl-list-row{display:flex;flex-direction:row;align-items:center;gap:12px;padding:8px 12px;border-radius:9px;overflow:visible;min-height:58px}.tpl-settings .tpl-list-row:hover{transform:none;box-shadow:none;background:color-mix(in srgb,var(--primary) 5%,white)}
.tpl-settings .tpl-list-row .tpl-preview{position:static;display:grid;place-items:center;padding:0;width:38px;height:38px;flex:none;border:0;border-radius:9px;background:color-mix(in srgb,var(--primary) 12%,white);color:var(--primary);font-size:20px;cursor:pointer}.tpl-settings .tpl-list-row .tpl-info{flex:1;display:flex;flex-direction:column;gap:3px;padding:0}.tpl-row-type{font-size:12px;color:#708694}.tpl-more{font-size:20px;line-height:1}.tpl-settings [hidden]{display:none!important}
.tpl-quick-preview{margin:auto 0 auto auto;width:min(520px,95vw);height:min(100vh,850px);border:0;border-radius:14px;padding:20px;box-shadow:0 12px 40px #142b3c44}.tpl-quick-preview header{display:flex;align-items:center;justify-content:space-between;gap:12px}.tpl-quick-preview::backdrop{background:#102a3b55}.tpl-quick-paper{max-width:390px;margin:20px auto;overflow:auto}.tpl-quick-paper .doc-thumb{width:100%}

.tpl-row-date{color:#708694;font-size:12px;white-space:nowrap}@media(max-width:620px){.tpl-row-date{display:none}}

.tpl-head-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}.tpl-restore-all{font-size:12px!important}

.template-privacy-review{display:flex!important;align-items:flex-start;gap:8px;font-size:12px;line-height:1.4}.template-privacy-review input{flex:none;width:auto!important;min-height:0!important;margin:2px 0 0}

.tpl-quick-preview{width:min(650px,95vw)}.tpl-quick-paper{max-width:100%}
