/* Tipos de tarefa e campos personalizados (gaveta da tarefa, biblioteca e montador) */

/* ---- campos na gaveta ---- */
.task-fields-wrap { margin: 0.25rem 0 0.25rem 2.1rem; }
.tf-card { border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-surface); padding: 0.7rem 0.85rem 0.85rem; }
.tf-head { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 0.55rem; }
.tf-head b { color: var(--text-primary); font-size: 0.9rem; }
.tf-pill { font-size: 0.68rem; font-weight: 700; padding: 0.05rem 0.5rem; border-radius: 999px; background: rgba(245, 158, 11, 0.14); color: #b45309; }
.tf-list { display: flex; flex-direction: column; gap: 0.7rem; }
.tf-field { display: flex; flex-direction: column; gap: 0.25rem; border-radius: 8px; transition: background-color .2s, box-shadow .2s; }
.tf-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.tf-req { color: #dc2626; font-style: normal; margin-left: 2px; }
.tf-hint { font-size: 0.74rem; color: var(--text-muted); }
.tf-err { font-size: 0.74rem; color: #dc2626; min-height: 0; }
.tf-err:empty { display: none; }
.tf-empty { color: var(--text-muted); font-size: 0.85rem; padding: 0.3rem 0; }
.tf-input { width: 100%; font-family: inherit; font-size: 0.9rem; color: var(--text-primary); background: var(--bg-surface-elevated); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.4rem 0.6rem; outline: none; box-sizing: border-box; }
.tf-input:focus { border-color: var(--accent-primary); background: var(--bg-surface); }
.tf-input:disabled { opacity: 0.75; cursor: default; }
textarea.tf-input { resize: none; overflow: hidden; line-height: 1.4; }
.tf-money { display: flex; align-items: center; gap: 0.4rem; }
.tf-money > span { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); }
.tf-seg { display: inline-flex; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; align-self: flex-start; }
.tf-seg button { font-family: inherit; font-size: 0.85rem; font-weight: 600; padding: 0.35rem 1.1rem; border: 0; background: var(--bg-surface-elevated); color: var(--text-secondary); cursor: pointer; }
.tf-seg button + button { border-left: 1px solid var(--border-color); }
.tf-seg button.on { background: var(--accent-primary); color: #fff; }
.tf-linkrow { display: flex; gap: 0.4rem; align-items: center; }
.tf-open { display: inline-flex; padding: 0.4rem; border-radius: 8px; color: var(--accent-primary); }
.tf-files { display: flex; flex-direction: column; gap: 0.4rem; }
.tf-file { position: relative; }
.tf-file-x { position: absolute; top: 4px; right: 4px; z-index: 2; display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: rgba(15, 23, 42, 0.55); color: #fff; cursor: pointer; opacity: 0; transition: opacity .15s; }
.tf-file:hover .tf-file-x, .tf-file-x:focus-visible { opacity: 1; }
.tf-addrow { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tf-addbtn { display: inline-flex; align-items: center; gap: 0.35rem; font-family: inherit; font-size: 0.82rem; font-weight: 600; padding: 0.4rem 0.8rem; border-radius: 8px; border: 1px dashed var(--border-color); background: transparent; color: var(--text-secondary); cursor: pointer; }
.tf-addbtn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.tf-hidden { display: none; }
.tf-field.tf-saved { background: rgba(16, 185, 129, 0.1); }
.tf-field.tf-busy { opacity: 0.6; pointer-events: none; }
.tf-field.is-missing { background: rgba(220, 38, 38, 0.07); box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.35); padding: 0.35rem; }
.tf-card .file-card { margin: 0; }

/* ---- biblioteca e montador (janelas) ---- */
.tipos-overlay { position: fixed; inset: 0; z-index: 2200; background: rgba(15, 23, 42, 0.5); display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.tipos-overlay.is-builder { z-index: 2500; }
.tipos-dialog { background: var(--bg-surface); color: var(--text-primary); border-radius: 16px; width: min(760px, 100%); max-height: calc(100vh - 3rem); display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35); overflow: hidden; }
.tipos-dialog.is-wide { width: min(1080px, 100%); }
.tipos-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.1rem 1.25rem 0.8rem; border-bottom: 1px solid var(--border-subtle); }
.tipos-head h2 { margin: 0; font-size: 1.15rem; }
.tipos-head p { margin: 0.2rem 0 0; font-size: 0.82rem; color: var(--text-secondary); max-width: 52ch; }
.tipos-head-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.tipos-x { display: inline-flex; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; padding: 0.3rem; border-radius: 8px; }
.tipos-x:hover { background: var(--bg-surface-elevated); color: var(--text-primary); }
.tipos-tabs { display: flex; gap: 0.25rem; padding: 0.6rem 1.25rem 0; border-bottom: 1px solid var(--border-subtle); overflow-x: auto; }
.tipos-tab { display: inline-flex; align-items: center; gap: 0.4rem; font-family: inherit; font-size: 0.85rem; font-weight: 600; padding: 0.45rem 0.8rem; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.tipos-tab.active { color: var(--text-primary); border-bottom-color: var(--accent-primary); }
.tipos-count { min-width: 1.2rem; text-align: center; font-size: 0.7rem; font-weight: 700; padding: 0 0.35rem; border-radius: 999px; background: var(--bg-surface-elevated); color: var(--text-secondary); }
.tipos-count.is-alert { background: #dc2626; color: #fff; }
.tipos-body { padding: 1rem 1.25rem 1.25rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.7rem; }
.tipos-loading, .tipos-empty { padding: 2rem 0; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
.tipos-row { display: flex; gap: 1rem; justify-content: space-between; border: 1px solid var(--border-color); border-radius: 12px; padding: 0.8rem 0.95rem; background: var(--bg-surface); }
.tipos-row-main { min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.tipos-row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.tipos-row-title b { font-size: 0.95rem; }
.tipos-row-sub { font-size: 0.76rem; color: var(--text-muted); }
.tipos-row-desc { font-size: 0.82rem; color: var(--text-secondary); }
.tipos-row-note { font-size: 0.78rem; color: #b45309; background: rgba(245, 158, 11, 0.1); border-radius: 8px; padding: 0.3rem 0.5rem; display: flex; gap: 0.35rem; align-items: flex-start; }
.tipos-row-fields { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.15rem; }
.tipos-chip { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--bg-surface-elevated); color: var(--text-secondary); }
.tipos-row-acts { display: flex; flex-direction: column; gap: 0.35rem; align-items: stretch; flex-shrink: 0; min-width: 8.5rem; }
.tipos-row-acts .btn.is-danger { color: #b91c1c; border-color: rgba(220, 38, 38, 0.4); }
.tipos-pill { font-size: 0.68rem; font-weight: 700; padding: 0.08rem 0.5rem; border-radius: 999px; background: var(--bg-surface-elevated); color: var(--text-secondary); }
.tipos-pill.is-ok { background: rgba(16, 185, 129, 0.14); color: #047857; }
.tipos-pill.is-wait { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.tipos-pill.is-bad { background: rgba(220, 38, 38, 0.12); color: #b91c1c; }
.tipos-pill.is-info { background: rgba(99, 102, 241, 0.13); color: #4338ca; }
.tipos-foot { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; padding: 0.8rem 1.25rem; border-top: 1px solid var(--border-subtle); }
.tipos-foot-note { margin-right: auto; font-size: 0.82rem; color: var(--text-muted); }
.tipos-foot-note.is-bad { color: #dc2626; font-weight: 600; }

.tb-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.9fr); gap: 1.25rem; padding: 1rem 1.25rem; overflow-y: auto; min-height: 0; }
.tb-form { display: flex; flex-direction: column; gap: 0.7rem; min-width: 0; }
.tb-lbl { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.tb-lbl input, .tb-lbl select, .tb-field-more input[type="text"], .tb-field-more select, .tb-field-more textarea { font-family: inherit; font-size: 0.9rem; font-weight: 400; color: var(--text-primary); background: var(--bg-surface-elevated); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.45rem 0.6rem; outline: none; box-sizing: border-box; width: 100%; }
.tb-lbl input:focus, .tb-field-more input:focus, .tb-field-more select:focus, .tb-field-more textarea:focus { border-color: var(--accent-primary); background: var(--bg-surface); }
.tb-fields-title { font-size: 0.85rem; font-weight: 700; margin-top: 0.3rem; }
.tb-fields-title small { font-weight: 400; color: var(--text-muted); }
.tb-fields { display: flex; flex-direction: column; gap: 0.45rem; }
.tb-field { border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-surface); position: relative; }
.tb-field.is-drag { opacity: 0.45; }
.tb-field.drop-above::before, .tb-field.drop-below::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; border-radius: 2px; background: var(--accent-primary); }
.tb-field.drop-above::before { top: -3px; }
.tb-field.drop-below::after { bottom: -3px; }
.tb-field-top { display: flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.5rem; }
.tb-grip { display: inline-flex; color: var(--text-muted); cursor: grab; }
.tb-ftype { display: inline-flex; color: var(--accent-primary); }
.tb-flabel { flex: 1; min-width: 0; font-family: inherit; font-size: 0.9rem; color: var(--text-primary); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 0.3rem 0.4rem; outline: none; }
.tb-flabel:hover, .tb-flabel:focus { background: var(--bg-surface-elevated); border-color: var(--border-color); }
.tb-req { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.76rem; font-weight: 600; color: var(--text-secondary); cursor: pointer; white-space: nowrap; }
.tb-arrows { display: inline-flex; flex-direction: column; }
.tb-arrows button, .tb-more, .tb-del { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; border-radius: 6px; padding: 0.15rem 0.3rem; }
.tb-arrows button:hover:not(:disabled), .tb-more:hover { color: var(--text-primary); background: var(--bg-surface-elevated); }
.tb-arrows button:disabled { opacity: 0.25; cursor: default; }
.tb-del:hover { color: #dc2626; background: rgba(220, 38, 38, 0.1); }
.tb-field.is-open .tb-more { color: var(--accent-primary); }
.tb-field-more { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.2rem 0.7rem 0.7rem 2.6rem; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.tb-field-more label { display: flex; flex-direction: column; gap: 0.25rem; }
.tb-field-more .tb-check { flex-direction: row; align-items: center; gap: 0.45rem; font-weight: 500; }
.tb-add { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--text-muted); }
.tb-addtype { display: inline-flex; align-items: center; gap: 0.3rem; font-family: inherit; font-size: 0.78rem; font-weight: 600; padding: 0.3rem 0.65rem; border-radius: 999px; border: 1px dashed var(--border-color); background: transparent; color: var(--text-secondary); cursor: pointer; }
.tb-addtype:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.tb-preview { min-width: 0; background: var(--bg-surface-elevated); border-radius: 12px; padding: 0.8rem; align-self: start; position: sticky; top: 0; }
.tb-preview-title { display: flex; gap: 0.4rem; align-items: center; font-size: 0.78rem; font-weight: 700; color: var(--text-muted); margin-bottom: 0.5rem; }
.tb-preview .tf-addbtn { pointer-events: none; opacity: 0.6; }

@media (max-width: 800px) {
  .task-fields-wrap { margin-left: 0; }
  .tipos-overlay { padding: 0; align-items: stretch; }
  .tipos-dialog, .tipos-dialog.is-wide { width: 100%; max-height: 100%; height: 100%; border-radius: 0; }
  .tipos-head { padding-top: calc(0.9rem + var(--m-top, 0px)); }
  .tipos-row { flex-direction: column; }
  .tipos-row-acts { flex-direction: row; flex-wrap: wrap; min-width: 0; }
  .tb-grid { grid-template-columns: 1fr; padding: 0.8rem; }
  .tb-preview { position: static; order: 2; }
  .tb-field-top { flex-wrap: wrap; }
  .tb-flabel { flex-basis: 55%; }
  .tb-grip { display: none; }
  .tb-field-more { padding-left: 0.7rem; }
  .tipos-foot { flex-wrap: wrap; padding-bottom: calc(0.8rem + var(--m-safe, 0px)); }
  .tipos-foot-note { flex: 1 0 100%; }
  .tf-file-x { opacity: 1; }
}

.tb-field-opts { padding: 0 0.7rem 0.6rem 2.6rem; }
.tb-field-opts label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.tb-field-opts small { font-weight: 400; color: var(--text-muted); }
.tb-field-opts textarea { width: 100%; box-sizing: border-box; font-family: inherit; font-size: 0.9rem; font-weight: 400; color: var(--text-primary); background: var(--bg-surface-elevated); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.45rem 0.6rem; outline: none; resize: vertical; }
.tb-field-opts textarea:focus { border-color: var(--accent-primary); background: var(--bg-surface); }
@media (max-width: 800px) { .tb-field-opts { padding-left: 0.7rem; } }

/* tamanhos: valor, número, data e horário não precisam ocupar a linha toda */
.tf-money { max-width: 14rem; }
.tf-input.tf-narrow { max-width: 14rem; }
.tf-opts { display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-start; }
.tf-opt { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text-primary); cursor: pointer; }
.tf-opt input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent-primary); }
.tf-clear { font-family: inherit; font-size: 0.76rem; font-weight: 600; color: var(--text-muted); background: none; border: 0; padding: 0.1rem 0; cursor: pointer; text-decoration: underline; }
.tf-clear:hover { color: var(--text-primary); }

.tb-lbl-hint { font-weight: 400; color: var(--text-muted); font-size: 0.74rem; }
.task-modal-prop-row.is-locked#btn-modal-open-projectpicker { cursor: not-allowed; }
.qa-chip.is-locked { cursor: not-allowed; opacity: 0.85; }

/* ---- quadros: grupos de campos com colunas ---- */
.tf-blocks { display: flex; flex-direction: column; gap: 0.9rem; }
.tf-block { --cols: 1; border-radius: 10px; }
.tf-block.has-head { border: 1px solid var(--border-subtle); padding: 0.55rem 0.75rem 0.75rem; background: var(--bg-surface); }
.tf-block-head { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0; margin: 0 0 0.5rem; background: none; border: 0; font-family: inherit; text-align: left; color: var(--text-primary); }
button.tf-block-head { cursor: pointer; margin-bottom: 0; padding: 0.15rem 0; }
.tf-block-title { font-size: 0.9rem; font-weight: 700; }
.tf-block-sum { display: none; font-size: 0.74rem; color: var(--text-muted); margin-left: auto; }
button.tf-block-head svg { margin-left: auto; transition: transform .15s; color: var(--text-muted); flex-shrink: 0; }
.tf-block-sum + svg { margin-left: 0.4rem; }
.tf-block.is-closed .tf-block-sum { display: inline; }
.tf-block.is-closed button.tf-block-head svg { transform: rotate(-90deg); }
.tf-block.is-closed .tf-grid { display: none; }
button.tf-block-head:not(.is-static) + .tf-grid { margin-top: 0.6rem; }
.tf-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 0.7rem 1rem; align-items: start; }
.tf-grid .tf-wide { grid-column: 1 / -1; }
.tf-note { display: flex; flex-direction: row; gap: 0.5rem; align-items: flex-start; background: rgba(14, 165, 233, 0.08); border-radius: 8px; padding: 0.5rem 0.65rem; color: var(--text-secondary); font-size: 0.84rem; }
.tf-note svg { color: #0284c7; flex-shrink: 0; margin-top: 2px; }
.tf-note p { margin: 0.1rem 0 0; white-space: pre-wrap; }
.tf-card .tf-grid > .tf-field { min-width: 0; }
@media (max-width: 800px) { .tf-grid { grid-template-columns: 1fr; } .tf-block-sum { font-size: 0.72rem; } }

/* ---- montador: quadros ---- */
.tb-group { display: flex; flex-direction: column; gap: 0.45rem; border: 1px dashed transparent; border-radius: 12px; padding: 0.15rem; }
.tb-group.is-block { border: 1px solid var(--border-color); background: var(--bg-surface-elevated); padding: 0.55rem; gap: 0.5rem; }
.tb-group.is-active.is-block { border-color: var(--accent-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 18%, transparent); }
.tb-group-title { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); padding: 0 0.2rem; }
.tb-group-body { display: flex; flex-direction: column; gap: 0.45rem; min-height: 0.5rem; border-radius: 8px; }
.tb-group-body.drop-end { outline: 2px dashed var(--accent-primary); outline-offset: 2px; }
.tb-block-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.tb-btitle { flex: 1 1 14rem; min-width: 0; font-family: inherit; font-size: 0.95rem; font-weight: 700; color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.4rem 0.6rem; outline: none; }
.tb-btitle:focus { border-color: var(--accent-primary); }
.tb-cols { display: inline-flex; gap: 0.25rem; }
.tb-cols button { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 30px; border: 1px solid var(--border-color); border-radius: 6px; background: var(--bg-surface); cursor: pointer; padding: 0; }
.tb-cols button.on { border-color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 12%, var(--bg-surface)); }
.tb-colicon { display: inline-flex; gap: 2px; }
.tb-colicon i { display: block; width: 7px; height: 14px; border-radius: 2px; background: var(--text-muted); }
.tb-cols button.on .tb-colicon i { background: var(--accent-primary); }
.tb-colicon.c1 i { width: 20px; }
.tb-colicon.c2 i { width: 10px; }
.tb-bcoll { font-size: 0.76rem; white-space: nowrap; }
.tb-arrows.is-row { flex-direction: row; }
.tb-addblock { align-self: flex-start; display: inline-flex; align-items: center; gap: 0.35rem; font-family: inherit; font-size: 0.85rem; font-weight: 700; padding: 0.45rem 0.9rem; border-radius: 8px; border: 1px solid var(--accent-primary); background: transparent; color: var(--accent-primary); cursor: pointer; }
.tb-addblock:hover { background: color-mix(in srgb, var(--accent-primary) 10%, transparent); }
.tb-preview .tf-block-head, .tb-preview button.tf-block-head { pointer-events: none; }

/* ---- condições ---- */
.tb-cond-badge { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.72rem; font-weight: 700; color: #7c3aed; background: rgba(124, 58, 237, 0.1); border-radius: 999px; padding: 0.1rem 0.45rem; }
.tb-more.has-cond { color: #7c3aed; }
.tb-rules-wrap { flex: 1 0 100%; }
.tb-rules { display: flex; flex-direction: column; gap: 0.4rem; background: rgba(124, 58, 237, 0.06); border: 1px solid rgba(124, 58, 237, 0.2); border-radius: 10px; padding: 0.55rem 0.65rem; font-weight: 500; }
.tb-rules-title { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; font-weight: 700; color: #6d28d9; }
.tb-rules-title small { font-weight: 400; color: var(--text-muted); }
.tb-rule { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.tb-rule select, .tb-rule input[type="text"], .tb-rule input[type="date"], .tb-rule input[type="time"] { width: auto; max-width: 100%; min-width: 0; font-size: 0.82rem; padding: 0.3rem 0.45rem; }
.tb-rule-vals { display: inline-flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; }
.tb-opt { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.82rem; font-weight: 500; color: var(--text-primary); }
.tb-rule-add { align-self: flex-start; font-family: inherit; font-size: 0.78rem; font-weight: 700; color: #6d28d9; background: none; border: 1px dashed rgba(124, 58, 237, 0.5); border-radius: 8px; padding: 0.25rem 0.6rem; cursor: pointer; }
.tb-answers { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.5rem; background: rgba(124, 58, 237, 0.06); border: 1px solid rgba(124, 58, 237, 0.2); border-radius: 10px; padding: 0.5rem 0.65rem; font-size: 0.8rem; }
.tb-answers > b { color: #6d28d9; }
.tb-answers small { color: var(--text-muted); font-weight: 400; }
.tb-answer { display: flex; align-items: center; gap: 0.5rem; }
.tb-answer > span { min-width: 6rem; font-weight: 600; color: var(--text-primary); }
.tb-answer select { width: auto; max-width: 100%; font-size: 0.82rem; padding: 0.3rem 0.45rem; }
.tb-pv-reset { margin-left: auto; font-family: inherit; font-size: 0.72rem; font-weight: 600; color: var(--text-muted); background: none; border: 0; text-decoration: underline; cursor: pointer; }
.tb-pv-hint { font-size: 0.76rem; color: #6d28d9; background: rgba(124, 58, 237, 0.07); border-radius: 8px; padding: 0.3rem 0.55rem; margin-bottom: 0.6rem; }
.tb-answer { align-items: flex-start; }
.tb-answer-targets { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; min-width: 0; }
.tb-chip-t { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.2rem 0.15rem 0.5rem; border-radius: 999px; background: var(--bg-surface); border: 1px solid rgba(124, 58, 237, 0.35); color: var(--text-primary); }
.tb-chip-t.is-f { border-style: dashed; }
.tb-chip-t button { border: 0; background: none; cursor: pointer; color: var(--text-muted); font-size: 0.95rem; line-height: 1; padding: 0 0.3rem; border-radius: 50%; }
.tb-chip-t button:hover { color: #dc2626; }
.tb-blocked { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.4rem; padding-top: 0.4rem; border-top: 1px dashed rgba(124, 58, 237, 0.3); }
.tb-blocked-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--text-secondary); }
.tb-blocked-item em { color: var(--text-muted); font-style: normal; }
.tb-blocked-item button { font-family: inherit; font-size: 0.74rem; font-weight: 700; color: #6d28d9; background: none; border: 1px solid rgba(124, 58, 237, 0.4); border-radius: 6px; padding: 0.1rem 0.45rem; cursor: pointer; }

/* ---- tabela de itens, campo calculado, somente leitura, cartão da lista ---- */
.tf-calc { font-size: 1rem; font-weight: 700; color: var(--text-primary); background: color-mix(in srgb, var(--accent-primary) 8%, var(--bg-surface)); border-radius: 8px; padding: 0.4rem 0.7rem; }
.tf-auto { color: var(--text-muted); font-weight: 400; }
.tf-table { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.tf-table-scroll { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 8px; }
.tf-table table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.tf-table th { text-align: left; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); padding: 0.35rem 0.4rem; background: var(--bg-surface-elevated); white-space: nowrap; }
.tf-table th.is-num, .tf-cell.is-num, .tf-tot { text-align: right; }
.tf-table td { padding: 0.15rem 0.2rem; border-top: 1px solid var(--border-subtle); }
.tf-cell { width: 100%; min-width: 5rem; box-sizing: border-box; font-family: inherit; font-size: 0.86rem; color: var(--text-primary); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 0.3rem 0.4rem; outline: none; }
.tf-cell:hover, .tf-cell:focus { background: var(--bg-surface-elevated); border-color: var(--border-color); }
.tf-row-act { width: 1.6rem; }
.tf-row-x { display: inline-flex; border: 0; background: none; color: var(--text-muted); cursor: pointer; border-radius: 6px; padding: 0.2rem; }
.tf-row-x:hover { color: #dc2626; background: rgba(220, 38, 38, 0.1); }
.tf-tot { font-weight: 700; color: var(--text-primary); background: var(--bg-surface-elevated); padding: 0.35rem 0.5rem !important; }
.tf-lock { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); background: var(--bg-surface-elevated); border-radius: 999px; padding: 0.05rem 0.5rem; }
.tf-block.has-head:has(.tf-lock) .tf-input, .tf-block.has-head:has(.tf-lock) .tf-cell { opacity: 0.85; }
.tt-card-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.45rem; margin-top: 0.2rem; font-size: 0.74rem; color: var(--text-secondary); }
.tt-name { display: inline-flex; align-items: center; gap: 0.2rem; font-weight: 700; color: var(--accent-primary); }
.tt-val { padding: 0.02rem 0.45rem; border-radius: 999px; background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle); color: var(--text-primary); font-weight: 600; white-space: nowrap; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }

/* ---- montador: colunas da tabela, fórmula, valor padrão, quem edita ---- */
.tb-cols-ed { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.8rem; color: var(--text-secondary); }
.tb-cols-ed > b { font-weight: 700; } .tb-cols-ed small { font-weight: 400; color: var(--text-muted); }
.tb-col { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.tb-col input[type="text"] { flex: 1 1 8rem; min-width: 0; } .tb-col select { width: auto; }
.tb-col input[type="text"], .tb-col select, .tb-formula, .tb-calc-tools select, .tb-default select, .tb-default input, .tb-bedit { font-family: inherit; font-size: 0.85rem; color: var(--text-primary); background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 8px; padding: 0.35rem 0.5rem; outline: none; box-sizing: border-box; }
.tb-formula { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; }
.tb-calc-tools { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.tb-default { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.2rem; }
.tb-bedit-wrap { flex: 1 0 100%; }
.tb-bedit { width: auto; max-width: 100%; font-size: 0.78rem; }
.tb-edit-people { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 0.6rem; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.tb-edit-people label { display: flex; flex-direction: column; gap: 0.2rem; flex: 1 1 12rem; }
.tb-edit-people select { width: 100%; font-size: 0.82rem; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-surface); color: var(--text-primary); }
.tb-edit-people small { flex: 1 0 100%; font-weight: 400; color: var(--text-muted); }

/* ---- recolher a configuração de campos e quadros ---- */
.tb-fold { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; border-radius: 6px; padding: 0.15rem; transition: transform .15s; }
.tb-fold:hover { background: var(--bg-surface-elevated); color: var(--text-primary); }
.tb-field.is-folded .tb-fold, .tb-group.is-folded .tb-block-head .tb-fold { transform: rotate(-90deg); }
.tb-fsum { display: none; flex: 0 1 auto; min-width: 0; font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 18rem; }
.tb-field.is-folded .tb-fsum:not(:empty) { display: inline; }
.tb-field.is-folded .tb-field-opts, .tb-field.is-folded .tb-field-more { display: none; }
.tb-bsum { display: none; font-size: 0.78rem; color: var(--text-muted); padding: 0 0.3rem; }
.tb-group.is-folded .tb-group-body { display: none; }
.tb-group.is-folded .tb-bsum { display: block; }
.tb-foldall { margin-left: 0.6rem; display: inline-flex; align-items: center; gap: 0.3rem; font-family: inherit; font-size: 0.74rem; font-weight: 600; color: var(--text-secondary); background: none; border: 1px solid var(--border-color); border-radius: 999px; padding: 0.15rem 0.6rem; cursor: pointer; vertical-align: middle; }
.tb-foldall:hover { color: var(--accent-primary); border-color: var(--accent-primary); }

/* ---- CPF/CNPJ unificado e aviso de documento repetido ---- */
.tf-doc { display: flex; align-items: center; gap: 0.45rem; max-width: 22rem; }
.tf-doc-tag { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.03em; color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 12%, var(--bg-surface)); border-radius: 999px; padding: 0.15rem 0.55rem; white-space: nowrap; }
.tf-doc-tag:empty { display: none; }
.tf-warn { font-size: 0.76rem; color: #92400e; background: rgba(245, 158, 11, 0.12); border-radius: 8px; padding: 0.3rem 0.5rem; }
.tf-warn:empty { display: none; }
.tf-warn svg { vertical-align: -2px; margin-right: 0.15rem; }
.tf-warn a { color: inherit; font-weight: 700; text-decoration: underline; }

/* ---- avisos e confirmações sempre por cima das janelas de tipos ---- */
#confirm-dialog-modal, #prompt-dialog-modal { z-index: 2600; }
.tipos-dialog { position: relative; }
.tb-leave { position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; padding: 0.9rem 1.25rem; background: var(--bg-surface); border-top: 3px solid #f59e0b; box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.22); }
.tb-leave-msg { display: flex; flex-direction: column; gap: 0.1rem; font-size: 0.85rem; color: var(--text-secondary); }
.tb-leave-msg b { color: var(--text-primary); font-size: 0.92rem; }
.tb-leave-btns { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tb-leave-btns .btn.is-danger { color: #b91c1c; border-color: rgba(220, 38, 38, 0.4); }

/* quadro selecionado: destaque claro e cabecalho compacto quando recolhido */
.tb-active-badge { display: none; font-size: 0.72rem; font-weight: 700; color: #fff; background: var(--accent-primary); border-radius: 999px; padding: 0.15rem 0.6rem; white-space: nowrap; cursor: pointer; }
.tb-group.is-active.is-block .tb-active-badge { display: inline-block; }
.tb-group.is-active.is-block { border-width: 2px; border-color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 6%, var(--bg-surface-elevated)); }
.tb-group.is-block { cursor: pointer; }
.tb-group.is-block .tb-group-body, .tb-group.is-block .tb-field { cursor: default; }
.tb-group.is-folded .tb-cols, .tb-group.is-folded .tb-bcoll, .tb-group.is-folded .tb-arrows, .tb-group.is-folded .tb-more, .tb-group.is-folded .tb-bedit-wrap, .tb-group.is-folded .tb-edit-people, .tb-group.is-folded .tb-rules-wrap { display: none; }

/* previa: o quadro selecionado no montador aparece destacado aqui tambem, e clicar nele o seleciona */
#tb-preview .tf-block { position: relative; cursor: pointer; border-radius: 12px; transition: box-shadow .15s, background .15s; }
#tb-preview .tf-block.is-selected { box-shadow: 0 0 0 2px var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 6%, transparent); }
#tb-preview .tf-block:not(.is-selected):hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-primary) 45%, transparent); }
#tb-preview .tf-sel-tag { position: absolute; top: -0.6rem; right: 0.6rem; z-index: 2; font-size: 0.68rem; font-weight: 700; color: #fff; background: var(--accent-primary); border-radius: 999px; padding: 0.1rem 0.55rem; pointer-events: none; }

/* ---- galeria de modelos, barra fixa, + Campo no quadro, pendencias, desfazer ---- */
.tb-gallery { border: 1px solid var(--border-color); border-radius: 12px; padding: 0.7rem; background: var(--bg-surface-elevated); display: flex; flex-direction: column; gap: 0.55rem; }
.tb-gallery-title { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.88rem; font-weight: 700; }
.tb-gallery-title small { font-weight: 400; color: var(--text-muted); }
.tb-gal-skip { font-family: inherit; font-size: 0.78rem; font-weight: 600; border: 0; background: transparent; color: var(--accent-primary); cursor: pointer; text-decoration: underline; }
.tb-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.5rem; }
.tb-tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; text-align: left; font-family: inherit; padding: 0.6rem 0.7rem; border-radius: 10px; border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-primary); cursor: pointer; }
.tb-tpl svg, .tb-tpl i { color: var(--accent-primary); }
.tb-tpl b { font-size: 0.86rem; }
.tb-tpl small { font-size: 0.74rem; color: var(--text-muted); }
.tb-tpl:hover { border-color: var(--accent-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 15%, transparent); }
.tb-add { position: sticky; bottom: -1rem; z-index: 6; background: var(--bg-surface); border-top: 1px solid var(--border-color); box-shadow: 0 -8px 16px rgba(15, 23, 42, 0.08); margin: 0 -0.25rem; padding: 0.55rem 0.25rem 0.9rem; max-height: 6.2rem; overflow-y: auto; }
.tb-add > span { flex: 1 0 100%; font-weight: 700; color: var(--text-primary); }
.tb-addhere-wrap { position: relative; align-self: flex-start; }
.tb-addhere { display: inline-flex; align-items: center; gap: 0.3rem; font-family: inherit; font-size: 0.78rem; font-weight: 700; padding: 0.3rem 0.65rem; border-radius: 8px; border: 1px dashed var(--accent-primary); background: transparent; color: var(--accent-primary); cursor: pointer; }
.tb-addhere:hover { background: color-mix(in srgb, var(--accent-primary) 10%, transparent); }
.tb-typemenu { position: absolute; left: 0; top: calc(100% + 4px); z-index: 30; display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 0.2rem; padding: 0.4rem; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22); max-height: 16rem; overflow-y: auto; }
.tb-typemenu[hidden] { display: none; }
.tb-typemenu button { display: flex; align-items: center; gap: 0.4rem; font-family: inherit; font-size: 0.8rem; font-weight: 600; text-align: left; padding: 0.35rem 0.5rem; border: 0; border-radius: 6px; background: transparent; color: var(--text-primary); cursor: pointer; }
.tb-typemenu button:hover { background: var(--bg-surface-elevated); color: var(--accent-primary); }
.tb-undo { display: inline-flex; gap: 0.25rem; margin-left: 0.6rem; }
.tb-undo button { display: inline-flex; align-items: center; gap: 0.25rem; font-family: inherit; font-size: 0.74rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 6px; border: 1px solid var(--border-color); background: transparent; color: var(--text-secondary); cursor: pointer; }
.tb-undo button:disabled { opacity: 0.4; cursor: default; }
.tb-undo button:hover:not(:disabled) { color: var(--accent-primary); border-color: var(--accent-primary); }
.tb-issues { position: sticky; top: -1rem; z-index: 8; border: 1px solid #f59e0b; border-left-width: 4px; border-radius: 10px; background: var(--bg-surface); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16); padding: 0.55rem 0.75rem; }
.tb-issues[hidden] { display: none; }
.tb-issues-head { display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem; }
.tb-issues-head.is-ok { color: #15803d; }
.tb-issues ul { list-style: none; margin: 0.35rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.tb-issues li button { display: flex; align-items: center; gap: 0.35rem; width: 100%; text-align: left; font-family: inherit; font-size: 0.8rem; padding: 0.3rem 0.4rem; border: 0; border-radius: 6px; background: transparent; color: var(--text-primary); cursor: pointer; }
.tb-issues li button:hover:not(:disabled) { background: rgba(245, 158, 11, 0.14); }
.tb-issues li button:disabled { cursor: default; color: var(--text-secondary); }
.tb-issues li em { margin-left: auto; font-style: normal; font-size: 0.72rem; color: var(--accent-primary); font-weight: 700; }
.tb-issues-x { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; padding: 0.15rem; border-radius: 6px; }
.tb-issues-btn { font-family: inherit; font-size: 0.8rem; font-weight: 700; padding: 0.35rem 0.7rem; border-radius: 999px; border: 1px solid #f59e0b; background: rgba(245, 158, 11, 0.12); color: #b45309; cursor: pointer; }
.tb-issues-btn[hidden] { display: none; }
@keyframes tb-flash { 0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); } 25%, 75% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.55); } }
.tb-flash { animation: tb-flash 1.6s ease; border-radius: 10px; }

/* ---- montador em tela quase cheia: estrutura | prévia grande | paleta de campos e configuração */
.tipos-overlay.is-builder { padding: 1.5vh 1vw; }
.tipos-dialog.is-xl { width: min(1900px, 98vw); height: 96vh; max-height: 96vh; }
.tipos-dialog.is-xl .tipos-head { padding: 0.8rem 1.4rem; }
.tipos-dialog.is-xl .tb-grid { grid-template-columns: minmax(380px, 1.05fr) minmax(360px, 1fr) minmax(300px, 0.62fr); gap: 0; padding: 0; overflow: hidden; flex: 1; min-height: 0; }
.tipos-dialog.is-xl .tb-form, .tipos-dialog.is-xl .tb-preview, .tipos-dialog.is-xl .tb-side { overflow-y: auto; min-height: 0; padding: 1rem 1.2rem; }
.tipos-dialog.is-xl .tb-form { border-right: 1px solid var(--border-color); }
.tipos-dialog.is-xl .tb-preview { position: static; align-self: stretch; border-radius: 0; background: var(--bg-surface-elevated); padding: 1rem 1.6rem 2rem; }
.tipos-dialog.is-xl .tb-side { border-left: 1px solid var(--border-color); background: var(--bg-surface); }
.tb-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 0.8rem; }
.tb-meta .tb-lbl:nth-child(2) { grid-column: 1 / -1; order: 5; }
.tb-preview-title { display: flex; align-items: center; gap: 0.4rem; }
.tb-preview-title .tb-dev { margin-left: auto; }
.tb-dev { display: inline-flex; gap: 0.2rem; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 999px; padding: 0.15rem; }
.tb-dev button { display: inline-flex; align-items: center; gap: 0.3rem; border: 0; background: transparent; padding: 0.25rem 0.7rem; border-radius: 999px; font: inherit; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.tb-dev button.on { background: var(--accent-primary); color: #fff; }
#tb-preview { transition: max-width 0.2s; }
#tb-preview.tb-pv-pc { max-width: 880px; margin: 0 auto; }
#tb-preview.tb-pv-pc .tf-card { padding: 1.2rem 1.4rem; font-size: 0.95rem; }
#tb-preview.tb-pv-mobile { max-width: 390px; margin: 0 auto; border: 8px solid #1f2937; border-radius: 28px; padding: 0.6rem; background: var(--bg-surface); }
#tb-preview.tb-pv-mobile .tf-grid { grid-template-columns: 1fr !important; }
#tb-preview .tf-field.is-picked { outline: 2px solid var(--accent-primary); outline-offset: 3px; border-radius: 8px; }
#tb-preview .tf-label { cursor: pointer; }
/* lista compacta */
.tb-field { cursor: pointer; }
.tb-field.is-selected { outline: 2px solid var(--accent-primary); outline-offset: -1px; background: color-mix(in srgb, var(--accent-primary) 6%, var(--bg-surface)); }
.tb-field .tb-fsum { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* faixa da direita */
.tb-pal-title { display: flex; align-items: center; gap: 0.4rem; font-weight: 800; font-size: 1rem; }
.tb-pal-where { font-size: 0.78rem; color: var(--text-muted); margin: 0.2rem 0 0.6rem; }
.tb-pal-q { width: 100%; box-sizing: border-box; margin-bottom: 0.6rem; padding: 0.45rem 0.7rem; border: 1px solid var(--border-color); border-radius: 9px; background: var(--bg-surface); color: var(--text-primary); font: inherit; font-size: 0.85rem; }
.tb-pal-group h4 { margin: 0.7rem 0 0.35rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.tb-pal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; }
.tb-pal .tb-addtype { display: flex; align-items: center; gap: 0.45rem; text-align: left; padding: 0.55rem 0.65rem; border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-surface); color: var(--text-primary); font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.tb-pal .tb-addtype:hover { border-color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 7%, var(--bg-surface)); }
.tb-pal .tb-addtype[hidden], .tb-pal-group[hidden] { display: none; }
.tb-pal-hint { margin-top: 1rem; font-size: 0.76rem; color: var(--text-muted); }
.tb-side-head { display: flex; align-items: center; gap: 0.6rem; position: sticky; top: -1rem; background: var(--bg-surface); padding: 0.2rem 0 0.7rem; margin-bottom: 0.4rem; border-bottom: 1px solid var(--border-color); z-index: 2; }
.tb-back { display: inline-flex; align-items: center; gap: 0.3rem; border: 1px solid var(--border-color); background: var(--bg-surface); border-radius: 8px; padding: 0.3rem 0.65rem; font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer; color: var(--text-primary); }
.tb-side-ttl { font-weight: 700; display: inline-flex; align-items: center; gap: 0.35rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-cfg .tb-field-opts, .tb-cfg .tb-field-more { margin: 0.7rem 0; padding: 0; border: 0; display: grid; gap: 0.55rem; }
.tb-cfg label { display: grid; gap: 0.25rem; font-size: 0.82rem; font-weight: 600; }
.tb-cfg label.tb-check { display: flex; align-items: center; gap: 0.4rem; font-weight: 500; }
.tb-cfg input[type="text"], .tb-cfg select, .tb-cfg textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 0.85rem; padding: 0.4rem 0.55rem; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-surface); color: var(--text-primary); }
@media (max-width: 1280px) {
  .tipos-dialog.is-xl .tb-grid { grid-template-columns: minmax(320px, 1fr) minmax(300px, 1fr) minmax(260px, 0.7fr); }
}
@media (max-width: 800px) {
  .tipos-dialog.is-xl { width: 100%; height: 100%; max-height: 100%; }
  .tipos-dialog.is-xl .tb-grid { display: block; overflow-y: auto; }
  .tipos-dialog.is-xl .tb-form, .tipos-dialog.is-xl .tb-preview, .tipos-dialog.is-xl .tb-side { overflow: visible; border: 0; }
}
.tb-pal-mini { margin: 0.4rem 0 0.2rem; padding: 0.5rem 0.6rem; border: 1px dashed var(--border-color); border-radius: 10px; }
.tb-pal-mini > span { display: block; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.35rem; }
.tb-pal-mini > div { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tb-pal-mini .tb-addtype { width: 2.1rem; height: 2.1rem; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-surface); color: var(--text-primary); cursor: pointer; padding: 0; }
.tb-pal-mini .tb-addtype:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.tb-more.is-on { color: var(--accent-primary); }
.tb-cfg label.tb-check { display: flex; flex-direction: row; align-items: flex-start; gap: 0.5rem; text-align: left; }
.tb-cfg label.tb-check input { margin-top: 0.15rem; flex-shrink: 0; width: auto; }

/* ---- a tarefa de verdade à esquerda; estrutura e campos à direita */
.tipos-dialog.is-xl .tb-grid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.tipos-dialog.is-xl .tb-preview { padding: 0; display: flex; flex-direction: column; border: 0; border-right: 1px solid var(--border-color); overflow: hidden; }
.tipos-dialog.is-xl .tb-preview-title { padding: 0.7rem 1.2rem; margin: 0; background: var(--bg-surface); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.tipos-dialog.is-xl .tb-mock-wrap { flex: 1; min-height: 0; padding: 1rem 1.2rem 1.2rem; display: flex; justify-content: center; align-items: stretch; background: var(--bg-surface-elevated); }
.tb-panel { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); min-width: 0; min-height: 0; overflow: hidden; }
.tipos-dialog.is-xl .tb-panel .tb-form { border-right: 1px solid var(--border-color); }
.tipos-dialog.is-xl .tb-panel .tb-side { border-left: 0; }
.tb-pv-reset { margin-left: 0.8rem; border: 0; background: transparent; color: var(--accent-primary); font: inherit; font-size: 0.78rem; text-decoration: underline; cursor: pointer; }
#tb-preview, #tb-preview.tb-pv-pc { width: 100%; max-width: none; height: 100%; margin: 0; }
#tb-preview.tb-pv-mobile { width: 390px; max-width: 100%; height: 100%; margin: 0 auto; border: 8px solid #1f2937; border-radius: 30px; overflow: hidden; padding: 0; background: var(--bg-surface); }
#tb-preview .tb-mock-modal.task-detail-modal { width: 100%; height: 100%; max-height: none; transform: none; border-radius: 14px; }
#tb-preview.tb-pv-mobile .tb-mock-modal.task-detail-modal { border-radius: 0; border: 0; }
#tb-preview.tb-pv-mobile .task-modal-grid { display: block; overflow-y: auto; }
#tb-preview.tb-pv-mobile .task-modal-main { overflow: visible; padding: 1rem; }
#tb-preview.tb-pv-mobile .task-modal-sidebar { border-left: 0; border-top: 1px solid var(--border-subtle); padding: 0.8rem 1rem 2rem; }
#tb-preview.tb-pv-mobile .tf-grid { grid-template-columns: 1fr !important; }
#tb-preview .tb-mock-modal .tf-card { box-shadow: none; }
#tb-preview .tb-mock-modal * { -webkit-user-select: none; user-select: none; }
#tb-preview .tb-mock-modal input, #tb-preview .tb-mock-modal textarea, #tb-preview .tb-mock-modal select { -webkit-user-select: text; user-select: text; }
#tb-preview .tb-mock-desc, #tb-preview .tb-mock-msg { color: var(--text-muted); }
#tb-preview .tb-mock-chat { color: var(--text-muted); font-size: 0.82rem; padding: 1rem; text-align: center; }
#tb-preview .task-modal-header .task-modal-btn { pointer-events: none; }
#tb-preview .tf-field { position: relative; cursor: pointer; border-radius: 8px; transition: background 0.15s; }
#tb-preview .tf-field:hover { background: color-mix(in srgb, var(--accent-primary) 5%, transparent); }
#tb-preview .tf-field.is-picked { outline: 2px solid var(--accent-primary); outline-offset: 3px; }
#tb-preview .tf-field.is-drag { opacity: 0.4; }
#tb-preview .tf-field.drop-above { box-shadow: 0 -3px 0 var(--accent-primary); }
#tb-preview .tf-field.drop-below { box-shadow: 0 3px 0 var(--accent-primary); }
#tb-preview .tf-grid.drop-end { outline: 2px dashed var(--accent-primary); outline-offset: 3px; }
.tb-fx { position: absolute; top: -31px; right: 0; z-index: 5; display: none; align-items: center; gap: 1px; padding: 2px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15); }
#tb-preview .tf-field:hover > .tb-fx, #tb-preview .tf-field.is-picked > .tb-fx { display: inline-flex; }
.tb-fx button, .tb-fx-grip { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; background: transparent; border-radius: 6px; color: var(--text-secondary); cursor: pointer; padding: 0; }
.tb-fx-grip { cursor: grab; }
.tb-fx button:hover, .tb-fx-grip:hover { background: var(--bg-surface-elevated); color: var(--accent-primary); }
.tb-fx button[data-fx="del"]:hover { color: #dc2626; }
@media (max-width: 1280px) {
  .tipos-dialog.is-xl .tb-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .tb-panel { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); }
}
@media (max-width: 800px) {
  .tipos-dialog.is-xl .tb-grid { display: block; }
  .tb-panel { display: block; overflow: visible; }
  .tipos-dialog.is-xl .tb-preview { height: 70vh; }
}

/* ---- campos à esquerda, tarefa (um pouco menor) à direita */
.tipos-dialog.is-xl .tb-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.tipos-dialog.is-xl .tb-preview { border-right: 0; border-left: 1px solid var(--border-color); }
/* tarefa a 65%, inteira (sem rolagem própria): quem rola é a área da prévia */
.tipos-dialog.is-xl .tb-mock-wrap { overflow-y: auto; align-items: flex-start; }
@media (min-width: 801px) {
  #tb-preview.tb-pv-pc { height: auto; overflow: visible; }
  #tb-preview.tb-pv-pc .tb-mock-modal.task-detail-modal { zoom: 0.65; transform: none; height: auto; overflow: visible; }
  #tb-preview.tb-pv-pc .task-modal-grid, #tb-preview.tb-pv-pc .task-modal-main { overflow: visible; }
  #tb-preview.tb-pv-pc .task-modal-main { min-height: 560px; }
}
@media (max-width: 1280px) {
  .tipos-dialog.is-xl .tb-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}

/* ---- linha do campo enxuta: nome, selos, configurar e menu de ações */
.tb-field-top { display: flex; align-items: center; gap: 0.4rem; }
.tb-field-top .tb-flabel { flex: 1; min-width: 0; }
.tb-badges { display: inline-flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.tb-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.2rem; height: 1.2rem; padding: 0 0.25rem; border-radius: 999px; background: color-mix(in srgb, var(--accent-primary) 12%, transparent); color: var(--accent-primary); font-size: 0.78rem; font-weight: 800; }
.tb-badge[hidden] { display: none; }
.tb-badge-req { background: color-mix(in srgb, #dc2626 12%, transparent); color: #dc2626; font-size: 0.95rem; }
.tb-menu-wrap { position: relative; display: inline-flex; }
.tb-fmenu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; display: flex; flex-direction: column; min-width: 9rem; padding: 0.25rem; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18); }
.tb-fmenu[hidden] { display: none; }
.tb-fmenu button { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.4rem 0.6rem; border: 0; background: transparent; border-radius: 7px; font: inherit; font-size: 0.82rem; color: var(--text-primary); cursor: pointer; text-align: left; }
.tb-fmenu button:hover:not(:disabled) { background: var(--bg-surface-elevated); }
.tb-fmenu button:disabled { opacity: 0.4; cursor: default; }
.tb-fmenu button.is-danger { color: #dc2626; }
.tb-req-cfg { padding: 0.5rem 0.65rem; border: 1px solid var(--border-color); border-radius: 10px; }

/* ---- painel do campo em seções curtas */
.tb-sec { margin: 0.9rem 0; }
.tb-sec > h4 { margin: 0 0 0.4rem; font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.tb-sec-help { margin: 0 0 0.5rem; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.35; }
details.tb-det { border: 1px solid var(--border-color); border-radius: 10px; padding: 0 0.75rem; background: var(--bg-surface); }
details.tb-det > summary { cursor: pointer; padding: 0.6rem 0; font-size: 0.85rem; font-weight: 700; color: var(--text-primary); list-style-position: inside; }
details.tb-det > summary small { font-weight: 400; color: var(--text-muted); }
details.tb-det[open] { padding-bottom: 0.7rem; }
details.tb-det[open] > summary { border-bottom: 1px solid var(--border-color); margin-bottom: 0.6rem; }
details.tb-det > label { display: grid; gap: 0.25rem; margin-bottom: 0.6rem; font-size: 0.82rem; font-weight: 600; }
details.tb-det > label.tb-check { display: flex; flex-direction: row; font-weight: 500; }
.tb-rules.is-bare { border: 0; background: transparent; padding: 0; margin: 0; }
/* cada resposta mostra... */
.tb-answers { display: grid; gap: 0.5rem; }
.tb-answer { padding: 0.6rem 0.7rem; border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-surface); }
.tb-ans-q { font-size: 0.85rem; }
.tb-ans-arrow { color: var(--text-muted); font-size: 0.78rem; margin-left: 0.2rem; }
.tb-answer .tb-answer-targets { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 0.4rem; }
.tb-ans-none { font-size: 0.8rem; color: var(--text-muted); font-style: italic; }
.tb-ans-add { border: 1px dashed var(--accent-primary); background: transparent; color: var(--accent-primary); border-radius: 999px; padding: 0.15rem 0.7rem; font: inherit; font-size: 0.78rem; font-weight: 700; cursor: pointer; }
.tb-ans-pop { margin-top: 0.5rem; padding: 0.55rem 0.65rem; border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-surface-elevated); max-height: 14rem; overflow-y: auto; }
.tb-ans-grp { display: grid; gap: 0.25rem; margin-bottom: 0.5rem; }
.tb-ans-grp > small { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.tb-ans-item { display: flex; align-items: center; gap: 0.45rem; font-size: 0.84rem; cursor: pointer; padding: 0.15rem 0; }
.tb-ans-grp.is-blocked { opacity: 0.85; }
.tb-ans-pop .tb-blocked-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; font-size: 0.82rem; color: var(--text-secondary); }
.tb-ans-pop .tb-blocked-item em { font-size: 0.76rem; color: var(--text-muted); }
.tb-ans-pop .tb-blocked-item button { border: 1px solid var(--border-color); background: var(--bg-surface); border-radius: 8px; padding: 0.1rem 0.5rem; font: inherit; font-size: 0.76rem; color: var(--accent-primary); cursor: pointer; }

.tb-cfg .tb-answer { display: block; grid-template-columns: none; }
.tb-cfg .tb-answer .tb-ans-q { display: block; margin: 0; }
.tb-cfg label.tb-ans-item { display: flex; flex-direction: row; align-items: center; gap: 0.45rem; font-weight: 500; padding: 0.2rem 0; }
.tb-cfg .tb-ans-item input { width: auto; flex-shrink: 0; }
.tb-cfg .tb-ans-item svg, .tb-cfg .tb-ans-item i { flex-shrink: 0; }

/* ---- cabeçalho do quadro enxuto; colunas e demais ajustes ficam no painel */
.tb-block-head { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.tb-block-head .tb-btitle { flex: 1; min-width: 8rem; }
.tb-cols-cfg { display: inline-flex; gap: 0.35rem; }
.tb-cfg .tb-bedit { width: 100%; }
.tb-more.has-cond { color: var(--accent-primary); font-weight: 700; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 0.2rem; }

.tb-ans-foot { position: sticky; bottom: -0.55rem; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0.4rem -0.65rem -0.55rem; padding: 0.5rem 0.65rem; background: var(--bg-surface-elevated); border-top: 1px solid var(--border-color); }
.tb-ans-count { font-size: 0.78rem; color: var(--text-muted); }
.tb-ans-ok { border: 0; background: var(--accent-primary); color: #fff; border-radius: 8px; padding: 0.3rem 1.1rem; font: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer; }

/* o quadro recolhido continua com a engrenagem e o menu de ações no cabeçalho */
.tb-group.is-folded .tb-block-head .tb-more, .tb-group.is-folded .tb-block-head .tb-menu-wrap { display: inline-flex; }

/* ---- largura do campo em colunas (só no computador; no celular tudo é uma coluna) */
@media (min-width: 801px) {
  .tf-grid > .tf-field[data-span]:not(.tf-wide) { grid-column: span var(--span, 1); }
  .tf-grid > .tf-field[data-newrow]:not(.tf-wide) { grid-column: 1 / span var(--span, 1); }
}
#tb-preview.tb-pv-mobile .tf-grid > .tf-field { grid-column: auto !important; }
.tf-grid { position: relative; }
.tb-guides { position: absolute; inset: -4px; display: grid; pointer-events: none; z-index: 0; }
.tb-guides i { border: 1px dashed color-mix(in srgb, var(--accent-primary) 45%, transparent); background: color-mix(in srgb, var(--accent-primary) 6%, transparent); border-radius: 8px; }
#tb-preview .tf-grid > .tf-field { z-index: 1; }
.tb-rz { position: absolute; top: 0; right: -10px; width: 16px; height: 100%; cursor: ew-resize; display: none; z-index: 7; touch-action: none; }
.tb-rz i { display: block; width: 5px; height: 34px; max-height: 80%; margin: 0 auto; position: relative; top: 50%; transform: translateY(-50%); border-radius: 3px; background: var(--accent-primary); box-shadow: 0 0 0 2px var(--bg-surface); }
#tb-preview .tf-field:hover > .tb-rz, #tb-preview .tf-field.is-picked > .tb-rz, #tb-preview .tf-field.is-resizing > .tb-rz { display: block; }
.tb-rz-tip { position: absolute; top: -28px; left: 50%; transform: translateX(-50%); padding: 0.15rem 0.5rem; border-radius: 6px; background: #1f2937; color: #fff; font-size: 0.72rem; white-space: nowrap; display: none; z-index: 9; }
#tb-preview .tf-field.is-resizing > .tb-rz-tip { display: block; }
#tb-preview .tf-field.drop-left { box-shadow: -3px 0 0 var(--accent-primary); }
#tb-preview .tf-field.drop-right { box-shadow: 3px 0 0 var(--accent-primary); }
.tb-width { display: grid; gap: 0.3rem; margin-bottom: 0.7rem; }
.tb-wlbl { font-size: 0.82rem; font-weight: 600; }
.tb-seg { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }
.tb-seg button { border: 1px solid var(--border-color); background: var(--bg-surface); border-radius: 8px; padding: 0.3rem 0.7rem; font: inherit; font-size: 0.8rem; cursor: pointer; color: var(--text-secondary); }
.tb-seg button.on { border-color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 10%, transparent); color: var(--accent-primary); font-weight: 700; }
.tb-wreset { justify-self: start; border: 0; background: transparent; color: var(--accent-primary); font: inherit; font-size: 0.76rem; text-decoration: underline; cursor: pointer; padding: 0; }
.tb-badge-w { font-size: 0.7rem; }

/* ---- arrastar o campo segurando em qualquer parte; a "casa" de destino aparece pontilhada */
#tb-preview .tf-field[draggable="true"] { cursor: grab; }
#tb-preview .tf-field[draggable="true"]:active { cursor: grabbing; }
#tb-preview .tf-field input, #tb-preview .tf-field select, #tb-preview .tf-field textarea { cursor: auto; }
.tb-slot { position: absolute; z-index: 2; pointer-events: none; display: flex; align-items: center; justify-content: center; border: 2px dashed var(--accent-primary); border-radius: 10px; background: color-mix(in srgb, var(--accent-primary) 14%, transparent); transition: left 0.08s, top 0.08s, width 0.08s, height 0.08s; }
.tb-slot span { font-size: 0.72rem; font-weight: 700; color: var(--accent-primary); background: var(--bg-surface); padding: 0.05rem 0.5rem; border-radius: 999px; }

/* ---- grade de 6 sextos: a largura de cada campo (1/3, 1/2, 2/3, 3/3 ou ajustável) é calculada por linha */
@media (min-width: 801px) {
  .tf-block .tf-grid, .tf-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .tf-grid > .tf-field { grid-column: span var(--u, 6); }
  .tf-grid > .tf-field[data-rowstart] { grid-column: 1 / span var(--u, 6); }
}
@media (max-width: 800px) { .tf-grid > .tf-field { grid-column: auto; } }

/* seletor de tipo de campo (flutuante, com busca e grupos) */
.tb-typepop { position: fixed; z-index: 2550; display: flex; flex-direction: column; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 16px 40px rgba(15, 23, 42, 0.3); overflow: hidden; }
.tb-typesearch { margin: 0.5rem; padding: 0.45rem 0.65rem; font-family: inherit; font-size: 0.85rem; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-surface-elevated); color: var(--text-primary); }
.tb-typesearch:focus { outline: 2px solid var(--accent-primary); outline-offset: 0; }
.tb-typelist { overflow-y: auto; padding: 0 0.5rem 0.5rem; }
.tb-typegt { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-secondary); padding: 0.5rem 0.25rem 0.2rem; }
.tb-typegrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.2rem; }
.tb-typegrid button { display: flex; align-items: center; gap: 0.45rem; font-family: inherit; font-size: 0.82rem; font-weight: 600; text-align: left; padding: 0.4rem 0.5rem; border: 0; border-radius: 6px; background: transparent; color: var(--text-primary); cursor: pointer; }
.tb-typegrid button:hover, .tb-typegrid button:focus-visible { background: var(--bg-surface-elevated); color: var(--accent-primary); outline: none; }
.tb-typegrid button[hidden], .tb-typegroup[hidden], .tb-typenone[hidden] { display: none; }
.tb-typenone { padding: 0.8rem 0.4rem; font-size: 0.82rem; color: var(--text-secondary); }
.tb-just-added { animation: tb-just 1.6s ease-out; }
@keyframes tb-just { 0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 55%, transparent); } 100% { box-shadow: 0 0 0 3px transparent; } }
/* o botao '+ Campo' acompanha a rolagem enquanto o quadro esta a vista */
.tb-addhere-wrap { position: sticky; bottom: 0.4rem; z-index: 4; }

/* editor de opções: uma linha por opção */
.tb-opts-ed { display: block; }
.tb-optshead { display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.tb-optshead small { color: var(--text-secondary); font-weight: 600; }
.tb-optshead small.is-bad { color: #dc2626; font-weight: 800; }
.tb-optacts { margin-left: auto; display: inline-flex; gap: 0.6rem; }
.tb-linkbtn { border: 0; background: transparent; color: var(--accent-primary); font-family: inherit; font-size: 0.76rem; font-weight: 700; cursor: pointer; padding: 0; }
.tb-linkbtn:hover { text-decoration: underline; }
.tb-optlist { display: flex; flex-direction: column; gap: 0.3rem; }
.tb-optrow { display: flex; align-items: center; gap: 0.4rem; padding: 0.15rem 0.2rem; border-radius: 8px; border: 1px solid transparent; }
.tb-optrow.is-over { border-color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 8%, transparent); }
.tb-optrow.is-dragging { opacity: 0.45; }
.tb-optgrip { color: var(--text-secondary); cursor: grab; display: inline-flex; padding: 0.15rem; }
.tb-opticon { color: var(--accent-primary); display: inline-flex; align-items: center; justify-content: center; width: 1.3rem; }
.tb-optnum { font-style: normal; font-size: 0.72rem; font-weight: 800; width: 1.2rem; height: 1.2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--accent-primary) 14%, transparent); }
.tb-optin { flex: 1; min-width: 0; font-family: inherit; font-size: 0.88rem; padding: 0.4rem 0.6rem; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-surface); color: var(--text-primary); }
.tb-optin:focus { outline: 2px solid var(--accent-primary); outline-offset: 0; }
.tb-optdel { border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; display: inline-flex; padding: 0.25rem; border-radius: 6px; }
.tb-optdel:hover { color: #dc2626; background: color-mix(in srgb, #dc2626 10%, transparent); }
.tb-optdupmsg { display: none; font-size: 0.7rem; font-weight: 700; color: #d97706; }
.tb-optrow.is-dup .tb-optdupmsg { display: inline; }
.tb-optrow.is-dup .tb-optin { border-color: #d97706; }
.tb-optadd { margin-top: 0.4rem; }
.tb-optpastebox { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.tb-optpastebox[hidden] { display: none; }
.tb-optpastebox textarea { font-family: inherit; font-size: 0.86rem; padding: 0.5rem 0.6rem; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-surface); color: var(--text-primary); resize: vertical; }
