/* Gerador de Relatórios (view do Hub) — tudo escopado em #report-builder-view / .rb-*
   para não colidir com Tailwind/CSS global. NÃO é o estilo do relatório (esse vem de /report-builder/model/). */
#report-builder-view { padding: 0; }

.rb-editor {
  --rb-bg: #f4f5f2; --rb-panel: #fff; --rb-line: #e2e4df; --rb-ink: #14161a; --rb-ink-2: #5b6069;
  --rb-lime: #ccff00; --rb-lime-ink: #0a0a0a; --rb-danger: #b23a3a;
  /* altura exata medida via JS (fitHeight) para caber sem scroll geral; fallback antes do JS */
  display: flex; flex-direction: column; height: var(--rb-h, calc(100vh - 120px)); position: relative;
  font: 13px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--rb-ink);
  background: var(--rb-bg); border: 1px solid var(--rb-line); border-radius: 10px; overflow: hidden;
}

/* Overlay de importação de copy (upload → geração) */
.rb-import { position: absolute; inset: 44px 0 0 0; background: rgba(20,22,26,.55);
  display: none; align-items: center; justify-content: center; padding: 24px; z-index: 5; }
.rb-import-card { background: #fff; border: 1px solid var(--rb-line); border-radius: 12px;
  padding: 24px; width: 100%; max-width: 480px; box-shadow: 0 12px 48px rgba(0,0,0,.25); }
