/* Trilha — estilos da aplicação (v1.2) */
:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f3f1;
  --text: #1d2523;
  --muted: #5c6865;
  --border: #dfe5e2;
  --accent: #2f5d50;
  --accent-soft: #e3eee9;
  --accent-text: #24493f;
  --warn: #9a5b13;
  --warn-soft: #fbf0e1;
  --danger: #a3382c;
  --danger-soft: #fbe9e6;
  --info: #2c5a8a;
  --info-soft: #e6eff8;
  --neutral-soft: #eceeed;
  --code-bg: #f3f5f4;
  --shadow: 0 1px 2px rgba(20, 30, 28, .05), 0 4px 16px rgba(20, 30, 28, .04);
  --lanes: 4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121716; --surface: #1a2120; --surface-2: #212a28; --text: #e4ebe8; --muted: #9aa8a4; --border: #2d3836;
    --accent: #7fc0aa; --accent-soft: #1f3a33; --accent-text: #a9dcca; --warn: #e8b06a; --warn-soft: #3a2c18;
    --danger: #f08f80; --danger-soft: #3d221e; --info: #8dbbe8; --info-soft: #1d2d3d; --neutral-soft: #262f2d;
    --code-bg: #151b1a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #121716; --surface: #1a2120; --surface-2: #212a28; --text: #e4ebe8; --muted: #9aa8a4; --border: #2d3836;
  --accent: #7fc0aa; --accent-soft: #1f3a33; --accent-text: #a9dcca; --warn: #e8b06a; --warn-soft: #3a2c18;
  --danger: #f08f80; --danger-soft: #3d221e; --info: #8dbbe8; --info-soft: #1d2d3d; --neutral-soft: #262f2d;
  --code-bg: #151b1a; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: .05em .35em; overflow-wrap: anywhere; }
h1, h2, h3, h4 { line-height: 1.25; }
[hidden] { display: none !important; }

