/* Keep the open-price switch wrapper aligned with the unit selector, including
 * releases whose older markup still has the generic p-3 utility. */
div:has(> button#preco_aberto) {
  height: 2.5rem;
  padding-top: 0;
  padding-bottom: 0;
}

/* Category/subcategory occupy the whole form row, not one half of it.
 * Keep both existing controls, with room to choose OR type a category.
 * Scoped to this dialog structure for compatibility with published markup. */
[role="dialog"] form .grid:has(> div > label[for="categoria"]):has(> div > label[for="subcategoria"]) {
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  gap: 1rem;
}

[role="dialog"] form .grid:has(> div > label[for="categoria"]):has(> div > label[for="subcategoria"]) > div {
  min-width: 0;
}

[role="dialog"] form div:has(> select#categoria),
[role="dialog"] form div:has(> select#subcategoria) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
}

[role="dialog"] form div:has(> select#categoria) > :is(select, input),
[role="dialog"] form div:has(> select#subcategoria) > :is(select, input) {
  width: 100%;
  min-width: 0;
  height: 2.5rem;
  font-size: 0.875rem;
}

@media (max-width: 640px) {
  [role="dialog"] form .grid:has(> div > label[for="categoria"]):has(> div > label[for="subcategoria"]) {
    grid-template-columns: minmax(0, 1fr);
  }

  [role="dialog"] form .grid:has(> div > label[for="nome"]) {
    grid-template-columns: minmax(0, 1fr);
  }

  [role="dialog"] form .grid:has(> div > label[for="nome"]) > .col-span-2 {
    grid-column: 1 / -1;
  }
}