.rb-import-card h2 { margin: 0 0 6px; font-size: 17px; }
.rb-import-card > p { margin: 0 0 16px; color: var(--rb-ink-2); font-size: 12.5px; }
.rb-drop { display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border: 1.5px dashed var(--rb-line); border-radius: 8px; padding: 22px; color: var(--rb-ink-2);
  background: #fafbf8; margin-bottom: 14px; }
.rb-drop:hover { border-color: var(--rb-lime); background: #fcfef2; }
.rb-drop i { font-size: 18px; }
.rb-import-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rb-import-msg { min-height: 18px; font-size: 12px; margin: 8px 0 0; color: var(--rb-ink-2); }
.rb-import-msg.err { color: var(--rb-danger); }
.rb-import-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.rb-btn.ghost.dark { color: var(--rb-ink-2); border-color: var(--rb-line); }
.rb-btn.ghost.dark:hover { background: #f0f2ed; }

/* Overlay "Meus relatórios" (lista de relatórios salvos) */
.rb-reports-card { max-width: 560px; }
.rb-reports-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rb-reports-head h2 { margin: 0; }
.rb-reports-list { max-height: 52vh; overflow: auto; margin: 6px 0 2px; display: flex; flex-direction: column; gap: 6px; }
.rb-reports-empty { padding: 20px 4px; color: var(--rb-ink-2); font-size: 12.5px; text-align: center; }
.rb-reports-empty.err { color: var(--rb-danger); }
.rb-report-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--rb-line); border-radius: 8px; background: #fafbf8; }
.rb-report-row.current { border-color: var(--rb-lime); background: #fcfef2; }
.rb-report-row:hover { border-color: #cdd2c6; }
.rb-report-info { flex: 1 1 auto; min-width: 0; cursor: pointer; }
.rb-report-title { font-size: 13px; font-weight: 600; color: var(--rb-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-report-sub { font-size: 11px; color: var(--rb-ink-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-report-acts { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.rb-report-acts .rb-btn { padding: 5px 10px; }

.rb-topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #101216; color: #fff; flex: 0 0 auto; }
.rb-title { font-weight: 600; }
.rb-title .rb-tag { font-size: 11px; color: #9aa0a6; margin-left: 8px; font-weight: 400; }
.rb-actions { display: flex; gap: 8px; align-items: center; }
.rb-btn { border: 1px solid transparent; border-radius: 6px; padding: 7px 12px; font-size: 12px;
  cursor: pointer; font-weight: 500; }
.rb-btn.ghost { background: transparent; color: #e6e8ea; border-color: #363a40; }
.rb-btn.ghost:hover { background: #1b1e23; }
.rb-btn.primary { background: var(--rb-lime); color: var(--rb-lime-ink); }
.rb-btn.primary:hover { filter: brightness(.95); }

.rb-workspace { display: grid; grid-template-columns: 400px 1fr; grid-template-rows: minmax(0, 1fr);
  flex: 1 1 auto; min-height: 0; }
/* min-height:0 permite que cada painel role por dentro em vez de esticar o grid */
.rb-left { min-height: 0; overflow-y: auto; padding: 12px; border-right: 1px solid var(--rb-line); }
.rb-right { min-height: 0; background: #d9dcd6; overflow: auto;
  display: flex; justify-content: center; align-items: flex-start; padding: 16px; }
/* altura definida por JS (fitPreviewHeight) = altura do conteúdo → single scroll na coluna */
.rb-preview { width: 210mm; height: 297mm; flex: none; display: block; border: none; background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,.14); }

.rb-panel { background: var(--rb-panel); border: 1px solid var(--rb-line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.rb-panel h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--rb-ink-2); }
/* Seção = página: card com barra de cabeçalho escura + corpo, p/ hierarquia perceptível */
.rb-section { padding: 0; overflow: hidden; border-left: 3px solid var(--rb-lime);
  margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.rb-section-head { display: flex; gap: 8px; align-items: center; background: #101216; padding: 7px 10px; }
#report-builder-view .rb-editor .rb-section-head .rb-sec-num {
  width: 40px; flex: none; text-align: center; font-weight: 700; padding: 4px;
  background: var(--rb-lime); color: var(--rb-lime-ink); border: none; border-radius: 4px; }
.rb-sec-title { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; color: #e6e8ea;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-section-head .rb-mini.danger { color: #ff9a9a; border-color: transparent; background: transparent; }
.rb-section-head .rb-mini.danger:hover { background: rgba(255,255,255,.08); }
.rb-section-body { padding: 12px; }

/* Rótulos de grupo no painel (Páginas do relatório / Encerramento) */
.rb-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  color: var(--rb-ink-2); margin: 14px 2px 8px; padding-top: 10px; border-top: 1px solid var(--rb-line); }

.rb-f { display: block; margin-bottom: 8px; }
.rb-f-lbl { display: block; font-size: 11px; color: var(--rb-ink-2); margin-bottom: 3px; }
/* dois campos curtos lado a lado (economiza espaço vertical) */
.rb-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.rb-row2 > .rb-f { min-width: 0; }
#report-builder-view .rb-editor input,
#report-builder-view .rb-editor textarea,
#report-builder-view .rb-editor select {
  width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--rb-line);
  border-radius: 6px; background: #fff; color: var(--rb-ink); }
#report-builder-view .rb-editor textarea { resize: vertical; min-height: 34px; }
#report-builder-view .rb-editor input:focus,
#report-builder-view .rb-editor textarea:focus,
#report-builder-view .rb-editor select:focus { outline: 2px solid var(--rb-lime); outline-offset: -1px; border-color: transparent; }

.rb-blocks { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.rb-block-card { border: 1px solid var(--rb-line); border-radius: 6px; background: #fbfcfa; }
.rb-block-card.dragging { opacity: .5; }
.rb-block-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-bottom: 1px solid var(--rb-line); background: #f2f4ef; border-radius: 6px 6px 0 0; }
.rb-block-head .rb-drag { cursor: grab; color: var(--rb-ink-2); user-select: none; }
.rb-type-sel { flex: 1; }
.rb-block-body { padding: 8px; }

.rb-mini { font-size: 11px; padding: 4px 8px; border: 1px solid var(--rb-line); border-radius: 5px;
  background: #fff; cursor: pointer; color: var(--rb-ink-2); width: auto; }
.rb-mini:hover { background: #f0f2ed; }
.rb-mini.add { color: var(--rb-ink); border-style: dashed; }
.rb-mini.add.wide { width: 100%; margin: 4px 0 12px; padding: 8px; }
.rb-mini.danger { color: var(--rb-danger); border-color: transparent; }
.rb-mini.danger:hover { background: #fbeaea; }
.rb-add-block { border-style: dashed; color: var(--rb-ink-2); }
.rb-sub-list { display: flex; flex-direction: column; gap: 6px; }
.rb-sub-row { display: flex; gap: 6px; align-items: flex-start; }
.rb-sub-row input, .rb-sub-row textarea { flex: 1; }
.rb-obj-row { border: 1px solid var(--rb-line); border-radius: 6px; padding: 8px; background: #fff; }
.rb-json { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; min-height: 160px; }
.rb-json-status { font-size: 11px; margin-top: 4px; }
.rb-json-status.ok { color: #2e7d32; }
.rb-json-status.err { color: var(--rb-danger); }

@media (max-width: 1024px) {
  .rb-workspace { grid-template-columns: 1fr; }
  .rb-right { display: none; }
}