/* ---------- botões e campos ---------- */
.btn, .seg button, .chip { font: inherit; font-size: .86rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover, .chip:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn.ghost { background: none; }
.btn.small { font-size: .8rem; padding: 4px 10px; }
.btn.icon { padding: 6px 10px; }
.chip { border-radius: 999px; font-size: .8rem; padding: 4px 11px; }
.chip[aria-pressed="true"] { background: var(--info); border-color: var(--info); color: var(--surface); }
.chip.ghost { background: none; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: var(--surface); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--surface); }
input[type="text"], input[type="search"], input[type="number"], select, textarea {
  font: inherit; font-size: .9rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
label.field { display: block; margin: 0 0 12px; }
label.field > span { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.hint { font-size: .8rem; color: var(--muted); }

/* ---------- topo e estrutura ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.brand .logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--surface); font-size: .95rem; }
.brand small { font-weight: 500; font-size: .75rem; color: var(--muted); }
.top-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.saved { font-size: .75rem; color: var(--muted); margin-right: 6px; }
.saved.alerta { color: var(--warn); font-weight: 600; }
/* tela de entrada (modo nuvem) */
.entrada { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.entrada-caixa { width: min(380px, 100%); display: grid; gap: 12px; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.entrada-caixa p { margin: 0; color: var(--muted); font-size: .9rem; }
.entrada-caixa .dlg-erro { color: var(--danger); }
.entrada-caixa input { font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.banner { padding: 10px 18px; font-size: .88rem; }
.banner.danger { background: var(--danger-soft); color: var(--danger); border-bottom: 1px solid var(--danger); }
.app { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 0; min-height: calc(100vh - 54px); }
.sidebar { border-right: 1px solid var(--border); background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.sidebar h2 { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 0 0; }
.lista-fluxos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lista-fluxos button { width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; cursor: pointer; }
.lista-fluxos button:hover { border-color: var(--accent); }
.lista-fluxos button[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); }
.lista-fluxos b { display: block; font-size: .9rem; line-height: 1.3; }
.lista-fluxos small { display: block; font-size: .74rem; color: var(--muted); margin-top: 2px; }
.sidebar .rodape { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
main { padding: 18px 22px 40px; min-width: 0; }
.empty-state { max-width: 560px; margin: 60px auto; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--text); }

.fx-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.fx-head h1 { font-size: 1.45rem; margin: 0 0 4px; }
.fx-head p { margin: 0; color: var(--muted); max-width: 80ch; }
.fx-head .meta { font-size: .78rem; margin-top: 4px; }
.fx-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- abas ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin: 14px 0 14px; }
.tabs button { font: inherit; font-size: .9rem; padding: 8px 14px; border: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }
.painel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); }

/* ---------- legenda e barras ---------- */
.legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--muted); margin: 0 0 10px; }
.legenda i { display: inline-block; width: 16px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1.5px solid var(--border); background: var(--surface); }
.legenda i.dec { border-style: dashed; border-color: var(--warn); background: var(--warn-soft); }
.legenda i.alt { border-color: var(--danger); }
.legenda i.fim { border-radius: 999px; border-color: var(--text); }
.legenda i.v-ok { box-shadow: inset 4px 0 0 var(--accent); }
.legenda i.v-aj { box-shadow: inset 4px 0 0 var(--warn); }
.legenda i.v-du { box-shadow: inset 4px 0 0 var(--danger); }
.barra { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 12px; }
.barra .lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: 4px; }
.barra-ferramentas { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.modo-ligar { background: var(--info-soft); border: 1px solid var(--info); color: var(--info); border-radius: 10px; padding: 8px 12px; margin: 0 0 12px; font-size: .88rem; }

/* ---------- cenário ---------- */
.scn-card { position: sticky; top: 64px; z-index: 6; background: var(--surface); border: 1.5px solid var(--info); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .10); }
.scn-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.scn-ctrl { display: flex; gap: 6px; align-items: center; font-size: .82rem; color: var(--muted); }
.scn-narr { font-size: .95rem; margin: .5rem 0 .6rem; }
.scn-narr .nm { font: 700 .75rem ui-monospace, Menlo, monospace; color: var(--info); margin-right: 6px; }
.scn-state { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; font-size: .82rem; }
.scn-state h5 { margin: 0 0 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.scn-state .resumo { font-weight: 700; color: var(--info); text-transform: none; letter-spacing: 0; }
.marcador { display: inline-block; padding: 3px 8px; border-radius: 6px; font: 600 .74rem ui-monospace, Menlo, monospace; margin: 2px; border: 1px solid var(--border); background: var(--surface-2); }
.marcador.verde { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.marcador.amarelo { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.marcador.azul { background: var(--info-soft); color: var(--info); border-color: transparent; }
.marcador.vermelho { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.marcador.cinza { background: var(--neutral-soft); color: var(--text); }

/* ---------- tabelas ---------- */
.tabela-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; vertical-align: top; padding: 8px 11px; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 600; font-size: .74rem; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.scn-state th, .scn-state td { padding: 4px 8px; font-size: .8rem; }

/* ---------- diagrama ---------- */
.canvas-wrap { overflow-x: auto; padding-bottom: 6px; }
.lanes-head, .flow { display: grid; grid-template-columns: repeat(var(--lanes), minmax(165px, 1fr)) 92px; column-gap: 14px; }
.lanes-head { margin-bottom: 4px; }
.lane-h { position: relative; text-align: center; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text); padding: 7px 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.lane-h small { display: block; text-transform: none; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.lane-h .lane-nome { display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.lane-acoes { position: absolute; top: 3px; right: 3px; display: none; gap: 2px; }
.lane-h:hover .lane-acoes, .lane-h:focus-within .lane-acoes { display: flex; }
.lane-acoes button { font: inherit; font-size: .72rem; line-height: 1; width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; padding: 0; }
.lane-acoes button[data-rmator] { color: var(--danger); }
.lane-acoes button:disabled { opacity: .35; cursor: default; }
.lane-add { display: grid; place-items: center; font-size: .8rem; color: var(--muted); border: 1.5px dashed var(--border); border-radius: 8px; cursor: pointer; padding: 6px 4px; text-align: center; }
.lane-add:hover { color: var(--accent); border-color: var(--accent); }
.flow { position: relative; row-gap: 30px; padding-top: 16px; padding-bottom: 16px; }
.lane-bg { background: color-mix(in srgb, var(--surface-2) 55%, transparent); border-radius: 10px; margin: -16px 0; z-index: 0; }
.cell { z-index: 1; min-height: 64px; border: 1.5px dashed transparent; border-radius: 10px; margin: 0 4px; display: grid; place-items: center; cursor: pointer; color: transparent; font-size: 1.3rem; background: none; font-family: inherit; }
.cell:hover { border-color: var(--border); color: var(--muted); }
.cell.drop, .node.drop { border-color: var(--info) !important; background: var(--info-soft); color: var(--info); }
.edges { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; color: var(--muted); }
.edges path.l { fill: none; stroke: currentColor; stroke-width: 1.6; }
.edges path.alternativa { stroke: var(--danger); stroke-dasharray: 5 4; }
.edges path.opcional { stroke-dasharray: 3 4; }
.edges path.retorno { stroke: var(--info); stroke-dasharray: 6 3; }
.edges text { font-size: 11px; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.node { display: block; position: relative; z-index: 2; align-self: center; margin: 0 4px; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px; padding: 8px 10px; cursor: pointer; box-shadow: var(--shadow); transition: opacity .2s; min-width: 0; }
.node:hover { border-color: var(--accent); }
.node .nm { font: 700 .72rem ui-monospace, Menlo, monospace; color: var(--accent); }
.node b { display: block; font-size: .84rem; line-height: 1.3; margin-top: 2px; overflow-wrap: anywhere; }
.node .sub { display: block; font-size: .74rem; color: var(--muted); line-height: 1.3; margin-top: 2px; }
.node .xtra { display: block; font-size: .72rem; color: var(--warn); margin-top: 4px; line-height: 1.3; }
.node .lane-tag { display: none; }
.node.decisao { border-style: dashed; border-color: var(--warn); background: var(--warn-soft); }
.node.alternativo { border-color: var(--danger); }
.node.fim { border-radius: 999px; text-align: center; border-color: var(--text); }
.node[data-v="ok"] { box-shadow: inset 5px 0 0 var(--accent), var(--shadow); }
.node[data-v="ajustar"] { box-shadow: inset 5px 0 0 var(--warn), var(--shadow); }
.node[data-v="duvida"] { box-shadow: inset 5px 0 0 var(--danger), var(--shadow); }
.node.ativo { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.node.arrastando { opacity: .4; }
.node:focus-visible, .cell:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.flow.ligando .node { cursor: crosshair; }
.flow.sim .node { opacity: .28; }
.flow.sim .node.no-caminho { opacity: .7; }
.flow.sim .node.feito { opacity: .95; }
.flow.sim .node.atual { opacity: 1; outline: 3px solid var(--info); outline-offset: 3px; }

/* ---------- painel lateral (detalhe/edição do passo) ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: -12px 0 40px rgba(0, 0, 0, .18); transform: translateX(105%); transition: transform .25s ease; z-index: 40; overflow-y: auto; padding: 0 20px 28px; }
.drawer.aberto { transform: none; }
.dr-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; position: sticky; top: 0; background: var(--surface); padding: 12px 0 8px; z-index: 1; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.dr-top .lane { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.dr-top .acoes { display: flex; gap: 6px; }
.dr-fechar { font: inherit; font-size: 1.1rem; line-height: 1; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; }
.drawer h3 { margin: 6px 0 6px; font-size: 1.15rem; }
.drawer h3 .nm { font: 700 .85rem ui-monospace, Menlo, monospace; color: var(--accent); margin-right: 6px; }
.drawer .desc { color: var(--muted); font-size: .92rem; margin: 0; white-space: pre-line; }
.sec h4 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; }
.sec ul { list-style: none; margin: 0; padding: 0; }
.sec li { margin: 0 0 7px; font-size: .9rem; line-height: 1.45; }
.sec .vazio { color: var(--muted); font-size: .85rem; font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .tag { font: 700 .78rem ui-monospace, Menlo, monospace; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.val-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.val-btns button { font: inherit; font-size: .84rem; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.val-btns button[data-v="ok"][aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.val-btns button[data-v="ajustar"][aria-pressed="true"] { background: var(--warn); border-color: var(--warn); color: var(--surface); }
.val-btns button[data-v="duvida"][aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.dr-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; }
.lista-edit { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.lista-edit .item { display: grid; gap: 6px; align-items: start; }
.lista-edit .item.regra { grid-template-columns: 110px 90px 1fr 32px; }
.lista-edit .item.ent { grid-template-columns: 1fr 100px 32px; }
.lista-edit .item textarea { min-height: 38px; }
.btn-x { font: inherit; border: 1px solid var(--border); background: var(--surface-2); color: var(--danger); border-radius: 8px; height: 36px; cursor: pointer; }
.lig-item { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; font-size: .86rem; }
.lig-item .acoes { display: flex; gap: 4px; flex: none; }

/* ---------- etiquetas ---------- */
.pill { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--neutral-soft); color: var(--muted); }
.pill.ok { background: var(--accent-soft); color: var(--accent-text); }
.pill.parcial { background: var(--warn-soft); color: var(--warn); }
.pill.aberta { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }
.src { display: inline-block; font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-right: 6px; vertical-align: 1px; white-space: nowrap; border: 1px solid transparent; }
.src.cartao { background: var(--accent-soft); color: var(--accent-text); }
.src.escopo { background: var(--info-soft); color: var(--info); }
.src.atual { background: var(--neutral-soft); color: var(--muted); border-color: var(--border); }
.src.analise { background: var(--warn-soft); color: var(--warn); }
.src.proposta { border: 1px dashed var(--warn); color: var(--warn); }
.src.pendente { background: var(--danger-soft); color: var(--danger); }
.src.outro { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.op { display: inline-block; font: 700 .68rem ui-monospace, Menlo, monospace; padding: 1px 6px; border-radius: 4px; margin-right: 6px; min-width: 52px; text-align: center; }
.op.C { background: var(--accent-soft); color: var(--accent-text); }
.op.A { background: var(--warn-soft); color: var(--warn); }
.op.L { background: var(--neutral-soft); color: var(--muted); }
.op.E { background: var(--info-soft); color: var(--info); }
.cat-0 { background: var(--accent-soft); color: var(--accent-text); }
.cat-1 { background: var(--info-soft); color: var(--info); }
.cat-2 { background: var(--warn-soft); color: var(--warn); }
.cat-3 { background: var(--neutral-soft); color: var(--muted); }
.cat-4 { background: var(--danger-soft); color: var(--danger); }

/* ---------- regras, estados, anotações, cenários ---------- */
.rl-grupo { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.rl-grupo h4 { margin: 0 0 6px; font-size: .92rem; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.rl-grupo ul { margin: 0; padding: 0; list-style: none; }
.rl-grupo li { margin: 0 0 6px; font-size: .9rem; }
.link { font: inherit; font-size: .8rem; border: 0; background: none; color: var(--accent); cursor: pointer; text-decoration: underline; padding: 0; }
.ciclo { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.ciclo h4 { margin: 0 0 8px; font-size: .95rem; }
.ciclo-linha { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ciclo-linha .st { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-size: .84rem; }
.ciclo-linha .st.final { border-color: var(--danger); }
.ciclo-linha .st small { font-size: .64rem; font-weight: 700; margin-left: 6px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.ciclo-linha .arr { color: var(--muted); }
.resumo-notas { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.acoes-notas { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.cen-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.cen-card h4 { margin: 0 0 4px; font-size: .95rem; }
.cen-card p { margin: 0; font-size: .85rem; color: var(--muted); }
.cen-card .acoes { display: flex; gap: 6px; flex-wrap: wrap; }
.etapas-edit .item { display: grid; grid-template-columns: 28px 1.1fr 2fr 1fr 96px; gap: 6px; align-items: start; margin-bottom: 6px; }
.etapas-edit .item .n { font: 700 .78rem ui-monospace, Menlo, monospace; color: var(--muted); padding-top: 9px; }
.etapas-edit .item .mv { display: flex; gap: 4px; }
.etapas-edit .item .mv button { height: 36px; min-width: 28px; }
.etapas-edit textarea { min-height: 38px; }
details.avancado { margin-top: 10px; }
details.avancado summary { cursor: pointer; font-size: .85rem; color: var(--muted); }
details.avancado textarea { min-height: 220px; font-family: ui-monospace, Menlo, monospace; font-size: .8rem; margin-top: 8px; }

/* ---------- diálogos ---------- */
dialog.dlg { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 40px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog.dlg.largo { width: min(1000px, calc(100vw - 24px)); }
dialog.dlg::backdrop { background: rgba(10, 16, 14, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-head h3 { margin: 0; font-size: 1.05rem; }
.dlg-body { padding: 16px 18px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.dlg-erro { color: var(--danger); font-size: .85rem; margin: 0 0 10px; }
.ator-item { display: grid; grid-template-columns: 1fr 1fr 34px 34px 34px; gap: 6px; align-items: center; margin-bottom: 6px; }
.ator-item button { height: 36px; }
.ciclo-edit { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }


/* ---------- edição direta (duplo clique) ---------- */
.fx-head [data-ed]:hover, .drawer [data-ed]:hover, .lanes-head [data-ed]:hover, .painel:not([data-painel="fluxo"]) [data-ed]:hover {
  outline: 1px dashed var(--muted); outline-offset: 2px; border-radius: 4px; cursor: text;
}
.fx-desc { color: var(--muted); max-width: 80ch; white-space: pre-line; }
.add-campo { display: inline-block; color: var(--muted); font-size: .85rem; font-weight: 500; text-transform: none; letter-spacing: 0; border-bottom: 1px dashed var(--border); cursor: pointer; }
.add-campo:hover { color: var(--accent); border-color: var(--accent); }
.editando { display: block; }
.ed-input { display: block; width: 100%; min-width: 120px; font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--info); border-radius: 6px; padding: 3px 7px; text-transform: none; letter-spacing: normal; }
textarea.ed-input { resize: vertical; line-height: 1.5; }
.node .ed-input { font-size: .84rem; }
.campo-linha { font-size: .85rem; color: var(--muted); margin: 4px 0 0; }
.campo-linha b { color: var(--text); font-weight: 600; }

.lst { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.lst.inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
.lst .it { position: relative; padding: 4px 30px 4px 6px; border-radius: 6px; font-size: .9rem; line-height: 1.45; }
.lst.inline .it { padding: 2px 22px 2px 2px; }
.lst .it:hover { background: var(--surface-2); }
.lst .it .x { position: absolute; right: 3px; top: 3px; opacity: 0; border: 0; background: none; color: var(--danger); cursor: pointer; font-size: 1rem; line-height: 1; padding: 2px 4px; border-radius: 4px; }
.lst.inline .it .x { top: 1px; right: 1px; }
.lst .it:hover .x, .lst .it:focus-within .x { opacity: 1; }
.lst .it .x:hover { background: var(--danger-soft); }
.lst .add { color: var(--muted); font-size: .84rem; padding: 4px 8px; border: 1px dashed var(--border); border-radius: 6px; cursor: pointer; align-self: flex-start; }
.lst.inline .add { align-self: center; }
.lst .add:hover, .lst .add:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }
.lst .lig small { display: block; color: var(--muted); font-size: .8rem; }
.lst .ir { position: absolute; right: 24px; top: 3px; border: 0; background: none; color: var(--accent); cursor: pointer; font-size: .95rem; line-height: 1; padding: 2px 4px; border-radius: 4px; }
.lst .ir:hover { background: var(--accent-soft); }
.lst .it:has(.ir) { padding-right: 50px; }
.lt { display: inline-block; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-right: 4px; vertical-align: 1px; }
.lt.principal { background: var(--accent-soft); color: var(--accent-text); }
.lt.alternativa { background: var(--danger-soft); color: var(--danger); }
.lt.opcional { background: var(--neutral-soft); color: var(--muted); }
.lt.retorno { background: var(--info-soft); color: var(--info); }
.lst.ciclo .it + .it::before, .lst.ciclo .it + .add::before { content: "→"; color: var(--muted); margin-right: 6px; }
.lst.ciclo .st { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-size: .84rem; display: inline-block; }
.lst.ciclo .st.final { border-color: var(--danger); }
.lst.ciclo .st small { font-size: .64rem; font-weight: 700; margin-left: 6px; text-transform: uppercase; letter-spacing: .04em; }
.row-ed { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; padding: 8px; border: 1px solid var(--info); border-radius: 8px; background: var(--info-soft); flex-basis: 100%; list-style: none; }
.row-ed select, .row-ed input[type="text"], .row-ed textarea { width: auto; min-width: 0; padding: 5px 8px; font-size: .86rem; }
.row-ed textarea { min-height: 36px; }
.row-acoes { display: flex; gap: 4px; margin-left: auto; }
.chk { display: inline-flex; gap: 5px; align-items: center; font-size: .82rem; color: var(--text); padding-top: 6px; }
.ciclo-titulo { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ciclo-titulo .x-bloco { border: 0; background: none; color: var(--danger); cursor: pointer; font-size: .82rem; opacity: .7; }
.ciclo-titulo .x-bloco:hover { opacity: 1; text-decoration: underline; }
.add-bloco { display: block; width: 100%; text-align: left; font: inherit; font-size: .88rem; color: var(--muted); padding: 10px 14px; border: 1.5px dashed var(--border); border-radius: 10px; background: none; cursor: pointer; margin-bottom: 10px; }
.add-bloco:hover, .add-bloco:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }
.lista-fluxos .add { font-size: .84rem; color: var(--muted); padding: 9px 11px; border: 1.5px dashed var(--border); border-radius: 10px; cursor: pointer; }
.lista-fluxos .add:hover, .lista-fluxos .add:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }
.dr-rodape { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--border); }
.exp-lista { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }
.exp-lista label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.exp-lista label:hover { border-color: var(--accent); }
.exp-lista input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.exp-lista small { display: block; color: var(--muted); font-size: .78rem; }
@media (max-width: 760px) {
  .lst .it .x, .lst .ir { opacity: 1; }
}


/* ---------- editor visual de cenário ---------- */
.cen-ed-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.cen-ed-titulo { margin: 8px 0 2px; font-size: 1.15rem; }
.cen-ed-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; margin-top: 14px; align-items: start; }
.etapas-col h4 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.etapas-lista.lst { gap: 6px; max-height: 72vh; overflow-y: auto; padding: 2px; }
.etapa { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 6px; row-gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); }
.etapa:hover { border-color: var(--accent); }
.etapa:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
.etapa.sel { border-color: var(--info); background: var(--info-soft); }
.etapa .n { grid-row: span 3; font: 700 .78rem ui-monospace, Menlo, monospace; color: var(--info); padding-top: 1px; }
.etapa .ep { font-size: .84rem; line-height: 1.3; padding-right: 56px; }
.etapa .ep small { color: var(--muted); font-weight: 500; }
.etapa .narr { font-size: .8rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.etapa .muda { grid-column: 2; font-size: .7rem; font-weight: 700; color: var(--warn); }
.acoes-etapa { position: absolute; top: 5px; right: 5px; display: none; gap: 2px; }
.etapa:hover .acoes-etapa, .etapa:focus-within .acoes-etapa, .etapa.sel .acoes-etapa { display: flex; }
.acoes-etapa button { font: inherit; font-size: .72rem; line-height: 1; width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; padding: 0; }
.acoes-etapa button[data-rmetapa] { color: var(--danger); }
.acoes-etapa button:disabled { opacity: .35; cursor: default; }
.estado-col { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface); min-width: 0; }
.estado-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 10px; }
.etapa-campos { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; }
.narr-ed { white-space: pre-line; }
.resumo-linha { font-size: .9rem; margin: 6px 0 4px; }
.herdado { color: var(--muted); }
.mudou-txt { color: var(--warn); font-weight: 700; }
.tab-cen td, .tab-cen th { position: relative; }
.tab-cen td.ident { font-weight: 600; }
.tab-cen td.herdado { color: var(--muted); }
.tab-cen td.mudou { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.tab-cen th.th-add { background: var(--surface); }
.x-mini { border: 0; background: none; color: var(--danger); cursor: pointer; font-size: .85rem; line-height: 1; margin-left: 4px; padding: 1px 3px; border-radius: 4px; opacity: .45; }
.x-mini:hover { opacity: 1; background: var(--danger-soft); }
.rev { border: 0; background: none; color: var(--warn); cursor: pointer; font-size: .85rem; line-height: 1; margin-left: 4px; padding: 1px 3px; border-radius: 4px; }
.rev:hover { background: var(--surface); }
.add-mini { display: inline-block; color: var(--muted); font-size: .8rem; font-weight: 500; text-transform: none; letter-spacing: 0; border: 1px dashed var(--border); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.add-mini:hover, .add-mini:focus-visible { color: var(--accent); border-color: var(--accent); outline: none; }
.add-mini.editando { display: block; border: 0; padding: 0; }
.marc-ed { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.marc-ed .marcador { display: inline-flex; align-items: center; gap: 2px; }
.marcador.mudou { box-shadow: 0 0 0 2px var(--warn); }
.cores-ed { display: flex; flex-direction: column; gap: 6px; }
.cor-linha { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cor-linha .marcador { min-width: 130px; }
.sw { width: 18px; height: 18px; border-radius: 50%; border: 0; cursor: pointer; padding: 0; opacity: .75; }
.sw:hover { opacity: 1; }
.sw.verde { background: var(--accent); }
.sw.amarelo { background: var(--warn); }
.sw.azul { background: var(--info); }
.sw.vermelho { background: var(--danger); }
.sw.cinza { background: var(--muted); }
.sw.sel { opacity: 1; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
@media (max-width: 860px) {
  .cen-ed-grid { grid-template-columns: minmax(0, 1fr); }
  .etapas-lista.lst { max-height: none; }
}

/* ---------- exportar imagem ---------- */
.img-opcoes { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.img-checks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 12px; }
.img-previa { border: 1px solid var(--border); border-radius: 10px; max-height: 48vh; overflow: auto; background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 16px 16px; padding: 10px; }
.img-previa img { display: block; max-width: 100%; height: auto; margin: 0 auto; box-shadow: var(--shadow); }
@media (max-width: 760px) { .img-opcoes { grid-template-columns: 1fr; } }

/* ---------- aviso flutuante ---------- */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 9px 16px; border-radius: 10px; font-size: .88rem; z-index: 60; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }

/* ---------- responsivo ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .lista-fluxos { flex-direction: row; overflow-x: auto; }
  .lista-fluxos li { min-width: 220px; }
  main { padding: 14px 14px 30px; }
}
@media (max-width: 760px) {
  .topbar { position: static; }
  .lanes-head, .lane-bg, .edges, .cell { display: none !important; }
  .flow { grid-template-columns: minmax(0, 1fr); row-gap: 20px; padding: 4px 0; }
  .flow .node { grid-column: 1 !important; grid-row: auto !important; margin: 0; }
  .flow .node::after { content: "↓"; position: absolute; left: 50%; bottom: -19px; color: var(--muted); font-size: .85rem; }
  .flow .node:last-child::after { content: none; }
  .flow .node.alternativo { margin-left: 22px; }
  .node .lane-tag { display: inline-block; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-left: 6px; }
  .scn-state, .row2, .row3 { grid-template-columns: minmax(0, 1fr); }
  .scn-card { position: static; }
  .lista-edit .item.regra { grid-template-columns: 1fr 1fr; }
  .lista-edit .item.regra textarea { grid-column: 1 / -1; }
  .etapas-edit .item { grid-template-columns: 1fr; }
  .painel { padding: 14px 12px; }
}
@media print {
  .topbar, .sidebar, .drawer, .barra, .tabs, .fx-actions { display: none !important; }
  .app { display: block; }
}
