/* O CONSTRUTOR DE AUTOMAÇÕES — medidas dos prints aprovados (05/11/2026,
 * `docs/referencias/construtor-aprovado/`). Cores e letras vêm da régua, para o tema escuro valer
 * sem uma linha a mais aqui. */

/* A TELA INTEIRA É DO CONSTRUTOR: sem a margem da moldura e sem a rolagem da folha. Pelo `:has`, e
 * não por classe, porque quem troca de tela não sabe dele: saiu, a regra deixa de valer sozinha. */
#conteudo:has(> .construtor) { padding: 0; overflow: hidden; }

.construtor {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
}
.cn-carregando { align-items: center; justify-content: center; }
.cn-nada { color: var(--muted); font-size: var(--texto-p); padding: var(--f4); margin: 0; }
.cn-traco { flex: none; display: block; }

/* ------------------------------------------------------------------------------- a barra */

.cn-barra {
  flex: none;
  height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--f3);
  padding: 0 var(--f4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.cn-barra-esq, .cn-barra-dir { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cn-barra-dir { justify-content: flex-end; flex-wrap: nowrap; margin: 0; }
.cn-barra .btn { flex: none; white-space: nowrap; gap: 6px; }
.btn.cn-so-icone { width: var(--alto-p); padding: 0; justify-content: center; }
.cn-nome {
  font-size: var(--texto-g);
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cn-barra-esq .selo { flex: none; }
.cn-estado {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--texto-pp);
  color: var(--muted);
  white-space: nowrap;
}
.cn-estado-sujo { color: var(--aviso); font-weight: 600; }

.cn-alterna { display: flex; background: var(--canvas); padding: 3px; border-radius: 9px; }
.cn-alterna button {
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--texto-p);
  font-weight: 600;
  color: var(--muted);
  padding: 5px var(--f4);
  border-radius: 7px;
  cursor: pointer;
}
.cn-alterna button.cn-ligado {
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
}
.barra-de-controles select.cn-periodo { width: auto; flex: none; font-size: var(--texto-p); }

/* NO NOTEBOOK PEQUENO A BARRA APERTA: quem tem ícone fica só com ele (o texto continua lá para o
 * leitor de tela), e "Tudo salvo" sai; "Alterações não salvas" fica, porque essa pede ação. O nome
 * da automação corta antes de qualquer botão sair da tela. */
@media (max-width: 1280px) {
  .cn-barra .cn-estado:not(.cn-estado-sujo) { display: none; }
  .cn-barra-dir [data-acao="organizar"] span,
  .cn-barra-dir [data-acao="simular"] span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
}

/* --------------------------------------------------------------------------------- a área */

.cn-area { flex: 1; min-height: 0; position: relative; display: flex; }

.cn-tela {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  outline: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
  background-color: var(--soft);
  background-image: radial-gradient(var(--line-forte) 1px, transparent 1px);
  background-size: 20px 20px;
}
.cn-tela.cn-arrastando { cursor: grabbing; }
.cn-palco { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }
.cn-caixas { position: absolute; left: 0; top: 0; }

/* ------------------------------------------------------------------------------- as setas */

.cn-setas { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.cn-seta { fill: none; stroke: var(--muted); stroke-width: 1.8; opacity: .75; }
.cn-seta-sim { stroke: var(--ok); opacity: 1; }
.cn-seta-nao { stroke: var(--ruim); opacity: 1; }
.cn-seta-marcada { stroke: var(--ink); stroke-width: 3; opacity: 1; }
.cn-seta-puxada { stroke: var(--roxo); stroke-dasharray: 6 5; opacity: 1; }
.cn-seta-toque { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
#cn-ponta path { fill: var(--muted); }
#cn-ponta-sim path { fill: var(--ok); }
#cn-ponta-nao path { fill: var(--ruim); }
#cn-ponta-marcada path { fill: var(--ink); }

/* ------------------------------------------------------------------------------- as caixas */

.cn-caixa {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(21, 46, 39, .06);
  cursor: pointer;
}
.cn-caixa:focus-visible { outline: 2px solid var(--roxo); outline-offset: 2px; }
.cn-caixa.cn-selecionada { border: 2px solid var(--ok); margin: -1px; box-shadow: 0 0 0 4px var(--ok-soft); }
.cn-caixa.cn-alvo { border: 2px dashed var(--roxo); margin: -1px; }
.cn-caixa.cn-com-falta { border: 2px solid var(--ruim); margin: -1px; }
.cn-caixa.cn-selecionada.cn-com-falta { border-color: var(--ruim); box-shadow: 0 0 0 4px var(--ruim-soft); }

.cn-cabeca { display: flex; align-items: center; gap: 9px; padding: 10px 11px 8px; }
.cn-icone {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.cn-cor-verde { background: var(--ok-soft); color: var(--ok); }
.cn-cor-ambar { background: var(--aviso-soft); color: var(--aviso); }
.cn-cor-violeta { background: var(--tag-violeta); color: var(--tag-violeta-tinta); }
.cn-cor-azul { background: var(--tag-azul); color: var(--tag-azul-tinta); }
.cn-titulos { min-width: 0; display: block; flex: 1; }
.cn-titulos strong {
  display: block;
  font-size: var(--texto-p);
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cn-titulos small {
  display: block;
  font-size: var(--texto-selo);
  color: var(--muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cn-etiqueta {
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
  font-size: var(--texto-selo);
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--tag-violeta);
  color: var(--tag-violeta-tinta);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cn-corpo { padding: 0 11px 10px; font-size: var(--texto-pp); }
.cn-bolha {
  background: var(--soft);
  border-radius: 8px;
  padding: 7px 9px;
  line-height: 1.35;
  margin-bottom: 5px;
  /* TEXTO LONGO NÃO ESTICA A CAIXA: três linhas bastam para reconhecer; o resto, na gaveta. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.cn-bolha-vazia { color: var(--muted); font-style: italic; }

.cn-saida {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: var(--texto-pp);
}
.cn-opcao {
  justify-content: flex-start;
  min-height: 29px;
  font-weight: 600;
  padding: 0 15px 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-top: 5px;
  background: var(--surface);
}
.cn-texto-da-opcao { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cn-solta { min-height: 24px; color: var(--muted); padding-right: 6px; }
.cn-sim { color: var(--ok); }
.cn-nao { color: var(--ruim); }

.cn-ponto, .cn-mais { position: absolute; top: 50%; padding: 0; cursor: crosshair; touch-action: none; }
.cn-ponto {
  right: -6px;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--surface);
  border: 2.5px solid var(--muted);
}
/* O ALVO DO DEDO E DO MOUSE É MAIOR QUE O DESENHO: 12 px é difícil de acertar. */
.cn-ponto::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; }
.cn-ponto-fixo { cursor: default; }
.cn-tom-sim { border-color: var(--ok); }
.cn-tom-nao { border-color: var(--ruim); }
.cn-solta .cn-ponto { right: -17px; }
.cn-mais {
  right: -13px;
  width: 26px;
  height: 26px;
  margin-top: -13px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px dashed var(--muted);
  color: var(--muted);
  display: grid;
  place-items: center;
}
.cn-solta .cn-mais { right: -24px; }
.cn-mais:hover { border-color: var(--ok); color: var(--ok); }
.cn-opcao:has(.cn-mais) { padding-right: 18px; }

.cn-entrada {
  position: absolute;
  left: -6px;
  top: 30px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  border: 2.5px solid var(--surface);
}

.cn-falta-na-caixa {
  display: flex;
  gap: 5px;
  align-items: flex-start;
  margin: 0 11px 10px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: var(--ruim);
  font-size: var(--texto-selo);
  line-height: 1.3;
}

.cn-numeros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  background: var(--soft);
  border-radius: 0 0 11px 11px;
}
.cn-numeros[data-colunas="2"] { grid-template-columns: repeat(2, 1fr); }
.cn-numeros div { padding: 6px 2px; text-align: center; }
.cn-numeros b { display: block; font-size: var(--texto-m); font-weight: 800; line-height: 1.15; }
.cn-numeros span { font-size: var(--texto-selo); color: var(--muted); }

/* A CAIXA VERDE. O fundo é o do aviso de "certo": ele é o único verde escuro nos dois temas, e a
 * letra branca precisa de fundo escuro. */
.cn-gatilho { background: var(--aviso-certo); border-color: var(--aviso-certo); color: #fff; cursor: grab; }
.cn-gatilho .cn-titulos small { color: rgba(255, 255, 255, .85); }
.cn-gatilho .cn-icone { background: rgba(255, 255, 255, .15); color: #fff; }
.cn-entrada-do-gatilho {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: var(--texto-pp);
  font-weight: 600;
  margin-bottom: 6px;
}
.cn-tirar-entrada {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--texto-p);
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.cn-nova-entrada {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  margin-bottom: 6px;
  padding: 6px 9px;
  border: 1px dashed rgba(255, 255, 255, .7);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: var(--texto-pp);
  font-weight: 600;
  cursor: pointer;
}
.cn-nova-entrada:hover { background: rgba(255, 255, 255, .12); }
.cn-gatilho .cn-solta { color: #fff; }
.cn-gatilho .cn-ponto { border-color: #fff; background: var(--aviso-certo); }
.cn-gatilho .cn-mais { border-color: #fff; color: #fff; background: var(--aviso-certo); }
.cn-gatilho .cn-etiqueta { background: var(--ok-soft); color: var(--ok); }

/* ---------------------------------------------------------- os recados e o zoom, por cima */

.cn-recados {
  position: absolute;
  left: 14px;
  top: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--f2);
  max-width: min(460px, calc(100% - 28px));
  max-height: calc(100% - 80px);
  cursor: default;
}
.cn-recado {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: var(--texto-pp);
  color: var(--muted);
}
.cn-faltas {
  background: var(--surface);
  border: 1px solid var(--ruim);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: var(--texto-pp);
  box-shadow: 0 4px 14px rgba(21, 46, 39, .1);
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  width: 100%;
}
.cn-faltas header { display: flex; align-items: center; justify-content: space-between; color: var(--ruim); margin-bottom: 4px; }
.cn-faltas ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cn-link {
  border: 0;
  background: none;
  padding: 2px 0;
  font: inherit;
  font-size: var(--texto-pp);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.cn-link:hover { color: var(--ok); }
.cn-gaveta .cn-link { color: var(--muted); text-decoration: underline; }

.cn-zoom {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 4px;
  box-shadow: 0 2px 6px rgba(21, 46, 39, .08);
  font-size: var(--texto-p);
  font-weight: 600;
  cursor: default;
}
.cn-zoom button {
  min-width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: inherit;
  display: grid;
  place-items: center;
  padding: 0 6px;
  cursor: pointer;
}
.cn-zoom button:hover { background: var(--soft); color: var(--ink); }
.cn-zoom [data-zoom-valor] { min-width: 42px; text-align: center; }

/* -------------------------------------------------------------- o lado: catálogo e gaveta */

.cn-lado { flex: none; background: var(--surface); border-left: 1px solid var(--line); min-height: 0; }
.cn-lado[hidden] { display: none; }
.cn-mini {
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.cn-mini:hover:not(:disabled) { background: var(--soft); color: var(--ink); }

.cn-catalogo {
  width: 288px;
  display: flex;
  flex-direction: column;
  padding: 13px 12px;
}
.cn-catalogo h2 { margin: 0; font-size: var(--texto-g); font-weight: 700; }
.cn-catalogo > small { color: var(--muted); font-size: var(--texto-pp); }
.cn-ligando {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--f2);
  padding: 6px 6px 6px 10px;
  border-radius: 8px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: var(--texto-pp);
  font-weight: 600;
}
.cn-ligando span { flex: 1; }
.cn-busca {
  display: flex;
  align-items: center;
  gap: 7px;
  height: var(--alto-p);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  margin: 9px 0 5px;
  color: var(--muted);
  background: var(--soft);
}
.cn-busca input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  margin: 0;
  padding: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: var(--texto-p);
}
.cn-itens { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.cn-grupo {
  font-size: var(--texto-selo);
  font-weight: 800;
  letter-spacing: .5px;
  color: var(--muted);
  text-transform: uppercase;
  margin: 10px 3px 3px;
}
.cn-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: grab;
}
.cn-item:hover { background: var(--soft); }
.cn-item-texto { min-width: 0; }
.cn-item-texto strong { display: block; font-size: var(--texto-p); font-weight: 600; line-height: 1.2; }
.cn-item-texto small { display: block; font-size: var(--texto-pp); color: var(--muted); line-height: 1.25; }

.cn-gaveta {
  width: 400px;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(21, 46, 39, .08);
  position: relative;
}
.cn-gaveta-topo {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px var(--f4);
  border-bottom: 1px solid var(--line);
}
.cn-gaveta-topo .cn-titulos strong { font-size: var(--texto-g); }
.cn-gaveta-topo .cn-titulos small { font-size: var(--texto-pp); }
.cn-gaveta-corpo {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 13px var(--f4);
  display: grid;
  gap: 11px;
  align-content: start;
  font-size: var(--texto-p);
}
.cn-gaveta-pe {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 11px var(--f4);
  border-top: 1px solid var(--line);
}
.btn.cn-excluir { color: var(--ruim); gap: 5px; }

.cn-campo { display: grid; gap: 4px; }
.cn-rotulo { font-size: var(--texto-pp); font-weight: 600; }
.cn-dica { margin: 0; font-size: var(--texto-pp); color: var(--muted); line-height: 1.35; }
.cn-dica-ruim { color: var(--ruim); }
.cn-dica-travada { background: var(--soft); border-radius: 8px; padding: 7px 10px; }
.cn-gaveta input[type="text"], .cn-gaveta input[type="number"], .cn-gaveta textarea, .cn-gaveta select {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: var(--texto-p);
  line-height: 1.35;
  color: var(--ink);
  background: var(--soft);
}
.cn-gaveta textarea { resize: vertical; min-height: 54px; field-sizing: content; max-height: 220px; }
.cn-cartao { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.cn-cartao header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--texto-p);
  font-weight: 700;
  margin-bottom: 6px;
  min-height: 24px;
}
.cn-acoes-do-cartao { display: flex; gap: 2px; }
.cn-acrescentar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-height: var(--alto-p);
  border: 1px dashed var(--line-forte);
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: var(--texto-p);
  font-weight: 600;
  color: var(--ok);
  cursor: pointer;
}
.cn-acrescentar:hover:not(:disabled) { background: var(--ok-soft); }
.cn-enviar-arquivo input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.cn-linha-do-botao { display: flex; align-items: center; gap: 4px; }
.cn-espera { display: grid; grid-template-columns: 90px 1fr; gap: 6px; }
.cn-duas-opcoes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cn-duas-opcoes button, .cn-arquivo {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--texto-p);
  padding: 6px 10px;
  cursor: pointer;
}
.cn-duas-opcoes .cn-ligado, .cn-arquivo.cn-ligado { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.cn-arquivo { display: flex; justify-content: space-between; gap: var(--f2); text-align: left; width: 100%; }
.cn-arquivo span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cn-arquivo small { flex: none; color: var(--muted); font-size: var(--texto-pp); }

/* ------------------------------------------------------------------------------- as versões */

.cn-versao {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--f3);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--texto-p);
}
.cn-versao span { min-width: 0; }
.cn-versao b, .cn-versao small { display: block; }
.cn-versao small { color: var(--muted); font-size: var(--texto-pp); }
.cn-versao .btn { flex: none; }

/* -------------------------------------------------------------------------------- o celular */

#conteudo:has(> .cn-no-celular) { overflow: auto; }
.cn-no-celular { height: auto; min-height: 100%; }
.cn-barra-do-celular {
  display: flex;
  align-items: center;
  gap: var(--f2);
  padding: 10px var(--f4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.cn-barra-do-celular .selo { flex: none; }
.cn-recado-celular { margin: var(--f3) var(--f4) 0; }
.cn-lista-do-celular { list-style: none; margin: var(--f3) 0 0; padding: 0 var(--f4) var(--f4); display: grid; gap: var(--f2); }
.cn-item-da-lista {
  display: flex;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.cn-item-da-lista .cn-titulos strong, .cn-item-da-lista .cn-titulos small { white-space: normal; overflow-wrap: anywhere; }
.cn-item-da-lista .cn-titulos small { font-size: var(--texto-pp); }
.cn-item-da-lista ul { margin: 4px 0 0; padding: 0; list-style: none; font-size: var(--texto-pp); color: var(--muted); }
